github.com/rish1988/moby@v25.0.2+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  
     9  	"github.com/docker/docker/api/types"
    10  	"github.com/docker/docker/api/types/container"
    11  	"github.com/docker/docker/api/types/events"
    12  	"github.com/docker/docker/api/types/filters"
    13  	"github.com/docker/docker/api/types/image"
    14  	"github.com/docker/docker/api/types/network"
    15  	"github.com/docker/docker/api/types/registry"
    16  	"github.com/docker/docker/api/types/swarm"
    17  	"github.com/docker/docker/api/types/system"
    18  	"github.com/docker/docker/api/types/volume"
    19  	ocispec "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 container.AttachOptions) (types.HijackedResponse, error)
    50  	ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error)
    51  	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
    52  	ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, 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 container.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 container.ListOptions) ([]types.Container, error)
    63  	ContainerLogs(ctx context.Context, container string, options container.LogsOptions) (io.ReadCloser, error)
    64  	ContainerPause(ctx context.Context, container string) error
    65  	ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
    66  	ContainerRename(ctx context.Context, container, newContainerName string) error
    67  	ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error
    68  	ContainerRestart(ctx context.Context, container string, options container.StopOptions) 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 container.StartOptions) error
    73  	ContainerStop(ctx context.Context, container string, options container.StopOptions) error
    74  	ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
    75  	ContainerUnpause(ctx context.Context, container string) error
    76  	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
    77  	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-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 image.CreateOptions) (io.ReadCloser, error)
    94  	ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
    95  	ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options image.ImportOptions) (io.ReadCloser, error)
    96  	ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
    97  	ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
    98  	ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
    99  	ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
   100  	ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)
   101  	ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, 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 *network.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) (swarm.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) (swarm.ServiceUpdateResponse, error)
   149  	ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
   150  	TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (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) (system.Info, error)
   170  	RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
   171  	DiskUsage(ctx context.Context, options types.DiskUsageOptions) (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 volume.CreateOptions) (volume.Volume, error)
   178  	VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
   179  	VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
   180  	VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
   181  	VolumeRemove(ctx context.Context, volumeID string, force bool) error
   182  	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
   183  	VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) error
   184  }
   185  
   186  // SecretAPIClient defines API client methods for secrets
   187  type SecretAPIClient interface {
   188  	SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error)
   189  	SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error)
   190  	SecretRemove(ctx context.Context, id string) error
   191  	SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error)
   192  	SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error
   193  }
   194  
   195  // ConfigAPIClient defines API client methods for configs
   196  type ConfigAPIClient interface {
   197  	ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error)
   198  	ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error)
   199  	ConfigRemove(ctx context.Context, id string) error
   200  	ConfigInspectWithRaw(ctx context.Context, name string) (swarm.Config, []byte, error)
   201  	ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error
   202  }