class Azure::Cosmosdb::Mgmt::V2019_08_01::DatabaseAccounts

Azure Cosmos DB Database Service Resource Provider REST API

Attributes

client[R]

@return [CosmosDBManagementClient] reference to the CosmosDBManagementClient

Public Class Methods

new(client) click to toggle source

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

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 17
def initialize(client)
  @client = client
end

Public Instance Methods

begin_create_or_update(resource_group_name, account_name, create_update_parameters, custom_headers:nil) click to toggle source

Creates or updates an Azure Cosmos DB database account. The “Update” method is preferred when performing updates on an account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param create_update_parameters [DatabaseAccountCreateUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountGetResults] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1563
def begin_create_or_update(resource_group_name, account_name, create_update_parameters, custom_headers:nil)
  response = begin_create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:nil) click to toggle source

Creates or updates an Azure Cosmos DB database account. The “Update” method is preferred when performing updates on an account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param create_update_parameters [DatabaseAccountCreateUpdateParameters] The parameters to provide for the current database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1598
def begin_create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'create_update_parameters is nil' if create_update_parameters.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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountCreateUpdateParameters.mapper()
  request_content = @client.serialize(request_mapper,  create_update_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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 == 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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountGetResults.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
begin_create_or_update_with_http_info(resource_group_name, account_name, create_update_parameters, custom_headers:nil) click to toggle source

Creates or updates an Azure Cosmos DB database account. The “Update” method is preferred when performing updates on an account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param create_update_parameters [DatabaseAccountCreateUpdateParameters] The parameters to provide for the current database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1581
def begin_create_or_update_with_http_info(resource_group_name, account_name, create_update_parameters, custom_headers:nil)
  begin_create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:custom_headers).value!
end
begin_delete(resource_group_name, account_name, custom_headers:nil) click to toggle source

Deletes an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1676
def begin_delete(resource_group_name, account_name, custom_headers:nil)
  response = begin_delete_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  nil
end
begin_delete_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Deletes an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1705
def begin_delete_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'

  request_url = @base_url || @client.base_url

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

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

    result
  end

  promise.execute
end
begin_delete_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Deletes an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1691
def begin_delete_with_http_info(resource_group_name, account_name, custom_headers:nil)
  begin_delete_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
begin_failover_priority_change(resource_group_name, account_name, failover_parameters, custom_headers:nil) click to toggle source

Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param failover_parameters [FailoverPolicies] The new failover policies for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1770
def begin_failover_priority_change(resource_group_name, account_name, failover_parameters, custom_headers:nil)
  response = begin_failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:custom_headers).value!
  nil
end
begin_failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:nil) click to toggle source

Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param failover_parameters [FailoverPolicies] The new failover policies for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1809
def begin_failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'failover_parameters is nil' if failover_parameters.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::Cosmosdb::Mgmt::V2019_08_01::Models::FailoverPolicies.mapper()
  request_content = @client.serialize(request_mapper,  failover_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/failoverPriorityChange'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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(:post, 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 == 202 || status_code == 204
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

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

    result
  end

  promise.execute
end
begin_failover_priority_change_with_http_info(resource_group_name, account_name, failover_parameters, custom_headers:nil) click to toggle source

Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param failover_parameters [FailoverPolicies] The new failover policies for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1790
def begin_failover_priority_change_with_http_info(resource_group_name, account_name, failover_parameters, custom_headers:nil)
  begin_failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:custom_headers).value!
end
begin_offline_region(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil) click to toggle source

Offline the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_offline [RegionForOnlineOffline] Cosmos DB region to offline for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1880
def begin_offline_region(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil)
  response = begin_offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:custom_headers).value!
  nil
end
begin_offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil) click to toggle source

Offline the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_offline [RegionForOnlineOffline] Cosmos DB region to offline for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1915
def begin_offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'region_parameter_for_offline is nil' if region_parameter_for_offline.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::Cosmosdb::Mgmt::V2019_08_01::Models::RegionForOnlineOffline.mapper()
  request_content = @client.serialize(request_mapper,  region_parameter_for_offline)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/offlineRegion'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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(:post, 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 == 202
      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?

    result
  end

  promise.execute
