2016-09-06 14:46:37 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/container"
|
2016-08-09 16:34:07 -04:00
|
|
|
"github.com/docker/docker/api/types/events"
|
2016-09-06 14:46:37 -04:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
2016-11-09 16:32:53 -05:00
|
|
|
"github.com/docker/docker/api/types/image"
|
2016-09-06 14:46:37 -04:00
|
|
|
"github.com/docker/docker/api/types/network"
|
|
|
|
"github.com/docker/docker/api/types/registry"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2016-10-14 16:20:13 -04:00
|
|
|
volumetypes "github.com/docker/docker/api/types/volume"
|
2016-09-06 14:46:37 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CommonAPIClient is the common methods between stable and experimental versions of APIClient.
|
|
|
|
type CommonAPIClient interface {
|
|
|
|
ContainerAPIClient
|
|
|
|
ImageAPIClient
|
|
|
|
NodeAPIClient
|
|
|
|
NetworkAPIClient
|
2016-11-09 20:49:09 -05:00
|
|
|
PluginAPIClient
|
2016-09-06 14:46:37 -04:00
|
|
|
ServiceAPIClient
|
|
|
|
SwarmAPIClient
|
2016-10-19 12:22:02 -04:00
|
|
|
SecretAPIClient
|
2016-09-06 14:46:37 -04:00
|
|
|
SystemAPIClient
|
|
|
|
VolumeAPIClient
|
|
|
|
ClientVersion() string
|
|
|
|
ServerVersion(ctx context.Context) (types.Version, error)
|
|
|
|
UpdateClientVersion(v string)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerAPIClient defines API client methods for the containers
|
|
|
|
type ContainerAPIClient interface {
|
|
|
|
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
|
2016-10-18 20:27:55 -04:00
|
|
|
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
|
2016-10-14 16:28:47 -04:00
|
|
|
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
|
2016-11-09 16:15:32 -05:00
|
|
|
ContainerDiff(ctx context.Context, container string) ([]container.ContainerChangeResponseItem, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ContainerExecAttach(ctx context.Context, execID string, config types.ExecConfig) (types.HijackedResponse, error)
|
2016-10-18 18:56:45 -04:00
|
|
|
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
|
|
|
|
ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
|
|
|
|
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
|
|
|
|
ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
|
|
|
|
ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
|
|
|
|
ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
|
|
|
|
ContainerKill(ctx context.Context, container, signal string) error
|
|
|
|
ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
|
|
|
|
ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
|
|
|
|
ContainerPause(ctx context.Context, container string) error
|
|
|
|
ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
|
|
|
|
ContainerRename(ctx context.Context, container, newContainerName string) error
|
|
|
|
ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
|
|
|
|
ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
|
|
|
|
ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
|
2016-09-07 19:08:51 -04:00
|
|
|
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
|
|
|
|
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
|
2016-11-14 14:50:16 -05:00
|
|
|
ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ContainerUnpause(ctx context.Context, container string) error
|
2016-10-18 20:35:45 -04:00
|
|
|
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
|
2016-10-20 18:56:27 -04:00
|
|
|
ContainerWait(ctx context.Context, container string) (int64, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
|
|
|
|
CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
|
2016-11-17 00:46:37 -05:00
|
|
|
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ImageAPIClient defines API client methods for the images
|
|
|
|
type ImageAPIClient interface {
|
|
|
|
ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
|
|
|
|
ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
|
2016-11-09 16:32:53 -05:00
|
|
|
ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
|
|
|
|
ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
|
2016-10-03 15:17:39 -04:00
|
|
|
ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
|
|
|
|
ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
|
|
|
|
ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
|
2016-11-10 11:27:56 -05:00
|
|
|
ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
|
|
|
|
ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
|
|
|
|
ImageTag(ctx context.Context, image, ref string) error
|
2016-11-17 00:46:37 -05:00
|
|
|
ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkAPIClient defines API client methods for the networks
|
|
|
|
type NetworkAPIClient interface {
|
|
|
|
NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
|
|
|
|
NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
|
|
|
|
NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error
|
2017-03-09 14:42:10 -05:00
|
|
|
NetworkInspect(ctx context.Context, networkID string, verbose bool) (types.NetworkResource, error)
|
|
|
|
NetworkInspectWithRaw(ctx context.Context, networkID string, verbose bool) (types.NetworkResource, []byte, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
|
|
|
|
NetworkRemove(ctx context.Context, networkID string) error
|
2016-11-17 00:46:37 -05:00
|
|
|
NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// NodeAPIClient defines API client methods for the nodes
|
|
|
|
type NodeAPIClient interface {
|
|
|
|
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
|
|
|
|
NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
|
|
|
|
NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
|
|
|
|
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
|
|
|
}
|
|
|
|
|
2016-11-09 20:49:09 -05:00
|
|
|
// PluginAPIClient defines API client methods for the plugins
|
|
|
|
type PluginAPIClient interface {
|
2016-11-23 07:58:15 -05:00
|
|
|
PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
|
2016-11-09 20:49:09 -05:00
|
|
|
PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
|
2016-11-21 12:24:01 -05:00
|
|
|
PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
|
2016-12-20 11:26:58 -05:00
|
|
|
PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error
|
2016-12-12 18:05:53 -05:00
|
|
|
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
|
2017-01-28 19:54:32 -05:00
|
|
|
PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
|
2016-12-12 18:05:53 -05:00
|
|
|
PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
|
2016-11-09 20:49:09 -05:00
|
|
|
PluginSet(ctx context.Context, name string, args []string) error
|
|
|
|
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
|
|
|
|
PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error
|
|
|
|
}
|
|
|
|
|
2016-09-06 14:46:37 -04:00
|
|
|
// ServiceAPIClient defines API client methods for the services
|
|
|
|
type ServiceAPIClient interface {
|
|
|
|
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
|
2017-03-30 20:15:54 -04:00
|
|
|
ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
|
|
|
|
ServiceRemove(ctx context.Context, serviceID string) error
|
2016-11-14 21:08:24 -05:00
|
|
|
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
|
2016-10-26 04:17:31 -04:00
|
|
|
ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
|
2017-03-21 14:35:55 -04:00
|
|
|
TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
|
|
|
|
TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SwarmAPIClient defines API client methods for the swarm
|
|
|
|
type SwarmAPIClient interface {
|
|
|
|
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
|
|
|
|
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
2016-10-27 21:50:49 -04:00
|
|
|
SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
|
2016-10-21 21:07:55 -04:00
|
|
|
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
2016-09-06 14:46:37 -04:00
|
|
|
SwarmLeave(ctx context.Context, force bool) error
|
|
|
|
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
|
|
|
SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// SystemAPIClient defines API client methods for the system
|
|
|
|
type SystemAPIClient interface {
|
2016-08-09 16:34:07 -04:00
|
|
|
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
|
2016-09-06 14:46:37 -04:00
|
|
|
Info(ctx context.Context) (types.Info, error)
|
2016-10-18 20:52:46 -04:00
|
|
|
RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error)
|
2016-09-22 17:04:34 -04:00
|
|
|
DiskUsage(ctx context.Context) (types.DiskUsage, error)
|
2016-11-02 20:43:32 -04:00
|
|
|
Ping(ctx context.Context) (types.Ping, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeAPIClient defines API client methods for the volumes
|
|
|
|
type VolumeAPIClient interface {
|
2016-10-06 12:57:17 -04:00
|
|
|
VolumeCreate(ctx context.Context, options volumetypes.VolumesCreateBody) (types.Volume, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
|
|
|
|
VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
|
2016-10-04 11:40:17 -04:00
|
|
|
VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumesListOKBody, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
VolumeRemove(ctx context.Context, volumeID string, force bool) error
|
2016-11-17 00:46:37 -05:00
|
|
|
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
2016-10-19 12:22:02 -04:00
|
|
|
|
|
|
|
// SecretAPIClient defines API client methods for secrets
|
|
|
|
type SecretAPIClient interface {
|
|
|
|
SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error)
|
|
|
|
SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error)
|
|
|
|
SecretRemove(ctx context.Context, id string) error
|
|
|
|
SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
|
2016-11-22 14:03:23 -05:00
|
|
|
SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
|
2016-10-19 12:22:02 -04:00
|
|
|
}
|