Class: Azure::AlertsManagement::Mgmt::V2019_03_01::SmartGroups

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb

Overview

AlertsManagement Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ SmartGroups

Creates and initializes a new instance of the SmartGroups class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientAlertsManagementClient (readonly)

Returns reference to the AlertsManagementClient.

Returns:



22
23
24
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 22

def client
  @client
end

Instance Method Details

#change_state(smart_group_id, new_state, custom_headers: nil) ⇒ SmartGroup

Change the state of a Smart Group.

include: ‘New’, ‘Acknowledged’, ‘Closed’ will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

  • new_state (AlertState)

    New state of the alert. Possible values

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

    A hash of custom headers that

Returns:

  • (SmartGroup)

    operation results.



319
320
321
322
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 319

def change_state(smart_group_id, new_state, custom_headers:nil)
  response = change_state_async(smart_group_id, new_state, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#change_state_async(smart_group_id, new_state, custom_headers: nil) ⇒ Concurrent::Promise

Change the state of a Smart Group.

include: ‘New’, ‘Acknowledged’, ‘Closed’ to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

  • new_state (AlertState)

    New state of the alert. Possible values

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 350

def change_state_async(smart_group_id, new_state, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'smart_group_id is nil' if smart_group_id.nil?
  @client.api_version = '2018-05-05'
  fail ArgumentError, 'new_state is nil' if new_state.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 = 'subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'smartGroupId' => smart_group_id},
      query_params: {'api-version' => @client.api_version,'newState' => new_state},
      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::AlertsManagement::Mgmt::V2019_03_01::Models::SmartGroup.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

#change_state_with_http_info(smart_group_id, new_state, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Change the state of a Smart Group.

include: ‘New’, ‘Acknowledged’, ‘Closed’ will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

  • new_state (AlertState)

    New state of the alert. Possible values

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



335
336
337
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 335

def change_state_with_http_info(smart_group_id, new_state, custom_headers:nil)
  change_state_async(smart_group_id, new_state, custom_headers:custom_headers).value!
end

#get_all(target_resource: nil, target_resource_group: nil, target_resource_type: nil, monitor_service: nil, monitor_condition: nil, severity: nil, smart_group_state: nil, time_range: nil, page_count: nil, sort_by: nil, sort_order: nil, custom_headers: nil) ⇒ SmartGroupsList

Get all Smart Groups within a specified subscription

List all the Smart Groups within a specified subscription.

ID) Default value is select all. Default value is select all. value is select all. generates the alert instance. Default value is select all. Possible values include: ‘Application Insights’, ‘ActivityLog Administrative’, ‘ActivityLog Security’, ‘ActivityLog Recommendation’, ‘ActivityLog Policy’, ‘ActivityLog Autoscale’, ‘Log Analytics’, ‘Nagios’, ‘Platform’, ‘SCOM’, ‘ServiceHealth’, ‘SmartDetector’, ‘VM Insights’, ‘Zabbix’, ‘Resource Health’ is either ‘Fired’ or ‘Resolved’. Default value is to select all. Possible values include: ‘Fired’, ‘Resolved’ Possible values include: ‘Sev0’, ‘Sev1’, ‘Sev2’, ‘Sev3’, ‘Sev4’ Default value is to select all. Possible values include: ‘New’, ‘Acknowledged’, ‘Closed’ Default value is 1 day. Possible values include: ‘1h’, ‘1d’, ‘7d’, ‘30d’ response. Permissible value is between 1 to 250. When the “includeContent” filter is selected, maximum value allowed is 25. Default value is 25. field. Default value is sort by ‘lastModifiedDateTime’. Possible values include: ‘alertsCount’, ‘state’, ‘severity’, ‘startDateTime’, ‘lastModifiedDateTime’ descending. Default value is ‘desc’ for time fields and ‘asc’ for others. Possible values include: ‘asc’, ‘desc’ will be added to the HTTP request.

Parameters:

  • target_resource (String) (defaults to: nil)

    Filter by target resource( which is full ARM

  • target_resource_group (String) (defaults to: nil)

    Filter by target resource group name.

  • target_resource_type (String) (defaults to: nil)

    Filter by target resource type. Default

  • monitor_service (MonitorService) (defaults to: nil)

    Filter by monitor service which

  • monitor_condition (MonitorCondition) (defaults to: nil)

    Filter by monitor condition which

  • severity (Severity) (defaults to: nil)

    Filter by severity. Default value is select all.

  • smart_group_state (AlertState) (defaults to: nil)

    Filter by state of the smart group.

  • time_range (TimeRange) (defaults to: nil)

    Filter by time range by below listed values.

  • page_count (Integer) (defaults to: nil)

    Determines number of alerts returned per page in

  • sort_by (SmartGroupsSortByFields) (defaults to: nil)

    Sort the query results by input

  • sort_order (Enum) (defaults to: nil)

    Sort the query results order in either ascending or

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

    A hash of custom headers that

Returns:

  • (SmartGroupsList)

    operation results.



66
67
68
69
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 66

def get_all(target_resource:nil, target_resource_group:nil, target_resource_type:nil, monitor_service:nil, monitor_condition:nil, severity:nil, smart_group_state:nil, time_range:nil, page_count:nil, sort_by:nil, sort_order:nil, custom_headers:nil)
  response = get_all_async(target_resource:target_resource, target_resource_group:target_resource_group, target_resource_type:target_resource_type, monitor_service:monitor_service, monitor_condition:monitor_condition, severity:severity, smart_group_state:smart_group_state, time_range:time_range, page_count:page_count, sort_by:sort_by, sort_order:sort_order, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#get_all_async(target_resource: nil, target_resource_group: nil, target_resource_type: nil, monitor_service: nil, monitor_condition: nil, severity: nil, smart_group_state: nil, time_range: nil, page_count: nil, sort_by: nil, sort_order: nil, custom_headers: nil) ⇒ Concurrent::Promise

Get all Smart Groups within a specified subscription

List all the Smart Groups within a specified subscription.

ID) Default value is select all. Default value is select all. value is select all. generates the alert instance. Default value is select all. Possible values include: ‘Application Insights’, ‘ActivityLog Administrative’, ‘ActivityLog Security’, ‘ActivityLog Recommendation’, ‘ActivityLog Policy’, ‘ActivityLog Autoscale’, ‘Log Analytics’, ‘Nagios’, ‘Platform’, ‘SCOM’, ‘ServiceHealth’, ‘SmartDetector’, ‘VM Insights’, ‘Zabbix’, ‘Resource Health’ is either ‘Fired’ or ‘Resolved’. Default value is to select all. Possible values include: ‘Fired’, ‘Resolved’ Possible values include: ‘Sev0’, ‘Sev1’, ‘Sev2’, ‘Sev3’, ‘Sev4’ Default value is to select all. Possible values include: ‘New’, ‘Acknowledged’, ‘Closed’ Default value is 1 day. Possible values include: ‘1h’, ‘1d’, ‘7d’, ‘30d’ response. Permissible value is between 1 to 250. When the “includeContent” filter is selected, maximum value allowed is 25. Default value is 25. field. Default value is sort by ‘lastModifiedDateTime’. Possible values include: ‘alertsCount’, ‘state’, ‘severity’, ‘startDateTime’, ‘lastModifiedDateTime’ descending. Default value is ‘desc’ for time fields and ‘asc’ for others. Possible values include: ‘asc’, ‘desc’ to the HTTP request.

Parameters:

  • target_resource (String) (defaults to: nil)

    Filter by target resource( which is full ARM

  • target_resource_group (String) (defaults to: nil)

    Filter by target resource group name.

  • target_resource_type (String) (defaults to: nil)

    Filter by target resource type. Default

  • monitor_service (MonitorService) (defaults to: nil)

    Filter by monitor service which

  • monitor_condition (MonitorCondition) (defaults to: nil)

    Filter by monitor condition which

  • severity (Severity) (defaults to: nil)

    Filter by severity. Default value is select all.

  • smart_group_state (AlertState) (defaults to: nil)

    Filter by state of the smart group.

  • time_range (TimeRange) (defaults to: nil)

    Filter by time range by below listed values.

  • page_count (Integer) (defaults to: nil)

    Determines number of alerts returned per page in

  • sort_by (SmartGroupsSortByFields) (defaults to: nil)

    Sort the query results by input

  • sort_order (Enum) (defaults to: nil)

    Sort the query results order in either ascending or

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 159

def get_all_async(target_resource:nil, target_resource_group:nil, target_resource_type:nil, monitor_service:nil, monitor_condition:nil, severity:nil, smart_group_state:nil, time_range:nil, page_count:nil, sort_by:nil, sort_order:nil, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  @client.api_version = '2018-05-05'


  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 = 'subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups'

  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: {'targetResource' => target_resource,'targetResourceGroup' => target_resource_group,'targetResourceType' => target_resource_type,'monitorService' => monitor_service,'monitorCondition' => monitor_condition,'severity' => severity,'smartGroupState' => smart_group_state,'timeRange' => time_range,'pageCount' => page_count,'sortBy' => sort_by,'sortOrder' => sort_order,'api-version' => @client.api_version},
      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::AlertsManagement::Mgmt::V2019_03_01::Models::SmartGroupsList.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_all_with_http_info(target_resource: nil, target_resource_group: nil, target_resource_type: nil, monitor_service: nil, monitor_condition: nil, severity: nil, smart_group_state: nil, time_range: nil, page_count: nil, sort_by: nil, sort_order: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Get all Smart Groups within a specified subscription

List all the Smart Groups within a specified subscription.

ID) Default value is select all. Default value is select all. value is select all. generates the alert instance. Default value is select all. Possible values include: ‘Application Insights’, ‘ActivityLog Administrative’, ‘ActivityLog Security’, ‘ActivityLog Recommendation’, ‘ActivityLog Policy’, ‘ActivityLog Autoscale’, ‘Log Analytics’, ‘Nagios’, ‘Platform’, ‘SCOM’, ‘ServiceHealth’, ‘SmartDetector’, ‘VM Insights’, ‘Zabbix’, ‘Resource Health’ is either ‘Fired’ or ‘Resolved’. Default value is to select all. Possible values include: ‘Fired’, ‘Resolved’ Possible values include: ‘Sev0’, ‘Sev1’, ‘Sev2’, ‘Sev3’, ‘Sev4’ Default value is to select all. Possible values include: ‘New’, ‘Acknowledged’, ‘Closed’ Default value is 1 day. Possible values include: ‘1h’, ‘1d’, ‘7d’, ‘30d’ response. Permissible value is between 1 to 250. When the “includeContent” filter is selected, maximum value allowed is 25. Default value is 25. field. Default value is sort by ‘lastModifiedDateTime’. Possible values include: ‘alertsCount’, ‘state’, ‘severity’, ‘startDateTime’, ‘lastModifiedDateTime’ descending. Default value is ‘desc’ for time fields and ‘asc’ for others. Possible values include: ‘asc’, ‘desc’ will be added to the HTTP request.

Parameters:

  • target_resource (String) (defaults to: nil)

    Filter by target resource( which is full ARM

  • target_resource_group (String) (defaults to: nil)

    Filter by target resource group name.

  • target_resource_type (String) (defaults to: nil)

    Filter by target resource type. Default

  • monitor_service (MonitorService) (defaults to: nil)

    Filter by monitor service which

  • monitor_condition (MonitorCondition) (defaults to: nil)

    Filter by monitor condition which

  • severity (Severity) (defaults to: nil)

    Filter by severity. Default value is select all.

  • smart_group_state (AlertState) (defaults to: nil)

    Filter by state of the smart group.

  • time_range (TimeRange) (defaults to: nil)

    Filter by time range by below listed values.

  • page_count (Integer) (defaults to: nil)

    Determines number of alerts returned per page in

  • sort_by (SmartGroupsSortByFields) (defaults to: nil)

    Sort the query results by input

  • sort_order (Enum) (defaults to: nil)

    Sort the query results order in either ascending or

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



113
114
115
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 113

def get_all_with_http_info(target_resource:nil, target_resource_group:nil, target_resource_type:nil, monitor_service:nil, monitor_condition:nil, severity:nil, smart_group_state:nil, time_range:nil, page_count:nil, sort_by:nil, sort_order:nil, custom_headers:nil)
  get_all_async(target_resource:target_resource, target_resource_group:target_resource_group, target_resource_type:target_resource_type, monitor_service:monitor_service, monitor_condition:monitor_condition, severity:severity, smart_group_state:smart_group_state, time_range:time_range, page_count:page_count, sort_by:sort_by, sort_order:sort_order, custom_headers:custom_headers).value!
end

#get_by_id(smart_group_id, custom_headers: nil) ⇒ SmartGroup

Get information related to a specific Smart Group.

Get information related to a specific Smart Group.

will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

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

    A hash of custom headers that

Returns:

  • (SmartGroup)

    operation results.



223
224
225
226
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 223

def get_by_id(smart_group_id, custom_headers:nil)
  response = get_by_id_async(smart_group_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#get_by_id_async(smart_group_id, custom_headers: nil) ⇒ Concurrent::Promise

Get information related to a specific Smart Group.

Get information related to a specific Smart Group.

to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 254

def get_by_id_async(smart_group_id, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'smart_group_id is nil' if smart_group_id.nil?
  @client.api_version = '2018-05-05'


  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 = 'subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'smartGroupId' => smart_group_id},
      query_params: {'api-version' => @client.api_version},
      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::AlertsManagement::Mgmt::V2019_03_01::Models::SmartGroup.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_by_id_with_http_info(smart_group_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Get information related to a specific Smart Group.

Get information related to a specific Smart Group.

will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



239
240
241
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 239

def get_by_id_with_http_info(smart_group_id, custom_headers:nil)
  get_by_id_async(smart_group_id, custom_headers:custom_headers).value!
end

#get_history(smart_group_id, custom_headers: nil) ⇒ SmartGroupModification

Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) .

will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

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

    A hash of custom headers that

Returns:

  • (SmartGroupModification)

    operation results.



415
416
417
418
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 415

def get_history(smart_group_id, custom_headers:nil)
  response = get_history_async(smart_group_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#get_history_async(smart_group_id, custom_headers: nil) ⇒ Concurrent::Promise

Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) .

to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 444

def get_history_async(smart_group_id, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
  fail ArgumentError, 'smart_group_id is nil' if smart_group_id.nil?
  @client.api_version = '2018-05-05'


  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 = 'subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'smartGroupId' => smart_group_id},
      query_params: {'api-version' => @client.api_version},
      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::AlertsManagement::Mgmt::V2019_03_01::Models::SmartGroupModification.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_history_with_http_info(smart_group_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) .

will be added to the HTTP request.

Parameters:

  • smart_group_id (String)

    Smart group unique id.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



430
431
432
# File 'lib/2019-03-01/generated/azure_mgmt_alerts_management/smart_groups.rb', line 430

def get_history_with_http_info(smart_group_id, custom_headers:nil)
  get_history_async(smart_group_id, custom_headers:custom_headers).value!
end