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