Class: Armrest::Services::ResourceGroup

Inherits:
Base
  • Object
show all
Defined in:
lib/armrest/services/resource_group.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Api::Settings

#client_id, #client_secret, #endpoint, #group, #location, #resource, #subscription_id, #tenant_id

Methods included from Api::HandleResponse

#load_json, #ok?

Methods included from Logging

#default_logger, #logger, #logger=

Constructor Details

This class inherits a constructor from Armrest::Services::Base

Instance Method Details

#check_existence(attrs = {}) ⇒ Object

docs.microsoft.com/en-us/rest/api/resources/resource-groups/check-existence HEAD management.azure.com/subscriptions/subscriptionId/resourcegroups/resourceGroupName?api-version=2021-04-01



5
6
7
8
9
10
# File 'lib/armrest/services/resource_group.rb', line 5

def check_existence(attrs={})
  name = attrs[:name]
  path = "subscriptions/#{subscription_id}/resourcegroups/#{name}"
  resp = api.head(path)
  resp.code == "204" # means it exists
end

#create_or_update(attrs = {}) ⇒ Object

docs.microsoft.com/en-us/rest/api/resources/resource-groups/create-or-update PUT management.azure.com/subscriptions/subscriptionId/resourcegroups/resourceGroupName?api-version=2021-04-01



14
15
16
17
18
19
20
21
# File 'lib/armrest/services/resource_group.rb', line 14

def create_or_update(attrs={})
  name = attrs.delete(:name)
  # https://docs.microsoft.com/en-us/rest/api/resources/resource-groups/create-or-update#request-body
  attrs[:location] ||= location
  attrs[:tags] = attrs[:tags] if attrs[:tags]
  path = "subscriptions/#{subscription_id}/resourcegroups/#{name}"
  api.put(path, attrs)
end