-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathalicloud_regions.rb
40 lines (34 loc) · 1.15 KB
/
alicloud_regions.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'alicloud_backend'
class AliCloudRegions < AliCloudResourceBase
name 'alicloud_regions'
desc 'Verifies settings for AliCloud Regions in bulk.'
example <<-EXAMPLE
describe alicloud_regions do
it { should exist }
end
EXAMPLE
attr_reader :table
FilterTable.create
.register_column(:region_names, field: :region_name)
.register_column(:endpoints, field: :endpoint)
.register_column(:region_local_names, field: :region_local_name)
.install_filter_methods_on_resource(self, :table)
def initialize(opts = {})
super(opts)
validate_parameters(required: %i(region))
@table = fetch_data
end
def fetch_data
region_rows = []
catch_alicloud_errors do
@regions = @alicloud.ecs_client.request(action: 'DescribeRegions')['Regions']['Region']
end
return [] if !@regions || @regions.empty?
@regions.each do |region|
region_rows += [{ region_name: region['RegionId'],
endpoint: region['RegionEndpoint'],
region_local_name: region['LocalName'] }]
end
@table = region_rows
end
end