github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/libnetwork/ipams/remote/api/api.go (about)

     1  // Package api defines the data structure to be used in the request/response
     2  // messages between libnetwork and the remote ipam plugin
     3  package api
     4  
     5  import "github.com/docker/docker/libnetwork/ipamapi"
     6  
     7  // Response is the basic response structure used in all responses
     8  type Response struct {
     9  	Error string
    10  }
    11  
    12  // IsSuccess returns whether the plugin response is successful
    13  func (r *Response) IsSuccess() bool {
    14  	return r.Error == ""
    15  }
    16  
    17  // GetError returns the error from the response, if any.
    18  func (r *Response) GetError() string {
    19  	return r.Error
    20  }
    21  
    22  // GetCapabilityResponse is the response of GetCapability request
    23  type GetCapabilityResponse struct {
    24  	Response
    25  	RequiresMACAddress    bool
    26  	RequiresRequestReplay bool
    27  }
    28  
    29  // ToCapability converts the capability response into the internal ipam driver capability structure
    30  func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability {
    31  	return &ipamapi.Capability{
    32  		RequiresMACAddress:    capRes.RequiresMACAddress,
    33  		RequiresRequestReplay: capRes.RequiresRequestReplay,
    34  	}
    35  }
    36  
    37  // GetAddressSpacesResponse is the response to the “get default address spaces“ request message
    38  type GetAddressSpacesResponse struct {
    39  	Response
    40  	LocalDefaultAddressSpace  string
    41  	GlobalDefaultAddressSpace string
    42  }
    43  
    44  // RequestPoolRequest represents the expected data in a “request address pool“ request message
    45  type RequestPoolRequest struct {
    46  	AddressSpace string
    47  	Pool         string
    48  	SubPool      string
    49  	Options      map[string]string
    50  	V6           bool
    51  }
    52  
    53  // RequestPoolResponse represents the response message to a “request address pool“ request
    54  type RequestPoolResponse struct {
    55  	Response
    56  	PoolID string
    57  	Pool   string // CIDR format
    58  	Data   map[string]string
    59  }
    60  
    61  // ReleasePoolRequest represents the expected data in a “release address pool“ request message
    62  type ReleasePoolRequest struct {
    63  	PoolID string
    64  }
    65  
    66  // ReleasePoolResponse represents the response message to a “release address pool“ request
    67  type ReleasePoolResponse struct {
    68  	Response
    69  }
    70  
    71  // RequestAddressRequest represents the expected data in a “request address“ request message
    72  type RequestAddressRequest struct {
    73  	PoolID  string
    74  	Address string
    75  	Options map[string]string
    76  }
    77  
    78  // RequestAddressResponse represents the expected data in the response message to a “request address“ request
    79  type RequestAddressResponse struct {
    80  	Response
    81  	Address string // in CIDR format
    82  	Data    map[string]string
    83  }
    84  
    85  // ReleaseAddressRequest represents the expected data in a “release address“ request message
    86  type ReleaseAddressRequest struct {
    87  	PoolID  string
    88  	Address string
    89  }
    90  
    91  // ReleaseAddressResponse represents the response message to a “release address“ request
    92  type ReleaseAddressResponse struct {
    93  	Response
    94  }