2015-09-22 13:20:55 -07:00
|
|
|
// Package api defines the data structure to be used in the request/response
|
|
|
|
// messages between libnetwork and the remote ipam plugin
|
|
|
|
package api
|
|
|
|
|
2021-04-06 00:24:47 +00:00
|
|
|
import "github.com/docker/docker/libnetwork/ipamapi"
|
2015-12-09 18:09:58 -08:00
|
|
|
|
2015-09-22 13:20:55 -07:00
|
|
|
// Response is the basic response structure used in all responses
|
|
|
|
type Response struct {
|
|
|
|
Error string
|
|
|
|
}
|
|
|
|
|
2017-06-12 11:30:30 -07:00
|
|
|
// IsSuccess returns whether the plugin response is successful
|
2015-09-22 13:20:55 -07:00
|
|
|
func (r *Response) IsSuccess() bool {
|
|
|
|
return r.Error == ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetError returns the error from the response, if any.
|
|
|
|
func (r *Response) GetError() string {
|
|
|
|
return r.Error
|
|
|
|
}
|
|
|
|
|
2015-12-09 18:09:58 -08:00
|
|
|
// GetCapabilityResponse is the response of GetCapability request
|
|
|
|
type GetCapabilityResponse struct {
|
|
|
|
Response
|
2016-04-18 15:11:36 -07:00
|
|
|
RequiresMACAddress bool
|
|
|
|
RequiresRequestReplay bool
|
2015-12-09 18:09:58 -08:00
|
|
|
}
|
|
|
|
|
2016-06-22 14:20:30 +08:00
|
|
|
// ToCapability converts the capability response into the internal ipam driver capability structure
|
2015-12-09 18:09:58 -08:00
|
|
|
func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability {
|
2016-04-18 15:11:36 -07:00
|
|
|
return &ipamapi.Capability{
|
|
|
|
RequiresMACAddress: capRes.RequiresMACAddress,
|
|
|
|
RequiresRequestReplay: capRes.RequiresRequestReplay,
|
|
|
|
}
|
2015-12-09 18:09:58 -08:00
|
|
|
}
|
|
|
|
|
2015-09-22 13:20:55 -07:00
|
|
|
// GetAddressSpacesResponse is the response to the ``get default address spaces`` request message
|
|
|
|
type GetAddressSpacesResponse struct {
|
|
|
|
Response
|
|
|
|
LocalDefaultAddressSpace string
|
|
|
|
GlobalDefaultAddressSpace string
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestPoolRequest represents the expected data in a ``request address pool`` request message
|
|
|
|
type RequestPoolRequest struct {
|
|
|
|
AddressSpace string
|
|
|
|
Pool string
|
|
|
|
SubPool string
|
|
|
|
Options map[string]string
|
|
|
|
V6 bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestPoolResponse represents the response message to a ``request address pool`` request
|
|
|
|
type RequestPoolResponse struct {
|
|
|
|
Response
|
|
|
|
PoolID string
|
2015-10-12 13:03:28 -07:00
|
|
|
Pool string // CIDR format
|
2015-09-22 13:20:55 -07:00
|
|
|
Data map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReleasePoolRequest represents the expected data in a ``release address pool`` request message
|
|
|
|
type ReleasePoolRequest struct {
|
|
|
|
PoolID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReleasePoolResponse represents the response message to a ``release address pool`` request
|
|
|
|
type ReleasePoolResponse struct {
|
|
|
|
Response
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestAddressRequest represents the expected data in a ``request address`` request message
|
|
|
|
type RequestAddressRequest struct {
|
|
|
|
PoolID string
|
2015-10-12 13:03:28 -07:00
|
|
|
Address string
|
2015-09-22 13:20:55 -07:00
|
|
|
Options map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestAddressResponse represents the expected data in the response message to a ``request address`` request
|
|
|
|
type RequestAddressResponse struct {
|
|
|
|
Response
|
2015-10-12 13:03:28 -07:00
|
|
|
Address string // in CIDR format
|
2015-09-22 13:20:55 -07:00
|
|
|
Data map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReleaseAddressRequest represents the expected data in a ``release address`` request message
|
|
|
|
type ReleaseAddressRequest struct {
|
|
|
|
PoolID string
|
2015-10-12 13:03:28 -07:00
|
|
|
Address string
|
2015-09-22 13:20:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// ReleaseAddressResponse represents the response message to a ``release address`` request
|
|
|
|
type ReleaseAddressResponse struct {
|
|
|
|
Response
|
|
|
|
}
|