github.com/adityamillind98/moby@v23.0.0-rc.4+incompatible/api/types/client.go (about) 1 package types // import "github.com/docker/docker/api/types" 2 3 import ( 4 "bufio" 5 "io" 6 "net" 7 8 "github.com/docker/docker/api/types/container" 9 "github.com/docker/docker/api/types/filters" 10 units "github.com/docker/go-units" 11 ) 12 13 // CheckpointCreateOptions holds parameters to create a checkpoint from a container 14 type CheckpointCreateOptions struct { 15 CheckpointID string 16 CheckpointDir string 17 Exit bool 18 } 19 20 // CheckpointListOptions holds parameters to list checkpoints for a container 21 type CheckpointListOptions struct { 22 CheckpointDir string 23 } 24 25 // CheckpointDeleteOptions holds parameters to delete a checkpoint from a container 26 type CheckpointDeleteOptions struct { 27 CheckpointID string 28 CheckpointDir string 29 } 30 31 // ContainerAttachOptions holds parameters to attach to a container. 32 type ContainerAttachOptions struct { 33 Stream bool 34 Stdin bool 35 Stdout bool 36 Stderr bool 37 DetachKeys string 38 Logs bool 39 } 40 41 // ContainerCommitOptions holds parameters to commit changes into a container. 42 type ContainerCommitOptions struct { 43 Reference string 44 Comment string 45 Author string 46 Changes []string 47 Pause bool 48 Config *container.Config 49 } 50 51 // ContainerExecInspect holds information returned by exec inspect. 52 type ContainerExecInspect struct { 53 ExecID string `json:"ID"` 54 ContainerID string 55 Running bool 56 ExitCode int 57 Pid int 58 } 59 60 // ContainerListOptions holds parameters to list containers with. 61 type ContainerListOptions struct { 62 Size bool 63 All bool 64 Latest bool 65 Since string 66 Before string 67 Limit int 68 Filters filters.Args 69 } 70 71 // ContainerLogsOptions holds parameters to filter logs with. 72 type ContainerLogsOptions struct { 73 ShowStdout bool 74 ShowStderr bool 75 Since string 76 Until string 77 Timestamps bool 78 Follow bool 79 Tail string 80 Details bool 81 } 82 83 // ContainerRemoveOptions holds parameters to remove containers. 84 type ContainerRemoveOptions struct { 85 RemoveVolumes bool 86 RemoveLinks bool 87 Force bool 88 } 89 90 // ContainerStartOptions holds parameters to start containers. 91 type ContainerStartOptions struct { 92 CheckpointID string 93 CheckpointDir string 94 } 95 96 // CopyToContainerOptions holds information 97 // about files to copy into a container 98 type CopyToContainerOptions struct { 99 AllowOverwriteDirWithFile bool 100 CopyUIDGID bool 101 } 102 103 // EventsOptions holds parameters to filter events with. 104 type EventsOptions struct { 105 Since string 106 Until string 107 Filters filters.Args 108 } 109 110 // NetworkListOptions holds parameters to filter the list of networks with. 111 type NetworkListOptions struct { 112 Filters filters.Args 113 } 114 115 // NewHijackedResponse intializes a HijackedResponse type 116 func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse { 117 return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType} 118 } 119 120 // HijackedResponse holds connection information for a hijacked request. 121 type HijackedResponse struct { 122 mediaType string 123 Conn net.Conn 124 Reader *bufio.Reader 125 } 126 127 // Close closes the hijacked connection and reader. 128 func (h *HijackedResponse) Close() { 129 h.Conn.Close() 130 } 131 132 // MediaType let client know if HijackedResponse hold a raw or multiplexed stream. 133 // returns false if HTTP Content-Type is not relevant, and container must be inspected 134 func (h *HijackedResponse) MediaType() (string, bool) { 135 if h.mediaType == "" { 136 return "", false 137 } 138 return h.mediaType, true 139 } 140 141 // CloseWriter is an interface that implements structs 142 // that close input streams to prevent from writing. 143 type CloseWriter interface { 144 CloseWrite() error 145 } 146 147 // CloseWrite closes a readWriter for writing. 148 func (h *HijackedResponse) CloseWrite() error { 149 if conn, ok := h.Conn.(CloseWriter); ok { 150 return conn.CloseWrite() 151 } 152 return nil 153 } 154 155 // ImageBuildOptions holds the information 156 // necessary to build images. 157 type ImageBuildOptions struct { 158 Tags []string 159 SuppressOutput bool 160 RemoteContext string 161 NoCache bool 162 Remove bool 163 ForceRemove bool 164 PullParent bool 165 Isolation container.Isolation 166 CPUSetCPUs string 167 CPUSetMems string 168 CPUShares int64 169 CPUQuota int64 170 CPUPeriod int64 171 Memory int64 172 MemorySwap int64 173 CgroupParent string 174 NetworkMode string 175 ShmSize int64 176 Dockerfile string 177 Ulimits []*units.Ulimit 178 // BuildArgs needs to be a *string instead of just a string so that 179 // we can tell the difference between "" (empty string) and no value 180 // at all (nil). See the parsing of buildArgs in 181 // api/server/router/build/build_routes.go for even more info. 182 BuildArgs map[string]*string 183 AuthConfigs map[string]AuthConfig 184 Context io.Reader 185 Labels map[string]string 186 // squash the resulting image's layers to the parent 187 // preserves the original image and creates a new one from the parent with all 188 // the changes applied to a single layer 189 Squash bool 190 // CacheFrom specifies images that are used for matching cache. Images 191 // specified here do not need to have a valid parent chain to match cache. 192 CacheFrom []string 193 SecurityOpt []string 194 ExtraHosts []string // List of extra hosts 195 Target string 196 SessionID string 197 Platform string 198 // Version specifies the version of the unerlying builder to use 199 Version BuilderVersion 200 // BuildID is an optional identifier that can be passed together with the 201 // build request. The same identifier can be used to gracefully cancel the 202 // build with the cancel request. 203 BuildID string 204 // Outputs defines configurations for exporting build results. Only supported 205 // in BuildKit mode 206 Outputs []ImageBuildOutput 207 } 208 209 // ImageBuildOutput defines configuration for exporting a build result 210 type ImageBuildOutput struct { 211 Type string 212 Attrs map[string]string 213 } 214 215 // BuilderVersion sets the version of underlying builder to use 216 type BuilderVersion string 217 218 const ( 219 // BuilderV1 is the first generation builder in docker daemon 220 BuilderV1 BuilderVersion = "1" 221 // BuilderBuildKit is builder based on moby/buildkit project 222 BuilderBuildKit BuilderVersion = "2" 223 ) 224 225 // ImageBuildResponse holds information 226 // returned by a server after building 227 // an image. 228 type ImageBuildResponse struct { 229 Body io.ReadCloser 230 OSType string 231 } 232 233 // ImageCreateOptions holds information to create images. 234 type ImageCreateOptions struct { 235 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry. 236 Platform string // Platform is the target platform of the image if it needs to be pulled from the registry. 237 } 238 239 // ImageImportSource holds source information for ImageImport 240 type ImageImportSource struct { 241 Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this. 242 SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. 243 } 244 245 // ImageImportOptions holds information to import images from the client host. 246 type ImageImportOptions struct { 247 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 248 Message string // Message is the message to tag the image with 249 Changes []string // Changes are the raw changes to apply to this image 250 Platform string // Platform is the target platform of the image 251 } 252 253 // ImageListOptions holds parameters to list images with. 254 type ImageListOptions struct { 255 // All controls whether all images in the graph are filtered, or just 256 // the heads. 257 All bool 258 259 // Filters is a JSON-encoded set of filter arguments. 260 Filters filters.Args 261 262 // SharedSize indicates whether the shared size of images should be computed. 263 SharedSize bool 264 265 // ContainerCount indicates whether container count should be computed. 266 ContainerCount bool 267 } 268 269 // ImageLoadResponse returns information to the client about a load process. 270 type ImageLoadResponse struct { 271 // Body must be closed to avoid a resource leak 272 Body io.ReadCloser 273 JSON bool 274 } 275 276 // ImagePullOptions holds information to pull images. 277 type ImagePullOptions struct { 278 All bool 279 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 280 PrivilegeFunc RequestPrivilegeFunc 281 Platform string 282 } 283 284 // RequestPrivilegeFunc is a function interface that 285 // clients can supply to retry operations after 286 // getting an authorization error. 287 // This function returns the registry authentication 288 // header value in base 64 format, or an error 289 // if the privilege request fails. 290 type RequestPrivilegeFunc func() (string, error) 291 292 // ImagePushOptions holds information to push images. 293 type ImagePushOptions ImagePullOptions 294 295 // ImageRemoveOptions holds parameters to remove images. 296 type ImageRemoveOptions struct { 297 Force bool 298 PruneChildren bool 299 } 300 301 // ImageSearchOptions holds parameters to search images with. 302 type ImageSearchOptions struct { 303 RegistryAuth string 304 PrivilegeFunc RequestPrivilegeFunc 305 Filters filters.Args 306 Limit int 307 } 308 309 // ResizeOptions holds parameters to resize a tty. 310 // It can be used to resize container ttys and 311 // exec process ttys too. 312 type ResizeOptions struct { 313 Height uint 314 Width uint 315 } 316 317 // NodeListOptions holds parameters to list nodes with. 318 type NodeListOptions struct { 319 Filters filters.Args 320 } 321 322 // NodeRemoveOptions holds parameters to remove nodes with. 323 type NodeRemoveOptions struct { 324 Force bool 325 } 326 327 // ServiceCreateOptions contains the options to use when creating a service. 328 type ServiceCreateOptions struct { 329 // EncodedRegistryAuth is the encoded registry authorization credentials to 330 // use when updating the service. 331 // 332 // This field follows the format of the X-Registry-Auth header. 333 EncodedRegistryAuth string 334 335 // QueryRegistry indicates whether the service update requires 336 // contacting a registry. A registry may be contacted to retrieve 337 // the image digest and manifest, which in turn can be used to update 338 // platform or other information about the service. 339 QueryRegistry bool 340 } 341 342 // ServiceCreateResponse contains the information returned to a client 343 // on the creation of a new service. 344 type ServiceCreateResponse struct { 345 // ID is the ID of the created service. 346 ID string 347 // Warnings is a set of non-fatal warning messages to pass on to the user. 348 Warnings []string `json:",omitempty"` 349 } 350 351 // Values for RegistryAuthFrom in ServiceUpdateOptions 352 const ( 353 RegistryAuthFromSpec = "spec" 354 RegistryAuthFromPreviousSpec = "previous-spec" 355 ) 356 357 // ServiceUpdateOptions contains the options to be used for updating services. 358 type ServiceUpdateOptions struct { 359 // EncodedRegistryAuth is the encoded registry authorization credentials to 360 // use when updating the service. 361 // 362 // This field follows the format of the X-Registry-Auth header. 363 EncodedRegistryAuth string 364 365 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 366 // into this field. While it does open API users up to racy writes, most 367 // users may not need that level of consistency in practice. 368 369 // RegistryAuthFrom specifies where to find the registry authorization 370 // credentials if they are not given in EncodedRegistryAuth. Valid 371 // values are "spec" and "previous-spec". 372 RegistryAuthFrom string 373 374 // Rollback indicates whether a server-side rollback should be 375 // performed. When this is set, the provided spec will be ignored. 376 // The valid values are "previous" and "none". An empty value is the 377 // same as "none". 378 Rollback string 379 380 // QueryRegistry indicates whether the service update requires 381 // contacting a registry. A registry may be contacted to retrieve 382 // the image digest and manifest, which in turn can be used to update 383 // platform or other information about the service. 384 QueryRegistry bool 385 } 386 387 // ServiceListOptions holds parameters to list services with. 388 type ServiceListOptions struct { 389 Filters filters.Args 390 391 // Status indicates whether the server should include the service task 392 // count of running and desired tasks. 393 Status bool 394 } 395 396 // ServiceInspectOptions holds parameters related to the "service inspect" 397 // operation. 398 type ServiceInspectOptions struct { 399 InsertDefaults bool 400 } 401 402 // TaskListOptions holds parameters to list tasks with. 403 type TaskListOptions struct { 404 Filters filters.Args 405 } 406 407 // PluginRemoveOptions holds parameters to remove plugins. 408 type PluginRemoveOptions struct { 409 Force bool 410 } 411 412 // PluginEnableOptions holds parameters to enable plugins. 413 type PluginEnableOptions struct { 414 Timeout int 415 } 416 417 // PluginDisableOptions holds parameters to disable plugins. 418 type PluginDisableOptions struct { 419 Force bool 420 } 421 422 // PluginInstallOptions holds parameters to install a plugin. 423 type PluginInstallOptions struct { 424 Disabled bool 425 AcceptAllPermissions bool 426 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 427 RemoteRef string // RemoteRef is the plugin name on the registry 428 PrivilegeFunc RequestPrivilegeFunc 429 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 430 Args []string 431 } 432 433 // SwarmUnlockKeyResponse contains the response for Engine API: 434 // GET /swarm/unlockkey 435 type SwarmUnlockKeyResponse struct { 436 // UnlockKey is the unlock key in ASCII-armored format. 437 UnlockKey string 438 } 439 440 // PluginCreateOptions hold all options to plugin create. 441 type PluginCreateOptions struct { 442 RepoName string 443 }