mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
api/types/network: define ConnectRequest and DisconnectRequest
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
This commit is contained in:
committed by
Sebastiaan van Stijn
parent
b5971b6ae3
commit
bae45f766d
@@ -2842,6 +2842,42 @@ definitions:
|
|||||||
type: "string"
|
type: "string"
|
||||||
x-nullable: false
|
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:
|
EndpointSettings:
|
||||||
description: "Configuration for a network endpoint."
|
description: "Configuration for a network endpoint."
|
||||||
type: "object"
|
type: "object"
|
||||||
@@ -11359,22 +11395,7 @@ paths:
|
|||||||
in: "body"
|
in: "body"
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: "object"
|
$ref: "#/definitions/NetworkConnectRequest"
|
||||||
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
|
|
||||||
tags: ["Network"]
|
tags: ["Network"]
|
||||||
|
|
||||||
/networks/{id}/disconnect:
|
/networks/{id}/disconnect:
|
||||||
@@ -11408,17 +11429,7 @@ paths:
|
|||||||
in: "body"
|
in: "body"
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: "object"
|
$ref: "#/definitions/NetworkDisconnectRequest"
|
||||||
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.
|
|
||||||
tags: ["Network"]
|
tags: ["Network"]
|
||||||
/networks/prune:
|
/networks/prune:
|
||||||
post:
|
post:
|
||||||
|
|||||||
@@ -2842,6 +2842,42 @@ definitions:
|
|||||||
type: "string"
|
type: "string"
|
||||||
x-nullable: false
|
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:
|
EndpointSettings:
|
||||||
description: "Configuration for a network endpoint."
|
description: "Configuration for a network endpoint."
|
||||||
type: "object"
|
type: "object"
|
||||||
@@ -11359,22 +11395,7 @@ paths:
|
|||||||
in: "body"
|
in: "body"
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: "object"
|
$ref: "#/definitions/NetworkConnectRequest"
|
||||||
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
|
|
||||||
tags: ["Network"]
|
tags: ["Network"]
|
||||||
|
|
||||||
/networks/{id}/disconnect:
|
/networks/{id}/disconnect:
|
||||||
@@ -11408,17 +11429,7 @@ paths:
|
|||||||
in: "body"
|
in: "body"
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: "object"
|
$ref: "#/definitions/NetworkDisconnectRequest"
|
||||||
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.
|
|
||||||
tags: ["Network"]
|
tags: ["Network"]
|
||||||
/networks/prune:
|
/networks/prune:
|
||||||
post:
|
post:
|
||||||
|
|||||||
20
api/types/network/connect_request.go
Normal file
20
api/types/network/connect_request.go
Normal file
@@ -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"`
|
||||||
|
}
|
||||||
21
api/types/network/disconnect_request.go
Normal file
21
api/types/network/disconnect_request.go
Normal file
@@ -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"`
|
||||||
|
}
|
||||||
@@ -18,11 +18,11 @@ func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nc := NetworkConnectOptions{
|
req := network.ConnectRequest{
|
||||||
Container: containerID,
|
Container: containerID,
|
||||||
EndpointConfig: config,
|
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)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var connect NetworkConnectOptions
|
var connect network.ConnectRequest
|
||||||
if err := json.NewDecoder(req.Body).Decode(&connect); err != nil {
|
if err := json.NewDecoder(req.Body).Decode(&connect); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/moby/moby/api/types/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetworkDisconnect disconnects a container from an existent network in the docker host.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nd := NetworkDisconnectOptions{
|
req := network.DisconnectRequest{
|
||||||
Container: containerID,
|
Container: containerID,
|
||||||
Force: force,
|
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)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
cerrdefs "github.com/containerd/errdefs"
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
|
"github.com/moby/moby/api/types/network"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
)
|
)
|
||||||
@@ -37,7 +38,7 @@ func TestNetworkDisconnect(t *testing.T) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var disconnect NetworkDisconnectOptions
|
var disconnect network.DisconnectRequest
|
||||||
if err := json.NewDecoder(req.Body).Decode(&disconnect); err != nil {
|
if err := json.NewDecoder(req.Body).Decode(&disconnect); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ generate_model types/network --keep-spec-order --additional-initialism=IPAM <<-
|
|||||||
EndpointResource
|
EndpointResource
|
||||||
IPAMStatus
|
IPAMStatus
|
||||||
Network
|
Network
|
||||||
|
NetworkConnectRequest
|
||||||
NetworkCreateResponse
|
NetworkCreateResponse
|
||||||
|
NetworkDisconnectRequest
|
||||||
NetworkInspect
|
NetworkInspect
|
||||||
NetworkStatus
|
NetworkStatus
|
||||||
NetworkSummary
|
NetworkSummary
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ func createNetwork(t *testing.T, config network.CreateRequest, expectedStatusCod
|
|||||||
}
|
}
|
||||||
|
|
||||||
func connectNetwork(t *testing.T, nid, cid string) {
|
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,
|
Container: cid,
|
||||||
}))
|
}))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|||||||
20
vendor/github.com/moby/moby/api/types/network/connect_request.go
generated
vendored
Normal file
20
vendor/github.com/moby/moby/api/types/network/connect_request.go
generated
vendored
Normal file
@@ -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"`
|
||||||
|
}
|
||||||
21
vendor/github.com/moby/moby/api/types/network/disconnect_request.go
generated
vendored
Normal file
21
vendor/github.com/moby/moby/api/types/network/disconnect_request.go
generated
vendored
Normal file
@@ -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"`
|
||||||
|
}
|
||||||
4
vendor/github.com/moby/moby/client/network_connect.go
generated
vendored
4
vendor/github.com/moby/moby/client/network_connect.go
generated
vendored
@@ -18,11 +18,11 @@ func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nc := NetworkConnectOptions{
|
req := network.ConnectRequest{
|
||||||
Container: containerID,
|
Container: containerID,
|
||||||
EndpointConfig: config,
|
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)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
6
vendor/github.com/moby/moby/client/network_disconnect.go
generated
vendored
6
vendor/github.com/moby/moby/client/network_disconnect.go
generated
vendored
@@ -2,6 +2,8 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/moby/moby/api/types/network"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NetworkDisconnect disconnects a container from an existent network in the docker host.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
nd := NetworkDisconnectOptions{
|
req := network.DisconnectRequest{
|
||||||
Container: containerID,
|
Container: containerID,
|
||||||
Force: force,
|
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)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user