types.go 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. package types
  2. import (
  3. "os"
  4. "time"
  5. "github.com/docker/docker/daemon/network"
  6. "github.com/docker/docker/pkg/version"
  7. "github.com/docker/docker/registry"
  8. "github.com/docker/docker/runconfig"
  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. // AuthResponse contains response of Remote API:
  25. // POST "/auth"
  26. type AuthResponse struct {
  27. // Status is the authentication status
  28. Status string `json:"Status"`
  29. }
  30. // ContainerWaitResponse contains response of Remote API:
  31. // POST "/containers/"+containerID+"/wait"
  32. type ContainerWaitResponse struct {
  33. // StatusCode is the status code of the wait job
  34. StatusCode int `json:"StatusCode"`
  35. }
  36. // ContainerCommitResponse contains response of Remote API:
  37. // POST "/commit?container="+containerID
  38. type ContainerCommitResponse struct {
  39. ID string `json:"Id"`
  40. }
  41. // ContainerChange contains response of Remote API:
  42. // GET "/containers/{name:.*}/changes"
  43. type ContainerChange struct {
  44. Kind int
  45. Path string
  46. }
  47. // ImageHistory contains response of Remote API:
  48. // GET "/images/{name:.*}/history"
  49. type ImageHistory struct {
  50. ID string `json:"Id"`
  51. Created int64
  52. CreatedBy string
  53. Tags []string
  54. Size int64
  55. Comment string
  56. }
  57. // ImageDelete contains response of Remote API:
  58. // DELETE "/images/{name:.*}"
  59. type ImageDelete struct {
  60. Untagged string `json:",omitempty"`
  61. Deleted string `json:",omitempty"`
  62. }
  63. // Image contains response of Remote API:
  64. // GET "/images/json"
  65. type Image struct {
  66. ID string `json:"Id"`
  67. ParentID string `json:"ParentId"`
  68. RepoTags []string
  69. RepoDigests []string
  70. Created int64
  71. Size int64
  72. VirtualSize int64
  73. Labels map[string]string
  74. }
  75. // GraphDriverData returns Image's graph driver config info
  76. // when calling inspect command
  77. type GraphDriverData struct {
  78. Name string
  79. Data map[string]string
  80. }
  81. // ImageInspect contains response of Remote API:
  82. // GET "/images/{name:.*}/json"
  83. type ImageInspect struct {
  84. ID string `json:"Id"`
  85. RepoTags []string
  86. RepoDigests []string
  87. Parent string
  88. Comment string
  89. Created string
  90. Container string
  91. ContainerConfig *runconfig.Config
  92. DockerVersion string
  93. Author string
  94. Config *runconfig.Config
  95. Architecture string
  96. Os string
  97. Size int64
  98. VirtualSize int64
  99. GraphDriver GraphDriverData
  100. }
  101. // Port stores open ports info of container
  102. // e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
  103. type Port struct {
  104. IP string `json:",omitempty"`
  105. PrivatePort int
  106. PublicPort int `json:",omitempty"`
  107. Type string
  108. }
  109. // Container contains response of Remote API:
  110. // GET "/containers/json"
  111. type Container struct {
  112. ID string `json:"Id"`
  113. Names []string
  114. Image string
  115. ImageID string
  116. Command string
  117. Created int64
  118. Ports []Port
  119. SizeRw int64 `json:",omitempty"`
  120. SizeRootFs int64 `json:",omitempty"`
  121. Labels map[string]string
  122. Status string
  123. HostConfig struct {
  124. NetworkMode string `json:",omitempty"`
  125. }
  126. }
  127. // CopyConfig contains request body of Remote API:
  128. // POST "/containers/"+containerID+"/copy"
  129. type CopyConfig struct {
  130. Resource string
  131. }
  132. // ContainerPathStat is used to encode the header from
  133. // GET "/containers/{name:.*}/archive"
  134. // "Name" is the file or directory name.
  135. type ContainerPathStat struct {
  136. Name string `json:"name"`
  137. Size int64 `json:"size"`
  138. Mode os.FileMode `json:"mode"`
  139. Mtime time.Time `json:"mtime"`
  140. LinkTarget string `json:"linkTarget"`
  141. }
  142. // ContainerProcessList contains response of Remote API:
  143. // GET "/containers/{name:.*}/top"
  144. type ContainerProcessList struct {
  145. Processes [][]string
  146. Titles []string
  147. }
  148. // Version contains response of Remote API:
  149. // GET "/version"
  150. type Version struct {
  151. Version string
  152. APIVersion version.Version `json:"ApiVersion"`
  153. GitCommit string
  154. GoVersion string
  155. Os string
  156. Arch string
  157. KernelVersion string `json:",omitempty"`
  158. Experimental bool `json:",omitempty"`
  159. BuildTime string `json:",omitempty"`
  160. }
  161. // Info contains response of Remote API:
  162. // GET "/info"
  163. type Info struct {
  164. ID string
  165. Containers int
  166. Images int
  167. Driver string
  168. DriverStatus [][2]string
  169. MemoryLimit bool
  170. SwapLimit bool
  171. CPUCfsPeriod bool `json:"CpuCfsPeriod"`
  172. CPUCfsQuota bool `json:"CpuCfsQuota"`
  173. IPv4Forwarding bool
  174. BridgeNfIptables bool
  175. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  176. Debug bool
  177. NFd int
  178. OomKillDisable bool
  179. NGoroutines int
  180. SystemTime string
  181. ExecutionDriver string
  182. LoggingDriver string
  183. NEventsListener int
  184. KernelVersion string
  185. OperatingSystem string
  186. IndexServerAddress string
  187. RegistryConfig *registry.ServiceConfig
  188. InitSha1 string
  189. InitPath string
  190. NCPU int
  191. MemTotal int64
  192. DockerRootDir string
  193. HTTPProxy string `json:"HttpProxy"`
  194. HTTPSProxy string `json:"HttpsProxy"`
  195. NoProxy string
  196. Name string
  197. Labels []string
  198. ExperimentalBuild bool
  199. ServerVersion string
  200. ClusterStore string
  201. }
  202. // ExecStartCheck is a temp struct used by execStart
  203. // Config fields is part of ExecConfig in runconfig package
  204. type ExecStartCheck struct {
  205. // ExecStart will first check if it's detached
  206. Detach bool
  207. // Check if there's a tty
  208. Tty bool
  209. }
  210. // ContainerState stores container's running state
  211. // it's part of ContainerJSONBase and will return by "inspect" command
  212. type ContainerState struct {
  213. Status string
  214. Running bool
  215. Paused bool
  216. Restarting bool
  217. OOMKilled bool
  218. Dead bool
  219. Pid int
  220. ExitCode int
  221. Error string
  222. StartedAt string
  223. FinishedAt string
  224. }
  225. // ContainerJSONBase contains response of Remote API:
  226. // GET "/containers/{name:.*}/json"
  227. type ContainerJSONBase struct {
  228. ID string `json:"Id"`
  229. Created string
  230. Path string
  231. Args []string
  232. State *ContainerState
  233. Image string
  234. NetworkSettings *network.Settings
  235. ResolvConfPath string
  236. HostnamePath string
  237. HostsPath string
  238. LogPath string
  239. Name string
  240. RestartCount int
  241. Driver string
  242. ExecDriver string
  243. MountLabel string
  244. ProcessLabel string
  245. AppArmorProfile string
  246. ExecIDs []string
  247. HostConfig *runconfig.HostConfig
  248. GraphDriver GraphDriverData
  249. SizeRw *int64 `json:",omitempty"`
  250. SizeRootFs *int64 `json:",omitempty"`
  251. }
  252. // ContainerJSON is newly used struct along with MountPoint
  253. type ContainerJSON struct {
  254. *ContainerJSONBase
  255. Mounts []MountPoint
  256. Config *runconfig.Config
  257. }
  258. // MountPoint represents a mount point configuration inside the container.
  259. type MountPoint struct {
  260. Name string `json:",omitempty"`
  261. Source string
  262. Destination string
  263. Driver string `json:",omitempty"`
  264. Mode string
  265. RW bool
  266. }
  267. // Volume represents the configuration of a volume for the remote API
  268. type Volume struct {
  269. Name string // Name is the name of the volume
  270. Driver string // Driver is the Driver name used to create the volume
  271. Mountpoint string // Mountpoint is the location on disk of the volume
  272. }
  273. // VolumesListResponse contains the response for the remote API:
  274. // GET "/volumes"
  275. type VolumesListResponse struct {
  276. Volumes []*Volume // Volumes is the list of volumes being returned
  277. }
  278. // VolumeCreateRequest contains the response for the remote API:
  279. // POST "/volumes/create"
  280. type VolumeCreateRequest struct {
  281. Name string // Name is the requested name of the volume
  282. Driver string // Driver is the name of the driver that should be used to create the volume
  283. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  284. }
  285. // NetworkResource is the body of the "get network" http response message
  286. type NetworkResource struct {
  287. Name string `json:"name"`
  288. ID string `json:"id"`
  289. Scope string `json:"scope"`
  290. Driver string `json:"driver"`
  291. IPAM network.IPAM `json:"ipam"`
  292. Containers map[string]EndpointResource `json:"containers"`
  293. Options map[string]string `json:"options"`
  294. }
  295. //EndpointResource contains network resources allocated and usd for a container in a network
  296. type EndpointResource struct {
  297. EndpointID string `json:"endpoint"`
  298. MacAddress string `json:"mac_address"`
  299. IPv4Address string `json:"ipv4_address"`
  300. IPv6Address string `json:"ipv6_address"`
  301. }
  302. // NetworkCreate is the expected body of the "create network" http request message
  303. type NetworkCreate struct {
  304. Name string `json:"name"`
  305. CheckDuplicate bool `json:"check_duplicate"`
  306. Driver string `json:"driver"`
  307. IPAM network.IPAM `json:"ipam"`
  308. Options map[string]string `json:"options"`
  309. }
  310. // NetworkCreateResponse is the response message sent by the server for network create call
  311. type NetworkCreateResponse struct {
  312. ID string `json:"id"`
  313. Warning string `json:"warning"`
  314. }
  315. // NetworkConnect represents the data to be used to connect a container to the network
  316. type NetworkConnect struct {
  317. Container string `json:"container"`
  318. }
  319. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  320. type NetworkDisconnect struct {
  321. Container string `json:"container"`
  322. }