github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/client/interface.go (about)

     1  package client // import "github.com/docker/docker/client"
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"net"
     7  	"net/http"
     8  	"time"
     9  
    10  	"github.com/docker/docker/api/types"
    11  	containertypes "github.com/docker/docker/api/types/container"
    12  	"github.com/docker/docker/api/types/events"
    13  	"github.com/docker/docker/api/types/filters"
    14  	"github.com/docker/docker/api/types/image"
    15  	networktypes "github.com/docker/docker/api/types/network"
    16  	"github.com/docker/docker/api/types/registry"
    17  	"github.com/docker/docker/api/types/swarm"
    18  	volumetypes "github.com/docker/docker/api/types/volume"
    19  	specs "github.com/opencontainers/image-spec/specs-go/v1"
    20  )
    21  
    22  // CommonAPIClient is the common methods between stable and experimental versions of APIClient.
    23  type CommonAPIClient interface {
    24  	ConfigAPIClient
    25  	ContainerAPIClient
    26  	DistributionAPIClient
    27  	ImageAPIClient
    28  	NodeAPIClient
    29  	NetworkAPIClient
    30  	PluginAPIClient
    31  	ServiceAPIClient
    32  	SwarmAPIClient
    33  	SecretAPIClient
    34  	SystemAPIClient
    35  	VolumeAPIClient
    36  	ClientVersion() string
    37  	DaemonHost() string
    38  	HTTPClient() *http.Client
    39  	ServerVersion(ctx context.Context) (types.Version, error)
    40  	NegotiateAPIVersion(ctx context.Context)
    41  	NegotiateAPIVersionPing(types.Ping)
    42  	DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error)
    43  	Dialer() func(context.Context) (net.Conn, error)
    44  	Close() error
    45  }
    46  
    47  // ContainerAPIClient defines API client methods for the containers
    48  type ContainerAPIClient interface {
    49  	ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
    50  	ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
    51  	ContainerCreate(ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *specs.Platform, containerName string) (containertypes.ContainerCreateCreatedBody, error)
    52  	ContainerDiff(ctx context.Context, container string) ([]containertypes.ContainerChangeResponseItem, error)
    53  	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
    54  	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
    55  	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
    56  	ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
    57  	ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
    58  	ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
    59  	ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
    60  	ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (types.ContainerJSON, []byte, error)
    61  	ContainerKill(ctx context.Context, container, signal string) error
    62  	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
    63  	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
    64  	ContainerPause(ctx context.Context, container string) error
    65  	ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
    66  	ContainerRename(ctx context.Context, container, newContainerName string) error
    67  	ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
    68  	ContainerRestart(ctx context.Context, container string, timeout *time.Duration) error
    69  	ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
    70  	ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
    71  	ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
    72  	ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
    73  	ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
    74  	ContainerTop(ctx context.Context, container string, arguments []string) (containertypes.ContainerTopOKBody, error)
    75  	ContainerUnpause(ctx context.Context, container string) error
    76  	ContainerUpdate(ctx context.Context, container string, updateConfig containertypes.UpdateConfig) (containertypes.ContainerUpdateOKBody, error)
    77  	ContainerWait(ctx context.Context, container string, condition containertypes.WaitCondition) (<-chan containertypes.ContainerWaitOKBody, <-chan error)
    78  	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
    79  	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
    80  	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
    81  }
    82  
    83  // DistributionAPIClient defines API client methods for the registry
    84  type DistributionAPIClient interface {
    85  	DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
    86  }
    87  
    88  // ImageAPIClient defines API client methods for the images
    89  type ImageAPIClient interface {
    90  	ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
    91  	BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
    92  	BuildCancel(ctx context.Context, id string) error
    93  	ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
    94  	ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
    95  	ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
    96  	ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
    97  	ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
    98  	ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
    99  	ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
   100  	ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
   101  	ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
   102  	ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
   103  	ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
   104  	ImageTag(ctx context.Context, image, ref string) error
   105  	ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error)
   106  }
   107  
   108  // NetworkAPIClient defines API client methods for the networks
   109  type NetworkAPIClient interface {
   110  	NetworkConnect(ctx context.Context, network, container string, config *networktypes.EndpointSettings) error
   111  	NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
   112  	NetworkDisconnect(ctx context.Context, network, container string, force bool) error
   113  	NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
   114  	NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error)
   115  	NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
   116  	NetworkRemove(ctx context.Context, network string) error
   117  	NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
   118  }
   119  
   120  // NodeAPIClient defines API client methods for the nodes
   121  type NodeAPIClient interface {
   122  	NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
   123  	NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
   124  	NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
   125  	NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
   126  }
   127  
   128  // PluginAPIClient defines API client methods for the plugins
   129  type PluginAPIClient interface {
   130  	PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
   131  	PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
   132  	PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
   133  	PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error
   134  	PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
   135  	PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
   136  	PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
   137  	PluginSet(ctx context.Context, name string, args []string) error
   138  	PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
   139  	PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error
   140  }
   141  
   142  // ServiceAPIClient defines API client methods for the services
   143  type ServiceAPIClient interface {
   144  	ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
   145  	ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
   146  	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
   147  	ServiceRemove(ctx context.Context, serviceID string) error
   148  	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
   149  	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
   150  	TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
   151  	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
   152  	TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
   153  }
   154  
   155  // SwarmAPIClient defines API client methods for the swarm
   156  type SwarmAPIClient interface {
   157  	SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
   158  	SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
   159  	SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
   160  	SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
   161  	SwarmLeave(ctx context.Context, force bool) error
   162  	SwarmInspect(ctx context.Context) (swarm.Swarm, error)
   163  	SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
   164  }
   165  
   166  // SystemAPIClient defines API client methods for the system
   167  type SystemAPIClient interface {
   168  	Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
   169  	Info(ctx context.Context) (types.Info, error)
   170  	RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error)
   171  	DiskUsage(ctx context.Context) (types.DiskUsage, error)
   172  	Ping(ctx context.Context) (types.Ping, error)
   173  }
   174  
   175  // VolumeAPIClient defines API client methods for the volumes
   176  type VolumeAPIClient interface {
   177  	VolumeCreate(ctx context.Context, options volumetypes.VolumeCreateBody) (types.Volume, error)
   178  	VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error)
   179  	VolumeInspectWithRaw(ctx context.Context, volumeID string) (types.Volume, []byte, error)
   180  	VolumeList(ctx context.Context, filter filters.Args) (volumetypes.VolumeListOKBody, error)
   181  	VolumeRemove(ctx context.Context, volumeID string, force bool) error
   182  	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
   183  }
   184  
   185  // SecretAPIClient defines API client methods for secrets
   186  type SecretAPIClient interface {
   187  	SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error)
   188  	SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error)
   189  	SecretRemove(ctx context.Context, id string) error
   190  	SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
   191  	SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
   192  }
   193  
   194  // ConfigAPIClient defines API client methods for configs
   195  type ConfigAPIClient interface {
   196  	ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
   197  	ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
   198  	ConfigRemove(ctx context.Context, id string) error
   199  	ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
   200  	ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
   201  }