class Azure::Policy::Mgmt::V2018_03_01::PolicyDefinitions

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

Attributes

client[R]

@return [PolicyClient] reference to the PolicyClient

Public Class Methods

new(client) click to toggle source

Creates and initializes a new instance of the PolicyDefinitions class. @param client service class for accessing basic functionality.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 18
def initialize(client)
  @client = client
end

Public Instance Methods

create_or_update(policy_definition_name, parameters, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a subscription.

This operation creates or updates a policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinition] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 39
def create_or_update(policy_definition_name, parameters, custom_headers:nil)
  response = create_or_update_async(policy_definition_name, parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_or_update_async(policy_definition_name, parameters, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a subscription.

This operation creates or updates a policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 76
def create_or_update_async(policy_definition_name, parameters, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
  fail ArgumentError, 'parameters is nil' if parameters.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?

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

  path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinition.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_or_update_at_management_group(policy_definition_name, parameters, management_group_id, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a management group.

This operation creates or updates a policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinition] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 444
def create_or_update_at_management_group(policy_definition_name, parameters, management_group_id, custom_headers:nil)
  response = create_or_update_at_management_group_async(policy_definition_name, parameters, management_group_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_or_update_at_management_group_async(policy_definition_name, parameters, management_group_id, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a management group.

This operation creates or updates a policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param management_group_id [String] The ID of the management group. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 483
def create_or_update_at_management_group_async(policy_definition_name, parameters, management_group_id, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
  fail ArgumentError, 'parameters is nil' if parameters.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_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?

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

  path_template = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 201
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinition.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_or_update_at_management_group_with_http_info(policy_definition_name, parameters, management_group_id, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a management group.

This operation creates or updates a policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 464
def create_or_update_at_management_group_with_http_info(policy_definition_name, parameters, management_group_id, custom_headers:nil)
  create_or_update_at_management_group_async(policy_definition_name, parameters, management_group_id, custom_headers:custom_headers).value!
end
create_or_update_with_http_info(policy_definition_name, parameters, custom_headers:nil) click to toggle source

Creates or updates a policy definition in a subscription.

This operation creates or updates a policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to create. @param parameters [PolicyDefinition] The policy definition properties. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 58
def create_or_update_with_http_info(policy_definition_name, parameters, custom_headers:nil)
  create_or_update_async(policy_definition_name, parameters, custom_headers:custom_headers).value!
end
delete(policy_definition_name, custom_headers:nil) click to toggle source

Deletes a policy definition in a subscription.

This operation deletes the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 150
def delete(policy_definition_name, custom_headers:nil)
  response = delete_async(policy_definition_name, custom_headers:custom_headers).value!
  nil
end
delete_async(policy_definition_name, custom_headers:nil) click to toggle source

Deletes a policy definition in a subscription.

This operation deletes the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 185
def delete_async(policy_definition_name, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_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}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyDefinitionName' => policy_definition_name,'subscriptionId' => @client.subscription_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 == 204 || status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_at_management_group(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Deletes a policy definition in a management group.

This operation deletes the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 558
def delete_at_management_group(policy_definition_name, management_group_id, custom_headers:nil)
  response = delete_at_management_group_async(policy_definition_name, management_group_id, custom_headers:custom_headers).value!
  nil
end
delete_at_management_group_async(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Deletes a policy definition in a management group.

This operation deletes the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param management_group_id [String] The ID of the management group. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 595
def delete_at_management_group_async(policy_definition_name, management_group_id, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_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 = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'policyDefinitionName' => policy_definition_name,'managementGroupId' => management_group_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 == 204 || status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_at_management_group_with_http_info(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Deletes a policy definition in a management group.

This operation deletes the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 577
def delete_at_management_group_with_http_info(policy_definition_name, management_group_id, custom_headers:nil)
  delete_at_management_group_async(policy_definition_name, management_group_id, custom_headers:custom_headers).value!
end
delete_with_http_info(policy_definition_name, custom_headers:nil) click to toggle source

Deletes a policy definition in a subscription.

This operation deletes the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to delete. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 168
def delete_with_http_info(policy_definition_name, custom_headers:nil)
  delete_async(policy_definition_name, custom_headers:custom_headers).value!
end
get(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a policy definition in a subscription.

This operation retrieves the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinition] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 242
def get(policy_definition_name, custom_headers:nil)
  response = get_async(policy_definition_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_async(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a policy definition in a subscription.

This operation retrieves the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 277
def get_async(policy_definition_name, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_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}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinition.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_at_management_group(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Retrieve a policy definition in a management group.

This operation retrieves the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinition] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 653
def get_at_management_group(policy_definition_name, management_group_id, custom_headers:nil)
  response = get_at_management_group_async(policy_definition_name, management_group_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_at_management_group_async(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Retrieve a policy definition in a management group.

This operation retrieves the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param management_group_id [String] The ID of the management group. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 690
def get_at_management_group_async(policy_definition_name, management_group_id, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_name.nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_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 = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinition.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_at_management_group_with_http_info(policy_definition_name, management_group_id, custom_headers:nil) click to toggle source

Retrieve a policy definition in a management group.

This operation retrieves the policy definition in the given management group with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 672
def get_at_management_group_with_http_info(policy_definition_name, management_group_id, custom_headers:nil)
  get_at_management_group_async(policy_definition_name, management_group_id, custom_headers:custom_headers).value!
end
get_built_in(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a built-in policy definition.

This operation retrieves the built-in policy definition with the given name.

@param policy_definition_name [String] The name of the built-in policy definition to get. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinition] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 343
def get_built_in(policy_definition_name, custom_headers:nil)
  response = get_built_in_async(policy_definition_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_built_in_async(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a built-in policy definition.

This operation retrieves the built-in policy definition with the given name.

@param policy_definition_name [String] The name of the built-in policy definition to get. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 376
def get_built_in_async(policy_definition_name, custom_headers:nil)
  fail ArgumentError, 'policy_definition_name is nil' if policy_definition_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 = 'providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinition.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_built_in_with_http_info(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a built-in policy definition.

This operation retrieves the built-in policy definition with the given name.

@param policy_definition_name [String] The name of the built-in policy definition to get. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 360
def get_built_in_with_http_info(policy_definition_name, custom_headers:nil)
  get_built_in_async(policy_definition_name, custom_headers:custom_headers).value!
end
get_with_http_info(policy_definition_name, custom_headers:nil) click to toggle source

Retrieves a policy definition in a subscription.

This operation retrieves the policy definition in the given subscription with the given name.

@param policy_definition_name [String] The name of the policy definition to get. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 260
def get_with_http_info(policy_definition_name, custom_headers:nil)
  get_async(policy_definition_name, custom_headers:custom_headers).value!
end
list(custom_headers:nil) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array<PolicyDefinition>] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 755
def list(custom_headers:nil)
  first_page = list_as_lazy(custom_headers:custom_headers)
  first_page.get_all_items
end
list_as_lazy(custom_headers:nil) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] which provide lazy access to pages of the response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1333
def list_as_lazy(custom_headers:nil)
  response = list_async(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(custom_headers:nil) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 786
def list_async(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/policyDefinitions'

  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: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

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

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

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array<PolicyDefinition>] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 849
def list_built_in(custom_headers:nil)
  first_page = list_built_in_as_lazy(custom_headers:custom_headers)
  first_page.get_all_items
end
list_built_in_as_lazy(custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] which provide lazy access to pages of the response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1355
def list_built_in_as_lazy(custom_headers:nil)
  response = list_built_in_async(custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_built_in_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end
list_built_in_async(custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 878
def list_built_in_async(custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?


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

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

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinitionListResult.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_built_in_next(next_page_link, custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1138
def list_built_in_next(next_page_link, custom_headers:nil)
  response = list_built_in_next_async(next_page_link, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_built_in_next_async(next_page_link, custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1171
def list_built_in_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


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

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

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinitionListResult.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_built_in_next_with_http_info(next_page_link, custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1155
def list_built_in_next_with_http_info(next_page_link, custom_headers:nil)
  list_built_in_next_async(next_page_link, custom_headers:custom_headers).value!
end
list_built_in_with_http_info(custom_headers:nil) click to toggle source

Retrieve built-in policy definitions

This operation retrieves a list of all the built-in policy definitions.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 864
def list_built_in_with_http_info(custom_headers:nil)
  list_built_in_async(custom_headers:custom_headers).value!
end
list_by_management_group(management_group_id, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array<PolicyDefinition>] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 941
def list_by_management_group(management_group_id, custom_headers:nil)
  first_page = list_by_management_group_as_lazy(management_group_id, custom_headers:custom_headers)
  first_page.get_all_items
end
list_by_management_group_as_lazy(management_group_id, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] which provide lazy access to pages of the response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1379
def list_by_management_group_as_lazy(management_group_id, custom_headers:nil)
  response = list_by_management_group_async(management_group_id, custom_headers:custom_headers).value!
  unless response.nil?
    page = response.body
    page.next_method = Proc.new do |next_page_link|
      list_by_management_group_next_async(next_page_link, custom_headers:custom_headers)
    end
    page
  end
end
list_by_management_group_async(management_group_id, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param management_group_id [String] The ID of the management group. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 974
def list_by_management_group_async(management_group_id, custom_headers:nil)
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'management_group_id is nil' if management_group_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 = 'providers/Microsoft.Management/managementgroups/{managementGroupId}/providers/Microsoft.Authorization/policyDefinitions'

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinitionListResult.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_by_management_group_next(next_page_link, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1235
def list_by_management_group_next(next_page_link, custom_headers:nil)
  response = list_by_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_by_management_group_next_async(next_page_link, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1270
def list_by_management_group_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


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

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

  request_url = @base_url || @client.base_url

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

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

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::Policy::Mgmt::V2018_03_01::Models::PolicyDefinitionListResult.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_by_management_group_next_with_http_info(next_page_link, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1253
def list_by_management_group_next_with_http_info(next_page_link, custom_headers:nil)
  list_by_management_group_next_async(next_page_link, custom_headers:custom_headers).value!
end
list_by_management_group_with_http_info(management_group_id, custom_headers:nil) click to toggle source

Retrieve policy definitions in a management group

This operation retrieves a list of all the policy definitions in a given management group.

@param management_group_id [String] The ID of the management group. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 958
def list_by_management_group_with_http_info(management_group_id, custom_headers:nil)
  list_by_management_group_async(management_group_id, custom_headers:custom_headers).value!
end
list_next(next_page_link, custom_headers:nil) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PolicyDefinitionListResult] operation results.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1040
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) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1075
def list_next_async(next_page_link, custom_headers:nil)
  fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?


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

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

  request_url = @base_url || @client.base_url

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

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

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

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param next_page_link [String] The NextLink from the previous successful call to List operation. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 1058
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(custom_headers:nil) click to toggle source

Retrieves policy definitions in a subscription

This operation retrieves a list of all the policy definitions in a given subscription.

@param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/2018-03-01/generated/azure_mgmt_policy/policy_definitions.rb, line 771
def list_with_http_info(custom_headers:nil)
  list_async(custom_headers:custom_headers).value!
end