create_container_group.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. //Licensed under the Apache License, Version 2.0 (the "License");
  2. //you may not use this file except in compliance with the License.
  3. //You may obtain a copy of the License at
  4. //
  5. //http://www.apache.org/licenses/LICENSE-2.0
  6. //
  7. //Unless required by applicable law or agreed to in writing, software
  8. //distributed under the License is distributed on an "AS IS" BASIS,
  9. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. //See the License for the specific language governing permissions and
  11. //limitations under the License.
  12. //
  13. // Code generated by Alibaba Cloud SDK Code Generator.
  14. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
  15. package eci
  16. import (
  17. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
  19. )
  20. // CreateContainerGroup invokes the eci.CreateContainerGroup API synchronously
  21. // api document: https://help.aliyun.com/api/eci/createcontainergroup.html
  22. func (client *Client) CreateContainerGroup(request *CreateContainerGroupRequest) (response *CreateContainerGroupResponse, err error) {
  23. response = CreateCreateContainerGroupResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // CreateContainerGroupWithChan invokes the eci.CreateContainerGroup API asynchronously
  28. // api document: https://help.aliyun.com/api/eci/createcontainergroup.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) CreateContainerGroupWithChan(request *CreateContainerGroupRequest) (<-chan *CreateContainerGroupResponse, <-chan error) {
  31. responseChan := make(chan *CreateContainerGroupResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.CreateContainerGroup(request)
  37. if err != nil {
  38. errChan <- err
  39. } else {
  40. responseChan <- response
  41. }
  42. })
  43. if err != nil {
  44. errChan <- err
  45. close(responseChan)
  46. close(errChan)
  47. }
  48. return responseChan, errChan
  49. }
  50. // CreateContainerGroupWithCallback invokes the eci.CreateContainerGroup API asynchronously
  51. // api document: https://help.aliyun.com/api/eci/createcontainergroup.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) CreateContainerGroupWithCallback(request *CreateContainerGroupRequest, callback func(response *CreateContainerGroupResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *CreateContainerGroupResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.CreateContainerGroup(request)
  60. callback(response, err)
  61. result <- 1
  62. })
  63. if err != nil {
  64. defer close(result)
  65. callback(nil, err)
  66. result <- 0
  67. }
  68. return result
  69. }
  70. // CreateContainerGroupRequest is the request struct for api CreateContainerGroup
  71. type CreateContainerGroupRequest struct {
  72. *requests.RpcRequest
  73. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  74. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  75. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  76. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  77. RegionId string `position:"Query" name:"RegionId"`
  78. ZoneId string `position:"Query" name:"ZoneId"`
  79. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  80. VSwitchId string `position:"Query" name:"VSwitchId"`
  81. ContainerGroupName string `position:"Query" name:"ContainerGroupName"`
  82. RestartPolicy string `position:"Query" name:"RestartPolicy"`
  83. Tag *[]CreateContainerGroupTag `position:"Query" name:"Tag" type:"Repeated"`
  84. ImageRegistryCredential *[]CreateContainerGroupImageRegistryCredential `position:"Query" name:"ImageRegistryCredential" type:"Repeated"`
  85. Container *[]CreateContainerGroupContainer `position:"Query" name:"Container" type:"Repeated"`
  86. Volume *[]CreateContainerGroupVolume `position:"Query" name:"Volume" type:"Repeated"`
  87. EipInstanceId string `position:"Query" name:"EipInstanceId"`
  88. InitContainer *[]CreateContainerGroupInitContainer `position:"Query" name:"InitContainer" type:"Repeated"`
  89. Cpu requests.Float `position:"Query" name:"Cpu"`
  90. Memory requests.Float `position:"Query" name:"Memory"`
  91. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  92. DnsPolicy string `position:"Query" name:"DnsPolicy"`
  93. ClientToken string `position:"Query" name:"ClientToken"`
  94. HostAliase *[]CreateContainerGroupHostAliase `position:"Query" name:"HostAliase" type:"Repeated"`
  95. Arn *[]CreateContainerGroupArn `position:"Query" name:"Arn" type:"Repeated"`
  96. InstanceType string `position:"Query" name:"InstanceType"`
  97. SlsEnable requests.Boolean `position:"Query" name:"SlsEnable"`
  98. ImageSnapshotId string `position:"Query" name:"ImageSnapshotId"`
  99. RamRoleName string `position:"Query" name:"RamRoleName"`
  100. NtpServer []string `position:"Query" name:"NtpServer" type:"Repeated"`
  101. TerminationGracePeriodSeconds requests.Integer `position:"Query" name:"TerminationGracePeriodSeconds"`
  102. AutoMatchImageCache requests.Boolean `position:"Query" name:"AutoMatchImageCache"`
  103. VkClientVersion string `position:"Query" name:"VkClientVersion"`
  104. Ipv6AddressCount requests.Integer `position:"Query" name:"Ipv6AddressCount"`
  105. ActiveDeadlineSeconds requests.Integer `position:"Query" name:"ActiveDeadlineSeconds"`
  106. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  107. SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
  108. VSwitchStrategy string `position:"Query" name:"VSwitchStrategy"`
  109. DnsConfig CreateContainerGroupDnsConfig `position:"Query" name:"DnsConfig" type:"Struct"`
  110. SecurityContext CreateContainerGroupSecurityContext `position:"Query" name:"SecurityContext" type:"Struct"`
  111. }
  112. type CreateContainerGroupTag struct {
  113. Key string `name:"Key"`
  114. Value string `name:"Value"`
  115. }
  116. type CreateContainerGroupImageRegistryCredential struct {
  117. Server string `name:"Server"`
  118. UserName string `name:"UserName"`
  119. Password string `name:"Password"`
  120. }
  121. type CreateContainerGroupContainer struct {
  122. Image string `name:"Image"`
  123. Name string `name:"Name"`
  124. Cpu requests.Float `name:"Cpu"`
  125. Memory requests.Float `name:"Memory"`
  126. WorkingDir string `name:"WorkingDir"`
  127. ImagePullPolicy string `name:"ImagePullPolicy"`
  128. Command []string `name:"Command" type:"Repeated"`
  129. Arg []string `name:"Arg" type:"Repeated"`
  130. VolumeMount *[]CreateContainerGroupVolumeMount `name:"VolumeMount" type:"Repeated"`
  131. Port *[]CreateContainerGroupPort `name:"Port" type:"Repeated"`
  132. EnvironmentVar *[]CreateContainerGroupEnvironmentVar `name:"EnvironmentVar" type:"Repeated"`
  133. Stdin requests.Boolean `name:"Stdin"`
  134. StdinOnce requests.Boolean `name:"StdinOnce"`
  135. Tty requests.Boolean `name:"Tty"`
  136. Gpu requests.Integer `name:"Gpu"`
  137. LifecyclePostStartHandlerHttpGetHost string `name:"LifecyclePostStartHandlerHttpGetHost"`
  138. LifecyclePostStartHandlerHttpGetPort requests.Integer `name:"LifecyclePostStartHandlerHttpGetPort"`
  139. LifecyclePostStartHandlerHttpGetPath string `name:"LifecyclePostStartHandlerHttpGetPath"`
  140. LifecyclePostStartHandlerHttpGetScheme string `name:"LifecyclePostStartHandlerHttpGetScheme"`
  141. LifecyclePostStartHandlerHttpGetHttpHeader *[]CreateContainerGroupLifecyclePostStartHandlerHttpGetHttpHeader `name:"LifecyclePostStartHandlerHttpGetHttpHeader" type:"Repeated"`
  142. LifecyclePostStartHandlerExec []string `name:"LifecyclePostStartHandlerExec" type:"Repeated"`
  143. LifecyclePostStartHandlerTcpSocketHost string `name:"LifecyclePostStartHandlerTcpSocketHost"`
  144. LifecyclePostStartHandlerTcpSocketPort requests.Integer `name:"LifecyclePostStartHandlerTcpSocketPort"`
  145. LifecyclePreStopHandlerHttpGetHost string `name:"LifecyclePreStopHandlerHttpGetHost"`
  146. LifecyclePreStopHandlerHttpGetPort requests.Integer `name:"LifecyclePreStopHandlerHttpGetPort"`
  147. LifecyclePreStopHandlerHttpGetPath string `name:"LifecyclePreStopHandlerHttpGetPath"`
  148. LifecyclePreStopHandlerHttpGetScheme string `name:"LifecyclePreStopHandlerHttpGetScheme"`
  149. LifecyclePreStopHandlerHttpGetHttpHeader *[]CreateContainerGroupLifecyclePreStopHandlerHttpGetHttpHeader `name:"LifecyclePreStopHandlerHttpGetHttpHeader" type:"Repeated"`
  150. LifecyclePreStopHandlerExec []string `name:"LifecyclePreStopHandlerExec" type:"Repeated"`
  151. LifecyclePreStopHandlerTcpSocketHost string `name:"LifecyclePreStopHandlerTcpSocketHost"`
  152. LifecyclePreStopHandlerTcpSocketPort requests.Integer `name:"LifecyclePreStopHandlerTcpSocketPort"`
  153. ReadinessProbe CreateContainerGroupReadinessProbe `name:"ReadinessProbe" type:"Struct"`
  154. LivenessProbe CreateContainerGroupLivenessProbe `name:"LivenessProbe" type:"Struct"`
  155. SecurityContext CreateContainerGroupSecurityContext `name:"SecurityContext" type:"Struct"`
  156. }
  157. type CreateContainerGroupVolume struct {
  158. Name string `name:"Name"`
  159. Type string `name:"Type"`
  160. NFSVolume CreateContainerGroupNFSVolume `name:"NFSVolume" type:"Struct"`
  161. ConfigFileVolume CreateContainerGroupConfigFileVolume `name:"ConfigFileVolume" type:"Struct"`
  162. EmptyDirVolume CreateContainerGroupEmptyDirVolume `name:"EmptyDirVolume" type:"Struct"`
  163. DiskVolume CreateContainerGroupDiskVolume `name:"DiskVolume" type:"Struct"`
  164. FlexVolume CreateContainerGroupFlexVolume `name:"FlexVolume" type:"Struct"`
  165. HostPathVolume CreateContainerGroupHostPathVolume `name:"HostPathVolume" type:"Struct"`
  166. }
  167. type CreateContainerGroupInitContainer struct {
  168. Name string `name:"Name"`
  169. Image string `name:"Image"`
  170. Cpu requests.Float `name:"Cpu"`
  171. Memory requests.Float `name:"Memory"`
  172. WorkingDir string `name:"WorkingDir"`
  173. ImagePullPolicy string `name:"ImagePullPolicy"`
  174. Command []string `name:"Command" type:"Repeated"`
  175. Arg []string `name:"Arg" type:"Repeated"`
  176. VolumeMount *[]CreateContainerGroupVolumeMount `name:"VolumeMount" type:"Repeated"`
  177. Port *[]CreateContainerGroupPort `name:"Port" type:"Repeated"`
  178. EnvironmentVar *[]CreateContainerGroupEnvironmentVar `name:"EnvironmentVar" type:"Repeated"`
  179. Gpu requests.Integer `name:"Gpu"`
  180. SecurityContext CreateContainerGroupSecurityContext `name:"SecurityContext" type:"Struct"`
  181. }
  182. type CreateContainerGroupHostAliase struct {
  183. Ip string `name:"Ip"`
  184. Hostname []string `name:"Hostname" type:"Repeated"`
  185. }
  186. type CreateContainerGroupArn struct {
  187. RoleArn string `name:"RoleArn"`
  188. RoleType string `name:"RoleType"`
  189. AssumeRoleFor string `name:"AssumeRoleFor"`
  190. }
  191. type CreateContainerGroupDnsConfig struct {
  192. NameServer []string `name:"NameServer"`
  193. Search []string `name:"Search"`
  194. Option *[]CreateContainerGroupOption `name:"Option"`
  195. }
  196. type CreateContainerGroupSecurityContext struct {
  197. Sysctl *[]CreateContainerGroupSysctl `name:"Sysctl"`
  198. }
  199. type CreateContainerGroupVolumeMount struct {
  200. MountPath string `name:"MountPath"`
  201. ReadOnly requests.Boolean `name:"ReadOnly"`
  202. Name string `name:"Name"`
  203. SubPath string `name:"SubPath"`
  204. }
  205. type CreateContainerGroupPort struct {
  206. Protocol string `name:"Protocol"`
  207. Port requests.Integer `name:"Port"`
  208. }
  209. type CreateContainerGroupEnvironmentVar struct {
  210. Key string `name:"Key"`
  211. Value string `name:"Value"`
  212. FieldRef CreateContainerGroupFieldRef `name:"FieldRef" type:"Struct"`
  213. }
  214. type CreateContainerGroupFieldRef struct {
  215. FieldPath string `name:"FieldPath"`
  216. }
  217. type CreateContainerGroupLifecyclePostStartHandlerHttpGetHttpHeader struct {
  218. Name string `name:"Name"`
  219. Value string `name:"Value"`
  220. }
  221. type CreateContainerGroupLifecyclePreStopHandlerHttpGetHttpHeader struct {
  222. Name string `name:"Name"`
  223. Value string `name:"Value"`
  224. }
  225. type CreateContainerGroupReadinessProbe struct {
  226. InitialDelaySeconds requests.Integer `name:"InitialDelaySeconds"`
  227. PeriodSeconds requests.Integer `name:"PeriodSeconds"`
  228. SuccessThreshold requests.Integer `name:"SuccessThreshold"`
  229. FailureThreshold requests.Integer `name:"FailureThreshold"`
  230. TimeoutSeconds requests.Integer `name:"TimeoutSeconds"`
  231. HttpGet CreateContainerGroupHttpGet `name:"HttpGet"`
  232. Exec CreateContainerGroupExec `name:"Exec"`
  233. TcpSocket CreateContainerGroupTcpSocket `name:"TcpSocket"`
  234. }
  235. type CreateContainerGroupHttpGet struct {
  236. Path string `name:"Path"`
  237. Port requests.Integer `name:"Port"`
  238. Scheme string `name:"Scheme"`
  239. }
  240. type CreateContainerGroupExec struct {
  241. Command []string `name:"Command"`
  242. }
  243. type CreateContainerGroupTcpSocket struct {
  244. Port requests.Integer `name:"Port"`
  245. }
  246. type CreateContainerGroupLivenessProbe struct {
  247. InitialDelaySeconds requests.Integer `name:"InitialDelaySeconds"`
  248. PeriodSeconds requests.Integer `name:"PeriodSeconds"`
  249. SuccessThreshold requests.Integer `name:"SuccessThreshold"`
  250. FailureThreshold requests.Integer `name:"FailureThreshold"`
  251. TimeoutSeconds requests.Integer `name:"TimeoutSeconds"`
  252. HttpGet CreateContainerGroupHttpGet `name:"HttpGet"`
  253. Exec CreateContainerGroupExec `name:"Exec"`
  254. TcpSocket CreateContainerGroupTcpSocket `name:"TcpSocket"`
  255. }
  256. type CreateContainerGroupNFSVolume struct {
  257. Server string `name:"Server"`
  258. Path string `name:"Path"`
  259. ReadOnly requests.Boolean `name:"ReadOnly"`
  260. }
  261. type CreateContainerGroupConfigFileVolume struct {
  262. ConfigFileToPath *[]CreateContainerGroupConfigFileToPath `name:"ConfigFileToPath"`
  263. DefaultModel requests.Integer `name:"DefaultModel"`
  264. }
  265. type CreateContainerGroupConfigFileToPath struct {
  266. Content string `name:"Content"`
  267. Path string `name:"Path"`
  268. Mode requests.Integer `name:"Mode"`
  269. }
  270. type CreateContainerGroupEmptyDirVolume struct {
  271. Medium string `name:"Medium"`
  272. }
  273. type CreateContainerGroupDiskVolume struct {
  274. DiskId string `name:"DiskId"`
  275. FsType string `name:"FsType"`
  276. DiskSize requests.Integer `name:"DiskSize"`
  277. }
  278. type CreateContainerGroupFlexVolume struct {
  279. Driver string `name:"Driver"`
  280. FsType string `name:"FsType"`
  281. Options string `name:"Options"`
  282. }
  283. type CreateContainerGroupHostPathVolume struct {
  284. Type string `name:"Type"`
  285. Path string `name:"Path"`
  286. }
  287. type CreateContainerGroupOption struct {
  288. Name string `name:"Name"`
  289. Value string `name:"Value"`
  290. }
  291. type CreateContainerGroupSysctl struct {
  292. Name string `name:"Name"`
  293. Value string `name:"Value"`
  294. }
  295. // CreateContainerGroupResponse is the response struct for api CreateContainerGroup
  296. type CreateContainerGroupResponse struct {
  297. *responses.BaseResponse
  298. RequestId string `json:"RequestId" xml:"RequestId"`
  299. ContainerGroupId string `json:"ContainerGroupId" xml:"ContainerGroupId"`
  300. }
  301. // CreateCreateContainerGroupRequest creates a request to invoke CreateContainerGroup API
  302. func CreateCreateContainerGroupRequest() (request *CreateContainerGroupRequest) {
  303. request = &CreateContainerGroupRequest{
  304. RpcRequest: &requests.RpcRequest{},
  305. }
  306. request.InitWithApiInfo("Eci", "2018-08-08", "CreateContainerGroup", "eci", "openAPI")
  307. return
  308. }
  309. // CreateCreateContainerGroupResponse creates a response to parse from CreateContainerGroup response
  310. func CreateCreateContainerGroupResponse() (response *CreateContainerGroupResponse) {
  311. response = &CreateContainerGroupResponse{
  312. BaseResponse: &responses.BaseResponse{},
  313. }
  314. return
  315. }