Class: Azure::Armrest::ResourceProviderService
- Inherits:
-
ArmrestService
- Object
- ArmrestService
- Azure::Armrest::ResourceProviderService
- Defined in:
- lib/azure/armrest/resource_provider_service.rb
Class Attribute Summary collapse
-
.cache_time ⇒ Object
Get or set the cache time for all methods.
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
The provider used in http requests.
Attributes inherited from ArmrestService
#api_version, #armrest_configuration, #base_url
Instance Method Summary collapse
- #_list_all ⇒ Object
-
#get(namespace) ⇒ Object
Return information about a specific
namespaceprovider. -
#initialize(configuration, options = {}) ⇒ ResourceProviderService
constructor
Creates and returns a new ResourceProviderService object.
-
#list ⇒ Object
List all the providers for the current subscription.
-
#list_all ⇒ Object
List all the providers for Azure.
-
#list_api_versions(namespace) ⇒ Object
Returns an array of supported api-versions for the given
namespaceprovider. -
#list_geo_locations(namespace) ⇒ Object
Returns an array of geo-locations for the given
namespaceprovider. -
#register(namespace) ⇒ Object
Register the current subscription with the
namespaceprovider. -
#unregister(namespace) ⇒ Object
Unregister the current subscription from the
namespaceprovider.
Methods inherited from ArmrestService
configure, #get_provider, #get_subscription, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #tags, #tenants
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’.
26 27 28 29 30 31 32 33 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 26 def initialize(configuration, = {}) super(configuration, 'resourceGroups', 'Microsoft.Resources', ) if [:cache_time] @cache_time = [:cache_time] self.class.send(:cache_time=, @cache_time) end end |
Class Attribute Details
.cache_time ⇒ Object
Get or set the cache time for all methods. The default is 24 hours.
14 15 16 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 14 def cache_time @cache_time end |
Instance Attribute Details
#provider ⇒ Object (readonly)
The provider used in http requests. The default is ‘Microsoft.Resources’
7 8 9 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 7 def provider @provider end |
Instance Method Details
#_list_all ⇒ Object
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 |
#list ⇒ Object
List all the providers for the current subscription. The results of this method are cached.
38 39 40 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 38 def list _list.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) } end |
#list_all ⇒ Object
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 |