api.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. Package api represents all requests and responses suitable for conversation
  3. with a remote driver.
  4. */
  5. package api
  6. import (
  7. "net"
  8. "github.com/docker/libnetwork/discoverapi"
  9. "github.com/docker/libnetwork/driverapi"
  10. )
  11. // Response is the basic response structure used in all responses.
  12. type Response struct {
  13. Err string
  14. }
  15. // GetError returns the error from the response, if any.
  16. func (r *Response) GetError() string {
  17. return r.Err
  18. }
  19. // GetCapabilityResponse is the response of GetCapability request
  20. type GetCapabilityResponse struct {
  21. Response
  22. Scope string
  23. }
  24. // CreateNetworkRequest requests a new network.
  25. type CreateNetworkRequest struct {
  26. // A network ID that remote plugins are expected to store for future
  27. // reference.
  28. NetworkID string
  29. // A free form map->object interface for communication of options.
  30. Options map[string]interface{}
  31. // IPAMData contains the address pool information for this network
  32. IPv4Data, IPv6Data []driverapi.IPAMData
  33. }
  34. // CreateNetworkResponse is the response to the CreateNetworkRequest.
  35. type CreateNetworkResponse struct {
  36. Response
  37. }
  38. // DeleteNetworkRequest is the request to delete an existing network.
  39. type DeleteNetworkRequest struct {
  40. // The ID of the network to delete.
  41. NetworkID string
  42. }
  43. // DeleteNetworkResponse is the response to a request for deleting a network.
  44. type DeleteNetworkResponse struct {
  45. Response
  46. }
  47. // CreateEndpointRequest is the request to create an endpoint within a network.
  48. type CreateEndpointRequest struct {
  49. // Provided at create time, this will be the network id referenced.
  50. NetworkID string
  51. // The ID of the endpoint for later reference.
  52. EndpointID string
  53. Interface *EndpointInterface
  54. Options map[string]interface{}
  55. }
  56. // EndpointInterface represents an interface endpoint.
  57. type EndpointInterface struct {
  58. Address string
  59. AddressIPv6 string
  60. MacAddress string
  61. }
  62. // CreateEndpointResponse is the response to the CreateEndpoint action.
  63. type CreateEndpointResponse struct {
  64. Response
  65. Interface *EndpointInterface
  66. }
  67. // Interface is the representation of a linux interface.
  68. type Interface struct {
  69. Address *net.IPNet
  70. AddressIPv6 *net.IPNet
  71. MacAddress net.HardwareAddr
  72. }
  73. // DeleteEndpointRequest describes the API for deleting an endpoint.
  74. type DeleteEndpointRequest struct {
  75. NetworkID string
  76. EndpointID string
  77. }
  78. // DeleteEndpointResponse is the response to the DeleteEndpoint action.
  79. type DeleteEndpointResponse struct {
  80. Response
  81. }
  82. // EndpointInfoRequest retrieves information about the endpoint from the network driver.
  83. type EndpointInfoRequest struct {
  84. NetworkID string
  85. EndpointID string
  86. }
  87. // EndpointInfoResponse is the response to an EndpointInfoRequest.
  88. type EndpointInfoResponse struct {
  89. Response
  90. Value map[string]interface{}
  91. }
  92. // JoinRequest describes the API for joining an endpoint to a sandbox.
  93. type JoinRequest struct {
  94. NetworkID string
  95. EndpointID string
  96. SandboxKey string
  97. Options map[string]interface{}
  98. }
  99. // InterfaceName is the struct represetation of a pair of devices with source
  100. // and destination, for the purposes of putting an endpoint into a container.
  101. type InterfaceName struct {
  102. SrcName string
  103. DstName string
  104. DstPrefix string
  105. }
  106. // StaticRoute is the plain JSON representation of a static route.
  107. type StaticRoute struct {
  108. Destination string
  109. RouteType int
  110. NextHop string
  111. }
  112. // JoinResponse is the response to a JoinRequest.
  113. type JoinResponse struct {
  114. Response
  115. InterfaceName *InterfaceName
  116. Gateway string
  117. GatewayIPv6 string
  118. StaticRoutes []StaticRoute
  119. DisableGatewayService bool
  120. }
  121. // LeaveRequest describes the API for detaching an endpoint from a sandbox.
  122. type LeaveRequest struct {
  123. NetworkID string
  124. EndpointID string
  125. }
  126. // LeaveResponse is the answer to LeaveRequest.
  127. type LeaveResponse struct {
  128. Response
  129. }
  130. // DiscoveryNotification represents a discovery notification
  131. type DiscoveryNotification struct {
  132. DiscoveryType discoverapi.DiscoveryType
  133. DiscoveryData interface{}
  134. }
  135. // DiscoveryResponse is used by libnetwork to log any plugin error processing the discovery notifications
  136. type DiscoveryResponse struct {
  137. Response
  138. }