run_instances.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. package ecs
  2. //Licensed under the Apache License, Version 2.0 (the "License");
  3. //you may not use this file except in compliance with the License.
  4. //You may obtain a copy of the License at
  5. //
  6. //http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. //Unless required by applicable law or agreed to in writing, software
  9. //distributed under the License is distributed on an "AS IS" BASIS,
  10. //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. //See the License for the specific language governing permissions and
  12. //limitations under the License.
  13. //
  14. // Code generated by Alibaba Cloud SDK Code Generator.
  15. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
  16. import (
  17. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
  18. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/responses"
  19. )
  20. // RunInstances invokes the ecs.RunInstances API synchronously
  21. func (client *Client) RunInstances(request *RunInstancesRequest) (response *RunInstancesResponse, err error) {
  22. response = CreateRunInstancesResponse()
  23. err = client.DoAction(request, response)
  24. return
  25. }
  26. // RunInstancesWithChan invokes the ecs.RunInstances API asynchronously
  27. func (client *Client) RunInstancesWithChan(request *RunInstancesRequest) (<-chan *RunInstancesResponse, <-chan error) {
  28. responseChan := make(chan *RunInstancesResponse, 1)
  29. errChan := make(chan error, 1)
  30. err := client.AddAsyncTask(func() {
  31. defer close(responseChan)
  32. defer close(errChan)
  33. response, err := client.RunInstances(request)
  34. if err != nil {
  35. errChan <- err
  36. } else {
  37. responseChan <- response
  38. }
  39. })
  40. if err != nil {
  41. errChan <- err
  42. close(responseChan)
  43. close(errChan)
  44. }
  45. return responseChan, errChan
  46. }
  47. // RunInstancesWithCallback invokes the ecs.RunInstances API asynchronously
  48. func (client *Client) RunInstancesWithCallback(request *RunInstancesRequest, callback func(response *RunInstancesResponse, err error)) <-chan int {
  49. result := make(chan int, 1)
  50. err := client.AddAsyncTask(func() {
  51. var response *RunInstancesResponse
  52. var err error
  53. defer close(result)
  54. response, err = client.RunInstances(request)
  55. callback(response, err)
  56. result <- 1
  57. })
  58. if err != nil {
  59. defer close(result)
  60. callback(nil, err)
  61. result <- 0
  62. }
  63. return result
  64. }
  65. // RunInstancesRequest is the request struct for api RunInstances
  66. type RunInstancesRequest struct {
  67. *requests.RpcRequest
  68. UniqueSuffix requests.Boolean `position:"Query" name:"UniqueSuffix"`
  69. SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
  70. MinAmount requests.Integer `position:"Query" name:"MinAmount"`
  71. DeletionProtection requests.Boolean `position:"Query" name:"DeletionProtection"`
  72. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  73. PrivatePoolOptionsMatchCriteria string `position:"Query" name:"PrivatePoolOptions.MatchCriteria"`
  74. HostName string `position:"Query" name:"HostName"`
  75. Password string `position:"Query" name:"Password"`
  76. DeploymentSetGroupNo requests.Integer `position:"Query" name:"DeploymentSetGroupNo"`
  77. SystemDiskAutoSnapshotPolicyId string `position:"Query" name:"SystemDisk.AutoSnapshotPolicyId"`
  78. CpuOptionsCore requests.Integer `position:"Query" name:"CpuOptions.Core"`
  79. Period requests.Integer `position:"Query" name:"Period"`
  80. DryRun requests.Boolean `position:"Query" name:"DryRun"`
  81. CpuOptionsNuma string `position:"Query" name:"CpuOptions.Numa"`
  82. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  83. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  84. PrivateIpAddress string `position:"Query" name:"PrivateIpAddress"`
  85. PeriodUnit string `position:"Query" name:"PeriodUnit"`
  86. AutoRenew requests.Boolean `position:"Query" name:"AutoRenew"`
  87. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  88. InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
  89. Affinity string `position:"Query" name:"Affinity"`
  90. ImageId string `position:"Query" name:"ImageId"`
  91. SpotInterruptionBehavior string `position:"Query" name:"SpotInterruptionBehavior"`
  92. NetworkInterfaceQueueNumber requests.Integer `position:"Query" name:"NetworkInterfaceQueueNumber"`
  93. IoOptimized string `position:"Query" name:"IoOptimized"`
  94. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  95. SystemDiskPerformanceLevel string `position:"Query" name:"SystemDisk.PerformanceLevel"`
  96. PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
  97. InstanceType string `position:"Query" name:"InstanceType"`
  98. HibernationConfigured requests.Boolean `position:"Query" name:"HibernationConfigured"`
  99. Arn *[]RunInstancesArn `position:"Query" name:"Arn" type:"Repeated"`
  100. SchedulerOptions string `position:"Query" name:"SchedulerOptions"`
  101. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  102. SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
  103. DedicatedHostId string `position:"Query" name:"DedicatedHostId"`
  104. SecurityGroupIds *[]string `position:"Query" name:"SecurityGroupIds" type:"Repeated"`
  105. SpotDuration requests.Integer `position:"Query" name:"SpotDuration"`
  106. SystemDiskSize string `position:"Query" name:"SystemDisk.Size"`
  107. ImageFamily string `position:"Query" name:"ImageFamily"`
  108. LaunchTemplateName string `position:"Query" name:"LaunchTemplateName"`
  109. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  110. HpcClusterId string `position:"Query" name:"HpcClusterId"`
  111. HttpPutResponseHopLimit requests.Integer `position:"Query" name:"HttpPutResponseHopLimit"`
  112. Isp string `position:"Query" name:"Isp"`
  113. KeyPairName string `position:"Query" name:"KeyPairName"`
  114. SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
  115. StorageSetPartitionNumber requests.Integer `position:"Query" name:"StorageSetPartitionNumber"`
  116. Tag *[]RunInstancesTag `position:"Query" name:"Tag" type:"Repeated"`
  117. PrivatePoolOptionsId string `position:"Query" name:"PrivatePoolOptions.Id"`
  118. AutoRenewPeriod requests.Integer `position:"Query" name:"AutoRenewPeriod"`
  119. LaunchTemplateId string `position:"Query" name:"LaunchTemplateId"`
  120. Ipv6AddressCount requests.Integer `position:"Query" name:"Ipv6AddressCount"`
  121. CapacityReservationPreference string `position:"Query" name:"CapacityReservationPreference"`
  122. VSwitchId string `position:"Query" name:"VSwitchId"`
  123. InstanceName string `position:"Query" name:"InstanceName"`
  124. ZoneId string `position:"Query" name:"ZoneId"`
  125. Ipv6Address *[]string `position:"Query" name:"Ipv6Address" type:"Repeated"`
  126. ClientToken string `position:"Query" name:"ClientToken"`
  127. InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
  128. Description string `position:"Query" name:"Description"`
  129. CpuOptionsThreadsPerCore requests.Integer `position:"Query" name:"CpuOptions.ThreadsPerCore"`
  130. SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
  131. CapacityReservationId string `position:"Query" name:"CapacityReservationId"`
  132. UserData string `position:"Query" name:"UserData"`
  133. HttpEndpoint string `position:"Query" name:"HttpEndpoint"`
  134. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  135. NetworkInterface *[]RunInstancesNetworkInterface `position:"Query" name:"NetworkInterface" type:"Repeated"`
  136. DeploymentSetId string `position:"Query" name:"DeploymentSetId"`
  137. Amount requests.Integer `position:"Query" name:"Amount"`
  138. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  139. Tenancy string `position:"Query" name:"Tenancy"`
  140. RamRoleName string `position:"Query" name:"RamRoleName"`
  141. AutoReleaseTime string `position:"Query" name:"AutoReleaseTime"`
  142. CreditSpecification string `position:"Query" name:"CreditSpecification"`
  143. DataDisk *[]RunInstancesDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
  144. LaunchTemplateVersion requests.Integer `position:"Query" name:"LaunchTemplateVersion"`
  145. SchedulerOptionsManagedPrivateSpaceId string `position:"Query" name:"SchedulerOptions.ManagedPrivateSpaceId"`
  146. StorageSetId string `position:"Query" name:"StorageSetId"`
  147. HttpTokens string `position:"Query" name:"HttpTokens"`
  148. SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
  149. }
  150. // RunInstancesArn is a repeated param struct in RunInstancesRequest
  151. type RunInstancesArn struct {
  152. AssumeRoleFor string `name:"AssumeRoleFor"`
  153. Rolearn string `name:"Rolearn"`
  154. RoleType string `name:"RoleType"`
  155. }
  156. // RunInstancesTag is a repeated param struct in RunInstancesRequest
  157. type RunInstancesTag struct {
  158. Key string `name:"Key"`
  159. Value string `name:"Value"`
  160. }
  161. // RunInstancesNetworkInterface is a repeated param struct in RunInstancesRequest
  162. type RunInstancesNetworkInterface struct {
  163. PrimaryIpAddress string `name:"PrimaryIpAddress"`
  164. VSwitchId string `name:"VSwitchId"`
  165. SecurityGroupId string `name:"SecurityGroupId"`
  166. SecurityGroupIds *[]string `name:"SecurityGroupIds" type:"Repeated"`
  167. NetworkInterfaceName string `name:"NetworkInterfaceName"`
  168. Description string `name:"Description"`
  169. QueueNumber string `name:"QueueNumber"`
  170. }
  171. // RunInstancesDataDisk is a repeated param struct in RunInstancesRequest
  172. type RunInstancesDataDisk struct {
  173. Size string `name:"Size"`
  174. SnapshotId string `name:"SnapshotId"`
  175. Category string `name:"Category"`
  176. Encrypted string `name:"Encrypted"`
  177. KMSKeyId string `name:"KMSKeyId"`
  178. DiskName string `name:"DiskName"`
  179. Description string `name:"Description"`
  180. Device string `name:"Device"`
  181. DeleteWithInstance string `name:"DeleteWithInstance"`
  182. PerformanceLevel string `name:"PerformanceLevel"`
  183. AutoSnapshotPolicyId string `name:"AutoSnapshotPolicyId"`
  184. EncryptAlgorithm string `name:"EncryptAlgorithm"`
  185. }
  186. // RunInstancesResponse is the response struct for api RunInstances
  187. type RunInstancesResponse struct {
  188. *responses.BaseResponse
  189. RequestId string `json:"RequestId" xml:"RequestId"`
  190. TradePrice float64 `json:"TradePrice" xml:"TradePrice"`
  191. InstanceIdSets InstanceIdSets `json:"InstanceIdSets" xml:"InstanceIdSets"`
  192. }
  193. // CreateRunInstancesRequest creates a request to invoke RunInstances API
  194. func CreateRunInstancesRequest() (request *RunInstancesRequest) {
  195. request = &RunInstancesRequest{
  196. RpcRequest: &requests.RpcRequest{},
  197. }
  198. request.InitWithApiInfo("Ecs", "2014-05-26", "RunInstances", "", "")
  199. request.Method = requests.POST
  200. return
  201. }
  202. // CreateRunInstancesResponse creates a response to parse from RunInstances response
  203. func CreateRunInstancesResponse() (response *RunInstancesResponse) {
  204. response = &RunInstancesResponse{
  205. BaseResponse: &responses.BaseResponse{},
  206. }
  207. return
  208. }