types.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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. }
  224. // ExecStartCheck is a temp struct used by execStart
  225. // Config fields is part of ExecConfig in runconfig package
  226. type ExecStartCheck struct {
  227. // ExecStart will first check if it's detached
  228. Detach bool
  229. // Check if there's a tty
  230. Tty bool
  231. }
  232. // ContainerState stores container's running state
  233. // it's part of ContainerJSONBase and will return by "inspect" command
  234. type ContainerState struct {
  235. Status string
  236. Running bool
  237. Paused bool
  238. Restarting bool
  239. OOMKilled bool
  240. Dead bool
  241. Pid int
  242. ExitCode int
  243. Error string
  244. StartedAt string
  245. FinishedAt string
  246. }
  247. // ContainerJSONBase contains response of Remote API:
  248. // GET "/containers/{name:.*}/json"
  249. type ContainerJSONBase struct {
  250. ID string `json:"Id"`
  251. Created string
  252. Path string
  253. Args []string
  254. State *ContainerState
  255. Image string
  256. ResolvConfPath string
  257. HostnamePath string
  258. HostsPath string
  259. LogPath string
  260. Name string
  261. RestartCount int
  262. Driver string
  263. MountLabel string
  264. ProcessLabel string
  265. AppArmorProfile string
  266. ExecIDs []string
  267. HostConfig *container.HostConfig
  268. GraphDriver GraphDriverData
  269. SizeRw *int64 `json:",omitempty"`
  270. SizeRootFs *int64 `json:",omitempty"`
  271. }
  272. // ContainerJSON is newly used struct along with MountPoint
  273. type ContainerJSON struct {
  274. *ContainerJSONBase
  275. Mounts []MountPoint
  276. Config *container.Config
  277. NetworkSettings *NetworkSettings
  278. }
  279. // NetworkSettings exposes the network settings in the api
  280. type NetworkSettings struct {
  281. NetworkSettingsBase
  282. DefaultNetworkSettings
  283. Networks map[string]*network.EndpointSettings
  284. }
  285. // SummaryNetworkSettings provides a summary of container's networks
  286. // in /containers/json
  287. type SummaryNetworkSettings struct {
  288. Networks map[string]*network.EndpointSettings
  289. }
  290. // NetworkSettingsBase holds basic information about networks
  291. type NetworkSettingsBase struct {
  292. Bridge string
  293. SandboxID string
  294. HairpinMode bool
  295. LinkLocalIPv6Address string
  296. LinkLocalIPv6PrefixLen int
  297. Ports nat.PortMap
  298. SandboxKey string
  299. SecondaryIPAddresses []network.Address
  300. SecondaryIPv6Addresses []network.Address
  301. }
  302. // DefaultNetworkSettings holds network information
  303. // during the 2 release deprecation period.
  304. // It will be removed in Docker 1.11.
  305. type DefaultNetworkSettings struct {
  306. EndpointID string
  307. Gateway string
  308. GlobalIPv6Address string
  309. GlobalIPv6PrefixLen int
  310. IPAddress string
  311. IPPrefixLen int
  312. IPv6Gateway string
  313. MacAddress string
  314. }
  315. // MountPoint represents a mount point configuration inside the container.
  316. type MountPoint struct {
  317. Name string `json:",omitempty"`
  318. Source string
  319. Destination string
  320. Driver string `json:",omitempty"`
  321. Mode string
  322. RW bool
  323. Propagation string
  324. }
  325. // Volume represents the configuration of a volume for the remote API
  326. type Volume struct {
  327. Name string // Name is the name of the volume
  328. Driver string // Driver is the Driver name used to create the volume
  329. Mountpoint string // Mountpoint is the location on disk of the volume
  330. }
  331. // VolumesListResponse contains the response for the remote API:
  332. // GET "/volumes"
  333. type VolumesListResponse struct {
  334. Volumes []*Volume // Volumes is the list of volumes being returned
  335. }
  336. // VolumeCreateRequest contains the response for the remote API:
  337. // POST "/volumes/create"
  338. type VolumeCreateRequest struct {
  339. Name string // Name is the requested name of the volume
  340. Driver string // Driver is the name of the driver that should be used to create the volume
  341. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  342. }
  343. // NetworkResource is the body of the "get network" http response message
  344. type NetworkResource struct {
  345. Name string
  346. ID string `json:"Id"`
  347. Scope string
  348. Driver string
  349. IPAM network.IPAM
  350. Containers map[string]EndpointResource
  351. Options map[string]string
  352. }
  353. // EndpointResource contains network resources allocated and used for a container in a network
  354. type EndpointResource struct {
  355. Name string
  356. EndpointID string
  357. MacAddress string
  358. IPv4Address string
  359. IPv6Address string
  360. }
  361. // NetworkCreate is the expected body of the "create network" http request message
  362. type NetworkCreate struct {
  363. Name string
  364. CheckDuplicate bool
  365. Driver string
  366. IPAM network.IPAM
  367. Options map[string]string
  368. }
  369. // NetworkCreateResponse is the response message sent by the server for network create call
  370. type NetworkCreateResponse struct {
  371. ID string `json:"Id"`
  372. Warning string
  373. }
  374. // NetworkConnect represents the data to be used to connect a container to the network
  375. type NetworkConnect struct {
  376. Container string
  377. }
  378. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  379. type NetworkDisconnect struct {
  380. Container string
  381. }