github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/libnetwork/drivers/remote/api/api.go (about) 1 /* 2 Package api represents all requests and responses suitable for conversation 3 with a remote driver. 4 */ 5 package api 6 7 import ( 8 "net" 9 10 "github.com/Prakhar-Agarwal-byte/moby/libnetwork/discoverapi" 11 "github.com/Prakhar-Agarwal-byte/moby/libnetwork/driverapi" 12 ) 13 14 // Response is the basic response structure used in all responses. 15 type Response struct { 16 Err string 17 } 18 19 // GetError returns the error from the response, if any. 20 func (r *Response) GetError() string { 21 return r.Err 22 } 23 24 // GetCapabilityResponse is the response of GetCapability request 25 type GetCapabilityResponse struct { 26 Response 27 Scope string 28 ConnectivityScope string 29 } 30 31 // AllocateNetworkRequest requests allocation of new network by manager 32 type AllocateNetworkRequest struct { 33 // A network ID that remote plugins are expected to store for future 34 // reference. 35 NetworkID string 36 37 // A free form map->object interface for communication of options. 38 Options map[string]string 39 40 // IPAMData contains the address pool information for this network 41 IPv4Data, IPv6Data []driverapi.IPAMData 42 } 43 44 // AllocateNetworkResponse is the response to the AllocateNetworkRequest. 45 type AllocateNetworkResponse struct { 46 Response 47 // A free form plugin specific string->string object to be sent in 48 // CreateNetworkRequest call in the libnetwork agents 49 Options map[string]string 50 } 51 52 // FreeNetworkRequest is the request to free allocated network in the manager 53 type FreeNetworkRequest struct { 54 // The ID of the network to be freed. 55 NetworkID string 56 } 57 58 // FreeNetworkResponse is the response to a request for freeing a network. 59 type FreeNetworkResponse struct { 60 Response 61 } 62 63 // CreateNetworkRequest requests a new network. 64 type CreateNetworkRequest struct { 65 // A network ID that remote plugins are expected to store for future 66 // reference. 67 NetworkID string 68 69 // A free form map->object interface for communication of options. 70 Options map[string]interface{} 71 72 // IPAMData contains the address pool information for this network 73 IPv4Data, IPv6Data []driverapi.IPAMData 74 } 75 76 // CreateNetworkResponse is the response to the CreateNetworkRequest. 77 type CreateNetworkResponse struct { 78 Response 79 } 80 81 // DeleteNetworkRequest is the request to delete an existing network. 82 type DeleteNetworkRequest struct { 83 // The ID of the network to delete. 84 NetworkID string 85 } 86 87 // DeleteNetworkResponse is the response to a request for deleting a network. 88 type DeleteNetworkResponse struct { 89 Response 90 } 91 92 // CreateEndpointRequest is the request to create an endpoint within a network. 93 type CreateEndpointRequest struct { 94 // Provided at create time, this will be the network id referenced. 95 NetworkID string 96 // The ID of the endpoint for later reference. 97 EndpointID string 98 Interface *EndpointInterface 99 Options map[string]interface{} 100 } 101 102 // EndpointInterface represents an interface endpoint. 103 type EndpointInterface struct { 104 Address string 105 AddressIPv6 string 106 MacAddress string 107 } 108 109 // CreateEndpointResponse is the response to the CreateEndpoint action. 110 type CreateEndpointResponse struct { 111 Response 112 Interface *EndpointInterface 113 } 114 115 // Interface is the representation of a linux interface. 116 type Interface struct { 117 Address *net.IPNet 118 AddressIPv6 *net.IPNet 119 MacAddress net.HardwareAddr 120 } 121 122 // DeleteEndpointRequest describes the API for deleting an endpoint. 123 type DeleteEndpointRequest struct { 124 NetworkID string 125 EndpointID string 126 } 127 128 // DeleteEndpointResponse is the response to the DeleteEndpoint action. 129 type DeleteEndpointResponse struct { 130 Response 131 } 132 133 // EndpointInfoRequest retrieves information about the endpoint from the network driver. 134 type EndpointInfoRequest struct { 135 NetworkID string 136 EndpointID string 137 } 138 139 // EndpointInfoResponse is the response to an EndpointInfoRequest. 140 type EndpointInfoResponse struct { 141 Response 142 Value map[string]interface{} 143 } 144 145 // JoinRequest describes the API for joining an endpoint to a sandbox. 146 type JoinRequest struct { 147 NetworkID string 148 EndpointID string 149 SandboxKey string 150 Options map[string]interface{} 151 } 152 153 // InterfaceName is the struct representation of a pair of devices with source 154 // and destination, for the purposes of putting an endpoint into a container. 155 type InterfaceName struct { 156 SrcName string 157 DstName string 158 DstPrefix string 159 } 160 161 // StaticRoute is the plain JSON representation of a static route. 162 type StaticRoute struct { 163 Destination string 164 RouteType int 165 NextHop string 166 } 167 168 // JoinResponse is the response to a JoinRequest. 169 type JoinResponse struct { 170 Response 171 InterfaceName *InterfaceName 172 Gateway string 173 GatewayIPv6 string 174 StaticRoutes []StaticRoute 175 DisableGatewayService bool 176 } 177 178 // LeaveRequest describes the API for detaching an endpoint from a sandbox. 179 type LeaveRequest struct { 180 NetworkID string 181 EndpointID string 182 } 183 184 // LeaveResponse is the answer to LeaveRequest. 185 type LeaveResponse struct { 186 Response 187 } 188 189 // ProgramExternalConnectivityRequest describes the API for programming the external connectivity for the given endpoint. 190 type ProgramExternalConnectivityRequest struct { 191 NetworkID string 192 EndpointID string 193 Options map[string]interface{} 194 } 195 196 // ProgramExternalConnectivityResponse is the answer to ProgramExternalConnectivityRequest. 197 type ProgramExternalConnectivityResponse struct { 198 Response 199 } 200 201 // RevokeExternalConnectivityRequest describes the API for revoking the external connectivity for the given endpoint. 202 type RevokeExternalConnectivityRequest struct { 203 NetworkID string 204 EndpointID string 205 } 206 207 // RevokeExternalConnectivityResponse is the answer to RevokeExternalConnectivityRequest. 208 type RevokeExternalConnectivityResponse struct { 209 Response 210 } 211 212 // DiscoveryNotification represents a discovery notification 213 type DiscoveryNotification struct { 214 DiscoveryType discoverapi.DiscoveryType 215 DiscoveryData interface{} 216 } 217 218 // DiscoveryResponse is used by libnetwork to log any plugin error processing the discovery notifications 219 type DiscoveryResponse struct { 220 Response 221 }