api.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. import "github.com/docker/libnetwork/ipamapi"
  5. // Response is the basic response structure used in all responses
  6. type Response struct {
  7. Error string
  8. }
  9. // IsSuccess returns wheter the plugin response is successful
  10. func (r *Response) IsSuccess() bool {
  11. return r.Error == ""
  12. }
  13. // GetError returns the error from the response, if any.
  14. func (r *Response) GetError() string {
  15. return r.Error
  16. }
  17. // GetCapabilityResponse is the response of GetCapability request
  18. type GetCapabilityResponse struct {
  19. Response
  20. RequiresMACAddress bool
  21. }
  22. // ToCapability converts the capability response into the internal ipam driver capaility structure
  23. func (capRes GetCapabilityResponse) ToCapability() *ipamapi.Capability {
  24. return &ipamapi.Capability{RequiresMACAddress: capRes.RequiresMACAddress}
  25. }
  26. // GetAddressSpacesResponse is the response to the ``get default address spaces`` request message
  27. type GetAddressSpacesResponse struct {
  28. Response
  29. LocalDefaultAddressSpace string
  30. GlobalDefaultAddressSpace string
  31. }
  32. // RequestPoolRequest represents the expected data in a ``request address pool`` request message
  33. type RequestPoolRequest struct {
  34. AddressSpace string
  35. Pool string
  36. SubPool string
  37. Options map[string]string
  38. V6 bool
  39. }
  40. // RequestPoolResponse represents the response message to a ``request address pool`` request
  41. type RequestPoolResponse struct {
  42. Response
  43. PoolID string
  44. Pool string // CIDR format
  45. Data map[string]string
  46. }
  47. // ReleasePoolRequest represents the expected data in a ``release address pool`` request message
  48. type ReleasePoolRequest struct {
  49. PoolID string
  50. }
  51. // ReleasePoolResponse represents the response message to a ``release address pool`` request
  52. type ReleasePoolResponse struct {
  53. Response
  54. }
  55. // RequestAddressRequest represents the expected data in a ``request address`` request message
  56. type RequestAddressRequest struct {
  57. PoolID string
  58. Address string
  59. Options map[string]string
  60. }
  61. // RequestAddressResponse represents the expected data in the response message to a ``request address`` request
  62. type RequestAddressResponse struct {
  63. Response
  64. Address string // in CIDR format
  65. Data map[string]string
  66. }
  67. // ReleaseAddressRequest represents the expected data in a ``release address`` request message
  68. type ReleaseAddressRequest struct {
  69. PoolID string
  70. Address string
  71. }
  72. // ReleaseAddressResponse represents the response message to a ``release address`` request
  73. type ReleaseAddressResponse struct {
  74. Response
  75. }