Class: Azure::Policy::Mgmt::V2019_09_01::PolicyAssignments

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

Parameters:

  • client

    service class for accessing basic functionality.



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

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientPolicyClient (readonly)

Returns reference to the PolicyClient.

Returns:



23
24
25
# File 'lib/2019-09-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 or updates a policy assignment.

This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment.

  • parameters (PolicyAssignment)

    Parameters for the policy assignment.

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



181
182
183
184
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 181

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 or updates a policy assignment.

This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment.

  • parameters (PolicyAssignment)

    Parameters for the policy assignment.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 236

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::V2019_09_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::V2019_09_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 or updates a policy assignment.

This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

create. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

  • parameters (PolicyAssignment)

    Parameters for policy assignment.

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



1207
1208
1209
1210
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1207

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 or updates a policy assignment.

This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

create. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

  • parameters (PolicyAssignment)

    Parameters for policy assignment.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1268

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::V2019_09_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::V2019_09_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 or updates a policy assignment.

This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

create. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

  • parameters (PolicyAssignment)

    Parameters for policy assignment.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1238
1239
1240
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1238

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 or updates a policy assignment.

This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment.

  • parameters (PolicyAssignment)

    Parameters for the policy assignment.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



209
210
211
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 209

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.

This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding ‘/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ delete. will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



48
49
50
51
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 48

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.

This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding ‘/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ delete. to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 103

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 || status_code == 204
      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::V2019_09_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.

This operation deletes the policy with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid formats for scope are: ‘/providers/Microsoft.Management/managementGroups/managementGroup’ (management group), ‘/subscriptions/subscriptionId’ (subscription), ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’ (resource group), or ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ (resource).

delete. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



1075
1076
1077
1078
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1075

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.

This operation deletes the policy with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid formats for scope are: ‘/providers/Microsoft.Management/managementGroups/managementGroup’ (management group), ‘/subscriptions/subscriptionId’ (subscription), ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’ (resource group), or ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ (resource).

delete. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
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
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1128

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 || status_code == 204
      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::V2019_09_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.

This operation deletes the policy with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid formats for scope are: ‘/providers/Microsoft.Management/managementGroups/managementGroup’ (management group), ‘/subscriptions/subscriptionId’ (subscription), ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’ (resource group), or ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ (resource).

delete. Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1102
1103
1104
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1102

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.

This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding ‘/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ delete. will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



76
77
78
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 76

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

Retrieves a policy assignment.

This operation retrieves a single policy assignment, given its name and the scope it was created at.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ get. will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



320
321
322
323
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 320

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

Retrieves a policy assignment.

This operation retrieves a single policy assignment, given its name and the scope it was created at.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ get. to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 371

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::V2019_09_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

Retrieves the policy assignment with the given ID.

The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to get.

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

    A hash of custom headers that

Returns:

  • (PolicyAssignment)

    operation results.



1351
1352
1353
1354
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1351

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

Retrieves the policy assignment with the given ID.

The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to get.

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1404

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::V2019_09_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

Retrieves the policy assignment with the given ID.

The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. Valid scopes are: management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’.

Use the format ‘scope/providers/Microsoft.Authorization/policyAssignments/policyAssignmentName’. will be added to the HTTP request.

Parameters:

  • policy_assignment_id (String)

    The ID of the policy assignment to get.

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1378
1379
1380
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1378

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

Retrieves a policy assignment.

This operation retrieves a single policy assignment, given its name and the scope it was created at.

