interface.go 11 KB

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