Class: Azure::Policy::Mgmt::V2016_04_01::PolicyAssignments

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb

Overview

To manage and control access to your resources, you can define customized policies and assign them at a scope.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PolicyAssignments

Creates and initializes a new instance of the PolicyAssignments class.



18
19
20
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientPolicyClient (readonly)



23
24
25
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 23

def client
  @client
end

Instance Method Details

#create(scope, policy_assignment_name, parameters, custom_headers: nil) ⇒ PolicyAssignment

Creates a policy assignment.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group.

will be added to the HTTP request.



137
138
139
140
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 137

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

#create_async(scope, policy_assignment_name, parameters, custom_headers: nil) ⇒ Concurrent::Promise

Creates a policy assignment.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group.

to the HTTP request.



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 176

def create_async(scope, policy_assignment_name, parameters, custom_headers:nil)
  fail ArgumentError, 'scope is nil' if scope.nil?
  fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyAssignmentName' => policy_assignment_name},
      skip_encoding_path_params: {'scope' => scope},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:put, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 201
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#create_by_id(policy_assignment_id, parameters, custom_headers: nil) ⇒ PolicyAssignment

Creates a policy assignment by ID.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

create. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



784
785
786
787
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 784

def create_by_id(policy_assignment_id, parameters, custom_headers:nil)
  response = create_by_id_async(policy_assignment_id, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end

#create_by_id_async(policy_assignment_id, parameters, custom_headers: nil) ⇒ Concurrent::Promise

Creates a policy assignment by ID.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

create. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. to the HTTP request.



835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 835

def create_by_id_async(policy_assignment_id, parameters, custom_headers:nil)
  fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
  request_content = @client.serialize(request_mapper,  parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = '{policyAssignmentId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
      query_params: {'api-version' => @client.api_version},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:put, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 201
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#create_by_id_with_http_info(policy_assignment_id, parameters, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Creates a policy assignment by ID.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group. When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

create. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



810
811
812
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 810

def create_by_id_with_http_info(policy_assignment_id, parameters, custom_headers:nil)
  create_by_id_async(policy_assignment_id, parameters, custom_headers:custom_headers).value!
end

#create_with_http_info(scope, policy_assignment_name, parameters, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Creates a policy assignment.

Policy assignments are inherited by child resources. For example, when you apply a policy to a resource group that policy is assigned to all resources in the group.

will be added to the HTTP request.



157
158
159
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 157

def create_with_http_info(scope, policy_assignment_name, parameters, custom_headers:nil)
  create_async(scope, policy_assignment_name, parameters, custom_headers:custom_headers).value!
end

#delete(scope, policy_assignment_name, custom_headers: nil) ⇒ PolicyAssignment

Deletes a policy assignment.

delete. will be added to the HTTP request.



36
37
38
39
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 36

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

#delete_async(scope, policy_assignment_name, custom_headers: nil) ⇒ Concurrent::Promise

Deletes a policy assignment.

delete. to the HTTP request.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 67

def delete_async(scope, policy_assignment_name, custom_headers:nil)
  fail ArgumentError, 'scope is nil' if scope.nil?
  fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyAssignmentName' => policy_assignment_name},
      skip_encoding_path_params: {'scope' => scope},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#delete_by_id(policy_assignment_id, custom_headers: nil) ⇒ PolicyAssignment

Deletes a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

delete. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



665
666
667
668
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 665

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

#delete_by_id_async(policy_assignment_id, custom_headers: nil) ⇒ Concurrent::Promise

Deletes a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

delete. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. to the HTTP request.



710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 710

def delete_by_id_async(policy_assignment_id, custom_headers:nil)
  fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{policyAssignmentId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#delete_by_id_with_http_info(policy_assignment_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

delete. Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



688
689
690
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 688

def delete_by_id_with_http_info(policy_assignment_id, custom_headers:nil)
  delete_by_id_async(policy_assignment_id, custom_headers:custom_headers).value!
end

#delete_with_http_info(scope, policy_assignment_name, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Deletes a policy assignment.

delete. will be added to the HTTP request.



52
53
54
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 52

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

#get(scope, policy_assignment_name, custom_headers: nil) ⇒ PolicyAssignment

Gets a policy assignment.

get. will be added to the HTTP request.



250
251
252
253
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 250

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

#get_async(scope, policy_assignment_name, custom_headers: nil) ⇒ Concurrent::Promise

Gets a policy assignment.

get. to the HTTP request.



281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 281

def get_async(scope, policy_assignment_name, custom_headers:nil)
  fail ArgumentError, 'scope is nil' if scope.nil?
  fail ArgumentError, 'policy_assignment_name is nil' if policy_assignment_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{scope}/providers/Microsoft.Authorization/policyassignments/{policyAssignmentName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyAssignmentName' => policy_assignment_name},
      skip_encoding_path_params: {'scope' => scope},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#get_by_id(policy_assignment_id, custom_headers: nil) ⇒ PolicyAssignment

Gets a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



914
915
916
917
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 914

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

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

Gets a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. to the HTTP request.



959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 959

def get_by_id_async(policy_assignment_id, custom_headers:nil)
  fail ArgumentError, 'policy_assignment_id is nil' if policy_assignment_id.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{policyAssignmentId}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'policyAssignmentId' => policy_assignment_id},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignment.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#get_by_id_with_http_info(policy_assignment_id, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets a policy assignment by ID.

When providing a scope for the assignment, use ‘/subscriptions/subscription-id/’ for subscriptions, ‘/subscriptions/subscription-id/resourceGroups/resource-group-name’ for resource groups, and ‘/subscriptions/subscription-id/resourceGroups/resource-group-name/providers/resource-provider-namespace/resource-type/resource-name’ for resources.

Use the format ‘/scope/providers/Microsoft.Authorization/policyAssignments/policy-assignment-name’. will be added to the HTTP request.



937
938
939
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 937

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

#get_with_http_info(scope, policy_assignment_name, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets a policy assignment.

get. will be added to the HTTP request.



266
267
268
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 266

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

#list(filter: nil, custom_headers: nil) ⇒ Array<PolicyAssignment>

Gets all the policy assignments for a subscription.

will be added to the HTTP request.



567
568
569
570
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 567

def list(filter:nil, custom_headers:nil)
  first_page = list_as_lazy(filter:filter, custom_headers:custom_headers)
  first_page.get_all_items
end

#list_as_lazy(filter: nil, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets all the policy assignments for a subscription.

will be added to the HTTP request.

the response.



1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1344

def list_as_lazy(filter:nil, custom_headers:nil)
  response = list_async(filter:filter, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end

#list_async(filter: nil, custom_headers: nil) ⇒ Concurrent::Promise

Gets all the policy assignments for a subscription.

to the HTTP request.



594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 594

def list_async(filter:nil, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyassignments'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id},
      query_params: {'$filter' => filter,'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_for_resource(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter: nil, custom_headers: nil) ⇒ Array<PolicyAssignment>

Gets policy assignments for a resource.

the resource. The name is case insensitive. provider. assignments. will be added to the HTTP request.



453
454
455
456
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 453

def list_for_resource(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
  first_page = list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers)
  first_page.get_all_items
end

#list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter: nil, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets policy assignments for a resource.

the resource. The name is case insensitive. provider. assignments. will be added to the HTTP request.

the response.



1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1323

def list_for_resource_as_lazy(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
  response = list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_for_resource_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end

#list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter: nil, custom_headers: nil) ⇒ Concurrent::Promise

Gets policy assignments for a resource.

the resource. The name is case insensitive. provider. assignments. to the HTTP request.



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 496

def list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
  fail ArgumentError, 'resource_provider_namespace is nil' if resource_provider_namespace.nil?
  fail ArgumentError, 'parent_resource_path is nil' if parent_resource_path.nil?
  fail ArgumentError, 'resource_type is nil' if resource_type.nil?
  fail ArgumentError, 'resource_name is nil' if resource_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/policyassignments'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'resourceProviderNamespace' => resource_provider_namespace,'resourceName' => resource_name,'subscriptionId' => @client.subscription_id},
      skip_encoding_path_params: {'parentResourcePath' => parent_resource_path,'resourceType' => resource_type},
      query_params: {'$filter' => filter,'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_for_resource_group(resource_group_name, filter: nil, custom_headers: nil) ⇒ Array<PolicyAssignment>

Gets policy assignments for the resource group.

contains policy assignments. will be added to the HTTP request.



347
348
349
350
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 347

def list_for_resource_group(resource_group_name, filter:nil, custom_headers:nil)
  first_page = list_for_resource_group_as_lazy(resource_group_name, filter:filter, custom_headers:custom_headers)
  first_page.get_all_items
end

#list_for_resource_group_as_lazy(resource_group_name, filter: nil, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets policy assignments for the resource group.

contains policy assignments. will be added to the HTTP request.

the response.



1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1294

def list_for_resource_group_as_lazy(resource_group_name, filter:nil, custom_headers:nil)
  response = list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end

#list_for_resource_group_async(resource_group_name, filter: nil, custom_headers: nil) ⇒ Concurrent::Promise

Gets policy assignments for the resource group.

contains policy assignments. to the HTTP request.



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 378

def list_for_resource_group_async(resource_group_name, filter:nil, custom_headers:nil)
  fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1
  fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/policyAssignments'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @client.api_version},
      skip_encoding_query_params: {'$filter' => filter},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_for_resource_group_next(next_page_link, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets policy assignments for the resource group.

to List operation. will be added to the HTTP request.



1022
1023
1024
1025
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1022

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

#list_for_resource_group_next_async(next_page_link, custom_headers: nil) ⇒ Concurrent::Promise

Gets policy assignments for the resource group.

to List operation. to the HTTP request.



1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1051

def list_for_resource_group_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_for_resource_group_next_with_http_info(next_page_link, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets policy assignments for the resource group.

to List operation. will be added to the HTTP request.



1037
1038
1039
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1037

def list_for_resource_group_next_with_http_info(next_page_link, custom_headers:nil)
  list_for_resource_group_next_async(next_page_link, custom_headers:custom_headers).value!
end

#list_for_resource_group_with_http_info(resource_group_name, filter: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets policy assignments for the resource group.

contains policy assignments. will be added to the HTTP request.



363
364
365
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 363

def list_for_resource_group_with_http_info(resource_group_name, filter:nil, custom_headers:nil)
  list_for_resource_group_async(resource_group_name, filter:filter, custom_headers:custom_headers).value!
end

#list_for_resource_next(next_page_link, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets policy assignments for a resource.

to List operation. will be added to the HTTP request.



1112
1113
1114
1115
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1112

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

#list_for_resource_next_async(next_page_link, custom_headers: nil) ⇒ Concurrent::Promise

Gets policy assignments for a resource.

to List operation. to the HTTP request.



1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1141

def list_for_resource_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_for_resource_next_with_http_info(next_page_link, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets policy assignments for a resource.

to List operation. will be added to the HTTP request.



1127
1128
1129
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1127

def list_for_resource_next_with_http_info(next_page_link, custom_headers:nil)
  list_for_resource_next_async(next_page_link, custom_headers:custom_headers).value!
end

#list_for_resource_with_http_info(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets policy assignments for a resource.

the resource. The name is case insensitive. provider. assignments. will be added to the HTTP request.



475
476
477
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 475

def list_for_resource_with_http_info(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:nil, custom_headers:nil)
  list_for_resource_async(resource_group_name, resource_provider_namespace, parent_resource_path, resource_type, resource_name, filter:filter, custom_headers:custom_headers).value!
end

#list_next(next_page_link, custom_headers: nil) ⇒ PolicyAssignmentListResult

Gets all the policy assignments for a subscription.

to List operation. will be added to the HTTP request.



1202
1203
1204
1205
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1202

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

#list_next_async(next_page_link, custom_headers: nil) ⇒ Concurrent::Promise

Gets all the policy assignments for a subscription.

to List operation. to the HTTP request.



1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1231

def list_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = '{nextLink}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      skip_encoding_path_params: {'nextLink' => next_page_link},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2016_04_01::Models::PolicyAssignmentListResult.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end

#list_next_with_http_info(next_page_link, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets all the policy assignments for a subscription.

to List operation. will be added to the HTTP request.



1217
1218
1219
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1217

def list_next_with_http_info(next_page_link, custom_headers:nil)
  list_next_async(next_page_link, custom_headers:custom_headers).value!
end

#list_with_http_info(filter: nil, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Gets all the policy assignments for a subscription.

will be added to the HTTP request.



581
582
583
# File 'lib/2016-04-01/generated/azure_mgmt_policy/policy_assignments.rb', line 581

def list_with_http_info(filter:nil, custom_headers:nil)
  list_async(filter:filter, custom_headers:custom_headers).value!
end