Class: Azure::Policy::Mgmt::V2018_05_01::PolicyAssignments

Inherits:
Object
  • Object
show all
Includes:
MsRestAzure
Defined in:
lib/2018-05-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/2018-05-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/2018-05-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/2018-05-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/2018-05-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::V2018_05_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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1080
1081
1082
1083
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1080

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.



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

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::V2018_05_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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1111
1112
1113
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1111

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/2018-05-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/2018-05-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/2018-05-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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



948
949
950
951
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 948

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.



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
1052
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1001

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



975
976
977
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 975

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/2018-05-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/2018-05-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/2018-05-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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1224
1225
1226
1227
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1224

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.



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
1328
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1277

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1251
1252
1253
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1251

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/2018-05-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.



816
817
818
819
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 816

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



1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1890

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.



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
918
919
920
921
922
923
924
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 873

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

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

    result
  end

  promise.execute
end

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

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/2018-05-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



1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1854

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/2018-05-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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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/2018-05-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



1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1793

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/2018-05-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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1354
1355
1356
1357
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1354

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.



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
1456
1457
1458
1459
1460
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1411

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1383
1384
1385
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1383

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/2018-05-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.



1500
1501
1502
1503
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1500

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.



1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1585

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1543
1544
1545
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1543

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/2018-05-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.



1659
1660
1661
1662
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1659

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.



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
1762
1763
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1714

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 MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_05_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.



1687
1688
1689
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 1687

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.



845
846
847
# File 'lib/2018-05-01/generated/azure_mgmt_policy/policy_assignments.rb', line 845

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