Class: Azure::Armrest::ResourceGroupService
- Inherits:
-
ArmrestService
- Object
- ArmrestService
- Azure::Armrest::ResourceGroupService
- Defined in:
- lib/azure/armrest/resource_group_service.rb
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
The provider used in http requests.
Attributes inherited from ArmrestService
#api_version, #armrest_configuration, #base_url, #service_name
Instance Method Summary collapse
-
#create(group, location, tags = nil) ⇒ Object
Creates a new
group
inlocation
for the current subscription. -
#delete(group) ⇒ Object
Delete a resource group from the current subscription.
-
#exists?(group) ⇒ Boolean
Returns whether or not the given resource group exists.
-
#get(group) ⇒ Object
Returns information for the given resource group.
-
#initialize(configuration, options = {}) ⇒ ResourceGroupService
constructor
Creates and returns a new ResourceGroupService object.
-
#list(options = {}) ⇒ Object
List all the resources for the current subscription.
-
#update(group, tags) ⇒ Object
Updates the tags for the given resource group.
Methods inherited from ArmrestService
configure, #get_provider, #get_subscription, #list_locations, #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, = {}) super(configuration, 'resourceGroups', 'Microsoft.Resources', ) end |
Instance Attribute Details
#provider ⇒ Object (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
.
44 45 46 47 48 49 50 51 |
# File 'lib/azure/armrest/resource_group_service.rb', line 44 def create(group, location, = nil) body = {:location => location, :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.
55 56 57 58 59 |
# File 'lib/azure/armrest/resource_group_service.rb', line 55 def delete(group) url = build_url(group) response = rest_delete(url) response.return! end |
#exists?(group) ⇒ Boolean
Returns whether or not the given resource group exists.
15 16 17 18 19 20 |
# File 'lib/azure/armrest/resource_group_service.rb', line 15 def exists?(group) url = build_url(group) rest_head(url) and true rescue Azure::Armrest::NotFoundException false end |
#get(group) ⇒ Object
Returns information for the given resource group.
63 64 65 66 67 |
# File 'lib/azure/armrest/resource_group_service.rb', line 63 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'")
32 33 34 35 36 37 38 39 |
# File 'lib/azure/armrest/resource_group_service.rb', line 32 def list( = {}) url = build_url url << "&$top=#{[:top]}" if [:top] url << "&$filter=#{[:filter]}" if [: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.
71 72 73 74 75 76 |
# File 'lib/azure/armrest/resource_group_service.rb', line 71 def update(group, ) body = {:tags => }.to_json url = build_url(group) response = rest_patch(url, body) response.return! end |