| 1 |
package ess |
| 2 |
|
| 3 |
import "github.com/denverdino/aliyungo/common" |
| 4 |
|
| 5 |
type AdjustmentType string |
| 6 |
|
| 7 |
const ( |
| 8 |
QuantityChangeInCapacity = AdjustmentType("QuantityChangeInCapacity") |
| 9 |
PercentChangeInCapacity = AdjustmentType("PercentChangeInCapacity") |
| 10 |
TotalCapacity = AdjustmentType("TotalCapacity") |
| 11 |
) |
| 12 |
|
| 13 |
type CreateScalingRuleArgs struct { |
| 14 |
RegionId common.Region |
| 15 |
ScalingGroupId string |
| 16 |
AdjustmentType AdjustmentType |
| 17 |
AdjustmentValue int |
| 18 |
Cooldown int |
| 19 |
ScalingRuleName string |
| 20 |
} |
| 21 |
|
| 22 |
type CreateScalingRuleResponse struct { |
| 23 |
common.Response |
| 24 |
ScalingRuleId string |
| 25 |
ScalingRuleAri string |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
func (client *Client) CreateScalingRule(args *CreateScalingRuleArgs) (resp *CreateScalingRuleResponse, err error) { |
| 32 |
response := CreateScalingRuleResponse{} |
| 33 |
err = client.Invoke("CreateScalingRule", args, &response) |
| 34 |
|
| 35 |
if err != nil { |
| 36 |
return nil, err |
| 37 |
} |
| 38 |
return &response, nil |
| 39 |
} |
| 40 |
|
| 41 |
type ModifyScalingRuleArgs struct { |
| 42 |
RegionId common.Region |
| 43 |
ScalingRuleId string |
| 44 |
AdjustmentType AdjustmentType |
| 45 |
AdjustmentValue int |
| 46 |
Cooldown int |
| 47 |
ScalingRuleName string |
| 48 |
} |
| 49 |
|
| 50 |
type ModifyScalingRuleResponse struct { |
| 51 |
common.Response |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
func (client *Client) ModifyScalingRule(args *ModifyScalingRuleArgs) (resp *ModifyScalingRuleResponse, err error) { |
| 58 |
response := ModifyScalingRuleResponse{} |
| 59 |
err = client.Invoke("ModifyScalingRule", args, &response) |
| 60 |
|
| 61 |
if err != nil { |
| 62 |
return nil, err |
| 63 |
} |
| 64 |
return &response, nil |
| 65 |
} |
| 66 |
|
| 67 |
type DescribeScalingRulesArgs struct { |
| 68 |
common.Pagination |
| 69 |
RegionId common.Region |
| 70 |
ScalingGroupId string |
| 71 |
ScalingRuleId common.FlattenArray |
| 72 |
ScalingRuleName common.FlattenArray |
| 73 |
ScalingRuleAri common.FlattenArray |
| 74 |
} |
| 75 |
|
| 76 |
type DescribeScalingRulesResponse struct { |
| 77 |
common.Response |
| 78 |
common.PaginationResult |
| 79 |
ScalingRules struct { |
| 80 |
ScalingRule []ScalingRuleItemType |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
type ScalingRuleItemType struct { |
| 85 |
ScalingRuleId string |
| 86 |
ScalingGroupId string |
| 87 |
ScalingRuleName string |
| 88 |
AdjustmentType string |
| 89 |
ScalingRuleAri string |
| 90 |
Cooldown int |
| 91 |
AdjustmentValue int |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
func (client *Client) DescribeScalingRules(args *DescribeScalingRulesArgs) (configs []ScalingRuleItemType, pagination *common.PaginationResult, err error) { |
| 98 |
args.Validate() |
| 99 |
response := DescribeScalingRulesResponse{} |
| 100 |
|
| 101 |
err = client.InvokeByFlattenMethod("DescribeScalingRules", args, &response) |
| 102 |
|
| 103 |
if err == nil { |
| 104 |
return response.ScalingRules.ScalingRule, &response.PaginationResult, nil |
| 105 |
} |
| 106 |
|
| 107 |
return nil, nil, err |
| 108 |
} |
| 109 |
|
| 110 |
type DeleteScalingRuleArgs struct { |
| 111 |
RegionId common.Region |
| 112 |
ScalingRuleId string |
| 113 |
} |
| 114 |
|
| 115 |
type DeleteScalingRuleResponse struct { |
| 116 |
common.Response |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
func (client *Client) DeleteScalingRule(args *DeleteScalingRuleArgs) (resp *DeleteScalingRuleResponse, err error) { |
| 123 |
response := DeleteScalingRuleResponse{} |
| 124 |
err = client.InvokeByFlattenMethod("DeleteScalingRule", args, &response) |
| 125 |
|
| 126 |
if err != nil { |
| 127 |
return nil, err |
| 128 |
} |
| 129 |
return &response, nil |
| 130 |
} |
| 131 |
|
| 132 |
type ExecuteScalingRuleArgs struct { |
| 133 |
ScalingRuleAri string |
| 134 |
ClientToken string |
| 135 |
} |
| 136 |
|
| 137 |
type ExecuteScalingRuleResponse struct { |
| 138 |
common.Response |
| 139 |
ScalingActivityId string |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
func (client *Client) ExecuteScalingRule(args *ExecuteScalingRuleArgs) (*ExecuteScalingRuleResponse, error) { |
| 146 |
resp := ExecuteScalingRuleResponse{} |
| 147 |
err := client.InvokeByFlattenMethod("ExecuteScalingRule", args, &resp) |
| 148 |
if err != nil { |
| 149 |
return nil, err |
| 150 |
} |
| 151 |
return &resp, nil |
| 152 |
} |