github.com/OpenFlowLabs/moby@v17.12.1-ce-rc2+incompatible/client/interface.go (about)

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