api.go 2.1 KB

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