2017-01-20 16:51:53 +00:00
|
|
|
|
|
|
|
require 'azure_mgmt_resources'
|
|
|
|
|
|
|
|
class ResourceGroups
|
2017-02-20 13:51:41 +00:00
|
|
|
|
|
|
|
attr_reader :client
|
|
|
|
|
2017-01-20 16:51:53 +00:00
|
|
|
def initialize(azure)
|
|
|
|
@client = Azure::ARM::Resources::ResourceManagementClient.new(azure.connection)
|
2017-02-20 13:51:41 +00:00
|
|
|
client.subscription_id = azure.subscription_id
|
2017-01-20 16:51:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def exists(name)
|
2017-02-20 13:51:41 +00:00
|
|
|
client.resource_groups.check_existence(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(name)
|
|
|
|
|
|
|
|
if exists(name)
|
|
|
|
client.resource_groups.get(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_resources(name)
|
|
|
|
|
|
|
|
if exists(name)
|
|
|
|
client.resource_groups.list_resources_as_lazy(name)
|
|
|
|
end
|
2017-01-20 16:51:53 +00:00
|
|
|
end
|
|
|
|
end
|