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
|
# File 'lib/puppet/functions/get_accounts.rb', line 6
Puppet::Functions.create_function(:get_accounts) do
dispatch :execute do
param 'String', :server_url
param 'String', :authtoken
param 'Optional[String]', :org
param 'Optional[String]', :certificate
param 'Optional[Array[Integer]]', :account_ids
param 'Optional[Array[Hash[String, Any]]]', :accounts
end
def execute(server_url, authtoken, org, certificate, account_ids, accounts)
initialized = API::Init.initialized
if initialized == false
API::Init.new(
server_url: server_url,
authtoken: authtoken,
org: org,
certificate: certificate,
)
end
API::Accounts.get(
account_ids: account_ids,
accounts: accounts,
)
rescue StandardError => e
Puppet.err("Failed to get account: #{e.message}")
nil
end
end
|