types.go 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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. CPUShares bool
  173. CPUSet bool
  174. IPv4Forwarding bool
  175. BridgeNfIptables bool
  176. BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
  177. Debug bool
  178. NFd int
  179. OomKillDisable bool
  180. NGoroutines int
  181. SystemTime string
  182. ExecutionDriver string
  183. LoggingDriver string
  184. NEventsListener int
  185. KernelVersion string
  186. OperatingSystem string
  187. IndexServerAddress string
  188. RegistryConfig *registry.ServiceConfig
  189. InitSha1 string
  190. InitPath string
  191. NCPU int
  192. MemTotal int64
  193. DockerRootDir string
  194. HTTPProxy string `json:"HttpProxy"`
  195. HTTPSProxy string `json:"HttpsProxy"`
  196. NoProxy string
  197. Name string
  198. Labels []string
  199. ExperimentalBuild bool
  200. ServerVersion string
  201. ClusterStore string
  202. }
  203. // ExecStartCheck is a temp struct used by execStart
  204. // Config fields is part of ExecConfig in runconfig package
  205. type ExecStartCheck struct {
  206. // ExecStart will first check if it's detached
  207. Detach bool
  208. // Check if there's a tty
  209. Tty bool
  210. }
  211. // ContainerState stores container's running state
  212. // it's part of ContainerJSONBase and will return by "inspect" command
  213. type ContainerState struct {
  214. Status string
  215. Running bool
  216. Paused bool
  217. Restarting bool
  218. OOMKilled bool
  219. Dead bool
  220. Pid int
  221. ExitCode int
  222. Error string
  223. StartedAt string
  224. FinishedAt string
  225. }
  226. // ContainerJSONBase contains response of Remote API:
  227. // GET "/containers/{name:.*}/json"
  228. type ContainerJSONBase struct {
  229. ID string `json:"Id"`
  230. Created string
  231. Path string
  232. Args []string
  233. State *ContainerState
  234. Image string
  235. NetworkSettings *network.Settings
  236. ResolvConfPath string
  237. HostnamePath string
  238. HostsPath string
  239. LogPath string
  240. Name string
  241. RestartCount int
  242. Driver string
  243. ExecDriver string
  244. MountLabel string
  245. ProcessLabel string
  246. AppArmorProfile string
  247. ExecIDs []string
  248. HostConfig *runconfig.HostConfig
  249. GraphDriver GraphDriverData
  250. }
  251. // ContainerJSON is newly used struct along with MountPoint
  252. type ContainerJSON struct {
  253. *ContainerJSONBase
  254. Mounts []MountPoint
  255. Config *runconfig.Config
  256. }
  257. // MountPoint represents a mount point configuration inside the container.
  258. type MountPoint struct {
  259. Name string `json:",omitempty"`
  260. Source string
  261. Destination string
  262. Driver string `json:",omitempty"`
  263. Mode string
  264. RW bool
  265. }
  266. // Volume represents the configuration of a volume for the remote API
  267. type Volume struct {
  268. Name string // Name is the name of the volume
  269. Driver string // Driver is the Driver name used to create the volume
  270. Mountpoint string // Mountpoint is the location on disk of the volume
  271. }
  272. // VolumesListResponse contains the response for the remote API:
  273. // GET "/volumes"
  274. type VolumesListResponse struct {
  275. Volumes []*Volume // Volumes is the list of volumes being returned
  276. }
  277. // VolumeCreateRequest contains the response for the remote API:
  278. // POST "/volumes"
  279. type VolumeCreateRequest struct {
  280. Name string // Name is the requested name of the volume
  281. Driver string // Driver is the name of the driver that should be used to create the volume
  282. DriverOpts map[string]string // DriverOpts holds the driver specific options to use for when creating the volume.
  283. }
  284. // NetworkResource is the body of the "get network" http response message
  285. type NetworkResource struct {
  286. Name string `json:"name"`
  287. ID string `json:"id"`
  288. Driver string `json:"driver"`
  289. Containers map[string]EndpointResource `json:"containers"`
  290. Options map[string]interface{} `json:"options,omitempty"`
  291. }
  292. //EndpointResource contains network resources allocated and usd for a container in a network
  293. type EndpointResource struct {
  294. EndpointID string `json:"endpoint"`
  295. MacAddress string `json:"mac_address"`
  296. IPv4Address string `json:"ipv4_address"`
  297. IPv6Address string `json:"ipv6_address"`
  298. }
  299. // NetworkCreate is the expected body of the "create network" http request message
  300. type NetworkCreate struct {
  301. Name string `json:"name"`
  302. CheckDuplicate bool `json:"check_duplicate"`
  303. Driver string `json:"driver"`
  304. Options map[string]interface{} `json:"options"`
  305. }
  306. // NetworkCreateResponse is the response message sent by the server for network create call
  307. type NetworkCreateResponse struct {
  308. ID string `json:"id"`
  309. Warning string `json:"warning"`
  310. }
  311. // NetworkConnect represents the data to be used to connect a container to the network
  312. type NetworkConnect struct {
  313. Container string `json:"container"`
  314. }
  315. // NetworkDisconnect represents the data to be used to disconnect a container from the network
  316. type NetworkDisconnect struct {
  317. Container string `json:"container"`
  318. }