| 1 |
package ecs |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/denverdino/aliyungo/common" |
| 5 |
) |
| 6 |
|
| 7 |
type ResourceType string |
| 8 |
|
| 9 |
const ( |
| 10 |
ResourceTypeInstance = ResourceType("Instance") |
| 11 |
ResourceTypeDisk = ResourceType("Disk") |
| 12 |
ResourceTypeVSwitch = ResourceType("VSwitch") |
| 13 |
ResourceTypeIOOptimizedInstance = ResourceType("IoOptimized") |
| 14 |
) |
| 15 |
|
| 16 |
|
| 17 |
type SupportedResourceType string |
| 18 |
|
| 19 |
const ( |
| 20 |
SupportedInstanceType = SupportedResourceType("supportedInstanceType") |
| 21 |
SupportedInstanceTypeFamily = SupportedResourceType("supportedInstanceTypeFamily") |
| 22 |
SupportedInstanceGeneration = SupportedResourceType("supportedInstanceGeneration") |
| 23 |
SupportedSystemDiskCategory = SupportedResourceType("supportedSystemDiskCategory") |
| 24 |
SupportedDataDiskCategory = SupportedResourceType("supportedDataDiskCategory") |
| 25 |
SupportedNetworkCategory = SupportedResourceType("supportedNetworkCategory") |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
type ResourcesInfoType struct { |
| 31 |
ResourcesInfo []AvailableResourcesType |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
type AvailableResourcesType struct { |
| 36 |
IoOptimized bool |
| 37 |
NetworkTypes map[SupportedResourceType][]string |
| 38 |
InstanceGenerations map[SupportedResourceType][]string |
| 39 |
InstanceTypeFamilies map[SupportedResourceType][]string |
| 40 |
InstanceTypes map[SupportedResourceType][]string |
| 41 |
SystemDiskCategories map[SupportedResourceType][]DiskCategory |
| 42 |
DataDiskCategories map[SupportedResourceType][]DiskCategory |
| 43 |
} |
| 44 |
|
| 45 |
type DescribeZonesArgs struct { |
| 46 |
RegionId common.Region |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
type AvailableResourceCreationType struct { |
| 52 |
ResourceTypes []ResourceType |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
type AvailableDiskCategoriesType struct { |
| 58 |
DiskCategories []DiskCategory |
| 59 |
} |
| 60 |
|
| 61 |
type AvailableInstanceTypesType struct { |
| 62 |
InstanceTypes []string |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
type ZoneType struct { |
| 68 |
ZoneId string |
| 69 |
LocalName string |
| 70 |
AvailableResources ResourcesInfoType |
| 71 |
AvailableInstanceTypes AvailableInstanceTypesType |
| 72 |
AvailableResourceCreation AvailableResourceCreationType |
| 73 |
AvailableDiskCategories AvailableDiskCategoriesType |
| 74 |
} |
| 75 |
|
| 76 |
type DescribeZonesResponse struct { |
| 77 |
common.Response |
| 78 |
Zones struct { |
| 79 |
Zone []ZoneType |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
func (client *Client) DescribeZones(regionId common.Region) (zones []ZoneType, err error) { |
| 85 |
response, err := client.DescribeZonesWithRaw(regionId) |
| 86 |
if err == nil { |
| 87 |
return response.Zones.Zone, nil |
| 88 |
} |
| 89 |
|
| 90 |
return []ZoneType{}, err |
| 91 |
} |
| 92 |
|
| 93 |
func (client *Client) DescribeZonesWithRaw(regionId common.Region) (response *DescribeZonesResponse, err error) { |
| 94 |
args := DescribeZonesArgs{ |
| 95 |
RegionId: regionId, |
| 96 |
} |
| 97 |
response = &DescribeZonesResponse{} |
| 98 |
|
| 99 |
err = client.Invoke("DescribeZones", &args, response) |
| 100 |
|
| 101 |
if err == nil { |
| 102 |
return response, nil |
| 103 |
} |
| 104 |
|
| 105 |
return nil, err |
| 106 |
} |
| 107 |
|
| 108 |
type DescribeAvailableResourceArgs struct { |
| 109 |
RegionId string |
| 110 |
DestinationResource string |
| 111 |
ZoneId string |
| 112 |
InstanceChargeType string |
| 113 |
SpotStrategy string |
| 114 |
IoOptimized string |
| 115 |
InstanceType string |
| 116 |
SystemDiskCategory string |
| 117 |
DataDiskCategory string |
| 118 |
NetworkCategory string |
| 119 |
} |
| 120 |
|
| 121 |
type DescribeAvailableResourceResponse struct { |
| 122 |
common.Response |
| 123 |
AvailableZones struct { |
| 124 |
AvailableZone []AvailableZoneType |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
type AvailableZoneType struct { |
| 129 |
RegionId string |
| 130 |
ZoneId string |
| 131 |
Status string |
| 132 |
AvailableResources struct { |
| 133 |
AvailableResource []NewAvailableResourcesType |
| 134 |
} |
| 135 |
} |
| 136 |
|
| 137 |
type NewAvailableResourcesType struct { |
| 138 |
Type string |
| 139 |
SupportedResources struct { |
| 140 |
SupportedResource []SupportedResourcesType |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
type SupportedResourcesType struct { |
| 145 |
Value string |
| 146 |
Status string |
| 147 |
Min string |
| 148 |
Max string |
| 149 |
Unit string |
| 150 |
} |
| 151 |
|
| 152 |
|
| 153 |
func (client *Client) DescribeAvailableResource(args *DescribeAvailableResourceArgs) (response *DescribeAvailableResourceResponse, err error) { |
| 154 |
|
| 155 |
response = &DescribeAvailableResourceResponse{} |
| 156 |
err = client.Invoke("DescribeAvailableResource", args, response) |
| 157 |
return response, err |
| 158 |
} |