end
begin_offline_region_with_http_info(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil) click to toggle source

Offline the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_offline [RegionForOnlineOffline] Cosmos DB region to offline for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1898
def begin_offline_region_with_http_info(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil)
  begin_offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:custom_headers).value!
end
begin_online_region(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil) click to toggle source

Online the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_online [RegionForOnlineOffline] Cosmos DB region to online for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1986
def begin_online_region(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil)
  response = begin_online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:custom_headers).value!
  nil
end
begin_online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil) click to toggle source

Online the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_online [RegionForOnlineOffline] Cosmos DB region to online for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 2021
def begin_online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'region_parameter_for_online is nil' if region_parameter_for_online.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::Cosmosdb::Mgmt::V2019_08_01::Models::RegionForOnlineOffline.mapper()
  request_content = @client.serialize(request_mapper,  region_parameter_for_online)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/onlineRegion'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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(:post, 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 == 202
      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?

    result
  end

  promise.execute
end
begin_online_region_with_http_info(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil) click to toggle source

Online the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_online [RegionForOnlineOffline] Cosmos DB region to online for the database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 2004
def begin_online_region_with_http_info(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil)
  begin_online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:custom_headers).value!
end
begin_regenerate_key(resource_group_name, account_name, key_to_regenerate, custom_headers:nil) click to toggle source

Regenerates an access key for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param key_to_regenerate [DatabaseAccountRegenerateKeyParameters] The name of the key to regenerate. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 2091
def begin_regenerate_key(resource_group_name, account_name, key_to_regenerate, custom_headers:nil)
  response = begin_regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:custom_headers).value!
  nil
end
begin_regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:nil) click to toggle source

Regenerates an access key for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param key_to_regenerate [DatabaseAccountRegenerateKeyParameters] The name of the key to regenerate. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 2124
def begin_regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'key_to_regenerate is nil' if key_to_regenerate.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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountRegenerateKeyParameters.mapper()
  request_content = @client.serialize(request_mapper,  key_to_regenerate)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/regenerateKey'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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(:post, 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 == 202
      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
begin_regenerate_key_with_http_info(resource_group_name, account_name, key_to_regenerate, custom_headers:nil) click to toggle source

Regenerates an access key for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param key_to_regenerate [DatabaseAccountRegenerateKeyParameters] The name of the key to regenerate. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 2108
def begin_regenerate_key_with_http_info(resource_group_name, account_name, key_to_regenerate, custom_headers:nil)
  begin_regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:custom_headers).value!
end
begin_update(resource_group_name, account_name, update_parameters, custom_headers:nil) click to toggle source

Updates the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param update_parameters [DatabaseAccountUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountGetResults] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1448
def begin_update(resource_group_name, account_name, update_parameters, custom_headers:nil)
  response = begin_update_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
begin_update_async(resource_group_name, account_name, update_parameters, custom_headers:nil) click to toggle source

