create_scaling_task_group.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package emr
  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. // CreateScalingTaskGroup invokes the emr.CreateScalingTaskGroup API synchronously
  21. // api document: https://help.aliyun.com/api/emr/createscalingtaskgroup.html
  22. func (client *Client) CreateScalingTaskGroup(request *CreateScalingTaskGroupRequest) (response *CreateScalingTaskGroupResponse, err error) {
  23. response = CreateCreateScalingTaskGroupResponse()
  24. err = client.DoAction(request, response)
  25. return
  26. }
  27. // CreateScalingTaskGroupWithChan invokes the emr.CreateScalingTaskGroup API asynchronously
  28. // api document: https://help.aliyun.com/api/emr/createscalingtaskgroup.html
  29. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  30. func (client *Client) CreateScalingTaskGroupWithChan(request *CreateScalingTaskGroupRequest) (<-chan *CreateScalingTaskGroupResponse, <-chan error) {
  31. responseChan := make(chan *CreateScalingTaskGroupResponse, 1)
  32. errChan := make(chan error, 1)
  33. err := client.AddAsyncTask(func() {
  34. defer close(responseChan)
  35. defer close(errChan)
  36. response, err := client.CreateScalingTaskGroup(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. // CreateScalingTaskGroupWithCallback invokes the emr.CreateScalingTaskGroup API asynchronously
  51. // api document: https://help.aliyun.com/api/emr/createscalingtaskgroup.html
  52. // asynchronous document: https://help.aliyun.com/document_detail/66220.html
  53. func (client *Client) CreateScalingTaskGroupWithCallback(request *CreateScalingTaskGroupRequest, callback func(response *CreateScalingTaskGroupResponse, err error)) <-chan int {
  54. result := make(chan int, 1)
  55. err := client.AddAsyncTask(func() {
  56. var response *CreateScalingTaskGroupResponse
  57. var err error
  58. defer close(result)
  59. response, err = client.CreateScalingTaskGroup(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. // CreateScalingTaskGroupRequest is the request struct for api CreateScalingTaskGroup
  71. type CreateScalingTaskGroupRequest struct {
  72. *requests.RpcRequest
  73. ResourceOwnerId requests.Integer `position:"Query" name:"ResourceOwnerId"`
  74. DataDiskCategory string `position:"Query" name:"DataDiskCategory"`
  75. ClusterId string `position:"Query" name:"ClusterId"`
  76. MinSize requests.Integer `position:"Query" name:"MinSize"`
  77. SpotStrategy string `position:"Query" name:"SpotStrategy"`
  78. DataDiskSize requests.Integer `position:"Query" name:"DataDiskSize"`
  79. SpotPriceLimits *[]CreateScalingTaskGroupSpotPriceLimits `position:"Query" name:"SpotPriceLimits" type:"Repeated"`
  80. ScalingRule *[]CreateScalingTaskGroupScalingRule `position:"Query" name:"ScalingRule" type:"Repeated"`
  81. ActiveRuleCategory string `position:"Query" name:"ActiveRuleCategory"`
  82. MaxSize requests.Integer `position:"Query" name:"MaxSize"`
  83. DataDiskCount requests.Integer `position:"Query" name:"DataDiskCount"`
  84. DefaultCooldown requests.Integer `position:"Query" name:"DefaultCooldown"`
  85. PayType string `position:"Query" name:"PayType"`
  86. InstanceTypeList *[]string `position:"Query" name:"InstanceTypeList" type:"Repeated"`
  87. }
  88. // CreateScalingTaskGroupSpotPriceLimits is a repeated param struct in CreateScalingTaskGroupRequest
  89. type CreateScalingTaskGroupSpotPriceLimits struct {
  90. InstanceType string `name:"InstanceType"`
  91. PriceLimit string `name:"PriceLimit"`
  92. }
  93. // CreateScalingTaskGroupScalingRule is a repeated param struct in CreateScalingTaskGroupRequest
  94. type CreateScalingTaskGroupScalingRule struct {
  95. LaunchTime string `name:"LaunchTime"`
  96. RuleCategory string `name:"RuleCategory"`
  97. AdjustmentValue string `name:"AdjustmentValue"`
  98. SchedulerTrigger *[]CreateScalingTaskGroupSchedulerTrigger `name:"SchedulerTrigger" type:"Repeated"`
  99. AdjustmentType string `name:"AdjustmentType"`
  100. Cooldown string `name:"Cooldown"`
  101. RuleName string `name:"RuleName"`
  102. LaunchExpirationTime string `name:"LaunchExpirationTime"`
  103. RecurrenceValue string `name:"RecurrenceValue"`
  104. RecurrenceEndTime string `name:"RecurrenceEndTime"`
  105. CloudWatchTrigger *[]CreateScalingTaskGroupCloudWatchTrigger `name:"CloudWatchTrigger" type:"Repeated"`
  106. RecurrenceType string `name:"RecurrenceType"`
  107. }
  108. // CreateScalingTaskGroupSchedulerTrigger is a repeated param struct in CreateScalingTaskGroupRequest
  109. type CreateScalingTaskGroupSchedulerTrigger struct {
  110. LaunchTime string `name:"LaunchTime"`
  111. LaunchExpirationTime string `name:"LaunchExpirationTime"`
  112. RecurrenceValue string `name:"RecurrenceValue"`
  113. RecurrenceEndTime string `name:"RecurrenceEndTime"`
  114. RecurrenceType string `name:"RecurrenceType"`
  115. }
  116. // CreateScalingTaskGroupCloudWatchTrigger is a repeated param struct in CreateScalingTaskGroupRequest
  117. type CreateScalingTaskGroupCloudWatchTrigger struct {
  118. Period string `name:"Period"`
  119. EvaluationCount string `name:"EvaluationCount"`
  120. Threshold string `name:"Threshold"`
  121. MetricName string `name:"MetricName"`
  122. ComparisonOperator string `name:"ComparisonOperator"`
  123. Statistics string `name:"Statistics"`
  124. }
  125. // CreateScalingTaskGroupResponse is the response struct for api CreateScalingTaskGroup
  126. type CreateScalingTaskGroupResponse struct {
  127. *responses.BaseResponse
  128. RequestId string `json:"RequestId" xml:"RequestId"`
  129. HostGroupId string `json:"HostGroupId" xml:"HostGroupId"`
  130. }
  131. // CreateCreateScalingTaskGroupRequest creates a request to invoke CreateScalingTaskGroup API
  132. func CreateCreateScalingTaskGroupRequest() (request *CreateScalingTaskGroupRequest) {
  133. request = &CreateScalingTaskGroupRequest{
  134. RpcRequest: &requests.RpcRequest{},
  135. }
  136. request.InitWithApiInfo("Emr", "2016-04-08", "CreateScalingTaskGroup", "emr", "openAPI")
  137. return
  138. }
  139. // CreateCreateScalingTaskGroupResponse creates a response to parse from CreateScalingTaskGroup response
  140. func CreateCreateScalingTaskGroupResponse() (response *CreateScalingTaskGroupResponse) {
  141. response = &CreateScalingTaskGroupResponse{
  142. BaseResponse: &responses.BaseResponse{},
  143. }
  144. return
  145. }