azure_mgmt_policy_insights 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights.rb +46 -0
  4. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/column.rb +68 -0
  5. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/operation.rb +59 -0
  6. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/operation_display.rb +79 -0
  7. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/operations_list_results.rb +55 -0
  8. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results.rb +55 -0
  9. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results_table.rb +88 -0
  10. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results_table_columns.rb +387 -0
  11. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results_table_metadata.rb +47 -0
  12. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +55 -0
  13. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results_table.rb +88 -0
  14. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results_table_columns.rb +362 -0
  15. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results_table_metadata.rb +47 -0
  16. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/policy_states_resource.rb +16 -0
  17. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/query_failure.rb +47 -0
  18. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/query_failure_error.rb +58 -0
  19. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/models/query_options.rb +112 -0
  20. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/module_definition.rb +9 -0
  21. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/operations.rb +107 -0
  22. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/policy_events.rb +507 -0
  23. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +135 -0
  24. data/lib/2017-08-09-preview/generated/azure_mgmt_policy_insights/policy_states.rb +555 -0
  25. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights.rb +41 -0
  26. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/operation.rb +59 -0
  27. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/operation_display.rb +79 -0
  28. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/operations_list_results.rb +70 -0
  29. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/policy_event.rb +384 -0
  30. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results.rb +82 -0
  31. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/policy_state.rb +361 -0
  32. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +82 -0
  33. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/policy_states_resource.rb +16 -0
  34. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/query_failure.rb +47 -0
  35. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/query_failure_error.rb +58 -0
  36. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/models/query_options.rb +112 -0
  37. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/module_definition.rb +9 -0
  38. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/operations.rb +107 -0
  39. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_events.rb +607 -0
  40. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +135 -0
  41. data/lib/2017-10-17-preview/generated/azure_mgmt_policy_insights/policy_states.rb +655 -0
  42. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights.rb +46 -0
  43. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/operation.rb +59 -0
  44. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/operation_display.rb +79 -0
  45. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/operations_list_results.rb +70 -0
  46. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_assignment_summary.rb +91 -0
  47. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_definition_summary.rb +70 -0
  48. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_event.rb +384 -0
  49. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_events_query_results.rb +82 -0
  50. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_state.rb +361 -0
  51. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +82 -0
  52. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/policy_states_resource.rb +16 -0
  53. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/query_failure.rb +47 -0
  54. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/query_failure_error.rb +58 -0
  55. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/query_options.rb +112 -0
  56. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/summarize_results.rb +83 -0
  57. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/summary.rb +92 -0
  58. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/models/summary_results.rb +76 -0
  59. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/module_definition.rb +9 -0
  60. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/operations.rb +107 -0
  61. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/policy_events.rb +1107 -0
  62. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/policy_insights_client.rb +135 -0
  63. data/lib/2017-12-12-preview/generated/azure_mgmt_policy_insights/policy_states.rb +2089 -0
  64. data/lib/2018-04-04/generated/azure_mgmt_policy_insights.rb +46 -0
  65. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/operation.rb +59 -0
  66. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/operation_display.rb +79 -0
  67. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/operations_list_results.rb +70 -0
  68. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_assignment_summary.rb +91 -0
  69. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_definition_summary.rb +81 -0
  70. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_event.rb +384 -0
  71. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_events_query_results.rb +82 -0
  72. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_state.rb +361 -0
  73. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_states_query_results.rb +82 -0
  74. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/policy_states_resource.rb +16 -0
  75. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/query_failure.rb +47 -0
  76. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/query_failure_error.rb +58 -0
  77. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/query_options.rb +112 -0
  78. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/summarize_results.rb +83 -0
  79. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/summary.rb +92 -0
  80. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/models/summary_results.rb +76 -0
  81. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/module_definition.rb +9 -0
  82. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/operations.rb +107 -0
  83. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_events.rb +1107 -0
  84. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_insights_client.rb +135 -0
  85. data/lib/2018-04-04/generated/azure_mgmt_policy_insights/policy_states.rb +2089 -0
  86. data/lib/azure_mgmt_policy_insights.rb +9 -0
  87. data/lib/module_definition.rb +7 -0
  88. data/lib/profiles/latest/modules/policyinsights_profile_module.rb +129 -0
  89. data/lib/profiles/latest/policyinsights_latest_profile_client.rb +40 -0
  90. data/lib/profiles/latest/policyinsights_module_definition.rb +8 -0
  91. data/lib/version.rb +7 -0
  92. metadata +210 -0
