diff --git a/api/docs/v1.52.yaml b/api/docs/v1.52.yaml index ee14466e0d..1e7b789fd1 100644 --- a/api/docs/v1.52.yaml +++ b/api/docs/v1.52.yaml @@ -2842,6 +2842,42 @@ definitions: type: "string" x-nullable: false + NetworkConnectRequest: + description: | + NetworkConnectRequest represents the data to be used to connect a container to a network. + type: "object" + x-go-name: "ConnectRequest" + required: ["Container"] + properties: + Container: + type: "string" + description: "The ID or name of the container to connect to the network." + x-nullable: false + example: "3613f73ba0e4" + EndpointConfig: + $ref: "#/definitions/EndpointSettings" + x-nullable: true + + NetworkDisconnectRequest: + description: | + NetworkDisconnectRequest represents the data to be used to disconnect a container from a network. + type: "object" + x-go-name: "DisconnectRequest" + required: ["Container"] + properties: + Container: + type: "string" + description: "The ID or name of the container to disconnect from the network." + x-nullable: false + example: "3613f73ba0e4" + Force: + type: "boolean" + description: "Force the container to disconnect from the network." + default: false + x-nullable: false + x-omitempty: false + example: false + EndpointSettings: description: "Configuration for a network endpoint." type: "object" @@ -11359,22 +11395,7 @@ paths: in: "body" required: true schema: - type: "object" - title: "NetworkConnectRequest" - properties: - Container: - type: "string" - description: "The ID or name of the container to connect to the network." - EndpointConfig: - $ref: "#/definitions/EndpointSettings" - example: - Container: "3613f73ba0e4" - EndpointConfig: - IPAMConfig: - IPv4Address: "172.24.56.89" - IPv6Address: "2001:db8::5689" - MacAddress: "02:42:ac:12:05:02" - Priority: 100 + $ref: "#/definitions/NetworkConnectRequest" tags: ["Network"] /networks/{id}/disconnect: @@ -11408,17 +11429,7 @@ paths: in: "body" required: true schema: - type: "object" - title: "NetworkDisconnectRequest" - properties: - Container: - type: "string" - description: | - The ID or name of the container to disconnect from the network. - Force: - type: "boolean" - description: | - Force the container to disconnect from the network. + $ref: "#/definitions/NetworkDisconnectRequest" tags: ["Network"] /networks/prune: post: diff --git a/api/swagger.yaml b/api/swagger.yaml index ee14466e0d..1e7b789fd1 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -2842,6 +2842,42 @@ definitions: type: "string" x-nullable: false + NetworkConnectRequest: + description: | + NetworkConnectRequest represents the data to be used to connect a container to a network. + type: "object" + x-go-name: "ConnectRequest" + required: ["Container"] + properties: + Container: + type: "string" + description: "The ID or name of the container to connect to the network." + x-nullable: false + example: "3613f73ba0e4" + EndpointConfig: + $ref: "#/definitions/EndpointSettings" + x-nullable: true + + NetworkDisconnectRequest: + description: | + NetworkDisconnectRequest represents the data to be used to disconnect a container from a network. + type: "object" + x-go-name: "DisconnectRequest" + required: ["Container"] + properties: + Container: + type: "string" + description: "The ID or name of the container to disconnect from the network." + x-nullable: false + example: "3613f73ba0e4" + Force: + type: "boolean" + description: "Force the container to disconnect from the network." + default: false + x-nullable: false + x-omitempty: false + example: false + EndpointSettings: description: "Configuration for a network endpoint." type: "object" @@ -11359,22 +11395,7 @@ paths: in: "body" required: true schema: - type: "object" - title: "NetworkConnectRequest" - properties: - Container: - type: "string" - description: "The ID or name of the container to connect to the network." - EndpointConfig: - $ref: "#/definitions/EndpointSettings" - example: - Container: "3613f73ba0e4" - EndpointConfig: - IPAMConfig: - IPv4Address: "172.24.56.89" - IPv6Address: "2001:db8::5689" - MacAddress: "02:42:ac:12:05:02" - Priority: 100 + $ref: "#/definitions/NetworkConnectRequest" tags: ["Network"] /networks/{id}/disconnect: @@ -11408,17 +11429,7 @@ paths: in: "body" required: true schema: - type: "object" - title: "NetworkDisconnectRequest" - properties: - Container: - type: "string" - description: | - The ID or name of the container to disconnect from the network. - Force: - type: "boolean" - description: | - Force the container to disconnect from the network. + $ref: "#/definitions/NetworkDisconnectRequest" tags: ["Network"] /networks/prune: post: diff --git a/api/types/network/connect_request.go b/api/types/network/connect_request.go new file mode 100644 index 0000000000..2ff14d3603 --- /dev/null +++ b/api/types/network/connect_request.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package network + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ConnectRequest NetworkConnectRequest represents the data to be used to connect a container to a network. +// +// swagger:model ConnectRequest +type ConnectRequest struct { + + // The ID or name of the container to connect to the network. + // Example: 3613f73ba0e4 + // Required: true + Container string `json:"Container"` + + // endpoint config + EndpointConfig *EndpointSettings `json:"EndpointConfig,omitempty"` +} diff --git a/api/types/network/disconnect_request.go b/api/types/network/disconnect_request.go new file mode 100644 index 0000000000..7b1f521e77 --- /dev/null +++ b/api/types/network/disconnect_request.go @@ -0,0 +1,21 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package network + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// DisconnectRequest NetworkDisconnectRequest represents the data to be used to disconnect a container from a network. +// +// swagger:model DisconnectRequest +type DisconnectRequest struct { + + // The ID or name of the container to disconnect from the network. + // Example: 3613f73ba0e4 + // Required: true + Container string `json:"Container"` + + // Force the container to disconnect from the network. + // Example: false + Force bool `json:"Force"` +} diff --git a/client/network_connect.go b/client/network_connect.go index 985b0f6fa3..9c8d22bbeb 100644 --- a/client/network_connect.go +++ b/client/network_connect.go @@ -18,11 +18,11 @@ func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID st return err } - nc := NetworkConnectOptions{ + req := network.ConnectRequest{ Container: containerID, EndpointConfig: config, } - resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil) + resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, req, nil) defer ensureReaderClosed(resp) return err } diff --git a/client/network_connect_test.go b/client/network_connect_test.go index ebaa4f8119..78b29fc998 100644 --- a/client/network_connect_test.go +++ b/client/network_connect_test.go @@ -38,7 +38,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) { return nil, err } - var connect NetworkConnectOptions + var connect network.ConnectRequest if err := json.NewDecoder(req.Body).Decode(&connect); err != nil { return nil, err } diff --git a/client/network_disconnect.go b/client/network_disconnect.go index 4931f536a7..375ce0a90c 100644 --- a/client/network_disconnect.go +++ b/client/network_disconnect.go @@ -2,6 +2,8 @@ package client import ( "context" + + "github.com/moby/moby/api/types/network" ) // NetworkDisconnect disconnects a container from an existent network in the docker host. @@ -16,11 +18,11 @@ func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID return err } - nd := NetworkDisconnectOptions{ + req := network.DisconnectRequest{ Container: containerID, Force: force, } - resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) + resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, req, nil) defer ensureReaderClosed(resp) return err } diff --git a/client/network_disconnect_test.go b/client/network_disconnect_test.go index f9ce369481..087af1e6f0 100644 --- a/client/network_disconnect_test.go +++ b/client/network_disconnect_test.go @@ -8,6 +8,7 @@ import ( "testing" cerrdefs "github.com/containerd/errdefs" + "github.com/moby/moby/api/types/network" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" ) @@ -37,7 +38,7 @@ func TestNetworkDisconnect(t *testing.T) { return nil, err } - var disconnect NetworkDisconnectOptions + var disconnect network.DisconnectRequest if err := json.NewDecoder(req.Body).Decode(&disconnect); err != nil { return nil, err } diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 9ccf87479b..fd74929027 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -65,7 +65,9 @@ generate_model types/network --keep-spec-order --additional-initialism=IPAM <<- EndpointResource IPAMStatus Network + NetworkConnectRequest NetworkCreateResponse + NetworkDisconnectRequest NetworkInspect NetworkStatus NetworkSummary diff --git a/integration-cli/docker_api_network_test.go b/integration-cli/docker_api_network_test.go index 9ac9422afa..188be8b3a0 100644 --- a/integration-cli/docker_api_network_test.go +++ b/integration-cli/docker_api_network_test.go @@ -236,7 +236,7 @@ func createNetwork(t *testing.T, config network.CreateRequest, expectedStatusCod } func connectNetwork(t *testing.T, nid, cid string) { - resp, _, err := request.Post(testutil.GetContext(t), "/networks/"+nid+"/connect", request.JSONBody(client.NetworkConnectOptions{ + resp, _, err := request.Post(testutil.GetContext(t), "/networks/"+nid+"/connect", request.JSONBody(network.ConnectRequest{ Container: cid, })) assert.NilError(t, err) diff --git a/vendor/github.com/moby/moby/api/types/network/connect_request.go b/vendor/github.com/moby/moby/api/types/network/connect_request.go new file mode 100644 index 0000000000..2ff14d3603 --- /dev/null +++ b/vendor/github.com/moby/moby/api/types/network/connect_request.go @@ -0,0 +1,20 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package network + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// ConnectRequest NetworkConnectRequest represents the data to be used to connect a container to a network. +// +// swagger:model ConnectRequest +type ConnectRequest struct { + + // The ID or name of the container to connect to the network. + // Example: 3613f73ba0e4 + // Required: true + Container string `json:"Container"` + + // endpoint config + EndpointConfig *EndpointSettings `json:"EndpointConfig,omitempty"` +} diff --git a/vendor/github.com/moby/moby/api/types/network/disconnect_request.go b/vendor/github.com/moby/moby/api/types/network/disconnect_request.go new file mode 100644 index 0000000000..7b1f521e77 --- /dev/null +++ b/vendor/github.com/moby/moby/api/types/network/disconnect_request.go @@ -0,0 +1,21 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package network + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +// DisconnectRequest NetworkDisconnectRequest represents the data to be used to disconnect a container from a network. +// +// swagger:model DisconnectRequest +type DisconnectRequest struct { + + // The ID or name of the container to disconnect from the network. + // Example: 3613f73ba0e4 + // Required: true + Container string `json:"Container"` + + // Force the container to disconnect from the network. + // Example: false + Force bool `json:"Force"` +} diff --git a/vendor/github.com/moby/moby/client/network_connect.go b/vendor/github.com/moby/moby/client/network_connect.go index 985b0f6fa3..9c8d22bbeb 100644 --- a/vendor/github.com/moby/moby/client/network_connect.go +++ b/vendor/github.com/moby/moby/client/network_connect.go @@ -18,11 +18,11 @@ func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID st return err } - nc := NetworkConnectOptions{ + req := network.ConnectRequest{ Container: containerID, EndpointConfig: config, } - resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil) + resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, req, nil) defer ensureReaderClosed(resp) return err } diff --git a/vendor/github.com/moby/moby/client/network_disconnect.go b/vendor/github.com/moby/moby/client/network_disconnect.go index 4931f536a7..375ce0a90c 100644 --- a/vendor/github.com/moby/moby/client/network_disconnect.go +++ b/vendor/github.com/moby/moby/client/network_disconnect.go @@ -2,6 +2,8 @@ package client import ( "context" + + "github.com/moby/moby/api/types/network" ) // NetworkDisconnect disconnects a container from an existent network in the docker host. @@ -16,11 +18,11 @@ func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID return err } - nd := NetworkDisconnectOptions{ + req := network.DisconnectRequest{ Container: containerID, Force: force, } - resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) + resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, req, nil) defer ensureReaderClosed(resp) return err }