Class: Azure::Monitor::Mgmt::V2018_09_01::MetricBaseline

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

Overview

MetricBaseline

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ MetricBaseline

Creates and initializes a new instance of the MetricBaseline class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.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-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 22

def client
  @client
end

Instance Method Details

#calculate_baseline(resource_uri, time_series_information, custom_headers: nil) ⇒ CalculateBaselineResponse

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

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 to be specified to calculate a baseline on a time series. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • time_series_information (TimeSeriesInformation)

    Information that need

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

    A hash of custom headers that

Returns:

  • (CalculateBaselineResponse)

    operation results.



193
194
195
196
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 193

def calculate_baseline(resource_uri, time_series_information, custom_headers:nil)
  response = calculate_baseline_async(resource_uri, time_series_information, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#calculate_baseline_async(resource_uri, time_series_information, custom_headers: nil) ⇒ Concurrent::Promise

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

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 to be specified to calculate a baseline on a time series. to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • time_series_information (TimeSeriesInformation)

    Information that need

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 232

def calculate_baseline_async(resource_uri, time_series_information, 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?
  fail ArgumentError, 'time_series_information is nil' if time_series_information.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::Monitor::Mgmt::V2018_09_01::Models::TimeSeriesInformation.mapper()
  request_content = @client.serialize(request_mapper,  time_series_information)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '{resourceUri}/providers/microsoft.insights/calculatebaseline'

  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: {'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::Monitor::Mgmt::V2018_09_01::Models::CalculateBaselineResponse.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

#calculate_baseline_with_http_info(resource_uri, time_series_information, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

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

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 to be specified to calculate a baseline on a time series. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • time_series_information (TimeSeriesInformation)

    Information that need

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



213
214
215
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 213

def calculate_baseline_with_http_info(resource_uri, time_series_information, custom_headers:nil)
  calculate_baseline_async(resource_uri, time_series_information, custom_headers:custom_headers).value!
end

#get(resource_uri, metric_name, timespan: nil, interval: nil, aggregation: nil, sensitivities: nil, result_type: nil, metricnamespace: nil, filter: nil, custom_headers: nil) ⇒ BaselineResponse

**Gets the baseline values for a specific metric**.

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 for. following format 'startDateTime_ISO/endDateTime_ISO'. the baseline for. retrieve. baseline. On data request all information is retrieved. Possible values include: 'Data', 'Metadata' for. dimensions with their concrete values which produce a specific metric�s time series, in which a baseline is requested for. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • metric_name (String)

    The name of the metric to retrieve the baseline

  • 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.

  • aggregation (String) (defaults to: nil)

    The aggregation type of the metric to retrieve

  • sensitivities (String) (defaults to: nil)

    The list of sensitivities (comma separated) to

  • result_type (ResultType) (defaults to: nil)

    Allows retrieving only metadata of the

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • filter (String) (defaults to: nil)

    The **$filter** is used to describe a set of

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

    A hash of custom headers that

Returns:

  • (BaselineResponse)

    operation results.



54
55
56
57
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 54

def get(resource_uri, metric_name, timespan:nil, interval:nil, aggregation:nil, sensitivities:nil, result_type:nil, metricnamespace:nil, filter:nil, custom_headers:nil)
  response = get_async(resource_uri, metric_name, timespan:timespan, interval:interval, aggregation:aggregation, sensitivities:sensitivities, result_type:result_type, metricnamespace:metricnamespace, filter:filter, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#get_async(resource_uri, metric_name, timespan: nil, interval: nil, aggregation: nil, sensitivities: nil, result_type: nil, metricnamespace: nil, filter: nil, custom_headers: nil) ⇒ Concurrent::Promise

**Gets the baseline values for a specific metric**.

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 for. following format 'startDateTime_ISO/endDateTime_ISO'. the baseline for. retrieve. baseline. On data request all information is retrieved. Possible values include: 'Data', 'Metadata' for. dimensions with their concrete values which produce a specific metric�s time series, in which a baseline is requested for. to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • metric_name (String)

    The name of the metric to retrieve the baseline

  • 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.

  • aggregation (String) (defaults to: nil)

    The aggregation type of the metric to retrieve

  • sensitivities (String) (defaults to: nil)

    The list of sensitivities (comma separated) to

  • result_type (ResultType) (defaults to: nil)

    Allows retrieving only metadata of the

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • filter (String) (defaults to: nil)

    The **$filter** is used to describe a set of

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 123

def get_async(resource_uri, metric_name, timespan:nil, interval:nil, aggregation:nil, sensitivities:nil, result_type:nil, metricnamespace:nil, filter:nil, custom_headers:nil)
  fail ArgumentError, 'resource_uri is nil' if resource_uri.nil?
  fail ArgumentError, 'metric_name is nil' if metric_name.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/baseline/{metricName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'metricName' => metric_name},
      skip_encoding_path_params: {'resourceUri' => resource_uri},
      query_params: {'timespan' => timespan,'interval' => interval,'aggregation' => aggregation,'sensitivities' => sensitivities,'resultType' => result_type,'api-version' => @client.api_version,'metricnamespace' => metricnamespace,'$filter' => filter},
      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_09_01::Models::BaselineResponse.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

#get_with_http_info(resource_uri, metric_name, timespan: nil, interval: nil, aggregation: nil, sensitivities: nil, result_type: nil, metricnamespace: nil, filter: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

**Gets the baseline values for a specific metric**.

following structure: subscriptions/subscriptionName/resourceGroups/resourceGroupName/providers/providerName/resourceName. For example: subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/vms/providers/Microsoft.Compute/virtualMachines/vm1 for. following format 'startDateTime_ISO/endDateTime_ISO'. the baseline for. retrieve. baseline. On data request all information is retrieved. Possible values include: 'Data', 'Metadata' for. dimensions with their concrete values which produce a specific metric�s time series, in which a baseline is requested for. will be added to the HTTP request.

Parameters:

  • resource_uri (String)

    The identifier of the resource. It has the

  • metric_name (String)

    The name of the metric to retrieve the baseline

  • 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.

  • aggregation (String) (defaults to: nil)

    The aggregation type of the metric to retrieve

  • sensitivities (String) (defaults to: nil)

    The list of sensitivities (comma separated) to

  • result_type (ResultType) (defaults to: nil)

    Allows retrieving only metadata of the

  • metricnamespace (String) (defaults to: nil)

    Metric namespace to query metric definitions

  • filter (String) (defaults to: nil)

    The **$filter** is used to describe a set of

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



89
90
91
# File 'lib/2018-09-01/generated/azure_mgmt_monitor/metric_baseline.rb', line 89

def get_with_http_info(resource_uri, metric_name, timespan:nil, interval:nil, aggregation:nil, sensitivities:nil, result_type:nil, metricnamespace:nil, filter:nil, custom_headers:nil)
  get_async(resource_uri, metric_name, timespan:timespan, interval:interval, aggregation:aggregation, sensitivities:sensitivities, result_type:result_type, metricnamespace:metricnamespace, filter:filter, custom_headers:custom_headers).value!
end