@@ -0,0 +1,135 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::PolicyInsights::Mgmt::V2017_12_12_preview
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class PolicyInsightsClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_accessor :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials
19
+
20
+ # @return [String] API version to use with the client requests.
21
+ attr_reader :api_version
22
+
23
+ # @return [String] Gets or sets the preferred language for the response.
24
+ attr_accessor :accept_language
25
+
26
+ # @return [Integer] Gets or sets the retry timeout in seconds for Long
27
+ # Running Operations. Default value is 30.
28
+ attr_accessor :long_running_operation_retry_timeout
29
+
30
+ # @return [Boolean] When set to true a unique x-ms-client-request-id value
31
+ # is generated and included in each request. Default is true.
32
+ attr_accessor :generate_client_request_id
33
+
34
+ # @return [PolicyEvents] policy_events
35
+ attr_reader :policy_events
36
+
37
+ # @return [PolicyStates] policy_states
38
+ attr_reader :policy_states
39
+
40
+ # @return [Operations] operations
41
+ attr_reader :operations
42
+
43
+ #
44
+ # Creates initializes a new instance of the PolicyInsightsClient class.
45
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
46
+ # @param base_url [String] the base URI of the service.
47
+ # @param options [Array] filters to be applied to the HTTP requests.
48
+ #
49
+ def initialize(credentials = nil, base_url = nil, options = nil)
50
+ super(credentials, options)
51
+ @base_url = base_url || 'https://management.azure.com'
52
+
53
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
54
+ @credentials = credentials
55
+
56
+ @policy_events = PolicyEvents.new(self)
57
+ @policy_states = PolicyStates.new(self)
58
+ @operations = Operations.new(self)
59
+ @api_version = '2017-12-12-preview'
60
+ @accept_language = 'en-US'
61
+ @long_running_operation_retry_timeout = 30
62
+ @generate_client_request_id = true
63
+ add_telemetry
64
+ end
65
+
66
+ #
67
+ # Makes a request and returns the body of the response.
68
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
69
+ # @param path [String] the path, relative to {base_url}.
70
+ # @param options [Hash{String=>String}] specifying any request options like :body.
71
+ # @return [Hash{String=>String}] containing the body of the response.
72
+ # Example:
73
+ #
74
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
75
+ # path = "/path"
76
+ # options = {
77
+ # body: request_content,
78
+ # query_params: {'api-version' => '2016-02-01'}
79
+ # }
80
+ # result = @client.make_request(:put, path, options)
81
+ #
82
+ def make_request(method, path, options = {})
83
+ result = make_request_with_http_info(method, path, options)
84
+ result.body unless result.nil?
85
+ end
86
+
87
+ #
88
+ # Makes a request and returns the operation response.
89
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
90
+ # @param path [String] the path, relative to {base_url}.
91
+ # @param options [Hash{String=>String}] specifying any request options like :body.
92
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
93
+ #
94
+ def make_request_with_http_info(method, path, options = {})
95
+ result = make_request_async(method, path, options).value!
96
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
97
+ result
98
+ end
99
+
100
+ #
101
+ # Makes a request asynchronously.
102
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
103
+ # @param path [String] the path, relative to {base_url}.
104
+ # @param options [Hash{String=>String}] specifying any request options like :body.
105
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
106
+ #
107
+ def make_request_async(method, path, options = {})
108
+ fail ArgumentError, 'method is nil' if method.nil?
109
+ fail ArgumentError, 'path is nil' if path.nil?
110
+
111
+ request_url = options[:base_url] || @base_url
112
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
113
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
114
+ end
115
+
116
+ request_headers = @request_headers
117
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
118
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
119
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
120
+
121
+ super(request_url, method, path, options)
122
+ end
123
+
124
+
125
+ private
126
+ #
127
+ # Adds telemetry information.
128
+ #
129
+ def add_telemetry
130
+ sdk_information = 'azure_mgmt_policy_insights'
131
+ sdk_information = "#{sdk_information}/0.16.0"
132
+ add_user_agent_information(sdk_information)
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,2089 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::PolicyInsights::Mgmt::V2017_12_12_preview
7
+ #
8
+ # PolicyStates
9
+ #
10
+ class PolicyStates
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the PolicyStates class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [PolicyInsightsClient] reference to the PolicyInsightsClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Queries policy states for the resources under the management group.
26
+ #
27
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
28
+ # under PolicyStates resource type. In a given time range, 'latest' represents
29
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
30
+ # Possible values include: 'default', 'latest'
31
+ # @param management_group_name [String] Management group name.
32
+ # @param query_options [QueryOptions] Additional parameters for the operation
33
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
34
+ # will be added to the HTTP request.
35
+ #
36
+ # @return [PolicyStatesQueryResults] operation results.
37
+ #
38
+ def list_query_results_for_management_group(policy_states_resource, management_group_name, query_options:nil, custom_headers:nil)
39
+ response = list_query_results_for_management_group_async(policy_states_resource, management_group_name, query_options:query_options, custom_headers:custom_headers).value!
40
+ response.body unless response.nil?
41
+ end
42
+
43
+ #
44
+ # Queries policy states for the resources under the management group.
45
+ #
46
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
47
+ # under PolicyStates resource type. In a given time range, 'latest' represents
48
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
49
+ # Possible values include: 'default', 'latest'
50
+ # @param management_group_name [String] Management group name.
51
+ # @param query_options [QueryOptions] Additional parameters for the operation
52
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
53
+ # will be added to the HTTP request.
54
+ #
55
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
56
+ #
57
+ def list_query_results_for_management_group_with_http_info(policy_states_resource, management_group_name, query_options:nil, custom_headers:nil)
58
+ list_query_results_for_management_group_async(policy_states_resource, management_group_name, query_options:query_options, custom_headers:custom_headers).value!
59
+ end
60
+
61
+ #
62
+ # Queries policy states for the resources under the management group.
63
+ #
64
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
65
+ # under PolicyStates resource type. In a given time range, 'latest' represents
66
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
67
+ # Possible values include: 'default', 'latest'
68
+ # @param management_group_name [String] Management group name.
69
+ # @param query_options [QueryOptions] Additional parameters for the operation
70
+ # @param [Hash{String => String}] A hash of custom headers that will be added
71
+ # to the HTTP request.
72
+ #
73
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
74
+ #
75
+ def list_query_results_for_management_group_async(policy_states_resource, management_group_name, query_options:nil, custom_headers:nil)
76
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
77
+ management_groups_namespace = 'Microsoft.Management'
78
+ fail ArgumentError, 'management_group_name is nil' if management_group_name.nil?
79
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
80
+
81
+ top = nil
82
+ order_by = nil
83
+ select = nil
84
+ from = nil
85
+ to = nil
86
+ filter = nil
87
+ apply = nil
88
+ unless query_options.nil?
89
+ top = query_options.Top
90
+ end
91
+ unless query_options.nil?
92
+ order_by = query_options.OrderBy
93
+ end
94
+ unless query_options.nil?
95
+ select = query_options.Select
96
+ end
97
+ unless query_options.nil?
98
+ from = query_options.From
99
+ end
100
+ unless query_options.nil?
101
+ to = query_options.To
102
+ end
103
+ unless query_options.nil?
104
+ filter = query_options.Filter
105
+ end
106
+ unless query_options.nil?
107
+ apply = query_options.Apply
108
+ end
109
+
110
+ request_headers = {}
111
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
112
+
113
+ # Set Headers
114
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
115
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
116
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
117
+
118
+ request_url = @base_url || @client.base_url
119
+
120
+ options = {
121
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
122
+ path_params: {'policyStatesResource' => policy_states_resource,'managementGroupsNamespace' => management_groups_namespace,'managementGroupName' => management_group_name},
123
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
124
+ headers: request_headers.merge(custom_headers || {}),
125
+ base_url: request_url
126
+ }
127
+ promise = @client.make_request_async(:post, path_template, options)
128
+
129
+ promise = promise.then do |result|
130
+ http_response = result.response
131
+ status_code = http_response.status
132
+ response_content = http_response.body
133
+ unless status_code == 200
134
+ error_model = JSON.load(response_content)
135
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
136
+ end
137
+
138
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
139
+ # Deserialize Response
140
+ if status_code == 200
141
+ begin
142
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
143
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
144
+ result.body = @client.deserialize(result_mapper, parsed_response)
145
+ rescue Exception => e
146
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
147
+ end
148
+ end
149
+
150
+ result
151
+ end
152
+
153
+ promise.execute
154
+ end
155
+
156
+ #
157
+ # Summarizes policy states for the resources under the management group.
158
+ #
159
+ # @param management_group_name [String] Management group name.
160
+ # @param query_options [QueryOptions] Additional parameters for the operation
161
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
162
+ # will be added to the HTTP request.
163
+ #
164
+ # @return [SummarizeResults] operation results.
165
+ #
166
+ def summarize_for_management_group(management_group_name, query_options:nil, custom_headers:nil)
167
+ response = summarize_for_management_group_async(management_group_name, query_options:query_options, custom_headers:custom_headers).value!
168
+ response.body unless response.nil?
169
+ end
170
+
171
+ #
172
+ # Summarizes policy states for the resources under the management group.
173
+ #
174
+ # @param management_group_name [String] Management group name.
175
+ # @param query_options [QueryOptions] Additional parameters for the operation
176
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
177
+ # will be added to the HTTP request.
178
+ #
179
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
180
+ #
181
+ def summarize_for_management_group_with_http_info(management_group_name, query_options:nil, custom_headers:nil)
182
+ summarize_for_management_group_async(management_group_name, query_options:query_options, custom_headers:custom_headers).value!
183
+ end
184
+
185
+ #
186
+ # Summarizes policy states for the resources under the management group.
187
+ #
188
+ # @param management_group_name [String] Management group name.
189
+ # @param query_options [QueryOptions] Additional parameters for the operation
190
+ # @param [Hash{String => String}] A hash of custom headers that will be added
191
+ # to the HTTP request.
192
+ #
193
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
194
+ #
195
+ def summarize_for_management_group_async(management_group_name, query_options:nil, custom_headers:nil)
196
+ policy_states_summary_resource = 'latest'
197
+ management_groups_namespace = 'Microsoft.Management'
198
+ fail ArgumentError, 'management_group_name is nil' if management_group_name.nil?
199
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
200
+
201
+ top = nil
202
+ from = nil
203
+ to = nil
204
+ filter = nil
205
+ unless query_options.nil?
206
+ top = query_options.Top
207
+ end
208
+ unless query_options.nil?
209
+ from = query_options.From
210
+ end
211
+ unless query_options.nil?
212
+ to = query_options.To
213
+ end
214
+ unless query_options.nil?
215
+ filter = query_options.Filter
216
+ end
217
+
218
+ request_headers = {}
219
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
220
+
221
+ # Set Headers
222
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
223
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
224
+ path_template = 'providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
225
+
226
+ request_url = @base_url || @client.base_url
227
+
228
+ options = {
229
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
230
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'managementGroupsNamespace' => management_groups_namespace,'managementGroupName' => management_group_name},
231
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
232
+ headers: request_headers.merge(custom_headers || {}),
233
+ base_url: request_url
234
+ }
235
+ promise = @client.make_request_async(:post, path_template, options)
236
+
237
+ promise = promise.then do |result|
238
+ http_response = result.response
239
+ status_code = http_response.status
240
+ response_content = http_response.body
241
+ unless status_code == 200
242
+ error_model = JSON.load(response_content)
243
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
244
+ end
245
+
246
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
247
+ # Deserialize Response
248
+ if status_code == 200
249
+ begin
250
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
251
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
252
+ result.body = @client.deserialize(result_mapper, parsed_response)
253
+ rescue Exception => e
254
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
255
+ end
256
+ end
257
+
258
+ result
259
+ end
260
+
261
+ promise.execute
262
+ end
263
+
264
+ #
265
+ # Queries policy states for the resources under the subscription.
266
+ #
267
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
268
+ # under PolicyStates resource type. In a given time range, 'latest' represents
269
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
270
+ # Possible values include: 'default', 'latest'
271
+ # @param subscription_id [String] Microsoft Azure subscription ID.
272
+ # @param query_options [QueryOptions] Additional parameters for the operation
273
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
274
+ # will be added to the HTTP request.
275
+ #
276
+ # @return [PolicyStatesQueryResults] operation results.
277
+ #
278
+ def list_query_results_for_subscription(policy_states_resource, subscription_id, query_options:nil, custom_headers:nil)
279
+ response = list_query_results_for_subscription_async(policy_states_resource, subscription_id, query_options:query_options, custom_headers:custom_headers).value!
280
+ response.body unless response.nil?
281
+ end
282
+
283
+ #
284
+ # Queries policy states for the resources under the subscription.
285
+ #
286
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
287
+ # under PolicyStates resource type. In a given time range, 'latest' represents
288
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
289
+ # Possible values include: 'default', 'latest'
290
+ # @param subscription_id [String] Microsoft Azure subscription ID.
291
+ # @param query_options [QueryOptions] Additional parameters for the operation
292
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
293
+ # will be added to the HTTP request.
294
+ #
295
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
296
+ #
297
+ def list_query_results_for_subscription_with_http_info(policy_states_resource, subscription_id, query_options:nil, custom_headers:nil)
298
+ list_query_results_for_subscription_async(policy_states_resource, subscription_id, query_options:query_options, custom_headers:custom_headers).value!
299
+ end
300
+
301
+ #
302
+ # Queries policy states for the resources under the subscription.
303
+ #
304
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
305
+ # under PolicyStates resource type. In a given time range, 'latest' represents
306
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
307
+ # Possible values include: 'default', 'latest'
308
+ # @param subscription_id [String] Microsoft Azure subscription ID.
309
+ # @param query_options [QueryOptions] Additional parameters for the operation
310
+ # @param [Hash{String => String}] A hash of custom headers that will be added
311
+ # to the HTTP request.
312
+ #
313
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
314
+ #
315
+ def list_query_results_for_subscription_async(policy_states_resource, subscription_id, query_options:nil, custom_headers:nil)
316
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
317
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
318
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
319
+
320
+ top = nil
321
+ order_by = nil
322
+ select = nil
323
+ from = nil
324
+ to = nil
325
+ filter = nil
326
+ apply = nil
327
+ unless query_options.nil?
328
+ top = query_options.Top
329
+ end
330
+ unless query_options.nil?
331
+ order_by = query_options.OrderBy
332
+ end
333
+ unless query_options.nil?
334
+ select = query_options.Select
335
+ end
336
+ unless query_options.nil?
337
+ from = query_options.From
338
+ end
339
+ unless query_options.nil?
340
+ to = query_options.To
341
+ end
342
+ unless query_options.nil?
343
+ filter = query_options.Filter
344
+ end
345
+ unless query_options.nil?
346
+ apply = query_options.Apply
347
+ end
348
+
349
+ request_headers = {}
350
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
351
+
352
+ # Set Headers
353
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
354
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
355
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
356
+
357
+ request_url = @base_url || @client.base_url
358
+
359
+ options = {
360
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
361
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id},
362
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
363
+ headers: request_headers.merge(custom_headers || {}),
364
+ base_url: request_url
365
+ }
366
+ promise = @client.make_request_async(:post, path_template, options)
367
+
368
+ promise = promise.then do |result|
369
+ http_response = result.response
370
+ status_code = http_response.status
371
+ response_content = http_response.body
372
+ unless status_code == 200
373
+ error_model = JSON.load(response_content)
374
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
375
+ end
376
+
377
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
378
+ # Deserialize Response
379
+ if status_code == 200
380
+ begin
381
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
382
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
383
+ result.body = @client.deserialize(result_mapper, parsed_response)
384
+ rescue Exception => e
385
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
386
+ end
387
+ end
388
+
389
+ result
390
+ end
391
+
392
+ promise.execute
393
+ end
394
+
395
+ #
396
+ # Summarizes policy states for the resources under the subscription.
397
+ #
398
+ # @param subscription_id [String] Microsoft Azure subscription ID.
399
+ # @param query_options [QueryOptions] Additional parameters for the operation
400
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
401
+ # will be added to the HTTP request.
402
+ #
403
+ # @return [SummarizeResults] operation results.
404
+ #
405
+ def summarize_for_subscription(subscription_id, query_options:nil, custom_headers:nil)
406
+ response = summarize_for_subscription_async(subscription_id, query_options:query_options, custom_headers:custom_headers).value!
407
+ response.body unless response.nil?
408
+ end
409
+
410
+ #
411
+ # Summarizes policy states for the resources under the subscription.
412
+ #
413
+ # @param subscription_id [String] Microsoft Azure subscription ID.
414
+ # @param query_options [QueryOptions] Additional parameters for the operation
415
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
416
+ # will be added to the HTTP request.
417
+ #
418
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
419
+ #
420
+ def summarize_for_subscription_with_http_info(subscription_id, query_options:nil, custom_headers:nil)
421
+ summarize_for_subscription_async(subscription_id, query_options:query_options, custom_headers:custom_headers).value!
422
+ end
423
+
424
+ #
425
+ # Summarizes policy states for the resources under the subscription.
426
+ #
427
+ # @param subscription_id [String] Microsoft Azure subscription ID.
428
+ # @param query_options [QueryOptions] Additional parameters for the operation
429
+ # @param [Hash{String => String}] A hash of custom headers that will be added
430
+ # to the HTTP request.
431
+ #
432
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
433
+ #
434
+ def summarize_for_subscription_async(subscription_id, query_options:nil, custom_headers:nil)
435
+ policy_states_summary_resource = 'latest'
436
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
437
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
438
+
439
+ top = nil
440
+ from = nil
441
+ to = nil
442
+ filter = nil
443
+ unless query_options.nil?
444
+ top = query_options.Top
445
+ end
446
+ unless query_options.nil?
447
+ from = query_options.From
448
+ end
449
+ unless query_options.nil?
450
+ to = query_options.To
451
+ end
452
+ unless query_options.nil?
453
+ filter = query_options.Filter
454
+ end
455
+
456
+ request_headers = {}
457
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
458
+
459
+ # Set Headers
460
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
461
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
462
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
463
+
464
+ request_url = @base_url || @client.base_url
465
+
466
+ options = {
467
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
468
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id},
469
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
470
+ headers: request_headers.merge(custom_headers || {}),
471
+ base_url: request_url
472
+ }
473
+ promise = @client.make_request_async(:post, path_template, options)
474
+
475
+ promise = promise.then do |result|
476
+ http_response = result.response
477
+ status_code = http_response.status
478
+ response_content = http_response.body
479
+ unless status_code == 200
480
+ error_model = JSON.load(response_content)
481
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
482
+ end
483
+
484
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
485
+ # Deserialize Response
486
+ if status_code == 200
487
+ begin
488
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
489
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
490
+ result.body = @client.deserialize(result_mapper, parsed_response)
491
+ rescue Exception => e
492
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
493
+ end
494
+ end
495
+
496
+ result
497
+ end
498
+
499
+ promise.execute
500
+ end
501
+
502
+ #
503
+ # Queries policy states for the resources under the resource group.
504
+ #
505
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
506
+ # under PolicyStates resource type. In a given time range, 'latest' represents
507
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
508
+ # Possible values include: 'default', 'latest'
509
+ # @param subscription_id [String] Microsoft Azure subscription ID.
510
+ # @param resource_group_name [String] Resource group name.
511
+ # @param query_options [QueryOptions] Additional parameters for the operation
512
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
513
+ # will be added to the HTTP request.
514
+ #
515
+ # @return [PolicyStatesQueryResults] operation results.
516
+ #
517
+ def list_query_results_for_resource_group(policy_states_resource, subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
518
+ response = list_query_results_for_resource_group_async(policy_states_resource, subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
519
+ response.body unless response.nil?
520
+ end
521
+
522
+ #
523
+ # Queries policy states for the resources under the resource group.
524
+ #
525
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
526
+ # under PolicyStates resource type. In a given time range, 'latest' represents
527
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
528
+ # Possible values include: 'default', 'latest'
529
+ # @param subscription_id [String] Microsoft Azure subscription ID.
530
+ # @param resource_group_name [String] Resource group name.
531
+ # @param query_options [QueryOptions] Additional parameters for the operation
532
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
533
+ # will be added to the HTTP request.
534
+ #
535
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
536
+ #
537
+ def list_query_results_for_resource_group_with_http_info(policy_states_resource, subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
538
+ list_query_results_for_resource_group_async(policy_states_resource, subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
539
+ end
540
+
541
+ #
542
+ # Queries policy states for the resources under the resource group.
543
+ #
544
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
545
+ # under PolicyStates resource type. In a given time range, 'latest' represents
546
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
547
+ # Possible values include: 'default', 'latest'
548
+ # @param subscription_id [String] Microsoft Azure subscription ID.
549
+ # @param resource_group_name [String] Resource group name.
550
+ # @param query_options [QueryOptions] Additional parameters for the operation
551
+ # @param [Hash{String => String}] A hash of custom headers that will be added
552
+ # to the HTTP request.
553
+ #
554
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
555
+ #
556
+ def list_query_results_for_resource_group_async(policy_states_resource, subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
557
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
558
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
559
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
560
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
561
+
562
+ top = nil
563
+ order_by = nil
564
+ select = nil
565
+ from = nil
566
+ to = nil
567
+ filter = nil
568
+ apply = nil
569
+ unless query_options.nil?
570
+ top = query_options.Top
571
+ end
572
+ unless query_options.nil?
573
+ order_by = query_options.OrderBy
574
+ end
575
+ unless query_options.nil?
576
+ select = query_options.Select
577
+ end
578
+ unless query_options.nil?
579
+ from = query_options.From
580
+ end
581
+ unless query_options.nil?
582
+ to = query_options.To
583
+ end
584
+ unless query_options.nil?
585
+ filter = query_options.Filter
586
+ end
587
+ unless query_options.nil?
588
+ apply = query_options.Apply
589
+ end
590
+
591
+ request_headers = {}
592
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
593
+
594
+ # Set Headers
595
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
596
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
597
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
598
+
599
+ request_url = @base_url || @client.base_url
600
+
601
+ options = {
602
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
603
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name},
604
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
605
+ headers: request_headers.merge(custom_headers || {}),
606
+ base_url: request_url
607
+ }
608
+ promise = @client.make_request_async(:post, path_template, options)
609
+
610
+ promise = promise.then do |result|
611
+ http_response = result.response
612
+ status_code = http_response.status
613
+ response_content = http_response.body
614
+ unless status_code == 200
615
+ error_model = JSON.load(response_content)
616
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
617
+ end
618
+
619
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
620
+ # Deserialize Response
621
+ if status_code == 200
622
+ begin
623
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
624
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
625
+ result.body = @client.deserialize(result_mapper, parsed_response)
626
+ rescue Exception => e
627
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
628
+ end
629
+ end
630
+
631
+ result
632
+ end
633
+
634
+ promise.execute
635
+ end
636
+
637
+ #
638
+ # Summarizes policy states for the resources under the resource group.
639
+ #
640
+ # @param subscription_id [String] Microsoft Azure subscription ID.
641
+ # @param resource_group_name [String] Resource group name.
642
+ # @param query_options [QueryOptions] Additional parameters for the operation
643
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
644
+ # will be added to the HTTP request.
645
+ #
646
+ # @return [SummarizeResults] operation results.
647
+ #
648
+ def summarize_for_resource_group(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
649
+ response = summarize_for_resource_group_async(subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
650
+ response.body unless response.nil?
651
+ end
652
+
653
+ #
654
+ # Summarizes policy states for the resources under the resource group.
655
+ #
656
+ # @param subscription_id [String] Microsoft Azure subscription ID.
657
+ # @param resource_group_name [String] Resource group name.
658
+ # @param query_options [QueryOptions] Additional parameters for the operation
659
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
660
+ # will be added to the HTTP request.
661
+ #
662
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
663
+ #
664
+ def summarize_for_resource_group_with_http_info(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
665
+ summarize_for_resource_group_async(subscription_id, resource_group_name, query_options:query_options, custom_headers:custom_headers).value!
666
+ end
667
+
668
+ #
669
+ # Summarizes policy states for the resources under the resource group.
670
+ #
671
+ # @param subscription_id [String] Microsoft Azure subscription ID.
672
+ # @param resource_group_name [String] Resource group name.
673
+ # @param query_options [QueryOptions] Additional parameters for the operation
674
+ # @param [Hash{String => String}] A hash of custom headers that will be added
675
+ # to the HTTP request.
676
+ #
677
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
678
+ #
679
+ def summarize_for_resource_group_async(subscription_id, resource_group_name, query_options:nil, custom_headers:nil)
680
+ policy_states_summary_resource = 'latest'
681
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
682
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
683
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
684
+
685
+ top = nil
686
+ from = nil
687
+ to = nil
688
+ filter = nil
689
+ unless query_options.nil?
690
+ top = query_options.Top
691
+ end
692
+ unless query_options.nil?
693
+ from = query_options.From
694
+ end
695
+ unless query_options.nil?
696
+ to = query_options.To
697
+ end
698
+ unless query_options.nil?
699
+ filter = query_options.Filter
700
+ end
701
+
702
+ request_headers = {}
703
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
704
+
705
+ # Set Headers
706
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
707
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
708
+ path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
709
+
710
+ request_url = @base_url || @client.base_url
711
+
712
+ options = {
713
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
714
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name},
715
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
716
+ headers: request_headers.merge(custom_headers || {}),
717
+ base_url: request_url
718
+ }
719
+ promise = @client.make_request_async(:post, path_template, options)
720
+
721
+ promise = promise.then do |result|
722
+ http_response = result.response
723
+ status_code = http_response.status
724
+ response_content = http_response.body
725
+ unless status_code == 200
726
+ error_model = JSON.load(response_content)
727
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
728
+ end
729
+
730
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
731
+ # Deserialize Response
732
+ if status_code == 200
733
+ begin
734
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
735
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
736
+ result.body = @client.deserialize(result_mapper, parsed_response)
737
+ rescue Exception => e
738
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
739
+ end
740
+ end
741
+
742
+ result
743
+ end
744
+
745
+ promise.execute
746
+ end
747
+
748
+ #
749
+ # Queries policy states for the resource.
750
+ #
751
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
752
+ # under PolicyStates resource type. In a given time range, 'latest' represents
753
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
754
+ # Possible values include: 'default', 'latest'
755
+ # @param resource_id [String] Resource ID.
756
+ # @param query_options [QueryOptions] Additional parameters for the operation
757
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
758
+ # will be added to the HTTP request.
759
+ #
760
+ # @return [PolicyStatesQueryResults] operation results.
761
+ #
762
+ def list_query_results_for_resource(policy_states_resource, resource_id, query_options:nil, custom_headers:nil)
763
+ response = list_query_results_for_resource_async(policy_states_resource, resource_id, query_options:query_options, custom_headers:custom_headers).value!
764
+ response.body unless response.nil?
765
+ end
766
+
767
+ #
768
+ # Queries policy states for the resource.
769
+ #
770
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
771
+ # under PolicyStates resource type. In a given time range, 'latest' represents
772
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
773
+ # Possible values include: 'default', 'latest'
774
+ # @param resource_id [String] Resource ID.
775
+ # @param query_options [QueryOptions] Additional parameters for the operation
776
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
777
+ # will be added to the HTTP request.
778
+ #
779
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
780
+ #
781
+ def list_query_results_for_resource_with_http_info(policy_states_resource, resource_id, query_options:nil, custom_headers:nil)
782
+ list_query_results_for_resource_async(policy_states_resource, resource_id, query_options:query_options, custom_headers:custom_headers).value!
783
+ end
784
+
785
+ #
786
+ # Queries policy states for the resource.
787
+ #
788
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
789
+ # under PolicyStates resource type. In a given time range, 'latest' represents
790
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
791
+ # Possible values include: 'default', 'latest'
792
+ # @param resource_id [String] Resource ID.
793
+ # @param query_options [QueryOptions] Additional parameters for the operation
794
+ # @param [Hash{String => String}] A hash of custom headers that will be added
795
+ # to the HTTP request.
796
+ #
797
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
798
+ #
799
+ def list_query_results_for_resource_async(policy_states_resource, resource_id, query_options:nil, custom_headers:nil)
800
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
801
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
802
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
803
+
804
+ top = nil
805
+ order_by = nil
806
+ select = nil
807
+ from = nil
808
+ to = nil
809
+ filter = nil
810
+ apply = nil
811
+ unless query_options.nil?
812
+ top = query_options.Top
813
+ end
814
+ unless query_options.nil?
815
+ order_by = query_options.OrderBy
816
+ end
817
+ unless query_options.nil?
818
+ select = query_options.Select
819
+ end
820
+ unless query_options.nil?
821
+ from = query_options.From
822
+ end
823
+ unless query_options.nil?
824
+ to = query_options.To
825
+ end
826
+ unless query_options.nil?
827
+ filter = query_options.Filter
828
+ end
829
+ unless query_options.nil?
830
+ apply = query_options.Apply
831
+ end
832
+
833
+ request_headers = {}
834
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
835
+
836
+ # Set Headers
837
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
838
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
839
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
840
+
841
+ request_url = @base_url || @client.base_url
842
+
843
+ options = {
844
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
845
+ path_params: {'policyStatesResource' => policy_states_resource},
846
+ skip_encoding_path_params: {'resourceId' => resource_id},
847
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
848
+ headers: request_headers.merge(custom_headers || {}),
849
+ base_url: request_url
850
+ }
851
+ promise = @client.make_request_async(:post, path_template, options)
852
+
853
+ promise = promise.then do |result|
854
+ http_response = result.response
855
+ status_code = http_response.status
856
+ response_content = http_response.body
857
+ unless status_code == 200
858
+ error_model = JSON.load(response_content)
859
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
860
+ end
861
+
862
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
863
+ # Deserialize Response
864
+ if status_code == 200
865
+ begin
866
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
867
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
868
+ result.body = @client.deserialize(result_mapper, parsed_response)
869
+ rescue Exception => e
870
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
871
+ end
872
+ end
873
+
874
+ result
875
+ end
876
+
877
+ promise.execute
878
+ end
879
+
880
+ #
881
+ # Summarizes policy states for the resource.
882
+ #
883
+ # @param resource_id [String] Resource ID.
884
+ # @param query_options [QueryOptions] Additional parameters for the operation
885
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
886
+ # will be added to the HTTP request.
887
+ #
888
+ # @return [SummarizeResults] operation results.
889
+ #
890
+ def summarize_for_resource(resource_id, query_options:nil, custom_headers:nil)
891
+ response = summarize_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
892
+ response.body unless response.nil?
893
+ end
894
+
895
+ #
896
+ # Summarizes policy states for the resource.
897
+ #
898
+ # @param resource_id [String] Resource ID.
899
+ # @param query_options [QueryOptions] Additional parameters for the operation
900
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
901
+ # will be added to the HTTP request.
902
+ #
903
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
904
+ #
905
+ def summarize_for_resource_with_http_info(resource_id, query_options:nil, custom_headers:nil)
906
+ summarize_for_resource_async(resource_id, query_options:query_options, custom_headers:custom_headers).value!
907
+ end
908
+
909
+ #
910
+ # Summarizes policy states for the resource.
911
+ #
912
+ # @param resource_id [String] Resource ID.
913
+ # @param query_options [QueryOptions] Additional parameters for the operation
914
+ # @param [Hash{String => String}] A hash of custom headers that will be added
915
+ # to the HTTP request.
916
+ #
917
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
918
+ #
919
+ def summarize_for_resource_async(resource_id, query_options:nil, custom_headers:nil)
920
+ policy_states_summary_resource = 'latest'
921
+ fail ArgumentError, 'resource_id is nil' if resource_id.nil?
922
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
923
+
924
+ top = nil
925
+ from = nil
926
+ to = nil
927
+ filter = nil
928
+ unless query_options.nil?
929
+ top = query_options.Top
930
+ end
931
+ unless query_options.nil?
932
+ from = query_options.From
933
+ end
934
+ unless query_options.nil?
935
+ to = query_options.To
936
+ end
937
+ unless query_options.nil?
938
+ filter = query_options.Filter
939
+ end
940
+
941
+ request_headers = {}
942
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
943
+
944
+ # Set Headers
945
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
946
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
947
+ path_template = '{resourceId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
948
+
949
+ request_url = @base_url || @client.base_url
950
+
951
+ options = {
952
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
953
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource},
954
+ skip_encoding_path_params: {'resourceId' => resource_id},
955
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
956
+ headers: request_headers.merge(custom_headers || {}),
957
+ base_url: request_url
958
+ }
959
+ promise = @client.make_request_async(:post, path_template, options)
960
+
961
+ promise = promise.then do |result|
962
+ http_response = result.response
963
+ status_code = http_response.status
964
+ response_content = http_response.body
965
+ unless status_code == 200
966
+ error_model = JSON.load(response_content)
967
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
968
+ end
969
+
970
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
971
+ # Deserialize Response
972
+ if status_code == 200
973
+ begin
974
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
975
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
976
+ result.body = @client.deserialize(result_mapper, parsed_response)
977
+ rescue Exception => e
978
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
979
+ end
980
+ end
981
+
982
+ result
983
+ end
984
+
985
+ promise.execute
986
+ end
987
+
988
+ #
989
+ # Queries policy states for the subscription level policy set definition.
990
+ #
991
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
992
+ # under PolicyStates resource type. In a given time range, 'latest' represents
993
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
994
+ # Possible values include: 'default', 'latest'
995
+ # @param subscription_id [String] Microsoft Azure subscription ID.
996
+ # @param policy_set_definition_name [String] Policy set definition name.
997
+ # @param query_options [QueryOptions] Additional parameters for the operation
998
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
999
+ # will be added to the HTTP request.
1000
+ #
1001
+ # @return [PolicyStatesQueryResults] operation results.
1002
+ #
1003
+ def list_query_results_for_policy_set_definition(policy_states_resource, subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1004
+ response = list_query_results_for_policy_set_definition_async(policy_states_resource, subscription_id, policy_set_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1005
+ response.body unless response.nil?
1006
+ end
1007
+
1008
+ #
1009
+ # Queries policy states for the subscription level policy set definition.
1010
+ #
1011
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1012
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1013
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1014
+ # Possible values include: 'default', 'latest'
1015
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1016
+ # @param policy_set_definition_name [String] Policy set definition name.
1017
+ # @param query_options [QueryOptions] Additional parameters for the operation
1018
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1019
+ # will be added to the HTTP request.
1020
+ #
1021
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1022
+ #
1023
+ def list_query_results_for_policy_set_definition_with_http_info(policy_states_resource, subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1024
+ list_query_results_for_policy_set_definition_async(policy_states_resource, subscription_id, policy_set_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1025
+ end
1026
+
1027
+ #
1028
+ # Queries policy states for the subscription level policy set definition.
1029
+ #
1030
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1031
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1032
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1033
+ # Possible values include: 'default', 'latest'
1034
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1035
+ # @param policy_set_definition_name [String] Policy set definition name.
1036
+ # @param query_options [QueryOptions] Additional parameters for the operation
1037
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1038
+ # to the HTTP request.
1039
+ #
1040
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1041
+ #
1042
+ def list_query_results_for_policy_set_definition_async(policy_states_resource, subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1043
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
1044
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1045
+ authorization_namespace = 'Microsoft.Authorization'
1046
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
1047
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1048
+
1049
+ top = nil
1050
+ order_by = nil
1051
+ select = nil
1052
+ from = nil
1053
+ to = nil
1054
+ filter = nil
1055
+ apply = nil
1056
+ unless query_options.nil?
1057
+ top = query_options.Top
1058
+ end
1059
+ unless query_options.nil?
1060
+ order_by = query_options.OrderBy
1061
+ end
1062
+ unless query_options.nil?
1063
+ select = query_options.Select
1064
+ end
1065
+ unless query_options.nil?
1066
+ from = query_options.From
1067
+ end
1068
+ unless query_options.nil?
1069
+ to = query_options.To
1070
+ end
1071
+ unless query_options.nil?
1072
+ filter = query_options.Filter
1073
+ end
1074
+ unless query_options.nil?
1075
+ apply = query_options.Apply
1076
+ end
1077
+
1078
+ request_headers = {}
1079
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1080
+
1081
+ # Set Headers
1082
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1083
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1084
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
1085
+
1086
+ request_url = @base_url || @client.base_url
1087
+
1088
+ options = {
1089
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1090
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policySetDefinitionName' => policy_set_definition_name},
1091
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
1092
+ headers: request_headers.merge(custom_headers || {}),
1093
+ base_url: request_url
1094
+ }
1095
+ promise = @client.make_request_async(:post, path_template, options)
1096
+
1097
+ promise = promise.then do |result|
1098
+ http_response = result.response
1099
+ status_code = http_response.status
1100
+ response_content = http_response.body
1101
+ unless status_code == 200
1102
+ error_model = JSON.load(response_content)
1103
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1104
+ end
1105
+
1106
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1107
+ # Deserialize Response
1108
+ if status_code == 200
1109
+ begin
1110
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1111
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
1112
+ result.body = @client.deserialize(result_mapper, parsed_response)
1113
+ rescue Exception => e
1114
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1115
+ end
1116
+ end
1117
+
1118
+ result
1119
+ end
1120
+
1121
+ promise.execute
1122
+ end
1123
+
1124
+ #
1125
+ # Summarizes policy states for the subscription level policy set definition.
1126
+ #
1127
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1128
+ # @param policy_set_definition_name [String] Policy set definition name.
1129
+ # @param query_options [QueryOptions] Additional parameters for the operation
1130
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1131
+ # will be added to the HTTP request.
1132
+ #
1133
+ # @return [SummarizeResults] operation results.
1134
+ #
1135
+ def summarize_for_policy_set_definition(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1136
+ response = summarize_for_policy_set_definition_async(subscription_id, policy_set_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1137
+ response.body unless response.nil?
1138
+ end
1139
+
1140
+ #
1141
+ # Summarizes policy states for the subscription level policy set definition.
1142
+ #
1143
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1144
+ # @param policy_set_definition_name [String] Policy set definition name.
1145
+ # @param query_options [QueryOptions] Additional parameters for the operation
1146
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1147
+ # will be added to the HTTP request.
1148
+ #
1149
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1150
+ #
1151
+ def summarize_for_policy_set_definition_with_http_info(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1152
+ summarize_for_policy_set_definition_async(subscription_id, policy_set_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1153
+ end
1154
+
1155
+ #
1156
+ # Summarizes policy states for the subscription level policy set definition.
1157
+ #
1158
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1159
+ # @param policy_set_definition_name [String] Policy set definition name.
1160
+ # @param query_options [QueryOptions] Additional parameters for the operation
1161
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1162
+ # to the HTTP request.
1163
+ #
1164
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1165
+ #
1166
+ def summarize_for_policy_set_definition_async(subscription_id, policy_set_definition_name, query_options:nil, custom_headers:nil)
1167
+ policy_states_summary_resource = 'latest'
1168
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1169
+ authorization_namespace = 'Microsoft.Authorization'
1170
+ fail ArgumentError, 'policy_set_definition_name is nil' if policy_set_definition_name.nil?
1171
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1172
+
1173
+ top = nil
1174
+ from = nil
1175
+ to = nil
1176
+ filter = nil
1177
+ unless query_options.nil?
1178
+ top = query_options.Top
1179
+ end
1180
+ unless query_options.nil?
1181
+ from = query_options.From
1182
+ end
1183
+ unless query_options.nil?
1184
+ to = query_options.To
1185
+ end
1186
+ unless query_options.nil?
1187
+ filter = query_options.Filter
1188
+ end
1189
+
1190
+ request_headers = {}
1191
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1192
+
1193
+ # Set Headers
1194
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1195
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1196
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policySetDefinitions/{policySetDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
1197
+
1198
+ request_url = @base_url || @client.base_url
1199
+
1200
+ options = {
1201
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1202
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policySetDefinitionName' => policy_set_definition_name},
1203
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
1204
+ headers: request_headers.merge(custom_headers || {}),
1205
+ base_url: request_url
1206
+ }
1207
+ promise = @client.make_request_async(:post, path_template, options)
1208
+
1209
+ promise = promise.then do |result|
1210
+ http_response = result.response
1211
+ status_code = http_response.status
1212
+ response_content = http_response.body
1213
+ unless status_code == 200
1214
+ error_model = JSON.load(response_content)
1215
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1216
+ end
1217
+
1218
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1219
+ # Deserialize Response
1220
+ if status_code == 200
1221
+ begin
1222
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1223
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
1224
+ result.body = @client.deserialize(result_mapper, parsed_response)
1225
+ rescue Exception => e
1226
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1227
+ end
1228
+ end
1229
+
1230
+ result
1231
+ end
1232
+
1233
+ promise.execute
1234
+ end
1235
+
1236
+ #
1237
+ # Queries policy states for the subscription level policy definition.
1238
+ #
1239
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1240
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1241
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1242
+ # Possible values include: 'default', 'latest'
1243
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1244
+ # @param policy_definition_name [String] Policy definition name.
1245
+ # @param query_options [QueryOptions] Additional parameters for the operation
1246
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1247
+ # will be added to the HTTP request.
1248
+ #
1249
+ # @return [PolicyStatesQueryResults] operation results.
1250
+ #
1251
+ def list_query_results_for_policy_definition(policy_states_resource, subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1252
+ response = list_query_results_for_policy_definition_async(policy_states_resource, subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1253
+ response.body unless response.nil?
1254
+ end
1255
+
1256
+ #
1257
+ # Queries policy states for the subscription level policy definition.
1258
+ #
1259
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1260
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1261
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1262
+ # Possible values include: 'default', 'latest'
1263
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1264
+ # @param policy_definition_name [String] Policy definition name.
1265
+ # @param query_options [QueryOptions] Additional parameters for the operation
1266
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1267
+ # will be added to the HTTP request.
1268
+ #
1269
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1270
+ #
1271
+ def list_query_results_for_policy_definition_with_http_info(policy_states_resource, subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1272
+ list_query_results_for_policy_definition_async(policy_states_resource, subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1273
+ end
1274
+
1275
+ #
1276
+ # Queries policy states for the subscription level policy definition.
1277
+ #
1278
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1279
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1280
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1281
+ # Possible values include: 'default', 'latest'
1282
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1283
+ # @param policy_definition_name [String] Policy definition name.
1284
+ # @param query_options [QueryOptions] Additional parameters for the operation
1285
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1286
+ # to the HTTP request.
1287
+ #
1288
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1289
+ #
1290
+ def list_query_results_for_policy_definition_async(policy_states_resource, subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1291
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
1292
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1293
+ authorization_namespace = 'Microsoft.Authorization'
1294
+ fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
1295
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1296
+
1297
+ top = nil
1298
+ order_by = nil
1299
+ select = nil
1300
+ from = nil
1301
+ to = nil
1302
+ filter = nil
1303
+ apply = nil
1304
+ unless query_options.nil?
1305
+ top = query_options.Top
1306
+ end
1307
+ unless query_options.nil?
1308
+ order_by = query_options.OrderBy
1309
+ end
1310
+ unless query_options.nil?
1311
+ select = query_options.Select
1312
+ end
1313
+ unless query_options.nil?
1314
+ from = query_options.From
1315
+ end
1316
+ unless query_options.nil?
1317
+ to = query_options.To
1318
+ end
1319
+ unless query_options.nil?
1320
+ filter = query_options.Filter
1321
+ end
1322
+ unless query_options.nil?
1323
+ apply = query_options.Apply
1324
+ end
1325
+
1326
+ request_headers = {}
1327
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1328
+
1329
+ # Set Headers
1330
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1331
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1332
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
1333
+
1334
+ request_url = @base_url || @client.base_url
1335
+
1336
+ options = {
1337
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1338
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policyDefinitionName' => policy_definition_name},
1339
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
1340
+ headers: request_headers.merge(custom_headers || {}),
1341
+ base_url: request_url
1342
+ }
1343
+ promise = @client.make_request_async(:post, path_template, options)
1344
+
1345
+ promise = promise.then do |result|
1346
+ http_response = result.response
1347
+ status_code = http_response.status
1348
+ response_content = http_response.body
1349
+ unless status_code == 200
1350
+ error_model = JSON.load(response_content)
1351
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1352
+ end
1353
+
1354
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1355
+ # Deserialize Response
1356
+ if status_code == 200
1357
+ begin
1358
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1359
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
1360
+ result.body = @client.deserialize(result_mapper, parsed_response)
1361
+ rescue Exception => e
1362
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1363
+ end
1364
+ end
1365
+
1366
+ result
1367
+ end
1368
+
1369
+ promise.execute
1370
+ end
1371
+
1372
+ #
1373
+ # Summarizes policy states for the subscription level policy definition.
1374
+ #
1375
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1376
+ # @param policy_definition_name [String] Policy definition name.
1377
+ # @param query_options [QueryOptions] Additional parameters for the operation
1378
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1379
+ # will be added to the HTTP request.
1380
+ #
1381
+ # @return [SummarizeResults] operation results.
1382
+ #
1383
+ def summarize_for_policy_definition(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1384
+ response = summarize_for_policy_definition_async(subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1385
+ response.body unless response.nil?
1386
+ end
1387
+
1388
+ #
1389
+ # Summarizes policy states for the subscription level policy definition.
1390
+ #
1391
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1392
+ # @param policy_definition_name [String] Policy definition name.
1393
+ # @param query_options [QueryOptions] Additional parameters for the operation
1394
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1395
+ # will be added to the HTTP request.
1396
+ #
1397
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1398
+ #
1399
+ def summarize_for_policy_definition_with_http_info(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1400
+ summarize_for_policy_definition_async(subscription_id, policy_definition_name, query_options:query_options, custom_headers:custom_headers).value!
1401
+ end
1402
+
1403
+ #
1404
+ # Summarizes policy states for the subscription level policy definition.
1405
+ #
1406
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1407
+ # @param policy_definition_name [String] Policy definition name.
1408
+ # @param query_options [QueryOptions] Additional parameters for the operation
1409
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1410
+ # to the HTTP request.
1411
+ #
1412
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1413
+ #
1414
+ def summarize_for_policy_definition_async(subscription_id, policy_definition_name, query_options:nil, custom_headers:nil)
1415
+ policy_states_summary_resource = 'latest'
1416
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1417
+ authorization_namespace = 'Microsoft.Authorization'
1418
+ fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
1419
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1420
+
1421
+ top = nil
1422
+ from = nil
1423
+ to = nil
1424
+ filter = nil
1425
+ unless query_options.nil?
1426
+ top = query_options.Top
1427
+ end
1428
+ unless query_options.nil?
1429
+ from = query_options.From
1430
+ end
1431
+ unless query_options.nil?
1432
+ to = query_options.To
1433
+ end
1434
+ unless query_options.nil?
1435
+ filter = query_options.Filter
1436
+ end
1437
+
1438
+ request_headers = {}
1439
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1440
+
1441
+ # Set Headers
1442
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1443
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1444
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
1445
+
1446
+ request_url = @base_url || @client.base_url
1447
+
1448
+ options = {
1449
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1450
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policyDefinitionName' => policy_definition_name},
1451
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
1452
+ headers: request_headers.merge(custom_headers || {}),
1453
+ base_url: request_url
1454
+ }
1455
+ promise = @client.make_request_async(:post, path_template, options)
1456
+
1457
+ promise = promise.then do |result|
1458
+ http_response = result.response
1459
+ status_code = http_response.status
1460
+ response_content = http_response.body
1461
+ unless status_code == 200
1462
+ error_model = JSON.load(response_content)
1463
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1464
+ end
1465
+
1466
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1467
+ # Deserialize Response
1468
+ if status_code == 200
1469
+ begin
1470
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1471
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
1472
+ result.body = @client.deserialize(result_mapper, parsed_response)
1473
+ rescue Exception => e
1474
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1475
+ end
1476
+ end
1477
+
1478
+ result
1479
+ end
1480
+
1481
+ promise.execute
1482
+ end
1483
+
1484
+ #
1485
+ # Queries policy states for the subscription level policy assignment.
1486
+ #
1487
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1488
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1489
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1490
+ # Possible values include: 'default', 'latest'
1491
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1492
+ # @param policy_assignment_name [String] Policy assignment name.
1493
+ # @param query_options [QueryOptions] Additional parameters for the operation
1494
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1495
+ # will be added to the HTTP request.
1496
+ #
1497
+ # @return [PolicyStatesQueryResults] operation results.
1498
+ #
1499
+ def list_query_results_for_subscription_level_policy_assignment(policy_states_resource, subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1500
+ response = list_query_results_for_subscription_level_policy_assignment_async(policy_states_resource, subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1501
+ response.body unless response.nil?
1502
+ end
1503
+
1504
+ #
1505
+ # Queries policy states for the subscription level policy assignment.
1506
+ #
1507
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1508
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1509
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1510
+ # Possible values include: 'default', 'latest'
1511
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1512
+ # @param policy_assignment_name [String] Policy assignment name.
1513
+ # @param query_options [QueryOptions] Additional parameters for the operation
1514
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1515
+ # will be added to the HTTP request.
1516
+ #
1517
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1518
+ #
1519
+ def list_query_results_for_subscription_level_policy_assignment_with_http_info(policy_states_resource, subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1520
+ list_query_results_for_subscription_level_policy_assignment_async(policy_states_resource, subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1521
+ end
1522
+
1523
+ #
1524
+ # Queries policy states for the subscription level policy assignment.
1525
+ #
1526
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1527
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1528
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1529
+ # Possible values include: 'default', 'latest'
1530
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1531
+ # @param policy_assignment_name [String] Policy assignment name.
1532
+ # @param query_options [QueryOptions] Additional parameters for the operation
1533
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1534
+ # to the HTTP request.
1535
+ #
1536
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1537
+ #
1538
+ def list_query_results_for_subscription_level_policy_assignment_async(policy_states_resource, subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1539
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
1540
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1541
+ authorization_namespace = 'Microsoft.Authorization'
1542
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
1543
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1544
+
1545
+ top = nil
1546
+ order_by = nil
1547
+ select = nil
1548
+ from = nil
1549
+ to = nil
1550
+ filter = nil
1551
+ apply = nil
1552
+ unless query_options.nil?
1553
+ top = query_options.Top
1554
+ end
1555
+ unless query_options.nil?
1556
+ order_by = query_options.OrderBy
1557
+ end
1558
+ unless query_options.nil?
1559
+ select = query_options.Select
1560
+ end
1561
+ unless query_options.nil?
1562
+ from = query_options.From
1563
+ end
1564
+ unless query_options.nil?
1565
+ to = query_options.To
1566
+ end
1567
+ unless query_options.nil?
1568
+ filter = query_options.Filter
1569
+ end
1570
+ unless query_options.nil?
1571
+ apply = query_options.Apply
1572
+ end
1573
+
1574
+ request_headers = {}
1575
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1576
+
1577
+ # Set Headers
1578
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1579
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1580
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
1581
+
1582
+ request_url = @base_url || @client.base_url
1583
+
1584
+ options = {
1585
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1586
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_name},
1587
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
1588
+ headers: request_headers.merge(custom_headers || {}),
1589
+ base_url: request_url
1590
+ }
1591
+ promise = @client.make_request_async(:post, path_template, options)
1592
+
1593
+ promise = promise.then do |result|
1594
+ http_response = result.response
1595
+ status_code = http_response.status
1596
+ response_content = http_response.body
1597
+ unless status_code == 200
1598
+ error_model = JSON.load(response_content)
1599
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1600
+ end
1601
+
1602
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1603
+ # Deserialize Response
1604
+ if status_code == 200
1605
+ begin
1606
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1607
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
1608
+ result.body = @client.deserialize(result_mapper, parsed_response)
1609
+ rescue Exception => e
1610
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1611
+ end
1612
+ end
1613
+
1614
+ result
1615
+ end
1616
+
1617
+ promise.execute
1618
+ end
1619
+
1620
+ #
1621
+ # Summarizes policy states for the subscription level policy assignment.
1622
+ #
1623
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1624
+ # @param policy_assignment_name [String] Policy assignment name.
1625
+ # @param query_options [QueryOptions] Additional parameters for the operation
1626
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1627
+ # will be added to the HTTP request.
1628
+ #
1629
+ # @return [SummarizeResults] operation results.
1630
+ #
1631
+ def summarize_for_subscription_level_policy_assignment(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1632
+ response = summarize_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1633
+ response.body unless response.nil?
1634
+ end
1635
+
1636
+ #
1637
+ # Summarizes policy states for the subscription level policy assignment.
1638
+ #
1639
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1640
+ # @param policy_assignment_name [String] Policy assignment name.
1641
+ # @param query_options [QueryOptions] Additional parameters for the operation
1642
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1643
+ # will be added to the HTTP request.
1644
+ #
1645
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1646
+ #
1647
+ def summarize_for_subscription_level_policy_assignment_with_http_info(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1648
+ summarize_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1649
+ end
1650
+
1651
+ #
1652
+ # Summarizes policy states for the subscription level policy assignment.
1653
+ #
1654
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1655
+ # @param policy_assignment_name [String] Policy assignment name.
1656
+ # @param query_options [QueryOptions] Additional parameters for the operation
1657
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1658
+ # to the HTTP request.
1659
+ #
1660
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1661
+ #
1662
+ def summarize_for_subscription_level_policy_assignment_async(subscription_id, policy_assignment_name, query_options:nil, custom_headers:nil)
1663
+ policy_states_summary_resource = 'latest'
1664
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1665
+ authorization_namespace = 'Microsoft.Authorization'
1666
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
1667
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1668
+
1669
+ top = nil
1670
+ from = nil
1671
+ to = nil
1672
+ filter = nil
1673
+ unless query_options.nil?
1674
+ top = query_options.Top
1675
+ end
1676
+ unless query_options.nil?
1677
+ from = query_options.From
1678
+ end
1679
+ unless query_options.nil?
1680
+ to = query_options.To
1681
+ end
1682
+ unless query_options.nil?
1683
+ filter = query_options.Filter
1684
+ end
1685
+
1686
+ request_headers = {}
1687
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1688
+
1689
+ # Set Headers
1690
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1691
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1692
+ path_template = 'subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
1693
+
1694
+ request_url = @base_url || @client.base_url
1695
+
1696
+ options = {
1697
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1698
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_name},
1699
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
1700
+ headers: request_headers.merge(custom_headers || {}),
1701
+ base_url: request_url
1702
+ }
1703
+ promise = @client.make_request_async(:post, path_template, options)
1704
+
1705
+ promise = promise.then do |result|
1706
+ http_response = result.response
1707
+ status_code = http_response.status
1708
+ response_content = http_response.body
1709
+ unless status_code == 200
1710
+ error_model = JSON.load(response_content)
1711
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1712
+ end
1713
+
1714
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1715
+ # Deserialize Response
1716
+ if status_code == 200
1717
+ begin
1718
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1719
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
1720
+ result.body = @client.deserialize(result_mapper, parsed_response)
1721
+ rescue Exception => e
1722
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1723
+ end
1724
+ end
1725
+
1726
+ result
1727
+ end
1728
+
1729
+ promise.execute
1730
+ end
1731
+
1732
+ #
1733
+ # Queries policy states for the resource group level policy assignment.
1734
+ #
1735
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1736
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1737
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1738
+ # Possible values include: 'default', 'latest'
1739
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1740
+ # @param resource_group_name [String] Resource group name.
1741
+ # @param policy_assignment_name [String] Policy assignment name.
1742
+ # @param query_options [QueryOptions] Additional parameters for the operation
1743
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1744
+ # will be added to the HTTP request.
1745
+ #
1746
+ # @return [PolicyStatesQueryResults] operation results.
1747
+ #
1748
+ def list_query_results_for_resource_group_level_policy_assignment(policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1749
+ response = list_query_results_for_resource_group_level_policy_assignment_async(policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1750
+ response.body unless response.nil?
1751
+ end
1752
+
1753
+ #
1754
+ # Queries policy states for the resource group level policy assignment.
1755
+ #
1756
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1757
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1758
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1759
+ # Possible values include: 'default', 'latest'
1760
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1761
+ # @param resource_group_name [String] Resource group name.
1762
+ # @param policy_assignment_name [String] Policy assignment name.
1763
+ # @param query_options [QueryOptions] Additional parameters for the operation
1764
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1765
+ # will be added to the HTTP request.
1766
+ #
1767
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1768
+ #
1769
+ def list_query_results_for_resource_group_level_policy_assignment_with_http_info(policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1770
+ list_query_results_for_resource_group_level_policy_assignment_async(policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1771
+ end
1772
+
1773
+ #
1774
+ # Queries policy states for the resource group level policy assignment.
1775
+ #
1776
+ # @param policy_states_resource [PolicyStatesResource] The virtual resource
1777
+ # under PolicyStates resource type. In a given time range, 'latest' represents
1778
+ # the latest policy state(s), whereas 'default' represents all policy state(s).
1779
+ # Possible values include: 'default', 'latest'
1780
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1781
+ # @param resource_group_name [String] Resource group name.
1782
+ # @param policy_assignment_name [String] Policy assignment name.
1783
+ # @param query_options [QueryOptions] Additional parameters for the operation
1784
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1785
+ # to the HTTP request.
1786
+ #
1787
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1788
+ #
1789
+ def list_query_results_for_resource_group_level_policy_assignment_async(policy_states_resource, subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1790
+ fail ArgumentError, 'policy_states_resource is nil' if policy_states_resource.nil?
1791
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1792
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1793
+ authorization_namespace = 'Microsoft.Authorization'
1794
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
1795
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1796
+
1797
+ top = nil
1798
+ order_by = nil
1799
+ select = nil
1800
+ from = nil
1801
+ to = nil
1802
+ filter = nil
1803
+ apply = nil
1804
+ unless query_options.nil?
1805
+ top = query_options.Top
1806
+ end
1807
+ unless query_options.nil?
1808
+ order_by = query_options.OrderBy
1809
+ end
1810
+ unless query_options.nil?
1811
+ select = query_options.Select
1812
+ end
1813
+ unless query_options.nil?
1814
+ from = query_options.From
1815
+ end
1816
+ unless query_options.nil?
1817
+ to = query_options.To
1818
+ end
1819
+ unless query_options.nil?
1820
+ filter = query_options.Filter
1821
+ end
1822
+ unless query_options.nil?
1823
+ apply = query_options.Apply
1824
+ end
1825
+
1826
+ request_headers = {}
1827
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1828
+
1829
+ # Set Headers
1830
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1831
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1832
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults'
1833
+
1834
+ request_url = @base_url || @client.base_url
1835
+
1836
+ options = {
1837
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1838
+ path_params: {'policyStatesResource' => policy_states_resource,'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_name},
1839
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$orderby' => order_by,'$select' => select,'$from' => from,'$to' => to,'$filter' => filter,'$apply' => apply},
1840
+ headers: request_headers.merge(custom_headers || {}),
1841
+ base_url: request_url
1842
+ }
1843
+ promise = @client.make_request_async(:post, path_template, options)
1844
+
1845
+ promise = promise.then do |result|
1846
+ http_response = result.response
1847
+ status_code = http_response.status
1848
+ response_content = http_response.body
1849
+ unless status_code == 200
1850
+ error_model = JSON.load(response_content)
1851
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1852
+ end
1853
+
1854
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1855
+ # Deserialize Response
1856
+ if status_code == 200
1857
+ begin
1858
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1859
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::PolicyStatesQueryResults.mapper()
1860
+ result.body = @client.deserialize(result_mapper, parsed_response)
1861
+ rescue Exception => e
1862
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1863
+ end
1864
+ end
1865
+
1866
+ result
1867
+ end
1868
+
1869
+ promise.execute
1870
+ end
1871
+
1872
+ #
1873
+ # Summarizes policy states for the resource group level policy assignment.
1874
+ #
1875
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1876
+ # @param resource_group_name [String] Resource group name.
1877
+ # @param policy_assignment_name [String] Policy assignment name.
1878
+ # @param query_options [QueryOptions] Additional parameters for the operation
1879
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1880
+ # will be added to the HTTP request.
1881
+ #
1882
+ # @return [SummarizeResults] operation results.
1883
+ #
1884
+ def summarize_for_resource_group_level_policy_assignment(subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1885
+ response = summarize_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1886
+ response.body unless response.nil?
1887
+ end
1888
+
1889
+ #
1890
+ # Summarizes policy states for the resource group level policy assignment.
1891
+ #
1892
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1893
+ # @param resource_group_name [String] Resource group name.
1894
+ # @param policy_assignment_name [String] Policy assignment name.
1895
+ # @param query_options [QueryOptions] Additional parameters for the operation
1896
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1897
+ # will be added to the HTTP request.
1898
+ #
1899
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
1900
+ #
1901
+ def summarize_for_resource_group_level_policy_assignment_with_http_info(subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1902
+ summarize_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_name, query_options:query_options, custom_headers:custom_headers).value!
1903
+ end
1904
+
1905
+ #
1906
+ # Summarizes policy states for the resource group level policy assignment.
1907
+ #
1908
+ # @param subscription_id [String] Microsoft Azure subscription ID.
1909
+ # @param resource_group_name [String] Resource group name.
1910
+ # @param policy_assignment_name [String] Policy assignment name.
1911
+ # @param query_options [QueryOptions] Additional parameters for the operation
1912
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1913
+ # to the HTTP request.
1914
+ #
1915
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1916
+ #
1917
+ def summarize_for_resource_group_level_policy_assignment_async(subscription_id, resource_group_name, policy_assignment_name, query_options:nil, custom_headers:nil)
1918
+ policy_states_summary_resource = 'latest'
1919
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
1920
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
1921
+ authorization_namespace = 'Microsoft.Authorization'
1922
+ fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
1923
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
1924
+
1925
+ top = nil
1926
+ from = nil
1927
+ to = nil
1928
+ filter = nil
1929
+ unless query_options.nil?
1930
+ top = query_options.Top
1931
+ end
1932
+ unless query_options.nil?
1933
+ from = query_options.From
1934
+ end
1935
+ unless query_options.nil?
1936
+ to = query_options.To
1937
+ end
1938
+ unless query_options.nil?
1939
+ filter = query_options.Filter
1940
+ end
1941
+
1942
+ request_headers = {}
1943
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1944
+
1945
+ # Set Headers
1946
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1947
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1948
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize'
1949
+
1950
+ request_url = @base_url || @client.base_url
1951
+
1952
+ options = {
1953
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1954
+ path_params: {'policyStatesSummaryResource' => policy_states_summary_resource,'subscriptionId' => subscription_id,'resourceGroupName' => resource_group_name,'authorizationNamespace' => authorization_namespace,'policyAssignmentName' => policy_assignment_name},
1955
+ query_params: {'api-version' => @client.api_version,'$top' => top,'$from' => from,'$to' => to,'$filter' => filter},
1956
+ headers: request_headers.merge(custom_headers || {}),
1957
+ base_url: request_url
1958
+ }
1959
+ promise = @client.make_request_async(:post, path_template, options)
1960
+
1961
+ promise = promise.then do |result|
1962
+ http_response = result.response
1963
+ status_code = http_response.status
1964
+ response_content = http_response.body
1965
+ unless status_code == 200
1966
+ error_model = JSON.load(response_content)
1967
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1968
+ end
1969
+
1970
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1971
+ # Deserialize Response
1972
+ if status_code == 200
1973
+ begin
1974
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1975
+ result_mapper = Azure::PolicyInsights::Mgmt::V2017_12_12_preview::Models::SummarizeResults.mapper()
1976
+ result.body = @client.deserialize(result_mapper, parsed_response)
1977
+ rescue Exception => e
1978
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1979
+ end
1980
+ end
1981
+
1982
+ result
1983
+ end
1984
+
1985
+ promise.execute
1986
+ end
1987
+
1988
+ #
1989
+ # Gets OData metadata XML document.
1990
+ #
1991
+ # @param scope [String] A valid scope, i.e. management group, subscription,
1992
+ # resource group, or resource ID. Scope used has no effect on metadata
1993
+ # returned.
1994
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1995
+ # will be added to the HTTP request.
1996
+ #
1997
+ # @return [String] operation results.
1998
+ #
1999
+ def get_metadata(scope, custom_headers:nil)
2000
+ response = get_metadata_async(scope, custom_headers:custom_headers).value!
2001
+ response.body unless response.nil?
2002
+ end
2003
+
2004
+ #
2005
+ # Gets OData metadata XML document.
2006
+ #
2007
+ # @param scope [String] A valid scope, i.e. management group, subscription,
2008
+ # resource group, or resource ID. Scope used has no effect on metadata
2009
+ # returned.
2010
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
2011
+ # will be added to the HTTP request.
2012
+ #
2013
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
2014
+ #
2015
+ def get_metadata_with_http_info(scope, custom_headers:nil)
2016
+ get_metadata_async(scope, custom_headers:custom_headers).value!
2017
+ end
2018
+
2019
+ #
2020
+ # Gets OData metadata XML document.
2021
+ #
2022
+ # @param scope [String] A valid scope, i.e. management group, subscription,
2023
+ # resource group, or resource ID. Scope used has no effect on metadata
2024
+ # returned.
2025
+ # @param [Hash{String => String}] A hash of custom headers that will be added
2026
+ # to the HTTP request.
2027
+ #
2028
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
2029
+ #
2030
+ def get_metadata_async(scope, custom_headers:nil)
2031
+ fail ArgumentError, 'scope is nil' if scope.nil?
2032
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
2033
+
2034
+
2035
+ request_headers = {}
2036
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
2037
+
2038
+ # Set Headers
2039
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
2040
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
2041
+ path_template = '{scope}/providers/Microsoft.PolicyInsights/policyStates/$metadata'
2042
+
2043
+ request_url = @base_url || @client.base_url
2044
+
2045
+ options = {
2046
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
2047
+ skip_encoding_path_params: {'scope' => scope},
2048
+ query_params: {'api-version' => @client.api_version},
2049
+ headers: request_headers.merge(custom_headers || {}),
2050
+ base_url: request_url
2051
+ }
2052
+ promise = @client.make_request_async(:get, path_template, options)
2053
+
2054
+ promise = promise.then do |result|
2055
+ http_response = result.response
2056
+ status_code = http_response.status
2057
+ response_content = http_response.body
2058
+ unless status_code == 200
2059
+ error_model = JSON.load(response_content)
2060
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
2061
+ end
2062
+
2063
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
2064
+ # Deserialize Response
2065
+ if status_code == 200
2066
+ begin
2067
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
2068
+ result_mapper = {
2069
+ client_side_validation: true,
2070
+ required: false,
2071
+ serialized_name: 'parsed_response',
2072
+ type: {
2073
+ name: 'String'
2074
+ }
2075
+ }
2076
+ result.body = @client.deserialize(result_mapper, parsed_response)
2077
+ rescue Exception => e
2078
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
2079
+ end
2080
+ end
2081
+
2082
+ result
2083
+ end
2084
+
2085
+ promise.execute
2086
+ end
2087
+
2088
+ end
2089
+ end