DescribeInstances.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // Copyright 2018 JDCLOUD.COM
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // NOTE: This class is auto generated by the jdcloud code generator program.
  16. package apis
  17. import (
  18. "github.com/jdcloud-api/jdcloud-sdk-go/core"
  19. vm "github.com/jdcloud-api/jdcloud-sdk-go/services/vm/models"
  20. common "github.com/jdcloud-api/jdcloud-sdk-go/services/common/models"
  21. )
  22. type DescribeInstancesRequest struct {
  23. core.JDCloudRequest
  24. /* 地域ID */
  25. RegionId string `json:"regionId"`
  26. /* 页码;默认为1 (Optional) */
  27. PageNumber *int `json:"pageNumber"`
  28. /* 分页大小;默认为20;取值范围[10, 100] (Optional) */
  29. PageSize *int `json:"pageSize"`
  30. /* instanceId - 云主机ID,精确匹配,支持多个
  31. privateIpAddress - 主网卡内网主IP地址,模糊匹配,支持多个
  32. az - 可用区,精确匹配,支持多个
  33. vpcId - 私有网络ID,精确匹配,支持多个
  34. status - 云主机状态,精确匹配,支持多个,<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
  35. name - 云主机名称,模糊匹配,支持单个
  36. imageId - 镜像ID,精确匹配,支持多个
  37. networkInterfaceId - 弹性网卡ID,精确匹配,支持多个
  38. subnetId - 子网ID,精确匹配,支持多个
  39. agId - 使用可用组id,支持单个
  40. faultDomain - 错误域,支持多个
  41. dedicatedHostId - 专有宿主机ID,精确匹配,支持多个
  42. dedicatedPoolId - 专有宿主机池ID,精确匹配,支持多个
  43. instanceType - 实例规格,精确匹配,支持多个
  44. elasticIpAddress - 公网IP地址,精确匹配,支持单个。该条件会将公网IP转换成networkInterfaceId进行查询,所以与networkInterfaceId为或者的关系。
  45. (Optional) */
  46. Filters []common.Filter `json:"filters"`
  47. }
  48. /*
  49. * param regionId: 地域ID (Required)
  50. *
  51. * @Deprecated, not compatible when mandatory parameters changed
  52. */
  53. func NewDescribeInstancesRequest(
  54. regionId string,
  55. ) *DescribeInstancesRequest {
  56. return &DescribeInstancesRequest{
  57. JDCloudRequest: core.JDCloudRequest{
  58. URL: "/regions/{regionId}/instances",
  59. Method: "GET",
  60. Header: nil,
  61. Version: "v1",
  62. },
  63. RegionId: regionId,
  64. }
  65. }
  66. /*
  67. * param regionId: 地域ID (Required)
  68. * param pageNumber: 页码;默认为1 (Optional)
  69. * param pageSize: 分页大小;默认为20;取值范围[10, 100] (Optional)
  70. * param filters: instanceId - 云主机ID,精确匹配,支持多个
  71. privateIpAddress - 主网卡内网主IP地址,模糊匹配,支持多个
  72. az - 可用区,精确匹配,支持多个
  73. vpcId - 私有网络ID,精确匹配,支持多个
  74. status - 云主机状态,精确匹配,支持多个,<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
  75. name - 云主机名称,模糊匹配,支持单个
  76. imageId - 镜像ID,精确匹配,支持多个
  77. networkInterfaceId - 弹性网卡ID,精确匹配,支持多个
  78. subnetId - 子网ID,精确匹配,支持多个
  79. agId - 使用可用组id,支持单个
  80. faultDomain - 错误域,支持多个
  81. dedicatedHostId - 专有宿主机ID,精确匹配,支持多个
  82. dedicatedPoolId - 专有宿主机池ID,精确匹配,支持多个
  83. instanceType - 实例规格,精确匹配,支持多个
  84. elasticIpAddress - 公网IP地址,精确匹配,支持单个。该条件会将公网IP转换成networkInterfaceId进行查询,所以与networkInterfaceId为或者的关系。
  85. (Optional)
  86. */
  87. func NewDescribeInstancesRequestWithAllParams(
  88. regionId string,
  89. pageNumber *int,
  90. pageSize *int,
  91. filters []common.Filter,
  92. ) *DescribeInstancesRequest {
  93. return &DescribeInstancesRequest{
  94. JDCloudRequest: core.JDCloudRequest{
  95. URL: "/regions/{regionId}/instances",
  96. Method: "GET",
  97. Header: nil,
  98. Version: "v1",
  99. },
  100. RegionId: regionId,
  101. PageNumber: pageNumber,
  102. PageSize: pageSize,
  103. Filters: filters,
  104. }
  105. }
  106. /* This constructor has better compatible ability when API parameters changed */
  107. func NewDescribeInstancesRequestWithoutParam() *DescribeInstancesRequest {
  108. return &DescribeInstancesRequest{
  109. JDCloudRequest: core.JDCloudRequest{
  110. URL: "/regions/{regionId}/instances",
  111. Method: "GET",
  112. Header: nil,
  113. Version: "v1",
  114. },
  115. }
  116. }
  117. /* param regionId: 地域ID(Required) */
  118. func (r *DescribeInstancesRequest) SetRegionId(regionId string) {
  119. r.RegionId = regionId
  120. }
  121. /* param pageNumber: 页码;默认为1(Optional) */
  122. func (r *DescribeInstancesRequest) SetPageNumber(pageNumber int) {
  123. r.PageNumber = &pageNumber
  124. }
  125. /* param pageSize: 分页大小;默认为20;取值范围[10, 100](Optional) */
  126. func (r *DescribeInstancesRequest) SetPageSize(pageSize int) {
  127. r.PageSize = &pageSize
  128. }
  129. /* param filters: instanceId - 云主机ID,精确匹配,支持多个
  130. privateIpAddress - 主网卡内网主IP地址,模糊匹配,支持多个
  131. az - 可用区,精确匹配,支持多个
  132. vpcId - 私有网络ID,精确匹配,支持多个
  133. status - 云主机状态,精确匹配,支持多个,<a href="http://docs.jdcloud.com/virtual-machines/api/vm_status">参考云主机状态</a>
  134. name - 云主机名称,模糊匹配,支持单个
  135. imageId - 镜像ID,精确匹配,支持多个
  136. networkInterfaceId - 弹性网卡ID,精确匹配,支持多个
  137. subnetId - 子网ID,精确匹配,支持多个
  138. agId - 使用可用组id,支持单个
  139. faultDomain - 错误域,支持多个
  140. dedicatedHostId - 专有宿主机ID,精确匹配,支持多个
  141. dedicatedPoolId - 专有宿主机池ID,精确匹配,支持多个
  142. instanceType - 实例规格,精确匹配,支持多个
  143. elasticIpAddress - 公网IP地址,精确匹配,支持单个。该条件会将公网IP转换成networkInterfaceId进行查询,所以与networkInterfaceId为或者的关系。
  144. (Optional) */
  145. func (r *DescribeInstancesRequest) SetFilters(filters []common.Filter) {
  146. r.Filters = filters
  147. }
  148. // GetRegionId returns path parameter 'regionId' if exist,
  149. // otherwise return empty string
  150. func (r DescribeInstancesRequest) GetRegionId() string {
  151. return r.RegionId
  152. }
  153. type DescribeInstancesResponse struct {
  154. RequestID string `json:"requestId"`
  155. Error core.ErrorResponse `json:"error"`
  156. Result DescribeInstancesResult `json:"result"`
  157. }
  158. type DescribeInstancesResult struct {
  159. Instances []vm.Instance `json:"instances"`
  160. TotalCount int `json:"totalCount"`
  161. }