interface.go 13 KB

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