CreateInstances.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. )
  21. type CreateInstancesRequest struct {
  22. core.JDCloudRequest
  23. /* 地域ID */
  24. RegionId string `json:"regionId"`
  25. /* 描述云主机配置
  26. */
  27. InstanceSpec *vm.InstanceSpec `json:"instanceSpec"`
  28. /* 购买云主机的数量;取值范围:[1,100],默认为1。
  29. (Optional) */
  30. MaxCount *int `json:"maxCount"`
  31. /* 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。
  32. (Optional) */
  33. ClientToken *string `json:"clientToken"`
  34. }
  35. /*
  36. * param regionId: 地域ID (Required)
  37. * param instanceSpec: 描述云主机配置
  38. (Required)
  39. *
  40. * @Deprecated, not compatible when mandatory parameters changed
  41. */
  42. func NewCreateInstancesRequest(
  43. regionId string,
  44. instanceSpec *vm.InstanceSpec,
  45. ) *CreateInstancesRequest {
  46. return &CreateInstancesRequest{
  47. JDCloudRequest: core.JDCloudRequest{
  48. URL: "/regions/{regionId}/instances",
  49. Method: "POST",
  50. Header: nil,
  51. Version: "v1",
  52. },
  53. RegionId: regionId,
  54. InstanceSpec: instanceSpec,
  55. }
  56. }
  57. /*
  58. * param regionId: 地域ID (Required)
  59. * param instanceSpec: 描述云主机配置
  60. (Required)
  61. * param maxCount: 购买云主机的数量;取值范围:[1,100],默认为1。
  62. (Optional)
  63. * param clientToken: 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。
  64. (Optional)
  65. */
  66. func NewCreateInstancesRequestWithAllParams(
  67. regionId string,
  68. instanceSpec *vm.InstanceSpec,
  69. maxCount *int,
  70. clientToken *string,
  71. ) *CreateInstancesRequest {
  72. return &CreateInstancesRequest{
  73. JDCloudRequest: core.JDCloudRequest{
  74. URL: "/regions/{regionId}/instances",
  75. Method: "POST",
  76. Header: nil,
  77. Version: "v1",
  78. },
  79. RegionId: regionId,
  80. InstanceSpec: instanceSpec,
  81. MaxCount: maxCount,
  82. ClientToken: clientToken,
  83. }
  84. }
  85. /* This constructor has better compatible ability when API parameters changed */
  86. func NewCreateInstancesRequestWithoutParam() *CreateInstancesRequest {
  87. return &CreateInstancesRequest{
  88. JDCloudRequest: core.JDCloudRequest{
  89. URL: "/regions/{regionId}/instances",
  90. Method: "POST",
  91. Header: nil,
  92. Version: "v1",
  93. },
  94. }
  95. }
  96. /* param regionId: 地域ID(Required) */
  97. func (r *CreateInstancesRequest) SetRegionId(regionId string) {
  98. r.RegionId = regionId
  99. }
  100. /* param instanceSpec: 描述云主机配置
  101. (Required) */
  102. func (r *CreateInstancesRequest) SetInstanceSpec(instanceSpec *vm.InstanceSpec) {
  103. r.InstanceSpec = instanceSpec
  104. }
  105. /* param maxCount: 购买云主机的数量;取值范围:[1,100],默认为1。
  106. (Optional) */
  107. func (r *CreateInstancesRequest) SetMaxCount(maxCount int) {
  108. r.MaxCount = &maxCount
  109. }
  110. /* param clientToken: 用于保证请求的幂等性。由客户端生成,长度不能超过64个字符。
  111. (Optional) */
  112. func (r *CreateInstancesRequest) SetClientToken(clientToken string) {
  113. r.ClientToken = &clientToken
  114. }
  115. // GetRegionId returns path parameter 'regionId' if exist,
  116. // otherwise return empty string
  117. func (r CreateInstancesRequest) GetRegionId() string {
  118. return r.RegionId
  119. }
  120. type CreateInstancesResponse struct {
  121. RequestID string `json:"requestId"`
  122. Error core.ErrorResponse `json:"error"`
  123. Result CreateInstancesResult `json:"result"`
  124. }
  125. type CreateInstancesResult struct {
  126. InstanceIds []string `json:"instanceIds"`
  127. }