Class: Azure::Armrest::ResourceGroupService

Inherits:
ArmrestService show all
Defined in:
lib/azure/armrest/resource_group_service.rb

Instance Attribute Summary collapse

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #service_name

Instance Method Summary collapse

Methods inherited from ArmrestService

configure, #get_provider, #get_subscription, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #poll, #tags, #tenants, #wait

Constructor Details

#initialize(configuration, options = {}) ⇒ ResourceGroupService

Creates and returns a new ResourceGroupService object.



9
10
11
# File 'lib/azure/armrest/resource_group_service.rb', line 9

def initialize(configuration, options = {})
  super(configuration, 'resourceGroups', 'Microsoft.Resources', options)
end

Instance Attribute Details

#providerObject (readonly)

The provider used in http requests. The default is ‘Microsoft.Resources’



5
6
7
# File 'lib/azure/armrest/resource_group_service.rb', line 5

def provider
  @provider
end

Instance Method Details

#create(group, location, tags = nil) ⇒ Object

Creates a new group in location for the current subscription. You may optionally apply tags.



35
36
37
38
39
40
41
42
# File 'lib/azure/armrest/resource_group_service.rb', line 35

def create(group, location, tags = nil)
  body = {:location => location, :tags => tags}.to_json
  url = build_url(group)

  response = rest_put(url, body)

  Azure::Armrest::ResourceGroup.new(response)
end

#delete(group) ⇒ Object

Delete a resource group from the current subscription.



46
47
48
49
50
# File 'lib/azure/armrest/resource_group_service.rb', line 46

def delete(group)
  url = build_url(group)
  response = rest_delete(url)
  response.return!
end

#get(group) ⇒ Object

Returns information for the given resource group.



54
55
56
57
58
# File 'lib/azure/armrest/resource_group_service.rb', line 54

def get(group)
  url = build_url(group)
  response = rest_get(url)
  Azure::Armrest::ResourceGroup.new(response)
end

#list(options = {}) ⇒ Object

List all the resources for the current subscription. You can optionally pass :top or :filter options as well to restrict returned results. The :filter option only applies to tags.

Examples:

rgs = ResourceGroupService.new
rgs.list(:top => 2)
rgs.list(:filter => "sometag eq 'value'")


23
24
25
26
27
28
29
30
# File 'lib/azure/armrest/resource_group_service.rb', line 23

def list(options = {})
  url = build_url
  url << "&$top=#{options[:top]}" if options[:top]
  url << "&$filter=#{options[:filter]}" if options[:filter]

  response = rest_get(url)
  Azure::Armrest::ArmrestCollection.create_from_response(response, Azure::Armrest::ResourceGroup)
end

#update(group, tags) ⇒ Object

Updates the tags for the given resource group.



62
63
64
65
66
67
# File 'lib/azure/armrest/resource_group_service.rb', line 62

def update(group, tags)
  body = {:tags => tags}.to_json
  url = build_url(group)
  response = rest_patch(url, body)
  response.return!
end