Class: Azure::Armrest::Insights::MetricsService
- Inherits:
-
ArmrestService
- Object
- ArmrestService
- Azure::Armrest::Insights::MetricsService
- Defined in:
- lib/azure/armrest/insights/metrics_service.rb
Instance Attribute Summary
Attributes inherited from ArmrestService
#api_version, #armrest_configuration, #base_url, #provider, #service_name
Instance Method Summary collapse
-
#initialize(armrest_configuration, options = {}) ⇒ MetricsService
constructor
Creates and returns a new MetricsService object.
-
#list(provider, resource_type, resource_name, resource_group = nil, options = {}) ⇒ Object
Return the metric definitions for the given
provider
,resource_type
, andresource_name
forresource_group
.
Methods inherited from ArmrestService
configure, #get_provider, #get_subscription, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #poll, #tags, #tenants, #wait
Constructor Details
#initialize(armrest_configuration, options = {}) ⇒ MetricsService
Creates and returns a new MetricsService object.
7 8 9 10 |
# File 'lib/azure/armrest/insights/metrics_service.rb', line 7 def initialize(armrest_configuration, = {}) ['api_version'] = '2014-04-01' # Must hard code for now super(armrest_configuration, 'metricDefinitions', 'Microsoft.Insights', ) end |
Instance Method Details
#list(provider, resource_type, resource_name, resource_group = nil, options = {}) ⇒ Object
Return the metric definitions for the given provider
, resource_type
, and resource_name
for resource_group
. You may pass a :filter option as well.
Example:
metrics = Azure::Armrest::Insights::MetricsService.new(conf)
metrics.list('Microsoft.SQL', 'servers', 'myServer/databases/myDB', 'mygroup')
metrics.list('Microsoft.Compute', 'virtualMachines', 'myVm', 'mygroup')
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/azure/armrest/insights/metrics_service.rb', line 22 def list(provider, resource_type, resource_name, resource_group = nil, = {}) resource_group ||= configuration.resource_group raise ArgumentError, "no resource group provided" unless resource_group url = build_url(provider, resource_type, resource_name, resource_group, ) response = rest_get(url) JSON.parse(response)['value'].map { |hash| Azure::Armrest::Insights::Metric.new(hash) } end |