Class: Azure::Armrest::ResourceProviderService
- Inherits:
-
ArmrestService
- Object
- ArmrestService
- Azure::Armrest::ResourceProviderService
- Extended by:
- Memoist
- Defined in:
- lib/azure/armrest/resource_provider_service.rb
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
The provider used in http requests.
Attributes inherited from ArmrestService
#api_version, #armrest_configuration, #base_url, #service_name
Instance Method Summary collapse
-
#get(namespace) ⇒ Object
Return information about a specific
namespace
provider. -
#initialize(configuration, options = {}) ⇒ ResourceProviderService
constructor
Creates and returns a new ResourceProviderService object.
-
#list(options = {}) ⇒ Object
List all the providers for the current subscription.
-
#list_all(options = {}) ⇒ Object
List all the providers for Azure.
-
#list_api_versions(namespace) ⇒ Object
Returns an array of supported api-versions for the given
namespace
provider. -
#list_geo_locations(namespace) ⇒ Object
Returns an array of geo-locations for the given
namespace
provider. -
#register(namespace) ⇒ Object
Register the current subscription with the
namespace
provider. -
#registered?(namespace) ⇒ Boolean
Returns whether or not the
namespace
provider is registered. -
#unregister(namespace) ⇒ Object
Unregister the current subscription from the
namespace
provider.
Methods inherited from ArmrestService
configure, #get_provider, #get_subscription, #list_locations, #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 also set the provider. The default is ‘Microsoft.Resources’.
15 16 17 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 15 def initialize(configuration, = {}) super(configuration, 'resourceGroups', 'Microsoft.Resources', ) 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
#get(namespace) ⇒ Object
Return information about a specific namespace
provider. The results of this method are cached.
68 69 70 71 72 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 68 def get(namespace) url = build_url(namespace) body = rest_get(url).body Azure::Armrest::ResourceProvider.new(body) end |
#list(options = {}) ⇒ Object
List all the providers for the current subscription. The results of this method are cached.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 22 def list( = {}) url = build_url url << "&$top=#{[:top]}" if [:top] url << "&$expand=#{[:expand]}" if [:expand] response = rest_get(url) resources = JSON.parse(response)['value'] resources.map{ |hash| Azure::Armrest::ResourceProvider.new(hash) } end |
#list_all(options = {}) ⇒ Object
List all the providers for Azure. This may include results that are not available for the current subscription. The results of this method are cached.
The options
hash takes the following options:
-
:top => Limit the result set to the top x results.
-
:expand => Additional properties to include in the results.
Examples:
rps.list_all # Get everything
rps.list_all(:top => 3) # Get first 3 results
rps.list_all(:expand => 'metadata') # Include metadata in results
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 50 def list_all( = {}) url = File.join(configuration.environment.resource_url, 'providers') url << "?api-version=#{@api_version}" url << "&$top=#{[:top]}" if [:top] url << "&$expand=#{[:expand]}" if [:expand] response = rest_get(url) resources = JSON.parse(response)['value'] resources.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.
89 90 91 92 93 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 89 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.
79 80 81 82 83 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 79 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.
98 99 100 101 102 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 98 def register(namespace) url = build_url(namespace, 'register') rest_post(url) nil end |
#registered?(namespace) ⇒ Boolean
Returns whether or not the namespace
provider is registered. If the provider cannot be found, false is returned.
115 116 117 118 119 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 115 def registered?(namespace) get(namespace).registration_state.casecmp("registered").zero? rescue Azure::Armrest::NotFoundException false end |
#unregister(namespace) ⇒ Object
Unregister the current subscription from the namespace
provider.
106 107 108 109 110 |
# File 'lib/azure/armrest/resource_provider_service.rb', line 106 def unregister(namespace) url = build_url(namespace, 'unregister') rest_post(url) nil end |