run_instances.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. // api document: https://help.aliyun.com/api/ecs/runinstances.html
  22. func (client *Client) RunInstances(request *RunInstancesRequest) (response *RunInstancesResponse, err error) {
  23. response = CreateRunInstancesResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // RunInstancesWithChan invokes the ecs.RunInstances API asynchronously
  28. // api document: https://help.aliyun.com/api/ecs/runinstances.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) RunInstancesWithChan(request *RunInstancesRequest) (<-chan *RunInstancesResponse, <-chan error) {
  31. responseChan := make(chan *RunInstancesResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.RunInstances(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. // RunInstancesWithCallback invokes the ecs.RunInstances API asynchronously
  51. // api document: https://help.aliyun.com/api/ecs/runinstances.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) RunInstancesWithCallback(request *RunInstancesRequest, callback func(response *RunInstancesResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *RunInstancesResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.RunInstances(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. // RunInstancesRequest is the request struct for api RunInstances
  71. type RunInstancesRequest struct {
  72. *requests.RpcRequest
  73. LaunchTemplateName string `position:"Query" name:"LaunchTemplateName"`
  74. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  75. UniqueSuffix requests.Boolean `position:"Query" name:"UniqueSuffix"`
  76. HpcClusterId string `position:"Query" name:"HpcClusterId"`
  77. SecurityEnhancementStrategy string `position:"Query" name:"SecurityEnhancementStrategy"`
  78. KeyPairName string `position:"Query" name:"KeyPairName"`
  79. MinAmount requests.Integer `position:"Query" name:"MinAmount"`
  80. SpotPriceLimit requests.Float `position:"Query" name:"SpotPriceLimit"`
  81. DeletionProtection requests.Boolean `position:"Query" name:"DeletionProtection"`
  82. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  83. HostName string `position:"Query" name:"HostName"`
  84. Password string `position:"Query" name:"Password"`
  85. Tag *[]RunInstancesTag `position:"Query" name:"Tag" type:"Repeated"`
  86. AutoRenewPeriod requests.Integer `position:"Query" name:"AutoRenewPeriod"`
  87. Period requests.Integer `position:"Query" name:"Period"`
  88. DryRun requests.Boolean `position:"Query" name:"DryRun"`
  89. LaunchTemplateId string `position:"Query" name:"LaunchTemplateId"`
  90. Ipv6AddressCount requests.Integer `position:"Query" name:"Ipv6AddressCount"`
  91. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  92. CapacityReservationPreference string `position:"Query" name:"CapacityReservationPreference"`
  93. VSwitchId string `position:"Query" name:"VSwitchId"`
  94. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  95. PrivateIpAddress string `position:"Query" name:"PrivateIpAddress"`
  96. PeriodUnit string `position:"Query" name:"PeriodUnit"`
  97. InstanceName string `position:"Query" name:"InstanceName"`
  98. AutoRenew requests.Boolean `position:"Query" name:"AutoRenew"`
  99. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  100. ZoneId string `position:"Query" name:"ZoneId"`
  101. Ipv6Address *[]string `position:"Query" name:"Ipv6Address" type:"Repeated"`
  102. InternetMaxBandwidthIn requests.Integer `position:"Query" name:"InternetMaxBandwidthIn"`
  103. Affinity string `position:"Query" name:"Affinity"`
  104. ImageId string `position:"Query" name:"ImageId"`
  105. SpotInterruptionBehavior string `position:"Query" name:"SpotInterruptionBehavior"`
  106. ClientToken string `position:"Query" name:"ClientToken"`
  107. IoOptimized string `position:"Query" name:"IoOptimized"`
  108. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  109. InternetMaxBandwidthOut requests.Integer `position:"Query" name:"InternetMaxBandwidthOut"`
  110. Description string `position:"Query" name:"Description"`
  111. SystemDiskCategory string `position:"Query" name:"SystemDisk.Category"`
  112. CapacityReservationId string `position:"Query" name:"CapacityReservationId"`
  113. UserData string `position:"Query" name:"UserData"`
  114. PasswordInherit requests.Boolean `position:"Query" name:"PasswordInherit"`
  115. InstanceType string `position:"Query" name:"InstanceType"`
  116. HibernationConfigured requests.Boolean `position:"Query" name:"HibernationConfigured"`
  117. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  118. NetworkInterface *[]RunInstancesNetworkInterface `position:"Query" name:"NetworkInterface" type:"Repeated"`
  119. DeploymentSetId string `position:"Query" name:"DeploymentSetId"`
  120. Amount requests.Integer `position:"Query" name:"Amount"`
  121. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  122. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  123. Tenancy string `position:"Query" name:"Tenancy"`
  124. SystemDiskDiskName string `position:"Query" name:"SystemDisk.DiskName"`
  125. RamRoleName string `position:"Query" name:"RamRoleName"`
  126. AutoReleaseTime string `position:"Query" name:"AutoReleaseTime"`
  127. DedicatedHostId string `position:"Query" name:"DedicatedHostId"`
  128. CreditSpecification string `position:"Query" name:"CreditSpecification"`
  129. SecurityGroupIds *[]string `position:"Query" name:"SecurityGroupIds" type:"Repeated"`
  130. DataDisk *[]RunInstancesDataDisk `position:"Query" name:"DataDisk" type:"Repeated"`
  131. LaunchTemplateVersion requests.Integer `position:"Query" name:"LaunchTemplateVersion"`
  132. SystemDiskSize string `position:"Query" name:"SystemDisk.Size"`
  133. SystemDiskDescription string `position:"Query" name:"SystemDisk.Description"`
  134. }
  135. // RunInstancesTag is a repeated param struct in RunInstancesRequest
  136. type RunInstancesTag struct {
  137. Key string `name:"Key"`
  138. Value string `name:"Value"`
  139. }
  140. // RunInstancesNetworkInterface is a repeated param struct in RunInstancesRequest
  141. type RunInstancesNetworkInterface struct {
  142. PrimaryIpAddress string `name:"PrimaryIpAddress"`
  143. VSwitchId string `name:"VSwitchId"`
  144. SecurityGroupId string `name:"SecurityGroupId"`
  145. NetworkInterfaceName string `name:"NetworkInterfaceName"`
  146. Description string `name:"Description"`
  147. }
  148. // RunInstancesDataDisk is a repeated param struct in RunInstancesRequest
  149. type RunInstancesDataDisk struct {
  150. Size string `name:"Size"`
  151. SnapshotId string `name:"SnapshotId"`
  152. Category string `name:"Category"`
  153. Encrypted string `name:"Encrypted"`
  154. KMSKeyId string `name:"KMSKeyId"`
  155. DiskName string `name:"DiskName"`
  156. Description string `name:"Description"`
  157. Device string `name:"Device"`
  158. DeleteWithInstance string `name:"DeleteWithInstance"`
  159. }
  160. // RunInstancesResponse is the response struct for api RunInstances
  161. type RunInstancesResponse struct {
  162. *responses.BaseResponse
  163. RequestId string `json:"RequestId" xml:"RequestId"`
  164. TradePrice float64 `json:"TradePrice" xml:"TradePrice"`
  165. InstanceIdSets InstanceIdSets `json:"InstanceIdSets" xml:"InstanceIdSets"`
  166. }
  167. // CreateRunInstancesRequest creates a request to invoke RunInstances API
  168. func CreateRunInstancesRequest() (request *RunInstancesRequest) {
  169. request = &RunInstancesRequest{
  170. RpcRequest: &requests.RpcRequest{},
  171. }
  172. request.InitWithApiInfo("Ecs", "2014-05-26", "RunInstances", "ecs", "openAPI")
  173. return
  174. }
  175. // CreateRunInstancesResponse creates a response to parse from RunInstances response
  176. func CreateRunInstancesResponse() (response *RunInstancesResponse) {
  177. response = &RunInstancesResponse{
  178. BaseResponse: &responses.BaseResponse{},
  179. }
  180. return
  181. }