-
Notifications
You must be signed in to change notification settings - Fork 9
/
alicloud_rd.rb
52 lines (43 loc) · 1.42 KB
/
alicloud_rd.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
43
44
45
46
47
48
49
50
51
52
require 'alicloud_backend'
class AliCloudResourceDirectory < AliCloudResourceBase
name 'alicloud_resource_directory'
desc 'Verifies settings for an AliCloud resource management.'
example <<-EXAMPLE
describe alicloud_resource_directory do
it { should exist}
its('resource_directory_id') { should eq 'rd-directory-id' }
its('master_account_name') { should eq 'master-account-name' }
end
EXAMPLE
attr_reader :resource_directory_id, :master_account_name, :master_account_id
def initialize(opts = {})
super(opts)
validate_parameters(required: %i(region))
catch_alicloud_errors do
@resp = @alicloud.rm_client.request(
action: 'GetResourceDirectory',
params: {
"RegionId": opts[:region],
},
)
end
if @resp.nil? || @resp['ResourceDirectory'].nil?
@resource_directory_id = nil
@master_account_name = nil
@master_account_id = nil
return
end
@resource_directory_id = @resp['ResourceDirectory']['ResourceDirectoryId']
@master_account_name = @resp['ResourceDirectory']['MasterAccountName']
@master_account_id = @resp['ResourceDirectory']['MasterAccountId']
end
def exists?
end
def resource_id
"#{@resource_directory_id}_#{@opts[:region]}"
end
def to_s
"AliCloud Resource Directory: #{@resource_directory_id}, Master Account: #{@master_account_name}(#{@master_account_id})"
end
end