Class: Azure::Armrest::ResourceProviderService

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

Class Attribute Summary collapse

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 = {}) ⇒ ResourceProviderService

Creates and returns a new ResourceProviderService object.

Note that many ResourceProviderService instance methods are cached. You can set the cache_time for certain methods in the constructor, but keep in mind that it is a global setting for the class. You can also set this at the class level if desired. The default cache time is 24 hours.

You can also set the provider. The default is ‘Microsoft.Resources’.



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

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

  if options[:cache_time]
    @cache_time = options[:cache_time]
    self.class.send(:cache_time=, @cache_time)
  end
end

Class Attribute Details

.cache_timeObject

Get or set the cache time for all methods. The default is 24 hours.



12
13
14
# File 'lib/azure/armrest/resource_provider_service.rb', line 12

def cache_time
  @cache_time
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_provider_service.rb', line 5

def provider
  @provider
end

Instance Method Details

#_list_allObject



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

def _list_all
  url = File.join(Azure::Armrest::RESOURCE, 'providers')
  url << "?api-version=#{@api_version}"
  response = rest_get(url)
  JSON.parse(response)['value']
end

#get(namespace) ⇒ Object

Return information about a specific namespace provider. The results of this method are cached.



75
76
77
# File 'lib/azure/armrest/resource_provider_service.rb', line 75

def get(namespace)
  Azure::Armrest::ResourceProvider.new(_get(namespace))
end

#listObject

List all the providers for the current subscription. The results of this method are cached.



36
37
38
# File 'lib/azure/armrest/resource_provider_service.rb', line 36

def list
  _list.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
end

#list_allObject

List all the providers for Azure. This may include results that are not available for the current subscription.



59
60
61
# File 'lib/azure/armrest/resource_provider_service.rb', line 59

def list_all
  _list_all.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) }
end

#list_api_versions(namespace) ⇒ Object

Returns an array of supported api-versions for the given namespace provider. The results of this method are cached.



102
103
104
105
106
# File 'lib/azure/armrest/resource_provider_service.rb', line 102

def list_api_versions(namespace)
  url = build_url(namespace)
  response = rest_get(url)
  JSON.parse(response)['resourceTypes'].first['apiVersions']
end

#list_geo_locations(namespace) ⇒ Object

Returns an array of geo-locations for the given namespace provider. The results of this method are cached.



91
92
93
94
95
# File 'lib/azure/armrest/resource_provider_service.rb', line 91

def list_geo_locations(namespace)
  url = build_url(namespace)
  response = rest_get(url)
  JSON.parse(response)['resourceTypes'].first['locations']
end

#register(namespace) ⇒ Object

Register the current subscription with the namespace provider.



112
113
114
115
116
# File 'lib/azure/armrest/resource_provider_service.rb', line 112

def register(namespace)
  url = build_url(namespace, 'register')
  rest_post(url)
  nil
end

#unregister(namespace) ⇒ Object

Unregister the current subscription from the namespace provider.



120
121
122
123
124
# File 'lib/azure/armrest/resource_provider_service.rb', line 120

def unregister(namespace)
  url = build_url(namespace, 'unregister')
  rest_post(url)
  nil
end