interface.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. "golang.org/x/net/context"
  13. )
  14. // CommonAPIClient is the common methods between stable and experimental versions of APIClient.
  15. type CommonAPIClient interface {
  16. ContainerAPIClient
  17. ImageAPIClient
  18. NodeAPIClient
  19. NetworkAPIClient
  20. ServiceAPIClient
  21. SwarmAPIClient
  22. SystemAPIClient
  23. VolumeAPIClient
  24. ClientVersion() string
  25. ServerVersion(ctx context.Context) (types.Version, error)
  26. UpdateClientVersion(v string)
  27. }
  28. // ContainerAPIClient defines API client methods for the containers
  29. type ContainerAPIClient interface {
  30. ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
  31. ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
  32. ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error)
  33. ContainerDiff(ctx context.Context, container string) ([]types.ContainerChange, error)
  34. ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
  35. ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.ContainerExecCreateResponse, error)
  36. ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
  37. ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
  38. ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
  39. ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
  40. ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
  41. ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
  42. ContainerKill(ctx context.Context, container, signal string) error
  43. ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
  44. ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
  45. ContainerPause(ctx context.Context, container string) error
  46. ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
  47. ContainerRename(ctx context.Context, container, newContainerName string) error
  48. ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
  49. ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
  50. ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
  51. ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
  52. ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
  53. ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
  54. ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
  55. ContainerUnpause(ctx context.Context, container string) error
  56. ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (types.ContainerUpdateResponse, error)
  57. ContainerWait(ctx context.Context, container string) (int, error)
  58. CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
  59. CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
  60. }
  61. // ImageAPIClient defines API client methods for the images
  62. type ImageAPIClient interface {
  63. ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
  64. ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
  65. ImageHistory(ctx context.Context, image string) ([]types.ImageHistory, error)
  66. ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
  67. ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
  68. ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error)
  69. ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
  70. ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
  71. ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
  72. ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDelete, error)
  73. ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
  74. ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
  75. ImageTag(ctx context.Context, image, ref string) error
  76. }
  77. // NetworkAPIClient defines API client methods for the networks
  78. type NetworkAPIClient interface {
  79. NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
  80. NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
  81. NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error
  82. NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error)
  83. NetworkInspectWithRaw(ctx context.Context, networkID string) (types.NetworkResource, []byte, error)
  84. NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
  85. NetworkRemove(ctx context.Context, networkID string) error
  86. }
  87. // NodeAPIClient defines API client methods for the nodes
  88. type NodeAPIClient interface {
  89. NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
  90. NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
  91. NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
  92. NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
  93. }
  94. // ServiceAPIClient defines API client methods for the services
  95. type ServiceAPIClient interface {
  96. ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
  97. ServiceInspectWithRaw(ctx context.Context, serviceID string) (swarm.Service, []byte, error)
  98. ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
  99. ServiceRemove(ctx context.Context, serviceID string) error
  100. ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) error
  101. TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
  102. TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
  103. }
  104. // SwarmAPIClient defines API client methods for the swarm
  105. type SwarmAPIClient interface {
  106. SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
  107. SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
  108. SwarmLeave(ctx context.Context, force bool) error
  109. SwarmInspect(ctx context.Context) (swarm.Swarm, error)
  110. SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
  111. }
  112. // SystemAPIClient defines API client methods for the system
  113. type SystemAPIClient interface {
  114. Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
  115. Info(ctx context.Context) (types.Info, error)
  116. RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error)
  117. }
  118. // VolumeAPIClient defines API client methods for the volumes
  119. type VolumeAPIClient interface {
  120. VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error)
  121. VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
  122. VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
  123. VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error)
  124. VolumeRemove(ctx context.Context, volumeID string, force bool) error
  125. }