types.go 9.6 KB

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