create_container_group.go 14 KB

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