-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathalicloud_region.rb
42 lines (33 loc) · 973 Bytes
/
alicloud_region.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
41
42
require 'alicloud_backend'
class AliCloudRegion < AliCloudResourceBase
name 'alicloud_region'
desc 'Verifies settings for an AliCloud region.'
example <<-EXAMPLE
describe alicloud_region('eu-west-1') do
it { should exist }
end
EXAMPLE
attr_reader :region_name, :endpoint, :region_local_name
def initialize(opts = {})
opts = { region_name: opts } if opts.is_a?(String)
super(opts)
validate_parameters(required: %i(region_name region))
@region_name = opts[:region_name]
catch_alicloud_errors do
@regions = @alicloud.ecs_client.request(action: 'DescribeRegions')['Regions']['Region']
resp = @regions.find { |r| r['RegionId'] == @region_name }
return if resp.nil?
@endpoint = resp['RegionEndpoint']
@region_local_name = resp['LocalName']
end
end
def exists?
end
def resource_id
@region_name
end
def to_s
"AliCloud Region #{@region_name}"
end
end