interface.go 9.4 KB

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