github.com/walkingsparrow/docker@v1.4.2-0.20151218153551-b708a2249bfa/api/types/types.go (about)

     1  package types
     2  
     3  import (
     4  	"os"
     5  	"time"
     6  
     7  	"github.com/docker/docker/api/types/network"
     8  	"github.com/docker/docker/api/types/registry"
     9  	"github.com/docker/docker/pkg/nat"
    10  	"github.com/docker/docker/pkg/version"
    11  	"github.com/docker/docker/runconfig"
    12  )
    13  
    14  // ContainerCreateResponse contains the information returned to a client on the
    15  // creation of a new container.
    16  type ContainerCreateResponse struct {
    17  	// ID is the ID of the created container.
    18  	ID string `json:"Id"`
    19  
    20  	// Warnings are any warnings encountered during the creation of the container.
    21  	Warnings []string `json:"Warnings"`
    22  }
    23  
    24  // ContainerExecCreateResponse contains response of Remote API:
    25  // POST "/containers/{name:.*}/exec"
    26  type ContainerExecCreateResponse struct {
    27  	// ID is the exec ID.
    28  	ID string `json:"Id"`
    29  }
    30  
    31  // AuthResponse contains response of Remote API:
    32  // POST "/auth"
    33  type AuthResponse struct {
    34  	// Status is the authentication status
    35  	Status string `json:"Status"`
    36  }
    37  
    38  // ContainerWaitResponse contains response of Remote API:
    39  // POST "/containers/"+containerID+"/wait"
    40  type ContainerWaitResponse struct {
    41  	// StatusCode is the status code of the wait job
    42  	StatusCode int `json:"StatusCode"`
    43  }
    44  
    45  // ContainerCommitResponse contains response of Remote API:
    46  // POST "/commit?container="+containerID
    47  type ContainerCommitResponse struct {
    48  	ID string `json:"Id"`
    49  }
    50  
    51  // ContainerChange contains response of Remote API:
    52  // GET "/containers/{name:.*}/changes"
    53  type ContainerChange struct {
    54  	Kind int
    55  	Path string
    56  }
    57  
    58  // ImageHistory contains response of Remote API:
    59  // GET "/images/{name:.*}/history"
    60  type ImageHistory struct {
    61  	ID        string `json:"Id"`
    62  	Created   int64
    63  	CreatedBy string
    64  	Tags      []string
    65  	Size      int64
    66  	Comment   string
    67  }
    68  
    69  // ImageDelete contains response of Remote API:
    70  // DELETE "/images/{name:.*}"
    71  type ImageDelete struct {
    72  	Untagged string `json:",omitempty"`
    73  	Deleted  string `json:",omitempty"`
    74  }
    75  
    76  // Image contains response of Remote API:
    77  // GET "/images/json"
    78  type Image struct {
    79  	ID          string `json:"Id"`
    80  	ParentID    string `json:"ParentId"`
    81  	RepoTags    []string
    82  	RepoDigests []string
    83  	Created     int64
    84  	Size        int64
    85  	VirtualSize int64
    86  	Labels      map[string]string
    87  }
    88  
    89  // GraphDriverData returns Image's graph driver config info
    90  // when calling inspect command
    91  type GraphDriverData struct {
    92  	Name string
    93  	Data map[string]string
    94  }
    95  
    96  // ImageInspect contains response of Remote API:
    97  // GET "/images/{name:.*}/json"
    98  type ImageInspect struct {
    99  	ID              string `json:"Id"`
   100  	RepoTags        []string
   101  	RepoDigests     []string
   102  	Parent          string
   103  	Comment         string
   104  	Created         string
   105  	Container       string
   106  	ContainerConfig *runconfig.Config
   107  	DockerVersion   string
   108  	Author          string
   109  	Config          *runconfig.Config
   110  	Architecture    string
   111  	Os              string
   112  	Size            int64
   113  	VirtualSize     int64
   114  	GraphDriver     GraphDriverData
   115  }
   116  
   117  // Port stores open ports info of container
   118  // e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
   119  type Port struct {
   120  	IP          string `json:",omitempty"`
   121  	PrivatePort int
   122  	PublicPort  int `json:",omitempty"`
   123  	Type        string
   124  }
   125  
   126  // Container contains response of Remote API:
   127  // GET  "/containers/json"
   128  type Container struct {
   129  	ID         string `json:"Id"`
   130  	Names      []string
   131  	Image      string
   132  	ImageID    string
   133  	Command    string
   134  	Created    int64
   135  	Ports      []Port
   136  	SizeRw     int64 `json:",omitempty"`
   137  	SizeRootFs int64 `json:",omitempty"`
   138  	Labels     map[string]string
   139  	Status     string
   140  	HostConfig struct {
   141  		NetworkMode string `json:",omitempty"`
   142  	}
   143  	NetworkSettings *SummaryNetworkSettings
   144  }
   145  
   146  // CopyConfig contains request body of Remote API:
   147  // POST "/containers/"+containerID+"/copy"
   148  type CopyConfig struct {
   149  	Resource string
   150  }
   151  
   152  // ContainerPathStat is used to encode the header from
   153  // GET "/containers/{name:.*}/archive"
   154  // "Name" is the file or directory name.
   155  type ContainerPathStat struct {
   156  	Name       string      `json:"name"`
   157  	Size       int64       `json:"size"`
   158  	Mode       os.FileMode `json:"mode"`
   159  	Mtime      time.Time   `json:"mtime"`
   160  	LinkTarget string      `json:"linkTarget"`
   161  }
   162  
   163  // ContainerProcessList contains response of Remote API:
   164  // GET "/containers/{name:.*}/top"
   165  type ContainerProcessList struct {
   166  	Processes [][]string
   167  	Titles    []string
   168  }
   169  
   170  // Version contains response of Remote API:
   171  // GET "/version"
   172  type Version struct {
   173  	Version       string
   174  	APIVersion    version.Version `json:"ApiVersion"`
   175  	GitCommit     string
   176  	GoVersion     string
   177  	Os            string
   178  	Arch          string
   179  	KernelVersion string `json:",omitempty"`
   180  	Experimental  bool   `json:",omitempty"`
   181  	BuildTime     string `json:",omitempty"`
   182  }
   183  
   184  // Info contains response of Remote API:
   185  // GET "/info"
   186  type Info struct {
   187  	ID                 string
   188  	Containers         int
   189  	Images             int
   190  	Driver             string
   191  	DriverStatus       [][2]string
   192  	Plugins            PluginsInfo
   193  	MemoryLimit        bool
   194  	SwapLimit          bool
   195  	CPUCfsPeriod       bool `json:"CpuCfsPeriod"`
   196  	CPUCfsQuota        bool `json:"CpuCfsQuota"`
   197  	CPUShares          bool
   198  	CPUSet             bool
   199  	IPv4Forwarding     bool
   200  	BridgeNfIptables   bool
   201  	BridgeNfIP6tables  bool `json:"BridgeNfIp6tables"`
   202  	Debug              bool
   203  	NFd                int
   204  	OomKillDisable     bool
   205  	NGoroutines        int
   206  	SystemTime         string
   207  	ExecutionDriver    string
   208  	LoggingDriver      string
   209  	NEventsListener    int
   210  	KernelVersion      string
   211  	OperatingSystem    string
   212  	OSType             string
   213  	Architecture       string
   214  	IndexServerAddress string
   215  	RegistryConfig     *registry.ServiceConfig
   216  	InitSha1           string
   217  	InitPath           string
   218  	NCPU               int
   219  	MemTotal           int64
   220  	DockerRootDir      string
   221  	HTTPProxy          string `json:"HttpProxy"`
   222  	HTTPSProxy         string `json:"HttpsProxy"`
   223  	NoProxy            string
   224  	Name               string
   225  	Labels             []string
   226  	ExperimentalBuild  bool
   227  	ServerVersion      string
   228  	ClusterStore       string
   229  	ClusterAdvertise   string
   230  }
   231  
   232  // PluginsInfo is temp struct holds Plugins name
   233  // registered with docker daemon. It used by Info struct
   234  type PluginsInfo struct {
   235  	// List of Volume plugins registered
   236  	Volume []string
   237  	// List of Network plugins registered
   238  	Network []string
   239  }
   240  
   241  // ExecStartCheck is a temp struct used by execStart
   242  // Config fields is part of ExecConfig in runconfig package
   243  type ExecStartCheck struct {
   244  	// ExecStart will first check if it's detached
   245  	Detach bool
   246  	// Check if there's a tty
   247  	Tty bool
   248  }
   249  
   250  // ContainerState stores container's running state
   251  // it's part of ContainerJSONBase and will return by "inspect" command
   252  type ContainerState struct {
   253  	Status     string
   254  	Running    bool
   255  	Paused     bool
   256  	Restarting bool
   257  	OOMKilled  bool
   258  	Dead       bool
   259  	Pid        int
   260  	ExitCode   int
   261  	Error      string
   262  	StartedAt  string
   263  	FinishedAt string
   264  }
   265  
   266  // ContainerJSONBase contains response of Remote API:
   267  // GET "/containers/{name:.*}/json"
   268  type ContainerJSONBase struct {
   269  	ID              string `json:"Id"`
   270  	Created         string
   271  	Path            string
   272  	Args            []string
   273  	State           *ContainerState
   274  	Image           string
   275  	ResolvConfPath  string
   276  	HostnamePath    string
   277  	HostsPath       string
   278  	LogPath         string
   279  	Name            string
   280  	RestartCount    int
   281  	Driver          string
   282  	MountLabel      string
   283  	ProcessLabel    string
   284  	AppArmorProfile string
   285  	ExecIDs         []string
   286  	HostConfig      *runconfig.HostConfig
   287  	GraphDriver     GraphDriverData
   288  	SizeRw          *int64 `json:",omitempty"`
   289  	SizeRootFs      *int64 `json:",omitempty"`
   290  }
   291  
   292  // ContainerJSON is newly used struct along with MountPoint
   293  type ContainerJSON struct {
   294  	*ContainerJSONBase
   295  	Mounts          []MountPoint
   296  	Config          *runconfig.Config
   297  	NetworkSettings *NetworkSettings
   298  }
   299  
   300  // NetworkSettings exposes the network settings in the api
   301  type NetworkSettings struct {
   302  	NetworkSettingsBase
   303  	DefaultNetworkSettings
   304  	Networks map[string]*network.EndpointSettings
   305  }
   306  
   307  // SummaryNetworkSettings provides a summary of container's networks
   308  // in /containers/json
   309  type SummaryNetworkSettings struct {
   310  	Networks map[string]*network.EndpointSettings
   311  }
   312  
   313  // NetworkSettingsBase holds basic information about networks
   314  type NetworkSettingsBase struct {
   315  	Bridge                 string
   316  	SandboxID              string
   317  	HairpinMode            bool
   318  	LinkLocalIPv6Address   string
   319  	LinkLocalIPv6PrefixLen int
   320  	Ports                  nat.PortMap
   321  	SandboxKey             string
   322  	SecondaryIPAddresses   []network.Address
   323  	SecondaryIPv6Addresses []network.Address
   324  }
   325  
   326  // DefaultNetworkSettings holds network information
   327  // during the 2 release deprecation period.
   328  // It will be removed in Docker 1.11.
   329  type DefaultNetworkSettings struct {
   330  	EndpointID          string
   331  	Gateway             string
   332  	GlobalIPv6Address   string
   333  	GlobalIPv6PrefixLen int
   334  	IPAddress           string
   335  	IPPrefixLen         int
   336  	IPv6Gateway         string
   337  	MacAddress          string
   338  }
   339  
   340  // MountPoint represents a mount point configuration inside the container.
   341  type MountPoint struct {
   342  	Name        string `json:",omitempty"`
   343  	Source      string
   344  	Destination string
   345  	Driver      string `json:",omitempty"`
   346  	Mode        string
   347  	RW          bool
   348  	Propagation string
   349  }
   350  
   351  // Volume represents the configuration of a volume for the remote API
   352  type Volume struct {
   353  	Name       string // Name is the name of the volume
   354  	Driver     string // Driver is the Driver name used to create the volume
   355  	Mountpoint string // Mountpoint is the location on disk of the volume
   356  }
   357  
   358  // VolumesListResponse contains the response for the remote API:
   359  // GET "/volumes"
   360  type VolumesListResponse struct {
   361  	Volumes []*Volume // Volumes is the list of volumes being returned
   362  }
   363  
   364  // VolumeCreateRequest contains the response for the remote API:
   365  // POST "/volumes/create"
   366  type VolumeCreateRequest struct {
   367  	Name       string            // Name is the requested name of the volume
   368  	Driver     string            // Driver is the name of the driver that should be used to create the volume
   369  	DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
   370  }
   371  
   372  // NetworkResource is the body of the "get network" http response message
   373  type NetworkResource struct {
   374  	Name       string
   375  	ID         string `json:"Id"`
   376  	Scope      string
   377  	Driver     string
   378  	IPAM       network.IPAM
   379  	Containers map[string]EndpointResource
   380  	Options    map[string]string
   381  }
   382  
   383  // EndpointResource contains network resources allocated and used for a container in a network
   384  type EndpointResource struct {
   385  	Name        string
   386  	EndpointID  string
   387  	MacAddress  string
   388  	IPv4Address string
   389  	IPv6Address string
   390  }
   391  
   392  // NetworkCreate is the expected body of the "create network" http request message
   393  type NetworkCreate struct {
   394  	Name           string
   395  	CheckDuplicate bool
   396  	Driver         string
   397  	IPAM           network.IPAM
   398  	Options        map[string]string
   399  }
   400  
   401  // NetworkCreateResponse is the response message sent by the server for network create call
   402  type NetworkCreateResponse struct {
   403  	ID      string `json:"Id"`
   404  	Warning string
   405  }
   406  
   407  // NetworkConnect represents the data to be used to connect a container to the network
   408  type NetworkConnect struct {
   409  	Container string
   410  }
   411  
   412  // NetworkDisconnect represents the data to be used to disconnect a container from the network
   413  type NetworkDisconnect struct {
   414  	Container string
   415  }