class Armrest::Services::ResourceGroup

Public Instance Methods

check_existence(attrs={}) click to toggle source

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

# 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={}) click to toggle source

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

# 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