Class: Azure::Armrest::Insights::MetricsService

Inherits:
ArmrestService show all
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

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, options = {})
  options['api_version'] = '2014-04-01' # Must hard code for now
  super(armrest_configuration, 'metricDefinitions', 'Microsoft.Insights', options)
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')

Raises:

  • (ArgumentError)


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, options = {})
  resource_group ||= configuration.resource_group

  raise ArgumentError, "no resource group provided" unless resource_group

  url = build_url(provider, resource_type, resource_name, resource_group, options)

  response = rest_get(url)

  JSON.parse(response)['value'].map { |hash| Azure::Armrest::Insights::Metric.new(hash) }
end