management group (format: ‘/providers/Microsoft.Management/managementGroups/managementGroup’), subscription (format: ‘/subscriptions/subscriptionId’), resource group (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName’, or resource (format: ‘/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/resourceProviderNamespace/[parentResourcePath/]resourceType/resourceName’ get. will be added to the HTTP request.

Parameters:

  • scope (String)

    The scope of the policy assignment. Valid scopes are:

  • policy_assignment_name (String)

    The name of the policy assignment to

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



346
347
348
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 346

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>

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (Array<PolicyAssignment>)

    operation results.



943
944
945
946
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 943

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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

the response.

Parameters:

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    which provide lazy access to pages of



2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 2167

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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. to the HTTP request.

Parameters:

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1000

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::V2019_09_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_management_group(management_group_id, filter, custom_headers: nil) ⇒ Array<PolicyAssignment>

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. A filter is required when listing policy assignments at management group scope. will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    The ID of the management group.

  • filter (String)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (Array<PolicyAssignment>)

    operation results.



813
814
815
816
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 813

def list_for_management_group(management_group_id, filter, custom_headers:nil)
  first_page = list_for_management_group_as_lazy(management_group_id, filter, custom_headers:custom_headers)
  first_page.get_all_items
end

#list_for_management_group_as_lazy(management_group_id, filter, custom_headers: nil) ⇒ PolicyAssignmentListResult

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. A filter is required when listing policy assignments at management group scope. will be added to the HTTP request.

the response.

Parameters:

  • management_group_id (String)

    The ID of the management group.

  • filter (String)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    which provide lazy access to pages of



2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 2131

def list_for_management_group_as_lazy(management_group_id, filter, custom_headers:nil)
  response = list_for_management_group_async(management_group_id, filter, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_for_management_group_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end

#list_for_management_group_async(management_group_id, filter, custom_headers: nil) ⇒ Concurrent::Promise

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. A filter is required when listing policy assignments at management group scope. to the HTTP request.

Parameters:

  • management_group_id (String)

    The ID of the management group.

  • filter (String)

    The filter to apply on the operation. Valid values for

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 864

def list_for_management_group_async(management_group_id, filter, custom_headers:nil)
  fail ArgumentError, 'management_group_id is nil' if management_group_id.nil?
  fail ArgumentError, 'filter is nil' if filter.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 = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyAssignments'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'managementGroupId' => management_group_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::V2019_09_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_management_group_next(next_page_link, custom_headers: nil) ⇒ PolicyAssignmentListResult

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    operation results.



1782
1783
1784
1785
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1782

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

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

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

to List operation. to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1829

def list_for_management_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::V2019_09_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_management_group_next_with_http_info(next_page_link, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1806
1807
1808
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1806

def list_for_management_group_next_with_http_info(next_page_link, custom_headers:nil)
  list_for_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
end

#list_for_management_group_with_http_info(management_group_id, filter, custom_headers: nil) ⇒ MsRestAzure::AzureOperationResponse

Retrieves all policy assignments that apply to a management group.

This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group’s ancestors. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the management group.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. A filter is required when listing policy assignments at management group scope. will be added to the HTTP request.

Parameters:

  • management_group_id (String)

    The ID of the management group.

  • filter (String)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



839
840
841
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 839

def list_for_management_group_with_http_info(management_group_id, filter, custom_headers:nil)
  list_for_management_group_async(management_group_id, filter, custom_headers:custom_headers).value!
end

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

the resource. provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) string if there is none. name of a web app is ‘sites’ (from Microsoft.Web/sites). $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group containing

  • resource_provider_namespace (String)

    The namespace of the resource

  • parent_resource_path (String)

    The parent resource path. Use empty

  • resource_type (String)

    The resource type name. For example the type

  • resource_name (String)

    The name of the resource.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (Array<PolicyAssignment>)

    operation results.



623
624
625
626
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 623

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

the resource. provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) string if there is none. name of a web app is ‘sites’ (from Microsoft.Web/sites). $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

the response.

Parameters:

  • resource_group_name (String)

    The name of the resource group containing

  • resource_provider_namespace (String)

    The namespace of the resource

  • parent_resource_path (String)

    The parent resource path. Use empty

  • resource_type (String)

    The resource type name. For example the type

  • resource_name (String)

    The name of the resource.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    which provide lazy access to pages of



2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 2098

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

the resource. provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) string if there is none. name of a web app is ‘sites’ (from Microsoft.Web/sites). $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group containing

  • resource_provider_namespace (String)

    The namespace of the resource

  • parent_resource_path (String)

    The parent resource path. Use empty

  • resource_type (String)

    The resource type name. For example the type

  • resource_name (String)

    The name of the resource.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 730

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::V2019_09_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>

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

contains policy assignments. $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group that

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (Array<PolicyAssignment>)

    operation results.



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

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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

contains policy assignments. $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

the response.

Parameters:

  • resource_group_name (String)

    The name of the resource group that

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    which provide lazy access to pages of



2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 2037

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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

contains policy assignments. $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group that

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



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
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 516

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::V2019_09_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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    operation results.



1481
1482
1483
1484
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1481

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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

to List operation. to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1538

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::V2019_09_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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1510
1511
1512
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1510

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

Retrieves all policy assignments that apply to a resource group.

This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource group.

contains policy assignments. $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group that

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



485
486
487
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 485

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    operation results.



1627
1628
1629
1630
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1627

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

to List operation. to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1712

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::V2019_09_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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1670
1671
1672
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1670

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

Retrieves all policy assignments that apply to a resource.

This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ”). For example a web app could be specified as (resourceProviderNamespace == ‘Microsoft.Web’, parentResourcePath == ”, resourceType == ‘sites’, resourceName == ‘MyWebApp’). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as (resourceProviderNamespace == ‘Microsoft.Compute’, parentResourcePath == ‘virtualMachines/MyVirtualMachine’, resourceType == ‘domainNames’, resourceName == ‘MyComputerName’). A convenient alternative to providing the namespace and type name separately is to provide both in the resourceType parameter, format: (resourceProviderNamespace == ”, parentResourcePath == ”, resourceType == ‘Microsoft.Web/sites’, resourceName == ‘MyWebApp’).

the resource. provider. For example, the namespace of a virtual machine is Microsoft.Compute (from Microsoft.Compute/virtualMachines) string if there is none. name of a web app is ‘sites’ (from Microsoft.Web/sites). $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • resource_group_name (String)

    The name of the resource group containing

  • resource_provider_namespace (String)

    The namespace of the resource

  • parent_resource_path (String)

    The parent resource path. Use empty

  • resource_type (String)

    The resource type name. For example the type

  • resource_name (String)

    The name of the resource.

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



677
678
679
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 677

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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (PolicyAssignmentListResult)

    operation results.



1903
1904
1905
1906
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1903

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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

to List operation. to the HTTP request.

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

  • A (Hash{String => String})

    hash of custom headers that will be added

Returns:

  • (Concurrent::Promise)

    Promise object which holds the HTTP response.



1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1958

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::V2019_09_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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

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

Parameters:

  • next_page_link (String)

    The NextLink from the previous successful call

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



1931
1932
1933
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1931

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

Retrieves all policy assignments that apply to a subscription.

This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=policyDefinitionId eq ‘value’ is provided, the returned list includes all policy assignments of the policy definition whose id is value.

$filter are: ‘atScope()’ or ‘policyDefinitionId eq ’value”. If $filter is not provided, no filtering is performed. will be added to the HTTP request.

Parameters:

  • filter (String) (defaults to: nil)

    The filter to apply on the operation. Valid values for

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

    A hash of custom headers that

Returns:

  • (MsRestAzure::AzureOperationResponse)

    HTTP response information.



972
973
974
# File 'lib/2019-09-01/generated/azure_mgmt_policy/policy_assignments.rb', line 972

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