describe_instances.go 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. // DescribeInstances invokes the ecs.DescribeInstances API synchronously
  21. // api document: https://help.aliyun.com/api/ecs/describeinstances.html
  22. func (client *Client) DescribeInstances(request *DescribeInstancesRequest) (response *DescribeInstancesResponse, err error) {
  23. response = CreateDescribeInstancesResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // DescribeInstancesWithChan invokes the ecs.DescribeInstances API asynchronously
  28. // api document: https://help.aliyun.com/api/ecs/describeinstances.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) DescribeInstancesWithChan(request *DescribeInstancesRequest) (<-chan *DescribeInstancesResponse, <-chan error) {
  31. responseChan := make(chan *DescribeInstancesResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.DescribeInstances(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. // DescribeInstancesWithCallback invokes the ecs.DescribeInstances API asynchronously
  51. // api document: https://help.aliyun.com/api/ecs/describeinstances.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) DescribeInstancesWithCallback(request *DescribeInstancesRequest, callback func(response *DescribeInstancesResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *DescribeInstancesResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.DescribeInstances(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. // DescribeInstancesRequest is the request struct for api DescribeInstances
  71. type DescribeInstancesRequest struct {
  72. *requests.RpcRequest
  73. Tag4Value string `position:"Query" name:"Tag.4.Value"`
  74. InnerIpAddresses string `position:"Query" name:"InnerIpAddresses"`
  75. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  76. Tag2Key string `position:"Query" name:"Tag.2.Key"`
  77. PrivateIpAddresses string `position:"Query" name:"PrivateIpAddresses"`
  78. HpcClusterId string `position:"Query" name:"HpcClusterId"`
  79. Filter2Value string `position:"Query" name:"Filter.2.Value"`
  80. Tag3Key string `position:"Query" name:"Tag.3.Key"`
  81. KeyPairName string `position:"Query" name:"KeyPairName"`
  82. Tag1Value string `position:"Query" name:"Tag.1.Value"`
  83. ResourceGroupId string `position:"Query" name:"ResourceGroupId"`
  84. LockReason string `position:"Query" name:"LockReason"`
  85. Filter1Key string `position:"Query" name:"Filter.1.Key"`
  86. DeviceAvailable requests.Boolean `position:"Query" name:"DeviceAvailable"`
  87. Filter3Value string `position:"Query" name:"Filter.3.Value"`
  88. DryRun requests.Boolean `position:"Query" name:"DryRun"`
  89. Tag5Key string `position:"Query" name:"Tag.5.Key"`
  90. Filter1Value string `position:"Query" name:"Filter.1.Value"`
  91. OwnerId requests.Integer `position:"Query" name:"OwnerId"`
  92. VSwitchId string `position:"Query" name:"VSwitchId"`
  93. InstanceName string `position:"Query" name:"InstanceName"`
  94. InstanceIds string `position:"Query" name:"InstanceIds"`
  95. InternetChargeType string `position:"Query" name:"InternetChargeType"`
  96. ZoneId string `position:"Query" name:"ZoneId"`
  97. Tag4Key string `position:"Query" name:"Tag.4.Key"`
  98. InstanceNetworkType string `position:"Query" name:"InstanceNetworkType"`
  99. Status string `position:"Query" name:"Status"`
  100. ImageId string `position:"Query" name:"ImageId"`
  101. Filter4Value string `position:"Query" name:"Filter.4.Value"`
  102. IoOptimized requests.Boolean `position:"Query" name:"IoOptimized"`
  103. SecurityGroupId string `position:"Query" name:"SecurityGroupId"`
  104. Filter4Key string `position:"Query" name:"Filter.4.Key"`
  105. PageNumber requests.Integer `position:"Query" name:"PageNumber"`
  106. RdmaIpAddresses string `position:"Query" name:"RdmaIpAddresses"`
  107. PageSize requests.Integer `position:"Query" name:"PageSize"`
  108. PublicIpAddresses string `position:"Query" name:"PublicIpAddresses"`
  109. InstanceType string `position:"Query" name:"InstanceType"`
  110. InstanceChargeType string `position:"Query" name:"InstanceChargeType"`
  111. Tag3Value string `position:"Query" name:"Tag.3.Value"`
  112. ResourceOwnerAccount string `position:"Query" name:"ResourceOwnerAccount"`
  113. OwnerAccount string `position:"Query" name:"OwnerAccount"`
  114. InstanceTypeFamily string `position:"Query" name:"InstanceTypeFamily"`
  115. Filter2Key string `position:"Query" name:"Filter.2.Key"`
  116. Tag5Value string `position:"Query" name:"Tag.5.Value"`
  117. Tag1Key string `position:"Query" name:"Tag.1.Key"`
  118. EipAddresses string `position:"Query" name:"EipAddresses"`
  119. VpcId string `position:"Query" name:"VpcId"`
  120. Tag2Value string `position:"Query" name:"Tag.2.Value"`
  121. Filter3Key string `position:"Query" name:"Filter.3.Key"`
  122. }
  123. // DescribeInstancesResponse is the response struct for api DescribeInstances
  124. type DescribeInstancesResponse struct {
  125. *responses.BaseResponse
  126. RequestId string `json:"RequestId" xml:"RequestId"`
  127. TotalCount int `json:"TotalCount" xml:"TotalCount"`
  128. PageNumber int `json:"PageNumber" xml:"PageNumber"`
  129. PageSize int `json:"PageSize" xml:"PageSize"`
  130. Instances Instances `json:"Instances" xml:"Instances"`
  131. }
  132. // CreateDescribeInstancesRequest creates a request to invoke DescribeInstances API
  133. func CreateDescribeInstancesRequest() (request *DescribeInstancesRequest) {
  134. request = &DescribeInstancesRequest{
  135. RpcRequest: &requests.RpcRequest{},
  136. }
  137. request.InitWithApiInfo("Ecs", "2014-05-26", "DescribeInstances", "ecs", "openAPI")
  138. return
  139. }
  140. // CreateDescribeInstancesResponse creates a response to parse from DescribeInstances response
  141. func CreateDescribeInstancesResponse() (response *DescribeInstancesResponse) {
  142. response = &DescribeInstancesResponse{
  143. BaseResponse: &responses.BaseResponse{},
  144. }
  145. return
  146. }