Class: Azure::Armrest::Billing::UsageService

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

Instance Attribute Summary

Attributes inherited from ArmrestService

#api_version, #armrest_configuration, #base_url, #provider

Instance Method Summary collapse

Methods inherited from ArmrestService

configure, #get_provider, #get_subscription, #list_resource_groups, #list_resources, #list_subscriptions, #locations, #tags, #tenants

Constructor Details

#initialize(configuration, options = {}) ⇒ UsageService

Creates and returns a new UsageService object.


7
8
9
10
# File 'lib/azure/armrest/billing/usage_service.rb', line 7

def initialize(configuration, options = {})
  options = options.merge('api_version' => '2015-06-01-preview')
  super(configuration, 'subscriptions', 'Microsoft.Commerce', options)
end

Instance Method Details

#list(options = {}) ⇒ Object

List usage details. The options hash may include the following filters:

:reportedStartTime        # e.g. 2016-05-30T00:00:00Z. Mandatory.
:reportedEndTime          # e.g. 2016-06-01T00:00:00Z. Mandatory.
:aggregationGranularity   # Either 'Daily' or 'Hourly'. Default is Daily.
:showDetails              # Either true or false. Default is true.
:continuationToken        # Token received from previous call. No default.

The :reportedStartTime and :reportedEndTime values should be in UTC + iso8601 format. For “Daily” aggregation, the time should be set to midnight. For “Hourly” aggregation, only the hour should be set, with minutes and seconds set to “00”.


26
27
28
29
30
# File 'lib/azure/armrest/billing/usage_service.rb', line 26

def list(options = {})
  url = build_url(options)
  response = rest_get(url)
  JSON.parse(response)['value'].map { |hash| Azure::Armrest::Usage.new(hash) }
end