class Azure::CostManagement::Mgmt::V2019_03_01_preview::QueryOperations

QueryOperations

Attributes

client[R]

@return [CostManagementClient] reference to the CostManagementClient

Public Class Methods

new(client) click to toggle source

Creates and initializes a new instance of the QueryOperations class. @param client service class for accessing basic functionality.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 17
def initialize(client)
  @client = client
end

Public Instance Methods

usage_by_billing_account(billing_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for billing account.

@param billing_account_id [String] BillingAccount ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 239
def usage_by_billing_account(billing_account_id, parameters, custom_headers:nil)
  response = usage_by_billing_account_async(billing_account_id, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_billing_account_async(billing_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for billing account.

@param billing_account_id [String] BillingAccount ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 270
def usage_by_billing_account_async(billing_account_id, parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'billing_account_id is nil' if billing_account_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'billingAccountId' => billing_account_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_billing_account_with_http_info(billing_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for billing account.

@param billing_account_id [String] BillingAccount ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 255
def usage_by_billing_account_with_http_info(billing_account_id, parameters, custom_headers:nil)
  usage_by_billing_account_async(billing_account_id, parameters, custom_headers:custom_headers).value!
end
usage_by_department(billing_account_id, department_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for department.

@param billing_account_id [String] BillingAccount ID @param department_id [String] Department ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 450
def usage_by_department(billing_account_id, department_id, parameters, custom_headers:nil)
  response = usage_by_department_async(billing_account_id, department_id, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_department_async(billing_account_id, department_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for department.

@param billing_account_id [String] BillingAccount ID @param department_id [String] Department ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 483
def usage_by_department_async(billing_account_id, department_id, parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'billing_account_id is nil' if billing_account_id.nil?
  fail ArgumentError, 'department_id is nil' if department_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'billingAccountId' => billing_account_id,'departmentId' => department_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_department_with_http_info(billing_account_id, department_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for department.

@param billing_account_id [String] BillingAccount ID @param department_id [String] Department ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 467
def usage_by_department_with_http_info(billing_account_id, department_id, parameters, custom_headers:nil)
  usage_by_department_async(billing_account_id, department_id, parameters, custom_headers:custom_headers).value!
end
usage_by_enrollment_account(billing_account_id, enrollment_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for an enrollment account.

@param billing_account_id [String] BillingAccount ID @param enrollment_account_id [String] Enrollment Account ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 343
def usage_by_enrollment_account(billing_account_id, enrollment_account_id, parameters, custom_headers:nil)
  response = usage_by_enrollment_account_async(billing_account_id, enrollment_account_id, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_enrollment_account_async(billing_account_id, enrollment_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for an enrollment account.

@param billing_account_id [String] BillingAccount ID @param enrollment_account_id [String] Enrollment Account ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 376
def usage_by_enrollment_account_async(billing_account_id, enrollment_account_id, parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'billing_account_id is nil' if billing_account_id.nil?
  fail ArgumentError, 'enrollment_account_id is nil' if enrollment_account_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'billingAccountId' => billing_account_id,'enrollmentAccountId' => enrollment_account_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_enrollment_account_with_http_info(billing_account_id, enrollment_account_id, parameters, custom_headers:nil) click to toggle source

Query the usage data for an enrollment account.

@param billing_account_id [String] BillingAccount ID @param enrollment_account_id [String] Enrollment Account ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 360
def usage_by_enrollment_account_with_http_info(billing_account_id, enrollment_account_id, parameters, custom_headers:nil)
  usage_by_enrollment_account_async(billing_account_id, enrollment_account_id, parameters, custom_headers:custom_headers).value!
end
usage_by_management_group(management_group_id, parameters, custom_headers:nil) click to toggle source

Lists the usage data for management group.

@param management_group_id [String] ManagementGroup ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 556
def usage_by_management_group(management_group_id, parameters, custom_headers:nil)
  response = usage_by_management_group_async(management_group_id, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_management_group_async(management_group_id, parameters, custom_headers:nil) click to toggle source

Lists the usage data for management group.

@param management_group_id [String] ManagementGroup ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 587
def usage_by_management_group_async(management_group_id, parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'managementGroupId' => management_group_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_management_group_with_http_info(management_group_id, parameters, custom_headers:nil) click to toggle source

Lists the usage data for management group.

@param management_group_id [String] ManagementGroup ID @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 572
def usage_by_management_group_with_http_info(management_group_id, parameters, custom_headers:nil)
  usage_by_management_group_async(management_group_id, parameters, custom_headers:custom_headers).value!
end
usage_by_resource_group(resource_group_name, parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId and resource group.

@param resource_group_name [String] Azure Resource Group Name. @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 135
def usage_by_resource_group(resource_group_name, parameters, custom_headers:nil)
  response = usage_by_resource_group_async(resource_group_name, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_resource_group_async(resource_group_name, parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId and resource group.

@param resource_group_name [String] Azure Resource Group Name. @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 166
def usage_by_resource_group_async(resource_group_name, parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_resource_group_with_http_info(resource_group_name, parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId and resource group.

@param resource_group_name [String] Azure Resource Group Name. @param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 151
def usage_by_resource_group_with_http_info(resource_group_name, parameters, custom_headers:nil)
  usage_by_resource_group_async(resource_group_name, parameters, custom_headers:custom_headers).value!
end
usage_by_subscription(parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId.

@param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [QueryResult] operation results.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 34
def usage_by_subscription(parameters, custom_headers:nil)
  response = usage_by_subscription_async(parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
usage_by_subscription_async(parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId.

@param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 63
def usage_by_subscription_async(parameters, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::ReportConfigDefinition.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/Query'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CostManagement::Mgmt::V2019_03_01_preview::Models::QueryResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
usage_by_subscription_with_http_info(parameters, custom_headers:nil) click to toggle source

Query the usage data for subscriptionId.

@param parameters [ReportConfigDefinition] Parameters supplied to the CreateOrUpdate Report Config operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2019-03-01-preview/generated/azure_mgmt_cost_management/query_operations.rb, line 49
def usage_by_subscription_with_http_info(parameters, custom_headers:nil)
  usage_by_subscription_async(parameters, custom_headers:custom_headers).value!
end