interface.go 10 KB

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