create_container_group.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. DnsConfig CreateContainerGroupDnsConfig `position:"Query" name:"DnsConfig" type:"Struct"`
  101. SecurityContext CreateContainerGroupSecurityContext `position:"Query" name:"SecurityContext" type:"Struct"`
  102. }
  103. type CreateContainerGroupTag struct {
  104. Key string `name:"Key"`
  105. Value string `name:"Value"`
  106. }
  107. type CreateContainerGroupImageRegistryCredential struct {
  108. Server string `name:"Server"`
  109. UserName string `name:"UserName"`
  110. Password string `name:"Password"`
  111. }
  112. type CreateContainerGroupContainer struct {
  113. Image string `name:"Image"`
  114. Name string `name:"Name"`
  115. Cpu requests.Float `name:"Cpu"`
  116. Memory requests.Float `name:"Memory"`
  117. WorkingDir string `name:"WorkingDir"`
  118. ImagePullPolicy string `name:"ImagePullPolicy"`
  119. Command []string `name:"Command" type:"Repeated"`
  120. Arg []string `name:"Arg" type:"Repeated"`
  121. VolumeMount *[]CreateContainerGroupVolumeMount `name:"VolumeMount" type:"Repeated"`
  122. Port *[]CreateContainerGroupPort `name:"Port" type:"Repeated"`
  123. EnvironmentVar *[]CreateContainerGroupEnvironmentVar `name:"EnvironmentVar" type:"Repeated"`
  124. Stdin requests.Boolean `name:"Stdin"`
  125. StdinOnce requests.Boolean `name:"StdinOnce"`
  126. Tty requests.Boolean `name:"Tty"`
  127. Gpu requests.Integer `name:"Gpu"`
  128. ReadinessProbe CreateContainerGroupReadinessProbe `name:"ReadinessProbe" type:"Struct"`
  129. LivenessProbe CreateContainerGroupLivenessProbe `name:"LivenessProbe" type:"Struct"`
  130. SecurityContext CreateContainerGroupSecurityContext `name:"SecurityContext" type:"Struct"`
  131. }
  132. type CreateContainerGroupVolume struct {
  133. Name string `name:"Name"`
  134. Type string `name:"Type"`
  135. NFSVolume CreateContainerGroupNFSVolume `name:"NFSVolume" type:"Struct"`
  136. ConfigFileVolume CreateContainerGroupConfigFileVolume `name:"ConfigFileVolume" type:"Struct"`
  137. EmptyDirVolume CreateContainerGroupEmptyDirVolume `name:"EmptyDirVolume" type:"Struct"`
  138. DiskVolume CreateContainerGroupDiskVolume `name:"DiskVolume" type:"Struct"`
  139. }
  140. type CreateContainerGroupInitContainer struct {
  141. Name string `name:"Name"`
  142. Image string `name:"Image"`
  143. Cpu requests.Float `name:"Cpu"`
  144. Memory requests.Float `name:"Memory"`
  145. WorkingDir string `name:"WorkingDir"`
  146. ImagePullPolicy string `name:"ImagePullPolicy"`
  147. Command []string `name:"Command" type:"Repeated"`
  148. Arg []string `name:"Arg" type:"Repeated"`
  149. VolumeMount *[]CreateContainerGroupVolumeMount `name:"VolumeMount" type:"Repeated"`
  150. Port *[]CreateContainerGroupPort `name:"Port" type:"Repeated"`
  151. EnvironmentVar *[]CreateContainerGroupEnvironmentVar `name:"EnvironmentVar" type:"Repeated"`
  152. Gpu requests.Integer `name:"Gpu"`
  153. SecurityContext CreateContainerGroupSecurityContext `name:"SecurityContext" type:"Struct"`
  154. }
  155. type CreateContainerGroupHostAliase struct {
  156. Ip string `name:"Ip"`
  157. Hostname []string `name:"Hostname" type:"Repeated"`
  158. }
  159. type CreateContainerGroupArn struct {
  160. RoleArn string `name:"RoleArn"`
  161. RoleType string `name:"RoleType"`
  162. AssumeRoleFor string `name:"AssumeRoleFor"`
  163. }
  164. type CreateContainerGroupDnsConfig struct {
  165. NameServer []string `name:"NameServer" type:"Repeated"`
  166. Search []string `name:"Search" type:"Repeated"`
  167. Option *[]CreateContainerGroupOption `name:"Option" type:"Repeated"`
  168. }
  169. type CreateContainerGroupSecurityContext struct {
  170. Sysctl *[]CreateContainerGroupSysctl `name:"Sysctl" type:"Repeated"`
  171. }
  172. type CreateContainerGroupVolumeMount struct {
  173. MountPath string `name:"MountPath"`
  174. ReadOnly requests.Boolean `name:"ReadOnly"`
  175. Name string `name:"Name"`
  176. SubPath string `name:"SubPath"`
  177. }
  178. type CreateContainerGroupPort struct {
  179. Protocol string `name:"Protocol"`
  180. Port requests.Integer `name:"Port"`
  181. }
  182. type CreateContainerGroupEnvironmentVar struct {
  183. Key string `name:"Key"`
  184. Value string `name:"Value"`
  185. FieldRef CreateContainerGroupFieldRef `name:"FieldRef" type:"Struct"`
  186. }
  187. type CreateContainerGroupFieldRef struct {
  188. FieldPath string `name:"FieldPath"`
  189. }
  190. type CreateContainerGroupReadinessProbe struct {
  191. InitialDelaySeconds requests.Integer `name:"InitialDelaySeconds"`
  192. PeriodSeconds requests.Integer `name:"PeriodSeconds"`
  193. SuccessThreshold requests.Integer `name:"SuccessThreshold"`
  194. FailureThreshold requests.Integer `name:"FailureThreshold"`
  195. TimeoutSeconds requests.Integer `name:"TimeoutSeconds"`
  196. HttpGet CreateContainerGroupHttpGet `name:"HttpGet"`
  197. Exec CreateContainerGroupExec `name:"Exec"`
  198. TcpSocket CreateContainerGroupTcpSocket `name:"TcpSocket"`
  199. }
  200. type CreateContainerGroupHttpGet struct {
  201. Path string `name:"Path"`
  202. Port requests.Integer `name:"Port"`
  203. Scheme string `name:"Scheme"`
  204. }
  205. type CreateContainerGroupExec struct {
  206. Command []string `name:"Command" type:"Repeated"`
  207. }
  208. type CreateContainerGroupTcpSocket struct {
  209. Port requests.Integer `name:"Port"`
  210. }
  211. type CreateContainerGroupLivenessProbe struct {
  212. InitialDelaySeconds requests.Integer `name:"InitialDelaySeconds"`
  213. PeriodSeconds requests.Integer `name:"PeriodSeconds"`
  214. SuccessThreshold requests.Integer `name:"SuccessThreshold"`
  215. FailureThreshold requests.Integer `name:"FailureThreshold"`
  216. TimeoutSeconds requests.Integer `name:"TimeoutSeconds"`
  217. HttpGet CreateContainerGroupHttpGet `name:"HttpGet"`
  218. Exec CreateContainerGroupExec `name:"Exec"`
  219. TcpSocket CreateContainerGroupTcpSocket `name:"TcpSocket"`
  220. }
  221. type CreateContainerGroupNFSVolume struct {
  222. Server string `name:"Server"`
  223. Path string `name:"Path"`
  224. ReadOnly requests.Boolean `name:"ReadOnly"`
  225. }
  226. type CreateContainerGroupConfigFileVolume struct {
  227. ConfigFileToPath *[]CreateContainerGroupConfigFileToPath `name:"ConfigFileToPath" type:"Repeated"`
  228. DefaultModel requests.Integer `name:"DefaultModel"`
  229. }
  230. type CreateContainerGroupConfigFileToPath struct {
  231. Content string `name:"Content"`
  232. Path string `name:"Path"`
  233. Mode requests.Integer `name:"Mode"`
  234. }
  235. type CreateContainerGroupEmptyDirVolume struct {
  236. Medium string `name:"Medium"`
  237. }
  238. type CreateContainerGroupDiskVolume struct {
  239. DiskId string `name:"DiskId"`
  240. FsType string `name:"FsType"`
  241. }
  242. type CreateContainerGroupOption struct {
  243. Name string `name:"Name"`
  244. Value string `name:"Value"`
  245. }
  246. type CreateContainerGroupSysctl struct {
  247. Name string `name:"Name"`
  248. Value string `name:"Value"`
  249. }
  250. // CreateContainerGroupResponse is the response struct for api CreateContainerGroup
  251. type CreateContainerGroupResponse struct {
  252. *responses.BaseResponse
  253. RequestId string `json:"RequestId" xml:"RequestId"`
  254. ContainerGroupId string `json:"ContainerGroupId" xml:"ContainerGroupId"`
  255. }
  256. // CreateCreateContainerGroupRequest creates a request to invoke CreateContainerGroup API
  257. func CreateCreateContainerGroupRequest() (request *CreateContainerGroupRequest) {
  258. request = &CreateContainerGroupRequest{
  259. RpcRequest: &requests.RpcRequest{},
  260. }
  261. request.InitWithApiInfo("Eci", "2018-08-08", "CreateContainerGroup", "eci", "openAPI")
  262. return
  263. }
  264. // CreateCreateContainerGroupResponse creates a response to parse from CreateContainerGroup response
  265. func CreateCreateContainerGroupResponse() (response *CreateContainerGroupResponse) {
  266. response = &CreateContainerGroupResponse{
  267. BaseResponse: &responses.BaseResponse{},
  268. }
  269. return
  270. }