types.go 11 KB

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