Class: Azure::Armrest::RoleService

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

Overview

Abstract base class for use by role related service classes.

Instance Attribute Summary

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #provider, #service_name

Instance Method Summary collapse

Methods inherited from ArmrestService

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

Constructor Details

This class inherits a constructor from Azure::Armrest::ArmrestService

Instance Method Details

#get_by_id(role_id, options = {}) ⇒ Object Also known as: get_by_resource

Gets information for the role assignment via a resource string ID.



36
37
38
39
40
# File 'lib/azure/armrest/role.rb', line 36

def get_by_id(role_id, options = {})
  url = build_url(options.merge(:resource => role_id))
  response = rest_get(url)
  model_class.new(response.body)
end

#get_by_name(role_name, options = {}) ⇒ Object Also known as: get

Gets information for the role assignment by name, where the “name” is really just the last portion (GUID) of an ID string.



26
27
28
29
30
# File 'lib/azure/armrest/role.rb', line 26

def get_by_name(role_name, options = {})
  url = build_url(options.merge(:subscription => true), role_name)
  response = rest_get(url)
  model_class.new(response.body)
end

#list(resource_group, options = {}) ⇒ Object Also known as: list_for_resource_group

List all role assignments for the given resource_group.



56
57
58
59
60
# File 'lib/azure/armrest/role.rb', line 56

def list(resource_group, options = {})
  url = build_url(options.merge(:resource_group => resource_group))
  response = rest_get(url)
  Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
end

#list_all(options = {}) ⇒ Object Also known as: list_for_subscription

List all role assignments for the current subscription.



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

def list_all(options = {})
  url = build_url(options.merge(:subscription => true))
  response = rest_get(url)
  Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
end

#list_for_resource(resource, options = {}) ⇒ Object

List all role assignments for the given resource.

Example:

vms = Azure::Armrest::VirtualMachineService.new(conf)
ads = Azure::Armrest::Role::AssignmentService.new(conf)

vm = vms.get('some_vm', 'some_group')
ads.list_for_resource(vm.id)


74
75
76
77
78
# File 'lib/azure/armrest/role.rb', line 74

def list_for_resource(resource, options = {})
  url = build_url(options.merge(:resource => resource))
  response = rest_get(url)
  Azure::Armrest::ArmrestCollection.create_from_response(response, model_class)
end