| 1 |
package ess |
| 2 |
|
| 3 |
import ( |
| 4 |
"encoding/base64" |
| 5 |
|
| 6 |
"github.com/denverdino/aliyungo/common" |
| 7 |
"github.com/denverdino/aliyungo/ecs" |
| 8 |
) |
| 9 |
|
| 10 |
type CreateScalingConfigurationArgs struct { |
| 11 |
ScalingGroupId string |
| 12 |
ImageId string |
| 13 |
InstanceType string |
| 14 |
IoOptimized ecs.IoOptimized |
| 15 |
SecurityGroupId string |
| 16 |
ScalingConfigurationName string |
| 17 |
InternetChargeType common.InternetChargeType |
| 18 |
InternetMaxBandwidthIn int |
| 19 |
InternetMaxBandwidthOut *int |
| 20 |
SystemDisk_Category common.UnderlineString |
| 21 |
SystemDisk_Size common.UnderlineString |
| 22 |
DataDisk []DataDiskType |
| 23 |
UserData string |
| 24 |
KeyPairName string |
| 25 |
RamRoleName string |
| 26 |
Tags string |
| 27 |
InstanceName string |
| 28 |
} |
| 29 |
|
| 30 |
type DataDiskType struct { |
| 31 |
Category string |
| 32 |
SnapshotId string |
| 33 |
Device string |
| 34 |
Size int |
| 35 |
} |
| 36 |
|
| 37 |
type CreateScalingConfigurationResponse struct { |
| 38 |
ScalingConfigurationId string |
| 39 |
common.Response |
| 40 |
} |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
func (client *Client) CreateScalingConfiguration(args *CreateScalingConfigurationArgs) (resp *CreateScalingConfigurationResponse, err error) { |
| 46 |
if args.UserData != "" { |
| 47 |
|
| 48 |
args.UserData = base64.StdEncoding.EncodeToString([]byte(args.UserData)) |
| 49 |
} |
| 50 |
response := CreateScalingConfigurationResponse{} |
| 51 |
err = client.InvokeByFlattenMethod("CreateScalingConfiguration", args, &response) |
| 52 |
|
| 53 |
if err != nil { |
| 54 |
return nil, err |
| 55 |
} |
| 56 |
return &response, nil |
| 57 |
} |
| 58 |
|
| 59 |
type DescribeScalingConfigurationsArgs struct { |
| 60 |
RegionId common.Region |
| 61 |
ScalingGroupId string |
| 62 |
ScalingConfigurationId common.FlattenArray |
| 63 |
ScalingConfigurationName common.FlattenArray |
| 64 |
common.Pagination |
| 65 |
} |
| 66 |
|
| 67 |
type DescribeScalingConfigurationsResponse struct { |
| 68 |
common.Response |
| 69 |
common.PaginationResult |
| 70 |
ScalingConfigurations struct { |
| 71 |
ScalingConfiguration []ScalingConfigurationItemType |
| 72 |
} |
| 73 |
} |
| 74 |
type TagItemType struct { |
| 75 |
Key string |
| 76 |
Value string |
| 77 |
} |
| 78 |
|
| 79 |
type ScalingConfigurationItemType struct { |
| 80 |
ScalingConfigurationId string |
| 81 |
ScalingConfigurationName string |
| 82 |
ScalingGroupId string |
| 83 |
ImageId string |
| 84 |
InstanceType string |
| 85 |
InstanceName string |
| 86 |
IoOptimized string |
| 87 |
SecurityGroupId string |
| 88 |
InternetChargeType string |
| 89 |
LifecycleState LifecycleState |
| 90 |
CreationTime string |
| 91 |
InternetMaxBandwidthIn int |
| 92 |
InternetMaxBandwidthOut int |
| 93 |
SystemDiskCategory string |
| 94 |
DataDisks struct { |
| 95 |
DataDisk []DataDiskItemType |
| 96 |
} |
| 97 |
KeyPairName string |
| 98 |
RamRoleName string |
| 99 |
UserData string |
| 100 |
Tags struct { |
| 101 |
Tag []TagItemType |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
type DataDiskItemType struct { |
| 106 |
Size int |
| 107 |
Category string |
| 108 |
SnapshotId string |
| 109 |
Device string |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
func (client *Client) DescribeScalingConfigurations(args *DescribeScalingConfigurationsArgs) (configs []ScalingConfigurationItemType, pagination *common.PaginationResult, err error) { |
| 116 |
args.Validate() |
| 117 |
response := DescribeScalingConfigurationsResponse{} |
| 118 |
|
| 119 |
err = client.InvokeByFlattenMethod("DescribeScalingConfigurations", args, &response) |
| 120 |
|
| 121 |
if err == nil { |
| 122 |
return response.ScalingConfigurations.ScalingConfiguration, &response.PaginationResult, nil |
| 123 |
} |
| 124 |
|
| 125 |
return nil, nil, err |
| 126 |
} |
| 127 |
|
| 128 |
type DeleteScalingConfigurationArgs struct { |
| 129 |
ScalingConfigurationId string |
| 130 |
ScalingGroupId string |
| 131 |
ImageId string |
| 132 |
} |
| 133 |
|
| 134 |
type DeleteScalingConfigurationResponse struct { |
| 135 |
common.Response |
| 136 |
} |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
func (client *Client) DeleteScalingConfiguration(args *DeleteScalingConfigurationArgs) (resp *DeleteScalingConfigurationResponse, err error) { |
| 142 |
response := DeleteScalingConfigurationResponse{} |
| 143 |
err = client.InvokeByFlattenMethod("DeleteScalingConfiguration", args, &response) |
| 144 |
|
| 145 |
if err != nil { |
| 146 |
return nil, err |
| 147 |
} |
| 148 |
return &response, nil |
| 149 |
} |
| 150 |
|
| 151 |
type DeactivateScalingConfigurationArgs struct { |
| 152 |
ScalingConfigurationId string |
| 153 |
} |
| 154 |
|
| 155 |
type DeactivateScalingConfigurationResponse struct { |
| 156 |
common.Response |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
func (client *Client) DeactivateScalingConfiguration(args *DeactivateScalingConfigurationArgs) (resp *DeactivateScalingConfigurationResponse, err error) { |
| 162 |
response := DeactivateScalingConfigurationResponse{} |
| 163 |
err = client.InvokeByFlattenMethod("DeactivateScalingConfiguration", args, &response) |
| 164 |
|
| 165 |
if err != nil { |
| 166 |
return nil, err |
| 167 |
} |
| 168 |
return &response, nil |
| 169 |
} |