types.go 11 KB

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