Class: Azure::PolicyInsights::Mgmt::V2018_04_04::PolicyEvents

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2018-04-04/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/2018-04-04/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/2018-04-04/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.



1033
1034
1035
1036
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 1033

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.



1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 1064

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.



1049
1050
1051
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 1049

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/2018-04-04/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/2018-04-04/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::V2018_04_04::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/2018-04-04/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_policy_definition(subscription_id, policy_definition_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the subscription level policy definition.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_definition_name (String)

    Policy definition 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.



651
652
653
654
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 651

def list_query_results_for_policy_definition(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_policy_definition_async(subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

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

Queries policy events for the subscription level policy definition.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_definition_name (String)

    Policy definition 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.



682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 682

def list_query_results_for_policy_definition_async(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
  authorization_namespace = 'Microsoft.Authorization'
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_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}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/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,'authorizationNamespace' => authorization_namespace,'policyDefinitionName' => policy_definition_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::V2018_04_04::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_policy_definition_with_http_info(subscription_id, policy_definition_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the subscription level policy definition.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_definition_name (String)

    Policy definition 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.



667
668
669
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 667

def list_query_results_for_policy_definition_with_http_info(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
  list_query_results_for_policy_definition_async(subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
end

#list_query_results_for_policy_set_definition(subscription_id, policy_set_definition_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the subscription level policy set definition.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_set_definition_name (String)

    Policy set definition 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.



525
526
527
528
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 525

def list_query_results_for_policy_set_definition(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_policy_set_definition_async(subscription_id, policy_set_definition_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

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

Queries policy events for the subscription level policy set definition.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_set_definition_name (String)

    Policy set definition 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.



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
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 556

def list_query_results_for_policy_set_definition_async(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
  authorization_namespace = 'Microsoft.Authorization'
  fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_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}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/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,'authorizationNamespace' => authorization_namespace,'policySetDefinitionName' => policy_set_definition_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::V2018_04_04::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_policy_set_definition_with_http_info(subscription_id, policy_set_definition_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the subscription level policy set definition.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_set_definition_name (String)

    Policy set definition 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.



541
542
543
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 541

def list_query_results_for_policy_set_definition_with_http_info(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
  list_query_results_for_policy_set_definition_async(subscription_id, policy_set_definition_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/2018-04-04/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/2018-04-04/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::V2018_04_04::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/2018-04-04/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/2018-04-04/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::V2018_04_04::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_level_policy_assignment(subscription_id, resource_group_name, policy_assignment_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the resource group level policy assignment.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • policy_assignment_name (String)

    Policy assignment 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.



904
905
906
907
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 904

def list_query_results_for_resource_group_level_policy_assignment(subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

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

Queries policy events for the resource group level policy assignment.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • policy_assignment_name (String)

    Policy assignment 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.



937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 937

def list_query_results_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_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?
  authorization_namespace = 'Microsoft.Authorization'
  fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_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/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/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,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_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::V2018_04_04::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_level_policy_assignment_with_http_info(subscription_id, resource_group_name, policy_assignment_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the resource group level policy assignment.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • resource_group_name (String)

    Resource group name.

  • policy_assignment_name (String)

    Policy assignment 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.



921
922
923
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 921

def list_query_results_for_resource_group_level_policy_assignment_with_http_info(subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
  list_query_results_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
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/2018-04-04/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/2018-04-04/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/2018-04-04/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/2018-04-04/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::V2018_04_04::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_level_policy_assignment(subscription_id, policy_assignment_name, query_options: nil, custom_headers: nil) ⇒ PolicyEventsQueryResults

Queries policy events for the subscription level policy assignment.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_assignment_name (String)

    Policy assignment 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.



777
778
779
780
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 777

def list_query_results_for_subscription_level_policy_assignment(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
  response = list_query_results_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

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

Queries policy events for the subscription level policy assignment.

to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_assignment_name (String)

    Policy assignment 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.



808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 808

def list_query_results_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
  policy_events_resource = 'default'
  fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
  authorization_namespace = 'Microsoft.Authorization'
  fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_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}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/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,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_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::V2018_04_04::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_level_policy_assignment_with_http_info(subscription_id, policy_assignment_name, query_options: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Queries policy events for the subscription level policy assignment.

will be added to the HTTP request.

Parameters:

  • subscription_id (String)

    Microsoft Azure subscription ID.

  • policy_assignment_name (String)

    Policy assignment 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.



793
794
795
# File 'lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb', line 793

def list_query_results_for_subscription_level_policy_assignment_with_http_info(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
  list_query_results_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
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/2018-04-04/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