Class: Azure::Monitor::Mgmt::V2018_01_01::Metrics

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb

Overview

Monitor Management Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Metrics

Creates and initializes a new instance of the Metrics class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientMonitorManagementClient (readonly)

Returns reference to the MonitorManagementClient.

Returns:



22
23
24
# File 'lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb', line 22

def client
  @client
end

Instance Method Details

#list(resource_uri, timespan: nil, interval: nil, metricnames: nil, aggregation: nil, top: nil, orderby: nil, filter: nil, result_type: nil, metricnamespace: nil, custom_headers: nil) ⇒ Response

**Lists the metric values for a resource**.

following format 'startDateTime_ISO/endDateTime_ISO'. retrieve. to retrieve. Valid only if $filter is specified. Defaults to 10. direction of the sort. Only one order can be specified. Examples: sum asc. data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' for. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource.

  • timespan (String) (defaults to: nil)

    The timespan of the query. It is a string with the

  • interval (Duration) (defaults to: nil)

    The interval (i.e. timegrain) of the query.

  • metricnames (String) (defaults to: nil)

    The names of the metrics (comma separated) to

  • aggregation (String) (defaults to: nil)

    The list of aggregation types (comma separated)

  • top (Integer) (defaults to: nil)

    The maximum number of records to retrieve.

  • orderby (String) (defaults to: nil)

    The aggregation to use for sorting results and the

  • filter (String) (defaults to: nil)

    The **$filter** is used to reduce the set of metric

  • result_type (ResultType) (defaults to: nil)

    Reduces the set of data collected. The syntax

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (Response)

    operation results.



62
63
64
65
# File 'lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb', line 62

def list(resource_uri, timespan:nil, interval:nil, metricnames:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, metricnamespace:nil, custom_headers:nil)
  response = list_async(resource_uri, timespan:timespan, interval:interval, metricnames:metricnames, aggregation:aggregation, top:top, orderby:orderby, filter:filter, result_type:result_type, metricnamespace:metricnamespace, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_async(resource_uri, timespan: nil, interval: nil, metricnames: nil, aggregation: nil, top: nil, orderby: nil, filter: nil, result_type: nil, metricnamespace: nil, custom_headers: nil) ⇒ Concurrent::Promise

**Lists the metric values for a resource**.

following format 'startDateTime_ISO/endDateTime_ISO'. retrieve. to retrieve. Valid only if $filter is specified. Defaults to 10. direction of the sort. Only one order can be specified. Examples: sum asc. data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' for. to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource.

  • timespan (String) (defaults to: nil)

    The timespan of the query. It is a string with the

  • interval (Duration) (defaults to: nil)

    The interval (i.e. timegrain) of the query.

  • metricnames (String) (defaults to: nil)

    The names of the metrics (comma separated) to

  • aggregation (String) (defaults to: nil)

    The list of aggregation types (comma separated)

  • top (Integer) (defaults to: nil)

    The maximum number of records to retrieve.

  • orderby (String) (defaults to: nil)

    The aggregation to use for sorting results and the

  • filter (String) (defaults to: nil)

    The **$filter** is used to reduce the set of metric

  • result_type (ResultType) (defaults to: nil)

    Reduces the set of data collected. The syntax

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb', line 147

def list_async(resource_uri, timespan:nil, interval:nil, metricnames:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, metricnamespace:nil, custom_headers:nil)
  fail ArgumentError, 'resource_uri is nil' if resource_uri.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.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?
  path_template = '{resourceUri}/providers/microsoft.insights/metrics'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'resourceUri' => resource_uri},
      query_params: {'timespan' => timespan,'interval' => interval,'metricnames' => metricnames,'aggregation' => aggregation,'top' => top,'orderby' => orderby,'$filter' => filter,'resultType' => result_type,'api-version' => @client.api_version,'metricnamespace' => metricnamespace},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, 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::Monitor::Mgmt::V2018_01_01::Models::Response.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

#list_with_http_info(resource_uri, timespan: nil, interval: nil, metricnames: nil, aggregation: nil, top: nil, orderby: nil, filter: nil, result_type: nil, metricnamespace: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

**Lists the metric values for a resource**.

following format 'startDateTime_ISO/endDateTime_ISO'. retrieve. to retrieve. Valid only if $filter is specified. Defaults to 10. direction of the sort. Only one order can be specified. Examples: sum asc. data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata' for. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource.

  • timespan (String) (defaults to: nil)

    The timespan of the query. It is a string with the

  • interval (Duration) (defaults to: nil)

    The interval (i.e. timegrain) of the query.

  • metricnames (String) (defaults to: nil)

    The names of the metrics (comma separated) to

  • aggregation (String) (defaults to: nil)

    The list of aggregation types (comma separated)

  • top (Integer) (defaults to: nil)

    The maximum number of records to retrieve.

  • orderby (String) (defaults to: nil)

    The aggregation to use for sorting results and the

  • filter (String) (defaults to: nil)

    The **$filter** is used to reduce the set of metric

  • result_type (ResultType) (defaults to: nil)

    Reduces the set of data collected. The syntax

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • custom_headers (Hash{String => String}) (defaults to: nil)

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



105
106
107
# File 'lib/2018-01-01/generated/azure_mgmt_monitor/metrics.rb', line 105

def list_with_http_info(resource_uri, timespan:nil, interval:nil, metricnames:nil, aggregation:nil, top:nil, orderby:nil, filter:nil, result_type:nil, metricnamespace:nil, custom_headers:nil)
  list_async(resource_uri, timespan:timespan, interval:interval, metricnames:metricnames, aggregation:aggregation, top:top, orderby:orderby, filter:filter, result_type:result_type, metricnamespace:metricnamespace, custom_headers:custom_headers).value!
end