Generated from a swagger spec and use it for container exec response
Signed-off-by: Daniel Nephin <dnephin@docker.com>
... | ... |
@@ -49,7 +49,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re |
49 | 49 |
return err |
50 | 50 |
} |
51 | 51 |
|
52 |
- return httputils.WriteJSON(w, http.StatusCreated, &types.ContainerExecCreateResponse{ |
|
52 |
+ return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ |
|
53 | 53 |
ID: id, |
54 | 54 |
}) |
55 | 55 |
} |
... | ... |
@@ -1075,6 +1075,16 @@ definitions: |
1075 | 1075 |
example: |
1076 | 1076 |
message: "Something went wrong." |
1077 | 1077 |
|
1078 |
+ IdResponse: |
|
1079 |
+ description: "Response to an API call that returns just an Id" |
|
1080 |
+ type: "object" |
|
1081 |
+ required: ["Id"] |
|
1082 |
+ properties: |
|
1083 |
+ Id: |
|
1084 |
+ description: "The id of the newly created object." |
|
1085 |
+ type: "string" |
|
1086 |
+ x-nullable: false |
|
1087 |
+ |
|
1078 | 1088 |
EndpointSettings: |
1079 | 1089 |
description: "Configuration for a network endpoint." |
1080 | 1090 |
type: "object" |
... | ... |
@@ -5194,19 +5204,7 @@ paths: |
5194 | 5194 |
201: |
5195 | 5195 |
description: "no error" |
5196 | 5196 |
schema: |
5197 |
- type: "object" |
|
5198 |
- properties: |
|
5199 |
- Id: |
|
5200 |
- description: "The ID of the exec instance created." |
|
5201 |
- type: "string" |
|
5202 |
- Warnings: |
|
5203 |
- type: "array" |
|
5204 |
- items: |
|
5205 |
- type: "string" |
|
5206 |
- examples: |
|
5207 |
- application/json: |
|
5208 |
- Id: "f90e34656806" |
|
5209 |
- Warnings: [] |
|
5197 |
+ $ref: "#/definitions/IdResponse" |
|
5210 | 5198 |
404: |
5211 | 5199 |
description: "no such container" |
5212 | 5200 |
schema: |
5213 | 5201 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,13 @@ |
0 |
+package types |
|
1 |
+ |
|
2 |
+// This file was generated by the swagger tool. |
|
3 |
+// Editing this file might prove futile when you re-run the swagger generate command |
|
4 |
+ |
|
5 |
+// IDResponse Response to an API call that returns just an Id |
|
6 |
+// swagger:model IdResponse |
|
7 |
+type IDResponse struct { |
|
8 |
+ |
|
9 |
+ // The id of the newly created object. |
|
10 |
+ // Required: true |
|
11 |
+ ID string `json:"Id"` |
|
12 |
+} |
... | ... |
@@ -13,13 +13,6 @@ import ( |
13 | 13 |
"github.com/docker/go-connections/nat" |
14 | 14 |
) |
15 | 15 |
|
16 |
-// ContainerExecCreateResponse contains response of Remote API: |
|
17 |
-// POST "/containers/{name:.*}/exec" |
|
18 |
-type ContainerExecCreateResponse struct { |
|
19 |
- // ID is the exec ID. |
|
20 |
- ID string `json:"Id"` |
|
21 |
-} |
|
22 |
- |
|
23 | 16 |
// ContainerUpdateResponse contains response of Remote API: |
24 | 17 |
// POST "/containers/{name:.*}/update" |
25 | 18 |
type ContainerUpdateResponse struct { |
... | ... |
@@ -8,8 +8,8 @@ import ( |
8 | 8 |
) |
9 | 9 |
|
10 | 10 |
// ContainerExecCreate creates a new exec configuration to run an exec process. |
11 |
-func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) { |
|
12 |
- var response types.ContainerExecCreateResponse |
|
11 |
+func (cli *Client) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) { |
|
12 |
+ var response types.IDResponse |
|
13 | 13 |
resp, err := cli.post(ctx, "/containers/"+container+"/exec", nil, config, nil) |
14 | 14 |
if err != nil { |
15 | 15 |
return response, err |
... | ... |
@@ -45,7 +45,7 @@ func TestContainerExecCreate(t *testing.T) { |
45 | 45 |
if execConfig.User != "user" { |
46 | 46 |
return nil, fmt.Errorf("expected an execConfig with User == 'user', got %v", execConfig) |
47 | 47 |
} |
48 |
- b, err := json.Marshal(types.ContainerExecCreateResponse{ |
|
48 |
+ b, err := json.Marshal(types.IDResponse{ |
|
49 | 49 |
ID: "exec_id", |
50 | 50 |
}) |
51 | 51 |
if err != nil { |
... | ... |
@@ -37,7 +37,7 @@ type ContainerAPIClient interface { |
37 | 37 |
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) |
38 | 38 |
ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error) |
39 | 39 |
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error) |
40 |
- ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error) |
|
40 |
+ ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) |
|
41 | 41 |
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) |
42 | 42 |
ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error |
43 | 43 |
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error |
... | ... |
@@ -7,7 +7,8 @@ swagger generate model -f api/swagger.yaml \ |
7 | 7 |
-n Port \ |
8 | 8 |
-n ImageSummary \ |
9 | 9 |
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType \ |
10 |
- -n ErrorResponse |
|
10 |
+ -n ErrorResponse \ |
|
11 |
+ -n IdResponse |
|
11 | 12 |
|
12 | 13 |
swagger generate operation -f api/swagger.yaml \ |
13 | 14 |
-t api -a types -m types -C api/swagger-gen.yaml \ |