github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/api/types/client.go (about) 1 package types 2 3 import ( 4 "bufio" 5 "io" 6 "net" 7 "os" 8 9 "github.com/docker/docker/api/types/container" 10 "github.com/docker/docker/api/types/filters" 11 "github.com/docker/go-units" 12 ) 13 14 // CheckpointCreateOptions holds parameters to create a checkpoint from a container 15 type CheckpointCreateOptions struct { 16 CheckpointID string 17 CheckpointDir string 18 Exit bool 19 } 20 21 // CheckpointListOptions holds parameters to list checkpoints for a container 22 type CheckpointListOptions struct { 23 CheckpointDir string 24 } 25 26 // CheckpointDeleteOptions holds parameters to delete a checkpoint from a container 27 type CheckpointDeleteOptions struct { 28 CheckpointID string 29 CheckpointDir string 30 } 31 32 // ContainerAttachOptions holds parameters to attach to a container. 33 type ContainerAttachOptions struct { 34 Stream bool 35 Stdin bool 36 Stdout bool 37 Stderr bool 38 DetachKeys string 39 Logs bool 40 } 41 42 // ContainerCommitOptions holds parameters to commit changes into a container. 43 type ContainerCommitOptions struct { 44 Reference string 45 Comment string 46 Author string 47 Changes []string 48 Pause bool 49 Config *container.Config 50 } 51 52 // ContainerExecInspect holds information returned by exec inspect. 53 type ContainerExecInspect struct { 54 ExecID string 55 ContainerID string 56 Running bool 57 ExitCode int 58 Pid int 59 } 60 61 // ContainerListOptions holds parameters to list containers with. 62 type ContainerListOptions struct { 63 Quiet bool 64 Size bool 65 All bool 66 Latest bool 67 Since string 68 Before string 69 Limit int 70 Filters filters.Args 71 } 72 73 // ContainerLogsOptions holds parameters to filter logs with. 74 type ContainerLogsOptions struct { 75 ShowStdout bool 76 ShowStderr bool 77 Since string 78 Timestamps bool 79 Follow bool 80 Tail string 81 Details bool 82 } 83 84 // ContainerRemoveOptions holds parameters to remove containers. 85 type ContainerRemoveOptions struct { 86 RemoveVolumes bool 87 RemoveLinks bool 88 Force bool 89 } 90 91 // ContainerStartOptions holds parameters to start containers. 92 type ContainerStartOptions struct { 93 CheckpointID string 94 CheckpointDir string 95 } 96 97 // CopyToContainerOptions holds information 98 // about files to copy into a container 99 type CopyToContainerOptions struct { 100 AllowOverwriteDirWithFile 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 // HijackedResponse holds connection information for a hijacked request. 116 type HijackedResponse struct { 117 Conn net.Conn 118 Reader *bufio.Reader 119 } 120 121 // Close closes the hijacked connection and reader. 122 func (h *HijackedResponse) Close() { 123 h.Conn.Close() 124 } 125 126 // CloseWriter is an interface that implements structs 127 // that close input streams to prevent from writing. 128 type CloseWriter interface { 129 CloseWrite() error 130 } 131 132 // CloseWrite closes a readWriter for writing. 133 func (h *HijackedResponse) CloseWrite() error { 134 if conn, ok := h.Conn.(CloseWriter); ok { 135 return conn.CloseWrite() 136 } 137 return nil 138 } 139 140 // ImageBuildOptions holds the information 141 // necessary to build images. 142 type ImageBuildOptions struct { 143 Tags []string 144 SuppressOutput bool 145 RemoteContext string 146 NoCache bool 147 Remove bool 148 ForceRemove bool 149 PullParent bool 150 Isolation container.Isolation 151 CPUSetCPUs string 152 CPUSetMems string 153 CPUShares int64 154 CPUQuota int64 155 CPUPeriod int64 156 Memory int64 157 MemorySwap int64 158 CgroupParent string 159 NetworkMode string 160 ShmSize int64 161 Dockerfile string 162 Ulimits []*units.Ulimit 163 // BuildArgs needs to be a *string instead of just a string so that 164 // we can tell the difference between "" (empty string) and no value 165 // at all (nil). See the parsing of buildArgs in 166 // api/server/router/build/build_routes.go for even more info. 167 BuildArgs map[string]*string 168 AuthConfigs map[string]AuthConfig 169 Context io.Reader 170 Labels map[string]string 171 // squash the resulting image's layers to the parent 172 // preserves the original image and creates a new one from the parent with all 173 // the changes applied to a single layer 174 Squash bool 175 // CacheFrom specifies images that are used for matching cache. Images 176 // specified here do not need to have a valid parent chain to match cache. 177 CacheFrom []string 178 SecurityOpt []string 179 } 180 181 // ImageBuildResponse holds information 182 // returned by a server after building 183 // an image. 184 type ImageBuildResponse struct { 185 Body io.ReadCloser 186 OSType string 187 } 188 189 // ImageCreateOptions holds information to create images. 190 type ImageCreateOptions struct { 191 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 192 } 193 194 // ImageImportSource holds source information for ImageImport 195 type ImageImportSource struct { 196 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. 197 SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute. 198 } 199 200 // ImageImportOptions holds information to import images from the client host. 201 type ImageImportOptions struct { 202 Tag string // Tag is the name to tag this image with. This attribute is deprecated. 203 Message string // Message is the message to tag the image with 204 Changes []string // Changes are the raw changes to apply to this image 205 } 206 207 // ImageListOptions holds parameters to filter the list of images with. 208 type ImageListOptions struct { 209 All bool 210 Filters filters.Args 211 } 212 213 // ImageLoadResponse returns information to the client about a load process. 214 type ImageLoadResponse struct { 215 // Body must be closed to avoid a resource leak 216 Body io.ReadCloser 217 JSON bool 218 } 219 220 // ImagePullOptions holds information to pull images. 221 type ImagePullOptions struct { 222 All bool 223 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 224 PrivilegeFunc RequestPrivilegeFunc 225 } 226 227 // RequestPrivilegeFunc is a function interface that 228 // clients can supply to retry operations after 229 // getting an authorization error. 230 // This function returns the registry authentication 231 // header value in base 64 format, or an error 232 // if the privilege request fails. 233 type RequestPrivilegeFunc func() (string, error) 234 235 //ImagePushOptions holds information to push images. 236 type ImagePushOptions ImagePullOptions 237 238 // ImageRemoveOptions holds parameters to remove images. 239 type ImageRemoveOptions struct { 240 Force bool 241 PruneChildren bool 242 } 243 244 // ImageSearchOptions holds parameters to search images with. 245 type ImageSearchOptions struct { 246 RegistryAuth string 247 PrivilegeFunc RequestPrivilegeFunc 248 Filters filters.Args 249 Limit int 250 } 251 252 // ResizeOptions holds parameters to resize a tty. 253 // It can be used to resize container ttys and 254 // exec process ttys too. 255 type ResizeOptions struct { 256 Height uint 257 Width uint 258 } 259 260 // VersionResponse holds version information for the client and the server 261 type VersionResponse struct { 262 Client *Version 263 Server *Version 264 } 265 266 // ServerOK returns true when the client could connect to the docker server 267 // and parse the information received. It returns false otherwise. 268 func (v VersionResponse) ServerOK() bool { 269 return v.Server != nil 270 } 271 272 // NodeListOptions holds parameters to list nodes with. 273 type NodeListOptions struct { 274 Filters filters.Args 275 } 276 277 // NodeRemoveOptions holds parameters to remove nodes with. 278 type NodeRemoveOptions struct { 279 Force bool 280 } 281 282 // ServiceCreateOptions contains the options to use when creating a service. 283 type ServiceCreateOptions struct { 284 // EncodedRegistryAuth is the encoded registry authorization credentials to 285 // use when updating the service. 286 // 287 // This field follows the format of the X-Registry-Auth header. 288 EncodedRegistryAuth string 289 } 290 291 // ServiceCreateResponse contains the information returned to a client 292 // on the creation of a new service. 293 type ServiceCreateResponse struct { 294 // ID is the ID of the created service. 295 ID string 296 // Warnings is a set of non-fatal warning messages to pass on to the user. 297 Warnings []string `json:",omitempty"` 298 } 299 300 // Values for RegistryAuthFrom in ServiceUpdateOptions 301 const ( 302 RegistryAuthFromSpec = "spec" 303 RegistryAuthFromPreviousSpec = "previous-spec" 304 ) 305 306 // ServiceUpdateOptions contains the options to be used for updating services. 307 type ServiceUpdateOptions struct { 308 // EncodedRegistryAuth is the encoded registry authorization credentials to 309 // use when updating the service. 310 // 311 // This field follows the format of the X-Registry-Auth header. 312 EncodedRegistryAuth string 313 314 // TODO(stevvooe): Consider moving the version parameter of ServiceUpdate 315 // into this field. While it does open API users up to racy writes, most 316 // users may not need that level of consistency in practice. 317 318 // RegistryAuthFrom specifies where to find the registry authorization 319 // credentials if they are not given in EncodedRegistryAuth. Valid 320 // values are "spec" and "previous-spec". 321 RegistryAuthFrom string 322 } 323 324 // ServiceListOptions holds parameters to list services with. 325 type ServiceListOptions struct { 326 Filters filters.Args 327 } 328 329 // TaskListOptions holds parameters to list tasks with. 330 type TaskListOptions struct { 331 Filters filters.Args 332 } 333 334 // PluginRemoveOptions holds parameters to remove plugins. 335 type PluginRemoveOptions struct { 336 Force bool 337 } 338 339 // PluginEnableOptions holds parameters to enable plugins. 340 type PluginEnableOptions struct { 341 Timeout int 342 } 343 344 // PluginDisableOptions holds parameters to disable plugins. 345 type PluginDisableOptions struct { 346 Force bool 347 } 348 349 // PluginInstallOptions holds parameters to install a plugin. 350 type PluginInstallOptions struct { 351 Disabled bool 352 AcceptAllPermissions bool 353 RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry 354 RemoteRef string // RemoteRef is the plugin name on the registry 355 PrivilegeFunc RequestPrivilegeFunc 356 AcceptPermissionsFunc func(PluginPrivileges) (bool, error) 357 Args []string 358 } 359 360 // SecretRequestOption is a type for requesting secrets 361 type SecretRequestOption struct { 362 Source string 363 Target string 364 UID string 365 GID string 366 Mode os.FileMode 367 } 368 369 // SwarmUnlockKeyResponse contains the response for Engine API: 370 // GET /swarm/unlockkey 371 type SwarmUnlockKeyResponse struct { 372 // UnlockKey is the unlock key in ASCII-armored format. 373 UnlockKey string 374 } 375 376 // PluginCreateOptions hold all options to plugin create. 377 type PluginCreateOptions struct { 378 RepoName string 379 }