github.com/adityamillind98/moby@v23.0.0-rc.4+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/volume"
    18  	specs "github.com/opencontainers/image-spec/specs-go/v1"
    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  	DialHijack(ctx context.Context, url, 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 *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.CreateResponse, error)
    51  	ContainerDiff(ctx context.Context, container string) ([]container.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, options container.StopOptions) 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  	ContainerStatsOneShot(ctx context.Context, container string) (types.ContainerStats, error)
    71  	ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
    72  	ContainerStop(ctx context.Context, container string, options container.StopOptions) error
    73  	ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
    74  	ContainerUnpause(ctx context.Context, container string) error
    75  	ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
    76  	ContainerWait(ctx context.Context, container string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
    77  	CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
    78  	CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
    79  	ContainersPrune(ctx context.Context, pruneFilters filters.Args) (types.ContainersPruneReport, error)
    80  }
    81  
    82  // DistributionAPIClient defines API client methods for the registry
    83  type DistributionAPIClient interface {
    84  	DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
    85  }
    86  
    87  // ImageAPIClient defines API client methods for the images
    88  type ImageAPIClient interface {
    89  	ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
    90  	BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
    91  	BuildCancel(ctx context.Context, id string) error
    92  	ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
    93  	ImageHistory(ctx context.Context, image string) ([]image.HistoryResponseItem, error)
    94  	ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error)
    95  	ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error)
    96  	ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
    97  	ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
    98  	ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
    99  	ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error)
   100  	ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
   101  	ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error)
   102  	ImageSave(ctx context.Context, images []string) (io.ReadCloser, error)
   103  	ImageTag(ctx context.Context, image, ref string) error
   104  	ImagesPrune(ctx context.Context, pruneFilter filters.Args) (types.ImagesPruneReport, error)
   105  }
   106  
   107  // NetworkAPIClient defines API client methods for the networks
   108  type NetworkAPIClient interface {
   109  	NetworkConnect(ctx context.Context, network, container string, config *network.EndpointSettings) error
   110  	NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
   111  	NetworkDisconnect(ctx context.Context, network, container string, force bool) error
   112  	NetworkInspect(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, error)
   113  	NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error)
   114  	NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
   115  	NetworkRemove(ctx context.Context, network string) error
   116  	NetworksPrune(ctx context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error)
   117  }
   118  
   119  // NodeAPIClient defines API client methods for the nodes
   120  type NodeAPIClient interface {
   121  	NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
   122  	NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
   123  	NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
   124  	NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
   125  }
   126  
   127  // PluginAPIClient defines API client methods for the plugins
   128  type PluginAPIClient interface {
   129  	PluginList(ctx context.Context, filter filters.Args) (types.PluginsListResponse, error)
   130  	PluginRemove(ctx context.Context, name string, options types.PluginRemoveOptions) error
   131  	PluginEnable(ctx context.Context, name string, options types.PluginEnableOptions) error
   132  	PluginDisable(ctx context.Context, name string, options types.PluginDisableOptions) error
   133  	PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
   134  	PluginUpgrade(ctx context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error)
   135  	PluginPush(ctx context.Context, name string, registryAuth string) (io.ReadCloser, error)
   136  	PluginSet(ctx context.Context, name string, args []string) error
   137  	PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
   138  	PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error
   139  }
   140  
   141  // ServiceAPIClient defines API client methods for the services
   142  type ServiceAPIClient interface {
   143  	ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (types.ServiceCreateResponse, error)
   144  	ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
   145  	ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
   146  	ServiceRemove(ctx context.Context, serviceID string) error
   147  	ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error)
   148  	ServiceLogs(ctx context.Context, serviceID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
   149  	TaskLogs(ctx context.Context, taskID string, options types.ContainerLogsOptions) (io.ReadCloser, error)
   150  	TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
   151  	TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
   152  }
   153  
   154  // SwarmAPIClient defines API client methods for the swarm
   155  type SwarmAPIClient interface {
   156  	SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
   157  	SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
   158  	SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
   159  	SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
   160  	SwarmLeave(ctx context.Context, force bool) error
   161  	SwarmInspect(ctx context.Context) (swarm.Swarm, error)
   162  	SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error
   163  }
   164  
   165  // SystemAPIClient defines API client methods for the system
   166  type SystemAPIClient interface {
   167  	Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
   168  	Info(ctx context.Context) (types.Info, error)
   169  	RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error)
   170  	DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)
   171  	Ping(ctx context.Context) (types.Ping, error)
   172  }
   173  
   174  // VolumeAPIClient defines API client methods for the volumes
   175  type VolumeAPIClient interface {
   176  	VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
   177  	VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)
   178  	VolumeInspectWithRaw(ctx context.Context, volumeID string) (volume.Volume, []byte, error)
   179  	VolumeList(ctx context.Context, filter filters.Args) (volume.ListResponse, error)
   180  	VolumeRemove(ctx context.Context, volumeID string, force bool) error
   181  	VolumesPrune(ctx context.Context, pruneFilter filters.Args) (types.VolumesPruneReport, error)
   182  	VolumeUpdate(ctx context.Context, volumeID string, version swarm.Version, options volume.UpdateOptions) 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  }