interface.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. package client // import "github.com/docker/docker/client"
  2. import (
  3. "context"
  4. "io"
  5. "net"
  6. "time"
  7. "github.com/docker/docker/api/types"
  8. containertypes "github.com/docker/docker/api/types/container"
  9. "github.com/docker/docker/api/types/events"
  10. "github.com/docker/docker/api/types/filters"
  11. "github.com/docker/docker/api/types/image"
  12. networktypes "github.com/docker/docker/api/types/network"
  13. "github.com/docker/docker/api/types/registry"
  14. "github.com/docker/docker/api/types/swarm"
  15. volumetypes "github.com/docker/docker/api/types/volume"
  16. )
  17. // CommonAPIClient is the common methods between stable and experimental versions of APIClient.
  18. type CommonAPIClient interface {
  19. ConfigAPIClient
  20. ContainerAPIClient
  21. DistributionAPIClient
  22. ImageAPIClient
  23. NodeAPIClient
  24. NetworkAPIClient
  25. PluginAPIClient
  26. ServiceAPIClient
  27. SwarmAPIClient
  28. SecretAPIClient
  29. SystemAPIClient
  30. VolumeAPIClient
  31. ClientVersion() string
  32. DaemonHost() string
  33. ServerVersion(ctx context.Context) (types.Version, error)
  34. NegotiateAPIVersion(ctx context.Context)
  35. NegotiateAPIVersionPing(types.Ping)
  36. DialSession(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error)
  37. Close() error
  38. }
  39. // ContainerAPIClient defines API client methods for the containers
  40. type ContainerAPIClient interface {
  41. ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
  42. ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
  43. ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, containerName string) (containertypes.ContainerCreateCreatedBody, error)
  44. ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, error)
  45. ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
  46. ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
  47. ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
  48. ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
  49. ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
  50. ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
  51. ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
  52. ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
  53. ContainerKill(ctx context.Context, container, signal string) error
  54. ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
  55. ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
  56. ContainerPause(ctx context.Context, container string) error
  57. ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
  58. ContainerRename(ctx context.Context, container, newContainerName string) error
  59. ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
  60. ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
  61. ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
  62. ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
  63. ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
  64. ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
  65. ContainerTop(ctx context.Context, container string, arguments []string) (containertypes.ContainerTopOKBody, error)
  66. ContainerUnpause(ctx context.Context, container string) error
  67. ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error)
  68. ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error)
  69. CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
  70. CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
  71. ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
  72. }
  73. // DistributionAPIClient defines API client methods for the registry
  74. type DistributionAPIClient interface {
  75. DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
  76. }
  77. // ImageAPIClient defines API client methods for the images
  78. type ImageAPIClient interface {
  79. ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
  80. BuildCachePrune(ctx context.Context) (*types.BuildCachePruneReport, error)
  81. ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
  82. ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
  83. ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
  84. ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
  85. ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
  86. ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
  87. ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
  88. ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
  89. ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
  90. ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
  91. ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
  92. ImageTag(ctx context.Context, image, ref string) error
  93. ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error)
  94. }
  95. // NetworkAPIClient defines API client methods for the networks
  96. type NetworkAPIClient interface {
  97. NetworkConnect(ctx context.Context, network, container string, config *networktypes.EndpointSettings) error
  98. NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
  99. NetworkDisconnect(ctx context.Context, network, container string, force bool) error
  100. NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
  101. NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error)
  102. NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
  103. NetworkRemove(ctx context.Context, network string) error
  104. NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
  105. }
  106. // NodeAPIClient defines API client methods for the nodes
  107. type NodeAPIClient interface {
  108. NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
  109. NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
  110. NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
  111. NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
  112. }
  113. // PluginAPIClient defines API client methods for the plugins
  114. type PluginAPIClient interface {
  115. PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
  116. PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
  117. PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
  118. PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error
  119. PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
  120. PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
  121. PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
  122. PluginSet(ctx context.Context, name string, args []string) error
  123. PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
  124. PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error
  125. }
  126. // ServiceAPIClient defines API client methods for the services
  127. type ServiceAPIClient interface {
  128. ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
  129. ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
  130. ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
  131. ServiceRemove(ctx context.Context, serviceID string) error
  132. ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
  133. ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
  134. TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
  135. TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
  136. TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
  137. }
  138. // SwarmAPIClient defines API client methods for the swarm
  139. type SwarmAPIClient interface {
  140. SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
  141. SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
  142. SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
  143. SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
  144. SwarmLeave(ctx context.Context, force bool) error
  145. SwarmInspect(ctx context.Context) (swarm.Swarm, error)
  146. SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
  147. }
  148. // SystemAPIClient defines API client methods for the system
  149. type SystemAPIClient interface {
  150. Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
  151. Info(ctx context.Context) (types.Info, error)
  152. RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error)
  153. DiskUsage(ctx context.Context) (types.DiskUsage, error)
  154. Ping(ctx context.Context) (types.Ping, error)
  155. }
  156. // VolumeAPIClient defines API client methods for the volumes
  157. type VolumeAPIClient interface {
  158. VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error)
  159. VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
  160. VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
  161. VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error)
  162. VolumeRemove(ctx context.Context, volumeID string, force bool) error
  163. VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
  164. }
  165. // SecretAPIClient defines API client methods for secrets
  166. type SecretAPIClient interface {
  167. SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error)
  168. SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error)
  169. SecretRemove(ctx context.Context, id string) error
  170. SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
  171. SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
  172. }
  173. // ConfigAPIClient defines API client methods for configs
  174. type ConfigAPIClient interface {
  175. ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
  176. ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
  177. ConfigRemove(ctx context.Context, id string) error
  178. ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
  179. ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
  180. }