Updates the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param update_parameters [DatabaseAccountUpdateParameters] The parameters to provide for the current database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1481
def begin_update_async(resource_group_name, account_name, update_parameters, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'update_parameters is nil' if update_parameters.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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountUpdateParameters.mapper()
  request_content = @client.serialize(request_mapper,  update_parameters)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      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(:patch, 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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountGetResults.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
begin_update_with_http_info(resource_group_name, account_name, update_parameters, custom_headers:nil) click to toggle source

Updates the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param update_parameters [DatabaseAccountUpdateParameters] The parameters to provide for the current database account. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1465
def begin_update_with_http_info(resource_group_name, account_name, update_parameters, custom_headers:nil)
  begin_update_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value!
end
check_name_exists(account_name, custom_headers:nil) click to toggle source

Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters.

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

@return [Boolean] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1033
def check_name_exists(account_name, custom_headers:nil)
  response = check_name_exists_async(account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
check_name_exists_async(account_name, custom_headers:nil) click to toggle source

Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters.

@param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1064
def check_name_exists_async(account_name, custom_headers:nil)
  fail ArgumentError, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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.DocumentDB/databaseAccountNames/{accountName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'accountName' => account_name},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:head, 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 == 404
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.body = (status_code == 200)
    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
check_name_exists_with_http_info(account_name, custom_headers:nil) click to toggle source

Checks that the Azure Cosmos DB account name already exists. A valid account name may contain only lowercase letters, numbers, and the '-' character, and must be between 3 and 50 characters.

@param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1049
def check_name_exists_with_http_info(account_name, custom_headers:nil)
  check_name_exists_async(account_name, custom_headers:custom_headers).value!
end
create_or_update(resource_group_name, account_name, create_update_parameters, custom_headers:nil) click to toggle source

Creates or updates an Azure Cosmos DB database account. The “Update” method is preferred when performing updates on an account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param create_update_parameters [DatabaseAccountCreateUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountGetResults] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 183
def create_or_update(resource_group_name, account_name, create_update_parameters, custom_headers:nil)
  response = create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param create_update_parameters [DatabaseAccountCreateUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 199
def create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:nil)
  # Send request
  promise = begin_create_or_update_async(resource_group_name, account_name, create_update_parameters, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountGetResults.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
delete(resource_group_name, account_name, custom_headers:nil) click to toggle source

Deletes an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 225
def delete(resource_group_name, account_name, custom_headers:nil)
  response = delete_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  nil
end
delete_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 239
def delete_async(resource_group_name, account_name, custom_headers:nil)
  # Send request
  promise = begin_delete_async(resource_group_name, account_name, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
failover_priority_change(resource_group_name, account_name, failover_parameters, custom_headers:nil) click to toggle source

Changes the failover priority for the Azure Cosmos DB database account. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param failover_parameters [FailoverPolicies] The new failover policies for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 268
def failover_priority_change(resource_group_name, account_name, failover_parameters, custom_headers:nil)
  response = failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:custom_headers).value!
  nil
end
failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param failover_parameters [FailoverPolicies] The new failover policies for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 284
def failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:nil)
  # Send request
  promise = begin_failover_priority_change_async(resource_group_name, account_name, failover_parameters, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
get(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountGetResults] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 34
def get(resource_group_name, account_name, custom_headers:nil)
  response = get_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 63
def get_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountGetResults.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_read_only_keys(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountListReadOnlyKeysResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 785
def get_read_only_keys(resource_group_name, account_name, custom_headers:nil)
  response = get_read_only_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_read_only_keys_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 816
def get_read_only_keys_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountListReadOnlyKeysResult.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_read_only_keys_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 801
def get_read_only_keys_with_http_info(resource_group_name, account_name, custom_headers:nil)
  get_read_only_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
get_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 49
def get_with_http_info(resource_group_name, account_name, custom_headers:nil)
  get_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
list(custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the subscription.

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

@return [DatabaseAccountsListResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 309
def list(custom_headers:nil)
  response = list_async(custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_async(custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the 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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 336
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.DocumentDB/databaseAccounts'

  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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountsListResult.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_resource_group(resource_group_name, custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the given resource group.

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

@return [DatabaseAccountsListResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 399
def list_by_resource_group(resource_group_name, custom_headers:nil)
  response = list_by_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_by_resource_group_async(resource_group_name, custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the given resource group.

@param resource_group_name [String] Name of an Azure resource 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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 428
def list_by_resource_group_async(resource_group_name, 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.DocumentDB/databaseAccounts'

  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},
      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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountsListResult.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_resource_group_with_http_info(resource_group_name, custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the given resource group.

@param resource_group_name [String] Name of an Azure resource 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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 414
def list_by_resource_group_with_http_info(resource_group_name, custom_headers:nil)
  list_by_resource_group_async(resource_group_name, custom_headers:custom_headers).value!
end
list_connection_strings(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the connection strings for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountListConnectionStringsResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 596
def list_connection_strings(resource_group_name, account_name, custom_headers:nil)
  response = list_connection_strings_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_connection_strings_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the connection strings for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 627
def list_connection_strings_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listConnectionStrings'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, 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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountListConnectionStringsResult.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_connection_strings_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the connection strings for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 612
def list_connection_strings_with_http_info(resource_group_name, account_name, custom_headers:nil)
  list_connection_strings_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
list_keys(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountListKeysResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 495
def list_keys(resource_group_name, account_name, custom_headers:nil)
  response = list_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_keys_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 524
def list_keys_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/listKeys'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, 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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountListKeysResult.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_keys_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 510
def list_keys_with_http_info(resource_group_name, account_name, custom_headers:nil)
  list_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
list_metric_definitions(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves metric definitions for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MetricDefinitionsListResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1346
def list_metric_definitions(resource_group_name, account_name, custom_headers:nil)
  response = list_metric_definitions_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_metric_definitions_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves metric definitions for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1375
def list_metric_definitions_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/metricDefinitions'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_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::Cosmosdb::Mgmt::V2019_08_01::Models::MetricDefinitionsListResult.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_metric_definitions_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Retrieves metric definitions for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1361
def list_metric_definitions_with_http_info(resource_group_name, account_name, custom_headers:nil)
  list_metric_definitions_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
list_metrics(resource_group_name, account_name, filter, custom_headers:nil) click to toggle source

Retrieves the metrics determined by the given filter for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and timeGrain. The supported operator is eq. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MetricListResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1126
def list_metrics(resource_group_name, account_name, filter, custom_headers:nil)
  response = list_metrics_async(resource_group_name, account_name, filter, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_metrics_async(resource_group_name, account_name, filter, custom_headers:nil) click to toggle source

Retrieves the metrics determined by the given filter for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and timeGrain. The supported operator is eq. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1165
def list_metrics_async(resource_group_name, account_name, filter, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).nil?
  fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
  fail ArgumentError, 'filter is nil' if filter.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.DocumentDB/databaseAccounts/{accountName}/metrics'

  request_url = @base_url || @client.base_url

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

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

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

Retrieves the metrics determined by the given filter for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of metrics to return. The parameters that can be filtered are name.value (name of the metric, can have an or of multiple names), startTime, endTime, and timeGrain. The supported operator is eq. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1146
def list_metrics_with_http_info(resource_group_name, account_name, filter, custom_headers:nil)
  list_metrics_async(resource_group_name, account_name, filter, custom_headers:custom_headers).value!
end
list_read_only_keys(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountListReadOnlyKeysResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 888
def list_read_only_keys(resource_group_name, account_name, custom_headers:nil)
  response = list_read_only_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_read_only_keys_async(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 919
def list_read_only_keys_async(resource_group_name, account_name, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/readonlykeys'

  request_url = @base_url || @client.base_url

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id,'resourceGroupName' => resource_group_name,'accountName' => account_name},
      query_params: {'api-version' => @client.api_version},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, 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::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountListReadOnlyKeysResult.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_read_only_keys_with_http_info(resource_group_name, account_name, custom_headers:nil) click to toggle source

Lists the read-only access keys for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 904
def list_read_only_keys_with_http_info(resource_group_name, account_name, custom_headers:nil)
  list_read_only_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value!
end
list_usages(resource_group_name, account_name, filter:nil, custom_headers:nil) click to toggle source

Retrieves the usages (most recent data) for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [UsagesResult] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1240
def list_usages(resource_group_name, account_name, filter:nil, custom_headers:nil)
  response = list_usages_async(resource_group_name, account_name, filter:filter, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_usages_async(resource_group_name, account_name, filter:nil, custom_headers:nil) click to toggle source

Retrieves the usages (most recent data) for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1275
def list_usages_async(resource_group_name, account_name, filter:nil, custom_headers:nil)
  fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.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, 'account_name is nil' if account_name.nil?
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '50'" if !account_name.nil? && account_name.length > 50
  fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3
  fail ArgumentError, "'account_name' should satisfy the constraint - 'Pattern': '^[a-z0-9]+(-[a-z0-9]+)*'" if !account_name.nil? && account_name.match(Regexp.new('^^[a-z0-9]+(-[a-z0-9]+)*$')).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 = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/usages'

  request_url = @base_url || @client.base_url

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

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

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

Retrieves the usages (most recent data) for the given database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param filter [String] An OData filter expression that describes a subset of usages to return. The supported parameter is name.value (name of the metric, can have an or of multiple names). @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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1258
def list_usages_with_http_info(resource_group_name, account_name, filter:nil, custom_headers:nil)
  list_usages_async(resource_group_name, account_name, filter:filter, custom_headers:custom_headers).value!
end
list_with_http_info(custom_headers:nil) click to toggle source

Lists all the Azure Cosmos DB database accounts available under the 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/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 323
def list_with_http_info(custom_headers:nil)
  list_async(custom_headers:custom_headers).value!
end
offline_region(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil) click to toggle source

Offline the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_offline [RegionForOnlineOffline] Cosmos DB region to offline for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 699
def offline_region(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil)
  response = offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:custom_headers).value!
  nil
end
offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_offline [RegionForOnlineOffline] Cosmos DB region to offline for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 715
def offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:nil)
  # Send request
  promise = begin_offline_region_async(resource_group_name, account_name, region_parameter_for_offline, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
online_region(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil) click to toggle source

Online the specified region for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_online [RegionForOnlineOffline] Cosmos DB region to online for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 742
def online_region(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil)
  response = online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:custom_headers).value!
  nil
end
online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param region_parameter_for_online [RegionForOnlineOffline] Cosmos DB region to online for the database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 758
def online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:nil)
  # Send request
  promise = begin_online_region_async(resource_group_name, account_name, region_parameter_for_online, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
regenerate_key(resource_group_name, account_name, key_to_regenerate, custom_headers:nil) click to toggle source

Regenerates an access key for the specified Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param key_to_regenerate [DatabaseAccountRegenerateKeyParameters] The name of the key to regenerate. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 990
def regenerate_key(resource_group_name, account_name, key_to_regenerate, custom_headers:nil)
  response = regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:custom_headers).value!
  nil
end
regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param key_to_regenerate [DatabaseAccountRegenerateKeyParameters] The name of the key to regenerate. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 1006
def regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:nil)
  # Send request
  promise = begin_regenerate_key_async(resource_group_name, account_name, key_to_regenerate, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end
update(resource_group_name, account_name, update_parameters, custom_headers:nil) click to toggle source

Updates the properties of an existing Azure Cosmos DB database account.

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param update_parameters [DatabaseAccountUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [DatabaseAccountGetResults] operation results.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 136
def update(resource_group_name, account_name, update_parameters, custom_headers:nil)
  response = update_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
update_async(resource_group_name, account_name, update_parameters, custom_headers:nil) click to toggle source

@param resource_group_name [String] Name of an Azure resource group. @param account_name [String] Cosmos DB database account name. @param update_parameters [DatabaseAccountUpdateParameters] The parameters to provide for the current database account. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] promise which provides async access to http response.

# File lib/2019-08-01/generated/azure_mgmt_cosmosdb/database_accounts.rb, line 152
def update_async(resource_group_name, account_name, update_parameters, custom_headers:nil)
  # Send request
  promise = begin_update_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers)

  promise = promise.then do |response|
    # Defining deserialization method.
    deserialize_method = lambda do |parsed_response|
      result_mapper = Azure::Cosmosdb::Mgmt::V2019_08_01::Models::DatabaseAccountGetResults.mapper()
      parsed_response = @client.deserialize(result_mapper, parsed_response)
    end

    # Waiting for response.
    @client.get_long_running_operation_result(response, deserialize_method)
  end

  promise
end