Add an IDResponse type
Generated from a swagger spec and use it for container exec response Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
bad849fc82
commit
01883c136d
8 changed files with 31 additions and 26 deletions
|
@ -49,7 +49,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re
|
|||
return err
|
||||
}
|
||||
|
||||
return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerExecCreateResponse{
|
||||
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{
|
||||
ID: id,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1075,6 +1075,16 @@ definitions:
|
|||
example:
|
||||
message: "Something went wrong."
|
||||
|
||||
IdResponse:
|
||||
description: "Response to an API call that returns just an Id"
|
||||
type: "object"
|
||||
required: ["Id"]
|
||||
properties:
|
||||
Id:
|
||||
description: "The id of the newly created object."
|
||||
type: "string"
|
||||
x-nullable: false
|
||||
|
||||
EndpointSettings:
|
||||
description: "Configuration for a network endpoint."
|
||||
type: "object"
|
||||
|
@ -5194,19 +5204,7 @@ paths:
|
|||
201:
|
||||
description: "no error"
|
||||
schema:
|
||||
type: "object"
|
||||
properties:
|
||||
Id:
|
||||
description: "The ID of the exec instance created."
|
||||
type: "string"
|
||||
Warnings:
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
examples:
|
||||
application/json:
|
||||
Id: "f90e34656806"
|
||||
Warnings: []
|
||||
$ref: "#/definitions/IdResponse"
|
||||
404:
|
||||
description: "no such container"
|
||||
schema:
|
||||
|
|
13
api/types/id_response.go
Normal file
13
api/types/id_response.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package types
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// IDResponse Response to an API call that returns just an Id
|
||||
// swagger:model IdResponse
|
||||
type IDResponse struct {
|
||||
|
||||
// The id of the newly created object.
|
||||
// Required: true
|
||||
ID string `json:"Id"`
|
||||
}
|
|
@ -13,13 +13,6 @@ import (
|
|||
"github.com/docker/go-connections/nat"
|
||||
)
|
||||
|
||||
// ContainerExecCreateResponse contains response of Remote API:
|
||||
// POST "/containers/{name:.*}/exec"
|
||||
type ContainerExecCreateResponse struct {
|
||||
// ID is the exec ID.
|
||||
ID string `json:"Id"`
|
||||
}
|
||||
|
||||
// ContainerUpdateResponse contains response of Remote API:
|
||||
// POST "/containers/{name:.*}/update"
|
||||
type ContainerUpdateResponse struct {
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
)
|
||||
|
||||
// ContainerExecCreate creates a new exec configuration to run an exec process.
|
||||
func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
|
||||
var response types.ContainerExecCreateResponse
|
||||
func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) {
|
||||
var response types.IDResponse
|
||||
resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil)
|
||||
if err != nil {
|
||||
return response, err
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestContainerExecCreate(t *testing.T) {
|
|||
if execConfig.User != "user" {
|
||||
return nil, fmt.Errorf("expected an execConfig with User == 'user', got %v", execConfig)
|
||||
}
|
||||
b, err := json.Marshal(types.ContainerExecCreateResponse{
|
||||
b, err := json.Marshal(types.IDResponse{
|
||||
ID: "exec_id",
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -37,7 +37,7 @@ type ContainerAPIClient interface {
|
|||
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
|
||||
ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
|
||||
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
|
||||
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error)
|
||||
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
|
||||
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
|
||||
ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
|
||||
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
|
||||
|
|
|
@ -7,7 +7,8 @@ swagger generate model -f api/swagger.yaml \
|
|||
-n Port \
|
||||
-n ImageSummary \
|
||||
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType \
|
||||
-n ErrorResponse
|
||||
-n ErrorResponse \
|
||||
-n IdResponse
|
||||
|
||||
swagger generate operation -f api/swagger.yaml \
|
||||
-t api -a types -m types -C api/swagger-gen.yaml \
|
||||
|
|
Loading…
Reference in a new issue