2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-09-06 18:46:37 +00:00
|
|
|
"io"
|
2017-05-15 19:59:15 +00:00
|
|
|
"net"
|
2018-05-15 13:12:30 +00:00
|
|
|
"net/http"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2022-04-17 11:47:37 +00:00
|
|
|
"github.com/docker/docker/api/types/container"
|
2016-08-09 20:34:07 +00:00
|
|
|
"github.com/docker/docker/api/types/events"
|
2016-09-06 18:46:37 +00:00
|
|
|
"github.com/docker/docker/api/types/filters"
|
2016-11-09 21:32:53 +00:00
|
|
|
"github.com/docker/docker/api/types/image"
|
2022-04-17 11:47:37 +00:00
|
|
|
"github.com/docker/docker/api/types/network"
|
2016-09-06 18:46:37 +00:00
|
|
|
"github.com/docker/docker/api/types/registry"
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2023-07-03 11:14:14 +00:00
|
|
|
"github.com/docker/docker/api/types/system"
|
2022-04-17 11:47:37 +00:00
|
|
|
"github.com/docker/docker/api/types/volume"
|
2023-05-08 09:57:52 +00:00
|
|
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
2016-09-06 18:46:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CommonAPIClient is the common methods between stable and experimental versions of APIClient.
|
|
|
|
type CommonAPIClient interface {
|
2017-03-15 22:04:32 +00:00
|
|
|
ConfigAPIClient
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerAPIClient
|
2017-04-05 22:43:17 +00:00
|
|
|
DistributionAPIClient
|
2016-09-06 18:46:37 +00:00
|
|
|
ImageAPIClient
|
|
|
|
NodeAPIClient
|
|
|
|
NetworkAPIClient
|
2016-11-10 01:49:09 +00:00
|
|
|
PluginAPIClient
|
2016-09-06 18:46:37 +00:00
|
|
|
ServiceAPIClient
|
|
|
|
SwarmAPIClient
|
2016-10-19 16:22:02 +00:00
|
|
|
SecretAPIClient
|
2016-09-06 18:46:37 +00:00
|
|
|
SystemAPIClient
|
|
|
|
VolumeAPIClient
|
|
|
|
ClientVersion() string
|
2017-05-17 14:46:15 +00:00
|
|
|
DaemonHost() string
|
2018-05-15 13:12:30 +00:00
|
|
|
HTTPClient() *http.Client
|
2016-09-06 18:46:37 +00:00
|
|
|
ServerVersion(ctx context.Context) (types.Version, error)
|
2017-06-21 05:58:16 +00:00
|
|
|
NegotiateAPIVersion(ctx context.Context)
|
|
|
|
NegotiateAPIVersionPing(types.Ping)
|
2019-04-02 04:08:16 +00:00
|
|
|
DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
|
2018-03-19 08:33:06 +00:00
|
|
|
Dialer() func(context.Context) (net.Conn, error)
|
2017-09-19 20:12:29 +00:00
|
|
|
Close() error
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerAPIClient defines API client methods for the containers
|
|
|
|
type ContainerAPIClient interface {
|
2023-08-25 18:10:15 +00:00
|
|
|
ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error)
|
2023-08-25 18:15:25 +00:00
|
|
|
ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error)
|
2023-05-08 09:57:52 +00:00
|
|
|
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
|
2023-04-16 07:40:24 +00:00
|
|
|
ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error)
|
2017-10-08 22:08:11 +00:00
|
|
|
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
|
2016-10-18 22:56:45 +00:00
|
|
|
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
|
2023-08-25 18:00:58 +00:00
|
|
|
ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error
|
2016-09-06 18:46:37 +00:00
|
|
|
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
|
2023-08-25 21:51:48 +00:00
|
|
|
ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error)
|
2023-08-25 22:19:21 +00:00
|
|
|
ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerPause(ctx context.Context, container string) error
|
2023-08-25 18:25:58 +00:00
|
|
|
ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerRename(ctx context.Context, container, newContainerName string) error
|
2023-08-25 18:00:58 +00:00
|
|
|
ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error
|
2022-02-16 10:36:37 +00:00
|
|
|
ContainerRestart(ctx context.Context, container string, options container.StopOptions) error
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
|
2016-09-07 23:08:51 +00:00
|
|
|
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
2020-02-07 23:55:06 +00:00
|
|
|
ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
|
2023-08-25 21:44:29 +00:00
|
|
|
ContainerStart(ctx context.Context, container string, options container.StartOptions) error
|
2022-02-16 10:36:37 +00:00
|
|
|
ContainerStop(ctx context.Context, container string, options container.StopOptions) error
|
2022-04-17 11:47:37 +00:00
|
|
|
ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ContainerUnpause(ctx context.Context, container string) error
|
2022-04-17 11:47:37 +00:00
|
|
|
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
|
2022-03-05 16:13:15 +00:00
|
|
|
ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
|
2016-09-06 18:46:37 +00: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 05:46:37 +00:00
|
|
|
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 22:43:17 +00:00
|
|
|
// DistributionAPIClient defines API client methods for the registry
|
|
|
|
type DistributionAPIClient interface {
|
|
|
|
DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
|
|
|
|
}
|
|
|
|
|
2016-09-06 18:46:37 +00: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)
|
2018-08-15 21:24:37 +00:00
|
|
|
BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
|
2018-04-19 18:08:33 +00:00
|
|
|
BuildCancel(ctx context.Context, id string) error
|
2023-07-07 11:40:24 +00:00
|
|
|
ImageCreate(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error)
|
2016-11-09 21:32:53 +00:00
|
|
|
ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
|
2023-07-07 11:40:24 +00:00
|
|
|
ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
|
2023-07-07 11:40:24 +00:00
|
|
|
ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
|
2023-07-07 11:40:24 +00:00
|
|
|
ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
|
|
|
|
ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)
|
|
|
|
ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error)
|
2016-09-06 18:46:37 +00: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 05:46:37 +00:00
|
|
|
ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NetworkAPIClient defines API client methods for the networks
|
|
|
|
type NetworkAPIClient interface {
|
2022-04-17 11:47:37 +00:00
|
|
|
NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
|
2016-09-06 18:46:37 +00:00
|
|
|
NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
|
2018-01-19 09:00:24 +00:00
|
|
|
NetworkDisconnect(ctx context.Context, network, container string, force bool) error
|
|
|
|
NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
|
|
|
|
NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
|
2018-01-19 09:00:24 +00:00
|
|
|
NetworkRemove(ctx context.Context, network string) error
|
2016-11-17 05:46:37 +00:00
|
|
|
NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
|
2016-09-06 18:46:37 +00: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-10 01:49:09 +00:00
|
|
|
// PluginAPIClient defines API client methods for the plugins
|
|
|
|
type PluginAPIClient interface {
|
2016-11-23 12:58:15 +00:00
|
|
|
PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
|
2016-11-10 01:49:09 +00:00
|
|
|
PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
|
2016-11-21 17:24:01 +00:00
|
|
|
PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
|
2016-12-20 16:26:58 +00:00
|
|
|
PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error
|
2016-12-12 23:05:53 +00:00
|
|
|
PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
|
2017-01-29 00:54:32 +00:00
|
|
|
PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
|
2016-12-12 23:05:53 +00:00
|
|
|
PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
|
2016-11-10 01:49:09 +00: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 18:46:37 +00:00
|
|
|
// ServiceAPIClient defines API client methods for the services
|
|
|
|
type ServiceAPIClient interface {
|
2022-11-24 18:36:01 +00:00
|
|
|
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
2017-03-31 00:15:54 +00:00
|
|
|
ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
|
|
|
|
ServiceRemove(ctx context.Context, serviceID string) error
|
2022-11-24 18:17:47 +00:00
|
|
|
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
2023-08-25 22:19:21 +00:00
|
|
|
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
|
|
|
|
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
|
2016-09-06 18:46:37 +00: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-28 01:50:49 +00:00
|
|
|
SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
|
2016-10-22 01:07:55 +00:00
|
|
|
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
2016-09-06 18:46:37 +00: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 20:34:07 +00:00
|
|
|
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
|
2023-07-03 11:14:14 +00:00
|
|
|
Info(ctx context.Context) (system.Info, error)
|
2022-03-03 09:27:23 +00:00
|
|
|
RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
|
2021-06-23 13:26:54 +00:00
|
|
|
DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)
|
2016-11-03 00:43:32 +00:00
|
|
|
Ping(ctx context.Context) (types.Ping, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeAPIClient defines API client methods for the volumes
|
|
|
|
type VolumeAPIClient interface {
|
2022-03-05 22:25:55 +00:00
|
|
|
VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
|
2022-03-18 15:33:43 +00:00
|
|
|
VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
|
|
|
|
VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
|
2019-11-01 15:11:35 +00:00
|
|
|
VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
|
2016-09-06 18:46:37 +00:00
|
|
|
VolumeRemove(ctx context.Context, volumeID string, force bool) error
|
2016-11-17 05:46:37 +00:00
|
|
|
VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
|
2021-05-14 17:38:50 +00:00
|
|
|
VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
2016-10-19 16:22:02 +00: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 19:03:23 +00:00
|
|
|
SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
|
2016-10-19 16:22:02 +00:00
|
|
|
}
|
2017-03-15 22:04:32 +00:00
|
|
|
|
|
|
|
// ConfigAPIClient defines API client methods for configs
|
|
|
|
type ConfigAPIClient interface {
|
|
|
|
ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
|
|
|
|
ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
|
|
|
|
ConfigRemove(ctx context.Context, id string) error
|
|
|
|
ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
|
|
|
|
ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
|
|
|
|
}
|