Class: Azure::PolicyInsights::Mgmt::V2017_10_17_preview::PolicyEvents

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb

Overview

PolicyEvents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PolicyEvents

Creates and initializes a new instance of the PolicyEvents class.

Parameters:

  • client

    service class for accessing basic functionality.



17
18
19
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 17

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientPolicyInsightsClient (readonly)

Returns reference to the PolicyInsightsClient.

Returns:



22
23
24
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 22

def client
  @client
end

Instance Method Details

#get_metadata(scope, custom_headers: nil) ⇒ String

Gets OData metadata XML document.

resource group, or resource ID. Scope used has no effect on metadata returned. will be added to the HTTP request.

Parameters:

  • scope (String)

    A valid scope, i.e. management group, subscription,

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

    A hash of custom headers that

Returns:

  • (String)

    operation results.



525
526
527
528
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 525

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

#get_metadata_async(scope, custom_headers: nil) ⇒ Concurrent::Promise

Gets OData metadata XML document.

resource group, or resource ID. Scope used has no effect on metadata returned. to the HTTP request.

Parameters:

  • scope (String)

    A valid scope, i.e. management group, subscription,

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 556

def (scope, custom_headers:nil)
  fail ArgumentError, 'scope is nil' if scope.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 = '{scope}/providers/Microsoft.PolicyInsights/policyEvents/$metadata'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'scope' => scope},
      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 = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'String'
          }
        }
        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_metadata_with_http_info(scope, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets OData metadata XML document.

resource group, or resource ID. Scope used has no effect on metadata returned. will be added to the HTTP request.

Parameters:

  • scope (String)

    A valid scope, i.e. management group, subscription,

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



541
542
543
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 541

def (scope, custom_headers:nil)
  (scope, custom_headers:custom_headers).value!
end

#list_query_results_for_management_group(management_group_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the resources under the management group.

will be added to the HTTP request.

Parameters:

  • management_group_name (String)

    Management group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (PolicyEventsQueryResults)

    operation results.



34
35
36
37
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 34

def list_query_results_for_management_group(management_group_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_management_group_async(management_group_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_query_results_for_management_group_async(management_group_name, query_options: nil, custom_headers: nil) ⇒ Concurrent::Promise

Queries policy events for the resources under the management group.

to the HTTP request.

Parameters:

  • management_group_name (String)

    Management group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 63

def list_query_results_for_management_group_async(management_group_name, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  management_groups_namespace = 'Microsoft.Management'
  fail ArgumentError, 'management_group_name is nil' if management_group_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?

  top = nil
  order_by = nil
  select = nil
  from = nil
  to = nil
  filter = nil
  apply = nil
  unless query_options.nil?
    top = query_options.Top
  end
  unless query_options.nil?
    order_by = query_options.OrderBy
  end
  unless query_options.nil?
    select = query_options.Select
  end
  unless query_options.nil?
    from = query_options.From
  end
  unless query_options.nil?
    to = query_options.To
  end
  unless query_options.nil?
    filter = query_options.Filter
  end
  unless query_options.nil?
    apply = query_options.Apply
  end

  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 = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyEventsResource' => policy_events_resource,'managementGroupsNamespace' => management_groups_namespace,'managementGroupName' => management_group_name},
      query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
      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::PolicyInsights::Mgmt::V2017_10_17_preview::Models::PolicyEventsQueryResults.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_query_results_for_management_group_with_http_info(management_group_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the resources under the management group.

will be added to the HTTP request.

Parameters:

  • management_group_name (String)

    Management group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



49
50
51
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 49

def list_query_results_for_management_group_with_http_info(management_group_name, query_options:nil, custom_headers:nil)
  list_query_results_for_management_group_async(management_group_name, query_options:query_options, custom_headers:custom_headers).value!
end

#list_query_results_for_resource(resource_id, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the resource.

will be added to the HTTP request.

Parameters:

  • resource_id (String)

    Resource ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (PolicyEventsQueryResults)

    operation results.



402
403
404
405
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 402

def list_query_results_for_resource(resource_id, query_options:nil, custom_headers:nil)
  response = list_query_results_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_query_results_for_resource_async(resource_id, query_options: nil, custom_headers: nil) ⇒ Concurrent::Promise

Queries policy events for the resource.

to the HTTP request.

Parameters:

  • resource_id (String)

    Resource ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



431
432
433
434
435
436
437
438
439
440
441
442
443
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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 431

def list_query_results_for_resource_async(resource_id, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'resource_id is nil' if resource_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?

  top = nil
  order_by = nil
  select = nil
  from = nil
  to = nil
  filter = nil
  apply = nil
  unless query_options.nil?
    top = query_options.Top
  end
  unless query_options.nil?
    order_by = query_options.OrderBy
  end
  unless query_options.nil?
    select = query_options.Select
  end
  unless query_options.nil?
    from = query_options.From
  end
  unless query_options.nil?
    to = query_options.To
  end
  unless query_options.nil?
    filter = query_options.Filter
  end
  unless query_options.nil?
    apply = query_options.Apply
  end

  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 = '{resourceId}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyEventsResource' => policy_events_resource},
      skip_encoding_path_params: {'resourceId' => resource_id},
      query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
      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::PolicyInsights::Mgmt::V2017_10_17_preview::Models::PolicyEventsQueryResults.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_query_results_for_resource_group(subscription_id, resource_group_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the resources under the resource group.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (PolicyEventsQueryResults)

    operation results.



278
279
280
281
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 278

def list_query_results_for_resource_group(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_resource_group_async(subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_query_results_for_resource_group_async(subscription_id, resource_group_name, query_options: nil, custom_headers: nil) ⇒ Concurrent::Promise

Queries policy events for the resources under the resource group.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
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
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 309

def list_query_results_for_resource_group_async(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?

  top = nil
  order_by = nil
  select = nil
  from = nil
  to = nil
  filter = nil
  apply = nil
  unless query_options.nil?
    top = query_options.Top
  end
  unless query_options.nil?
    order_by = query_options.OrderBy
  end
  unless query_options.nil?
    select = query_options.Select
  end
  unless query_options.nil?
    from = query_options.From
  end
  unless query_options.nil?
    to = query_options.To
  end
  unless query_options.nil?
    filter = query_options.Filter
  end
  unless query_options.nil?
    apply = query_options.Apply
  end

  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}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyEventsResource' => policy_events_resource,'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name},
      query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
      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::PolicyInsights::Mgmt::V2017_10_17_preview::Models::PolicyEventsQueryResults.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_query_results_for_resource_group_with_http_info(subscription_id, resource_group_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the resources under the resource group.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



294
295
296
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 294

def list_query_results_for_resource_group_with_http_info(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
  list_query_results_for_resource_group_async(subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
end

#list_query_results_for_resource_with_http_info(resource_id, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the resource.

will be added to the HTTP request.

Parameters:

  • resource_id (String)

    Resource ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



417
418
419
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 417

def list_query_results_for_resource_with_http_info(resource_id, query_options:nil, custom_headers:nil)
  list_query_results_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
end

#list_query_results_for_subscription(subscription_id, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the resources under the subscription.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (PolicyEventsQueryResults)

    operation results.



156
157
158
159
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 156

def list_query_results_for_subscription(subscription_id, query_options:nil, custom_headers:nil)
  response = list_query_results_for_subscription_async(subscription_id, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#list_query_results_for_subscription_async(subscription_id, query_options: nil, custom_headers: nil) ⇒ Concurrent::Promise

Queries policy events for the resources under the subscription.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
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
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 185

def list_query_results_for_subscription_async(subscription_id, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?

  top = nil
  order_by = nil
  select = nil
  from = nil
  to = nil
  filter = nil
  apply = nil
  unless query_options.nil?
    top = query_options.Top
  end
  unless query_options.nil?
    order_by = query_options.OrderBy
  end
  unless query_options.nil?
    select = query_options.Select
  end
  unless query_options.nil?
    from = query_options.From
  end
  unless query_options.nil?
    to = query_options.To
  end
  unless query_options.nil?
    filter = query_options.Filter
  end
  unless query_options.nil?
    apply = query_options.Apply
  end

  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.PolicyInsights/policyEvents/{policyEventsResource}/queryResults'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyEventsResource' => policy_events_resource,'subscriptionId' => subscription_id},
      query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
      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::PolicyInsights::Mgmt::V2017_10_17_preview::Models::PolicyEventsQueryResults.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_query_results_for_subscription_with_http_info(subscription_id, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the resources under the subscription.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • query_options (QueryOptions) (defaults to: nil)

    Additional parameters for the operation

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



171
172
173
# File 'lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb', line 171

def list_query_results_for_subscription_with_http_info(subscription_id, query_options:nil, custom_headers:nil)
  list_query_results_for_subscription_async(subscription_id, query_options:query_options, custom_headers:custom_headers).value!
end