# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure::Cosmosdb::Mgmt::V2015_04_08 # # Azure Cosmos DB Database Service Resource Provider REST API # class DatabaseAccounts include MsRestAzure # # Creates and initializes a new instance of the DatabaseAccounts class. # @param client service class for accessing basic functionality. # def initialize(client) @client = client end # @return [CosmosDB] reference to the CosmosDB attr_reader :client # # 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 [DatabaseAccount] operation results. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::Models::DatabaseAccount.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 # # Patches 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 [DatabaseAccountPatchParameters] The tags parameter # to patch 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 [DatabaseAccount] operation results. # def patch(resource_group_name, account_name, update_parameters, custom_headers:nil) response = patch_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param update_parameters [DatabaseAccountPatchParameters] The tags parameter # to patch 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. # def patch_async(resource_group_name, account_name, update_parameters, custom_headers:nil) # Send request promise = begin_patch_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::V2015_04_08::Models::DatabaseAccount.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 # # Creates or updates an 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 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 [DatabaseAccount] operation results. # 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 # # @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. # 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::V2015_04_08::Models::DatabaseAccount.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 # # 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. # 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 # # @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. # 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 # # 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. # 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 # # @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. # 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 # # 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. # def list(custom_headers:nil) response = list_async(custom_headers:custom_headers).value! response.body unless response.nil? end # # 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. # def list_with_http_info(custom_headers:nil) list_async(custom_headers:custom_headers).value! end # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # @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. # 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 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. # 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 # # @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. # 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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # @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. # 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 # # 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. # 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 # # 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. # def check_name_exists_with_http_info(account_name, custom_headers:nil) check_name_exists_async(account_name, custom_headers:custom_headers).value! end # # 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. # 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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # Lists the SQL databases under 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 [SqlDatabaseListResult] operation results. # def list_sql_databases(resource_group_name, account_name, custom_headers:nil) response = list_sql_databases_async(resource_group_name, account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the SQL databases under 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. # def list_sql_databases_with_http_info(resource_group_name, account_name, custom_headers:nil) list_sql_databases_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Lists the SQL databases under 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. # def list_sql_databases_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}/apis/sql/databases' 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::V2015_04_08::Models::SqlDatabaseListResult.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 # # Gets the SQL database under an existing Azure Cosmos DB database account with # the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlDatabase] operation results. # def get_sql_database(resource_group_name, account_name, database_name, custom_headers:nil) response = get_sql_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the SQL database under an existing Azure Cosmos DB database account with # the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_sql_database_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_sql_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the SQL database under an existing Azure Cosmos DB database account with # the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_sql_database_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}' 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,'databaseName' => database_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::V2015_04_08::Models::SqlDatabase.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_sql_database_parameters # [SqlDatabaseCreateUpdateParameters] The parameters to provide for the current # SQL database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlDatabase] operation results. # def create_update_sql_database(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:nil) response = create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_sql_database_parameters # [SqlDatabaseCreateUpdateParameters] The parameters to provide for the current # SQL database. # @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. # def create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:nil) # Send request promise = begin_create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::SqlDatabase.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 # # Deletes an existing Azure Cosmos DB SQL database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_sql_database(resource_group_name, account_name, database_name, custom_headers:nil) response = delete_sql_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def delete_sql_database_async(resource_group_name, account_name, database_name, custom_headers:nil) # Send request promise = begin_delete_sql_database_async(resource_group_name, account_name, database_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 # # Gets the RUs per second of the SQL database under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_sql_database_throughput(resource_group_name, account_name, database_name, custom_headers:nil) response = get_sql_database_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the SQL database under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_sql_database_throughput_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_sql_database_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the SQL database under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_sql_database_throughput_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_sql_database_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL database. # @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. # def update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the SQL container under 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 database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlContainerListResult] operation results. # def list_sql_containers(resource_group_name, account_name, database_name, custom_headers:nil) response = list_sql_containers_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the SQL container under 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 database_name [String] Cosmos DB database 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. # def list_sql_containers_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) list_sql_containers_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Lists the SQL container under 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 database_name [String] Cosmos DB database 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. # def list_sql_containers_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers' 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,'databaseName' => database_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::V2015_04_08::Models::SqlContainerListResult.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 # # Gets the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlContainer] operation results. # def get_sql_container(resource_group_name, account_name, database_name, container_name, custom_headers:nil) response = get_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def get_sql_container_with_http_info(resource_group_name, account_name, database_name, container_name, custom_headers:nil) get_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! end # # Gets the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def get_sql_container_async(resource_group_name, account_name, database_name, container_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'container_name is nil' if container_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}' 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,'databaseName' => database_name,'containerName' => container_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::V2015_04_08::Models::SqlContainer.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param create_update_sql_container_parameters # [SqlContainerCreateUpdateParameters] The parameters to provide for the # current SQL container. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlContainer] operation results. # def create_update_sql_container(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:nil) response = create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param create_update_sql_container_parameters # [SqlContainerCreateUpdateParameters] The parameters to provide for the # current SQL container. # @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. # def create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:nil) # Send request promise = begin_create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::SqlContainer.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 # # Deletes an existing Azure Cosmos DB SQL container. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_sql_container(resource_group_name, account_name, database_name, container_name, custom_headers:nil) response = delete_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def delete_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:nil) # Send request promise = begin_delete_sql_container_async(resource_group_name, account_name, database_name, container_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 # # Gets the RUs per second of the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_sql_container_throughput(resource_group_name, account_name, database_name, container_name, custom_headers:nil) response = get_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def get_sql_container_throughput_with_http_info(resource_group_name, account_name, database_name, container_name, custom_headers:nil) get_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the SQL container under 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 database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def get_sql_container_throughput_async(resource_group_name, account_name, database_name, container_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'container_name is nil' if container_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput' 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,'databaseName' => database_name,'containerName' => container_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL container. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_sql_container_throughput(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:nil) response = update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL container. # @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. # def update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the MongoDB databases under 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 [MongoDBDatabaseListResult] operation results. # def list_mongo_dbdatabases(resource_group_name, account_name, custom_headers:nil) response = list_mongo_dbdatabases_async(resource_group_name, account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the MongoDB databases under 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. # def list_mongo_dbdatabases_with_http_info(resource_group_name, account_name, custom_headers:nil) list_mongo_dbdatabases_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Lists the MongoDB databases under 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. # def list_mongo_dbdatabases_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}/apis/mongodb/databases' 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::V2015_04_08::Models::MongoDBDatabaseListResult.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 # # Gets the MongoDB databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBDatabase] operation results. # def get_mongo_dbdatabase(resource_group_name, account_name, database_name, custom_headers:nil) response = get_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the MongoDB databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_mongo_dbdatabase_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the MongoDB databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_mongo_dbdatabase_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}' 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,'databaseName' => database_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::V2015_04_08::Models::MongoDBDatabase.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or updates Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_mongo_dbdatabase_parameters # [MongoDBDatabaseCreateUpdateParameters] The parameters to provide for the # current MongoDB database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBDatabase] operation results. # def create_update_mongo_dbdatabase(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:nil) response = create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_mongo_dbdatabase_parameters # [MongoDBDatabaseCreateUpdateParameters] The parameters to provide for the # current MongoDB database. # @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. # def create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:nil) # Send request promise = begin_create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::MongoDBDatabase.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 # # Deletes an existing Azure Cosmos DB MongoDB database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_mongo_dbdatabase(resource_group_name, account_name, database_name, custom_headers:nil) response = delete_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def delete_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:nil) # Send request promise = begin_delete_mongo_dbdatabase_async(resource_group_name, account_name, database_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 # # Gets the RUs per second of the MongoDB database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_mongo_dbdatabase_throughput(resource_group_name, account_name, database_name, custom_headers:nil) response = get_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the MongoDB database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_mongo_dbdatabase_throughput_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the MongoDB database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of the an Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_mongo_dbdatabase_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB database. # @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. # def update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the MongoDB collection under 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 database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBCollectionListResult] operation results. # def list_mongo_dbcollections(resource_group_name, account_name, database_name, custom_headers:nil) response = list_mongo_dbcollections_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the MongoDB collection under 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 database_name [String] Cosmos DB database 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. # def list_mongo_dbcollections_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) list_mongo_dbcollections_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Lists the MongoDB collection under 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 database_name [String] Cosmos DB database 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. # def list_mongo_dbcollections_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections' 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,'databaseName' => database_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::V2015_04_08::Models::MongoDBCollectionListResult.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 # # Gets the MongoDB collection under 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 database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBCollection] operation results. # def get_mongo_dbcollection(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) response = get_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the MongoDB collection under 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 database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def get_mongo_dbcollection_with_http_info(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) get_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! end # # Gets the MongoDB collection under 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 database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def get_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'collection_name is nil' if collection_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}' 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,'databaseName' => database_name,'collectionName' => collection_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::V2015_04_08::Models::MongoDBCollection.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB MongoDB Collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param create_update_mongo_dbcollection_parameters # [MongoDBCollectionCreateUpdateParameters] The parameters to provide for the # current MongoDB Collection. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBCollection] operation results. # def create_update_mongo_dbcollection(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:nil) response = create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param create_update_mongo_dbcollection_parameters # [MongoDBCollectionCreateUpdateParameters] The parameters to provide for the # current MongoDB Collection. # @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. # def create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:nil) # Send request promise = begin_create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::MongoDBCollection.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 # # Deletes an existing Azure Cosmos DB MongoDB Collection. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_mongo_dbcollection(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) response = delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) # Send request promise = begin_delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_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 # # Gets the RUs per second of the MongoDB collection under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_mongo_dbcollection_throughput(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) response = get_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the MongoDB collection under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def get_mongo_dbcollection_throughput_with_http_info(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) get_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the MongoDB collection under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def get_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'collection_name is nil' if collection_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput' 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,'databaseName' => database_name,'collectionName' => collection_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::V2015_04_08::Models::Throughput.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 # # Update the RUs per second of an Azure Cosmos DB MongoDB collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB collection. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_mongo_dbcollection_throughput(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:nil) response = update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB collection. # @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. # def update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the Tables under 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 [TableListResult] operation results. # def list_tables(resource_group_name, account_name, custom_headers:nil) response = list_tables_async(resource_group_name, account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the Tables under 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. # def list_tables_with_http_info(resource_group_name, account_name, custom_headers:nil) list_tables_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Lists the Tables under 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. # def list_tables_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}/apis/table/tables' 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::V2015_04_08::Models::TableListResult.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 # # Gets the Tables under an existing Azure Cosmos DB database account with the # provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Table] operation results. # def get_table(resource_group_name, account_name, table_name, custom_headers:nil) response = get_table_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Tables under an existing Azure Cosmos DB database account with the # provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def get_table_with_http_info(resource_group_name, account_name, table_name, custom_headers:nil) get_table_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! end # # Gets the Tables under an existing Azure Cosmos DB database account with the # provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def get_table_async(resource_group_name, account_name, table_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, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}' 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,'tableName' => table_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::V2015_04_08::Models::Table.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param create_update_table_parameters [TableCreateUpdateParameters] The # parameters to provide for the current Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Table] operation results. # def create_update_table(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:nil) response = create_update_table_async(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param create_update_table_parameters [TableCreateUpdateParameters] The # parameters to provide for the current Table. # @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. # def create_update_table_async(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:nil) # Send request promise = begin_create_update_table_async(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Table.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 # # Deletes an existing Azure Cosmos DB Table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_table(resource_group_name, account_name, table_name, custom_headers:nil) response = delete_table_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def delete_table_async(resource_group_name, account_name, table_name, custom_headers:nil) # Send request promise = begin_delete_table_async(resource_group_name, account_name, table_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 # # Gets the RUs per second of the Table under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_table_throughput(resource_group_name, account_name, table_name, custom_headers:nil) response = get_table_throughput_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the Table under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def get_table_throughput_with_http_info(resource_group_name, account_name, table_name, custom_headers:nil) get_table_throughput_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the Table under an existing Azure Cosmos DB # database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def get_table_throughput_async(resource_group_name, account_name, table_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, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}/settings/throughput' 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,'tableName' => table_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_table_throughput(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:nil) response = update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current Table. # @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. # def update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the Cassandra keyspaces under 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 [CassandraKeyspaceListResult] operation results. # def list_cassandra_keyspaces(resource_group_name, account_name, custom_headers:nil) response = list_cassandra_keyspaces_async(resource_group_name, account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the Cassandra keyspaces under 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. # def list_cassandra_keyspaces_with_http_info(resource_group_name, account_name, custom_headers:nil) list_cassandra_keyspaces_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Lists the Cassandra keyspaces under 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. # def list_cassandra_keyspaces_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}/apis/cassandra/keyspaces' 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::V2015_04_08::Models::CassandraKeyspaceListResult.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 # # Gets the Cassandra keyspaces under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraKeyspace] operation results. # def get_cassandra_keyspace(resource_group_name, account_name, keyspace_name, custom_headers:nil) response = get_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Cassandra keyspaces under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def get_cassandra_keyspace_with_http_info(resource_group_name, account_name, keyspace_name, custom_headers:nil) get_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! end # # Gets the Cassandra keyspaces under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def get_cassandra_keyspace_async(resource_group_name, account_name, keyspace_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}' 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,'keyspaceName' => keyspace_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::V2015_04_08::Models::CassandraKeyspace.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Cassandra keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param create_update_cassandra_keyspace_parameters # [CassandraKeyspaceCreateUpdateParameters] The parameters to provide for the # current Cassandra keyspace. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraKeyspace] operation results. # def create_update_cassandra_keyspace(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:nil) response = create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param create_update_cassandra_keyspace_parameters # [CassandraKeyspaceCreateUpdateParameters] The parameters to provide for the # current Cassandra keyspace. # @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. # def create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:nil) # Send request promise = begin_create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::CassandraKeyspace.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 # # Deletes an existing Azure Cosmos DB Cassandra keyspace. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_cassandra_keyspace(resource_group_name, account_name, keyspace_name, custom_headers:nil) response = delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:nil) # Send request promise = begin_delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_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 # # Gets the RUs per second of the Cassandra Keyspace under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_cassandra_keyspace_throughput(resource_group_name, account_name, keyspace_name, custom_headers:nil) response = get_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the Cassandra Keyspace under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def get_cassandra_keyspace_throughput_with_http_info(resource_group_name, account_name, keyspace_name, custom_headers:nil) get_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the Cassandra Keyspace under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def get_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput' 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,'keyspaceName' => keyspace_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB Cassandra Keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra Keyspace. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_cassandra_keyspace_throughput(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:nil) response = update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra Keyspace. # @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. # def update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraTableListResult] operation results. # def list_cassandra_tables(resource_group_name, account_name, keyspace_name, custom_headers:nil) response = list_cassandra_tables_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace 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. # def list_cassandra_tables_with_http_info(resource_group_name, account_name, keyspace_name, custom_headers:nil) list_cassandra_tables_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! end # # Lists the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace 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. # def list_cassandra_tables_async(resource_group_name, account_name, keyspace_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables' 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,'keyspaceName' => keyspace_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::V2015_04_08::Models::CassandraTableListResult.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 # # Gets the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraTable] operation results. # def get_cassandra_table(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) response = get_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def get_cassandra_table_with_http_info(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) get_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! end # # Gets the Cassandra table under 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 keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def get_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}' 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,'keyspaceName' => keyspace_name,'tableName' => table_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::V2015_04_08::Models::CassandraTable.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Cassandra Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param create_update_cassandra_table_parameters # [CassandraTableCreateUpdateParameters] The parameters to provide for the # current Cassandra Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraTable] operation results. # def create_update_cassandra_table(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:nil) response = create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param create_update_cassandra_table_parameters # [CassandraTableCreateUpdateParameters] The parameters to provide for the # current Cassandra Table. # @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. # def create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:nil) # Send request promise = begin_create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::CassandraTable.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 # # Deletes an existing Azure Cosmos DB Cassandra table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_cassandra_table(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) response = delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) # Send request promise = begin_delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_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 # # Gets the RUs per second of the Cassandra table under an existing Azure Cosmos # DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_cassandra_table_throughput(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) response = get_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the Cassandra table under an existing Azure Cosmos # DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def get_cassandra_table_throughput_with_http_info(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) get_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the Cassandra table under an existing Azure Cosmos # DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def get_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput' 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,'keyspaceName' => keyspace_name,'tableName' => table_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB Cassandra table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_cassandra_table_throughput(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:nil) response = update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra table. # @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. # def update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the Gremlin databases under 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 [GremlinDatabaseListResult] operation results. # def list_gremlin_databases(resource_group_name, account_name, custom_headers:nil) response = list_gremlin_databases_async(resource_group_name, account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the Gremlin databases under 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. # def list_gremlin_databases_with_http_info(resource_group_name, account_name, custom_headers:nil) list_gremlin_databases_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Lists the Gremlin databases under 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. # def list_gremlin_databases_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}/apis/gremlin/databases' 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::V2015_04_08::Models::GremlinDatabaseListResult.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 # # Gets the Gremlin databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinDatabase] operation results. # def get_gremlin_database(resource_group_name, account_name, database_name, custom_headers:nil) response = get_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Gremlin databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_gremlin_database_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the Gremlin databases under an existing Azure Cosmos DB database account # with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_gremlin_database_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}' 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,'databaseName' => database_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::V2015_04_08::Models::GremlinDatabase.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_gremlin_database_parameters # [GremlinDatabaseCreateUpdateParameters] The parameters to provide for the # current Gremlin database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinDatabase] operation results. # def create_update_gremlin_database(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:nil) response = create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_gremlin_database_parameters # [GremlinDatabaseCreateUpdateParameters] The parameters to provide for the # current Gremlin database. # @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. # def create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:nil) # Send request promise = begin_create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::GremlinDatabase.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 # # Deletes an existing Azure Cosmos DB Gremlin database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_gremlin_database(resource_group_name, account_name, database_name, custom_headers:nil) response = delete_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def delete_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:nil) # Send request promise = begin_delete_gremlin_database_async(resource_group_name, account_name, database_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 # # Gets the RUs per second of the Gremlin database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_gremlin_database_throughput(resource_group_name, account_name, database_name, custom_headers:nil) response = get_gremlin_database_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the RUs per second of the Gremlin database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_gremlin_database_throughput_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) get_gremlin_database_throughput_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Gets the RUs per second of the Gremlin database under an existing Azure # Cosmos DB database account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def get_gremlin_database_throughput_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_gremlin_database_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin database. # @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. # def update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Lists the Gremlin graph under 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 database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinGraphListResult] operation results. # def list_gremlin_graphs(resource_group_name, account_name, database_name, custom_headers:nil) response = list_gremlin_graphs_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the Gremlin graph under 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 database_name [String] Cosmos DB database 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. # def list_gremlin_graphs_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) list_gremlin_graphs_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Lists the Gremlin graph under 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 database_name [String] Cosmos DB database 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. # def list_gremlin_graphs_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs' 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,'databaseName' => database_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::V2015_04_08::Models::GremlinGraphListResult.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 # # Gets the Gremlin graph under 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 database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinGraph] operation results. # def get_gremlin_graph(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) response = get_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Gremlin graph under 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 database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def get_gremlin_graph_with_http_info(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) get_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! end # # Gets the Gremlin graph under 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 database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def get_gremlin_graph_async(resource_group_name, account_name, database_name, graph_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'graph_name is nil' if graph_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}' 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,'databaseName' => database_name,'graphName' => graph_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::V2015_04_08::Models::GremlinGraph.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param create_update_gremlin_graph_parameters # [GremlinGraphCreateUpdateParameters] The parameters to provide for the # current Gremlin graph. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinGraph] operation results. # def create_update_gremlin_graph(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:nil) response = create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param create_update_gremlin_graph_parameters # [GremlinGraphCreateUpdateParameters] The parameters to provide for the # current Gremlin graph. # @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. # def create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:nil) # Send request promise = begin_create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::GremlinGraph.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 # # Deletes an existing Azure Cosmos DB Gremlin graph. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def delete_gremlin_graph(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) response = delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) # Send request promise = begin_delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_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 # # Gets the Gremlin graph throughput under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def get_gremlin_graph_throughput(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) response = get_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Gets the Gremlin graph throughput under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def get_gremlin_graph_throughput_with_http_info(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) get_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! end # # Gets the Gremlin graph throughput under an existing Azure Cosmos DB database # account with the provided name. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def get_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'graph_name is nil' if graph_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput' 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,'databaseName' => database_name,'graphName' => graph_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::V2015_04_08::Models::Throughput.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 # # Update RUs per second of an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin graph. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def update_gremlin_graph_throughput(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:nil) response = update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin graph. # @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. # def update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:nil) # Send request promise = begin_update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Cosmosdb::Mgmt::V2015_04_08::Models::Throughput.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 # # Patches 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 [DatabaseAccountPatchParameters] The tags parameter # to patch 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 [DatabaseAccount] operation results. # def begin_patch(resource_group_name, account_name, update_parameters, custom_headers:nil) response = begin_patch_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Patches 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 [DatabaseAccountPatchParameters] The tags parameter # to patch 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. # def begin_patch_with_http_info(resource_group_name, account_name, update_parameters, custom_headers:nil) begin_patch_async(resource_group_name, account_name, update_parameters, custom_headers:custom_headers).value! end # # Patches 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 [DatabaseAccountPatchParameters] The tags parameter # to patch 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. # def begin_patch_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::V2015_04_08::Models::DatabaseAccountPatchParameters.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::V2015_04_08::Models::DatabaseAccount.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 # # Creates or updates an 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 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 [DatabaseAccount] operation results. # 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 # # Creates or updates an 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 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. # 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 # # Creates or updates an 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 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. # 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::V2015_04_08::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::V2015_04_08::Models::DatabaseAccount.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 # # 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. # # 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 # # 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. # 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 # # 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. # 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 # # 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. # # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # 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. # # 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 # # 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. # 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 # # 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. # 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::V2015_04_08::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 # # Create or update an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_sql_database_parameters # [SqlDatabaseCreateUpdateParameters] The parameters to provide for the current # SQL database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlDatabase] operation results. # def begin_create_update_sql_database(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:nil) response = begin_create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_sql_database_parameters # [SqlDatabaseCreateUpdateParameters] The parameters to provide for the current # SQL database. # @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. # def begin_create_update_sql_database_with_http_info(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:nil) begin_create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_sql_database_parameters # [SqlDatabaseCreateUpdateParameters] The parameters to provide for the current # SQL database. # @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. # def begin_create_update_sql_database_async(resource_group_name, account_name, database_name, create_update_sql_database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_sql_database_parameters is nil' if create_update_sql_database_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::V2015_04_08::Models::SqlDatabaseCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_sql_database_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}/apis/sql/databases/{databaseName}' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::SqlDatabase.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 # # Deletes an existing Azure Cosmos DB SQL database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_sql_database(resource_group_name, account_name, database_name, custom_headers:nil) response = begin_delete_sql_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB SQL database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_sql_database_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) begin_delete_sql_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB SQL database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_sql_database_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}' 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,'databaseName' => database_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 # # Update RUs per second of an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_sql_database_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = begin_update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL database. # @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. # def begin_update_sql_database_throughput_with_http_info(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) begin_update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB SQL database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL database. # @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. # def begin_update_sql_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/sql/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param create_update_sql_container_parameters # [SqlContainerCreateUpdateParameters] The parameters to provide for the # current SQL container. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [SqlContainer] operation results. # def begin_create_update_sql_container(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:nil) response = begin_create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param create_update_sql_container_parameters # [SqlContainerCreateUpdateParameters] The parameters to provide for the # current SQL container. # @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. # def begin_create_update_sql_container_with_http_info(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:nil) begin_create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param create_update_sql_container_parameters # [SqlContainerCreateUpdateParameters] The parameters to provide for the # current SQL container. # @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. # def begin_create_update_sql_container_async(resource_group_name, account_name, database_name, container_name, create_update_sql_container_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'container_name is nil' if container_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_sql_container_parameters is nil' if create_update_sql_container_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::V2015_04_08::Models::SqlContainerCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_sql_container_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}/apis/sql/databases/{databaseName}/containers/{containerName}' 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,'databaseName' => database_name,'containerName' => container_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 == 202 || 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::V2015_04_08::Models::SqlContainer.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 # # Deletes an existing Azure Cosmos DB SQL container. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_sql_container(resource_group_name, account_name, database_name, container_name, custom_headers:nil) response = begin_delete_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB SQL container. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def begin_delete_sql_container_with_http_info(resource_group_name, account_name, database_name, container_name, custom_headers:nil) begin_delete_sql_container_async(resource_group_name, account_name, database_name, container_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB SQL container. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container 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. # def begin_delete_sql_container_async(resource_group_name, account_name, database_name, container_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'container_name is nil' if container_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/sql/databases/{databaseName}/containers/{containerName}' 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,'databaseName' => database_name,'containerName' => container_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 # # Update RUs per second of an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL container. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_sql_container_throughput(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:nil) response = begin_update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL container. # @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. # def begin_update_sql_container_throughput_with_http_info(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:nil) begin_update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB SQL container # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param container_name [String] Cosmos DB container name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current SQL container. # @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. # def begin_update_sql_container_throughput_async(resource_group_name, account_name, database_name, container_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'container_name is nil' if container_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/sql/databases/{databaseName}/containers/{containerName}/settings/throughput' 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,'databaseName' => database_name,'containerName' => container_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or updates Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_mongo_dbdatabase_parameters # [MongoDBDatabaseCreateUpdateParameters] The parameters to provide for the # current MongoDB database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBDatabase] operation results. # def begin_create_update_mongo_dbdatabase(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:nil) response = begin_create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or updates Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_mongo_dbdatabase_parameters # [MongoDBDatabaseCreateUpdateParameters] The parameters to provide for the # current MongoDB database. # @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. # def begin_create_update_mongo_dbdatabase_with_http_info(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:nil) begin_create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_parameters, custom_headers:custom_headers).value! end # # Create or updates Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_mongo_dbdatabase_parameters # [MongoDBDatabaseCreateUpdateParameters] The parameters to provide for the # current MongoDB database. # @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. # def begin_create_update_mongo_dbdatabase_async(resource_group_name, account_name, database_name, create_update_mongo_dbdatabase_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_mongo_dbdatabase_parameters is nil' if create_update_mongo_dbdatabase_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::V2015_04_08::Models::MongoDBDatabaseCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_mongo_dbdatabase_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}/apis/mongodb/databases/{databaseName}' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::MongoDBDatabase.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 # # Deletes an existing Azure Cosmos DB MongoDB database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_mongo_dbdatabase(resource_group_name, account_name, database_name, custom_headers:nil) response = begin_delete_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB MongoDB database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_mongo_dbdatabase_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) begin_delete_mongo_dbdatabase_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB MongoDB database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_mongo_dbdatabase_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}' 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,'databaseName' => database_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 # # Update RUs per second of the an Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_mongo_dbdatabase_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = begin_update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of the an Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB database. # @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. # def begin_update_mongo_dbdatabase_throughput_with_http_info(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) begin_update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of the an Azure Cosmos DB MongoDB database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB database. # @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. # def begin_update_mongo_dbdatabase_throughput_async(resource_group_name, account_name, database_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/mongodb/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB MongoDB Collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param create_update_mongo_dbcollection_parameters # [MongoDBCollectionCreateUpdateParameters] The parameters to provide for the # current MongoDB Collection. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MongoDBCollection] operation results. # def begin_create_update_mongo_dbcollection(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:nil) response = begin_create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB MongoDB Collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param create_update_mongo_dbcollection_parameters # [MongoDBCollectionCreateUpdateParameters] The parameters to provide for the # current MongoDB Collection. # @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. # def begin_create_update_mongo_dbcollection_with_http_info(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:nil) begin_create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB MongoDB Collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param create_update_mongo_dbcollection_parameters # [MongoDBCollectionCreateUpdateParameters] The parameters to provide for the # current MongoDB Collection. # @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. # def begin_create_update_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, create_update_mongo_dbcollection_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'collection_name is nil' if collection_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_mongo_dbcollection_parameters is nil' if create_update_mongo_dbcollection_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::V2015_04_08::Models::MongoDBCollectionCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_mongo_dbcollection_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}/apis/mongodb/databases/{databaseName}/collections/{collectionName}' 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,'databaseName' => database_name,'collectionName' => collection_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 == 202 || 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::V2015_04_08::Models::MongoDBCollection.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 # # Deletes an existing Azure Cosmos DB MongoDB Collection. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_mongo_dbcollection(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) response = begin_delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB MongoDB Collection. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def begin_delete_mongo_dbcollection_with_http_info(resource_group_name, account_name, database_name, collection_name, custom_headers:nil) begin_delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB MongoDB Collection. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection 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. # def begin_delete_mongo_dbcollection_async(resource_group_name, account_name, database_name, collection_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'collection_name is nil' if collection_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/mongodb/databases/{databaseName}/collections/{collectionName}' 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,'databaseName' => database_name,'collectionName' => collection_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 # # Update the RUs per second of an Azure Cosmos DB MongoDB collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB collection. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_mongo_dbcollection_throughput(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:nil) response = begin_update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update the RUs per second of an Azure Cosmos DB MongoDB collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB collection. # @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. # def begin_update_mongo_dbcollection_throughput_with_http_info(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:nil) begin_update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update the RUs per second of an Azure Cosmos DB MongoDB collection # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param collection_name [String] Cosmos DB collection name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current MongoDB collection. # @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. # def begin_update_mongo_dbcollection_throughput_async(resource_group_name, account_name, database_name, collection_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'collection_name is nil' if collection_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/mongodb/databases/{databaseName}/collections/{collectionName}/settings/throughput' 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,'databaseName' => database_name,'collectionName' => collection_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param create_update_table_parameters [TableCreateUpdateParameters] The # parameters to provide for the current Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Table] operation results. # def begin_create_update_table(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:nil) response = begin_create_update_table_async(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param create_update_table_parameters [TableCreateUpdateParameters] The # parameters to provide for the current Table. # @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. # def begin_create_update_table_with_http_info(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:nil) begin_create_update_table_async(resource_group_name, account_name, table_name, create_update_table_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param create_update_table_parameters [TableCreateUpdateParameters] The # parameters to provide for the current Table. # @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. # def begin_create_update_table_async(resource_group_name, account_name, table_name, create_update_table_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, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_table_parameters is nil' if create_update_table_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::V2015_04_08::Models::TableCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_table_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}/apis/table/tables/{tableName}' 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,'tableName' => table_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 == 202 || 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::V2015_04_08::Models::Table.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 # # Deletes an existing Azure Cosmos DB Table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_table(resource_group_name, account_name, table_name, custom_headers:nil) response = begin_delete_table_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB Table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def begin_delete_table_with_http_info(resource_group_name, account_name, table_name, custom_headers:nil) begin_delete_table_async(resource_group_name, account_name, table_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB Table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table 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. # def begin_delete_table_async(resource_group_name, account_name, table_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, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/table/tables/{tableName}' 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,'tableName' => table_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 # # Update RUs per second of an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_table_throughput(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:nil) response = begin_update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current Table. # @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. # def begin_update_table_throughput_with_http_info(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:nil) begin_update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The # parameters to provide for the RUs per second of the current Table. # @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. # def begin_update_table_throughput_async(resource_group_name, account_name, table_name, update_throughput_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, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/table/tables/{tableName}/settings/throughput' 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,'tableName' => table_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Cassandra keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param create_update_cassandra_keyspace_parameters # [CassandraKeyspaceCreateUpdateParameters] The parameters to provide for the # current Cassandra keyspace. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraKeyspace] operation results. # def begin_create_update_cassandra_keyspace(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:nil) response = begin_create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB Cassandra keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param create_update_cassandra_keyspace_parameters # [CassandraKeyspaceCreateUpdateParameters] The parameters to provide for the # current Cassandra keyspace. # @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. # def begin_create_update_cassandra_keyspace_with_http_info(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:nil) begin_create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB Cassandra keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param create_update_cassandra_keyspace_parameters # [CassandraKeyspaceCreateUpdateParameters] The parameters to provide for the # current Cassandra keyspace. # @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. # def begin_create_update_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, create_update_cassandra_keyspace_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_cassandra_keyspace_parameters is nil' if create_update_cassandra_keyspace_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::V2015_04_08::Models::CassandraKeyspaceCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_cassandra_keyspace_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}/apis/cassandra/keyspaces/{keyspaceName}' 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,'keyspaceName' => keyspace_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 == 202 || 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::V2015_04_08::Models::CassandraKeyspace.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 # # Deletes an existing Azure Cosmos DB Cassandra keyspace. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_cassandra_keyspace(resource_group_name, account_name, keyspace_name, custom_headers:nil) response = begin_delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB Cassandra keyspace. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def begin_delete_cassandra_keyspace_with_http_info(resource_group_name, account_name, keyspace_name, custom_headers:nil) begin_delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB Cassandra keyspace. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace 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. # def begin_delete_cassandra_keyspace_async(resource_group_name, account_name, keyspace_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}' 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,'keyspaceName' => keyspace_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 # # Update RUs per second of an Azure Cosmos DB Cassandra Keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra Keyspace. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_cassandra_keyspace_throughput(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:nil) response = begin_update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB Cassandra Keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra Keyspace. # @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. # def begin_update_cassandra_keyspace_throughput_with_http_info(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:nil) begin_update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB Cassandra Keyspace # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra Keyspace. # @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. # def begin_update_cassandra_keyspace_throughput_async(resource_group_name, account_name, keyspace_name, update_throughput_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/cassandra/keyspaces/{keyspaceName}/settings/throughput' 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,'keyspaceName' => keyspace_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Cassandra Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param create_update_cassandra_table_parameters # [CassandraTableCreateUpdateParameters] The parameters to provide for the # current Cassandra Table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CassandraTable] operation results. # def begin_create_update_cassandra_table(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:nil) response = begin_create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB Cassandra Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param create_update_cassandra_table_parameters # [CassandraTableCreateUpdateParameters] The parameters to provide for the # current Cassandra Table. # @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. # def begin_create_update_cassandra_table_with_http_info(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:nil) begin_create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB Cassandra Table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param create_update_cassandra_table_parameters # [CassandraTableCreateUpdateParameters] The parameters to provide for the # current Cassandra Table. # @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. # def begin_create_update_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, create_update_cassandra_table_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_cassandra_table_parameters is nil' if create_update_cassandra_table_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::V2015_04_08::Models::CassandraTableCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_cassandra_table_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}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}' 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,'keyspaceName' => keyspace_name,'tableName' => table_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 == 202 || 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::V2015_04_08::Models::CassandraTable.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 # # Deletes an existing Azure Cosmos DB Cassandra table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_cassandra_table(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) response = begin_delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB Cassandra table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def begin_delete_cassandra_table_with_http_info(resource_group_name, account_name, keyspace_name, table_name, custom_headers:nil) begin_delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB Cassandra table. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table 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. # def begin_delete_cassandra_table_async(resource_group_name, account_name, keyspace_name, table_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}' 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,'keyspaceName' => keyspace_name,'tableName' => table_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 # # Update RUs per second of an Azure Cosmos DB Cassandra table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra table. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_cassandra_table_throughput(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:nil) response = begin_update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB Cassandra table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra table. # @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. # def begin_update_cassandra_table_throughput_with_http_info(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:nil) begin_update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB Cassandra table # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param keyspace_name [String] Cosmos DB keyspace name. # @param table_name [String] Cosmos DB table name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Cassandra table. # @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. # def begin_update_cassandra_table_throughput_async(resource_group_name, account_name, keyspace_name, table_name, update_throughput_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, 'keyspace_name is nil' if keyspace_name.nil? fail ArgumentError, 'table_name is nil' if table_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/cassandra/keyspaces/{keyspaceName}/tables/{tableName}/settings/throughput' 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,'keyspaceName' => keyspace_name,'tableName' => table_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_gremlin_database_parameters # [GremlinDatabaseCreateUpdateParameters] The parameters to provide for the # current Gremlin database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinDatabase] operation results. # def begin_create_update_gremlin_database(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:nil) response = begin_create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_gremlin_database_parameters # [GremlinDatabaseCreateUpdateParameters] The parameters to provide for the # current Gremlin database. # @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. # def begin_create_update_gremlin_database_with_http_info(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:nil) begin_create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param create_update_gremlin_database_parameters # [GremlinDatabaseCreateUpdateParameters] The parameters to provide for the # current Gremlin database. # @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. # def begin_create_update_gremlin_database_async(resource_group_name, account_name, database_name, create_update_gremlin_database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_gremlin_database_parameters is nil' if create_update_gremlin_database_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::V2015_04_08::Models::GremlinDatabaseCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_gremlin_database_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}/apis/gremlin/databases/{databaseName}' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::GremlinDatabase.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 # # Deletes an existing Azure Cosmos DB Gremlin database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_gremlin_database(resource_group_name, account_name, database_name, custom_headers:nil) response = begin_delete_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB Gremlin database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_gremlin_database_with_http_info(resource_group_name, account_name, database_name, custom_headers:nil) begin_delete_gremlin_database_async(resource_group_name, account_name, database_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB Gremlin database. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database 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. # def begin_delete_gremlin_database_async(resource_group_name, account_name, database_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}' 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,'databaseName' => database_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 # # Update RUs per second of an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin database. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_gremlin_database_throughput(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) response = begin_update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin database. # @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. # def begin_update_gremlin_database_throughput_with_http_info(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:nil) begin_update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB Gremlin database # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin database. # @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. # def begin_update_gremlin_database_throughput_async(resource_group_name, account_name, database_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/gremlin/databases/{databaseName}/settings/throughput' 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,'databaseName' => database_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 == 202 || 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::V2015_04_08::Models::Throughput.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # Create or update an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param create_update_gremlin_graph_parameters # [GremlinGraphCreateUpdateParameters] The parameters to provide for the # current Gremlin graph. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [GremlinGraph] operation results. # def begin_create_update_gremlin_graph(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:nil) response = begin_create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Create or update an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param create_update_gremlin_graph_parameters # [GremlinGraphCreateUpdateParameters] The parameters to provide for the # current Gremlin graph. # @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. # def begin_create_update_gremlin_graph_with_http_info(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:nil) begin_create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_parameters, custom_headers:custom_headers).value! end # # Create or update an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param create_update_gremlin_graph_parameters # [GremlinGraphCreateUpdateParameters] The parameters to provide for the # current Gremlin graph. # @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. # def begin_create_update_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, create_update_gremlin_graph_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'graph_name is nil' if graph_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'create_update_gremlin_graph_parameters is nil' if create_update_gremlin_graph_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::V2015_04_08::Models::GremlinGraphCreateUpdateParameters.mapper() request_content = @client.serialize(request_mapper, create_update_gremlin_graph_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}/apis/gremlin/databases/{databaseName}/graphs/{graphName}' 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,'databaseName' => database_name,'graphName' => graph_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 == 202 || 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::V2015_04_08::Models::GremlinGraph.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 # # Deletes an existing Azure Cosmos DB Gremlin graph. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_delete_gremlin_graph(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) response = begin_delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! nil end # # Deletes an existing Azure Cosmos DB Gremlin graph. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def begin_delete_gremlin_graph_with_http_info(resource_group_name, account_name, database_name, graph_name, custom_headers:nil) begin_delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_name, custom_headers:custom_headers).value! end # # Deletes an existing Azure Cosmos DB Gremlin graph. # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph 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. # def begin_delete_gremlin_graph_async(resource_group_name, account_name, database_name, graph_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'graph_name is nil' if graph_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/apis/gremlin/databases/{databaseName}/graphs/{graphName}' 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,'databaseName' => database_name,'graphName' => graph_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 # # Update RUs per second of an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin graph. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Throughput] operation results. # def begin_update_gremlin_graph_throughput(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:nil) response = begin_update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Update RUs per second of an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin graph. # @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. # def begin_update_gremlin_graph_throughput_with_http_info(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:nil) begin_update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_parameters, custom_headers:custom_headers).value! end # # Update RUs per second of an Azure Cosmos DB Gremlin graph # # @param resource_group_name [String] Name of an Azure resource group. # @param account_name [String] Cosmos DB database account name. # @param database_name [String] Cosmos DB database name. # @param graph_name [String] Cosmos DB graph name. # @param update_throughput_parameters [ThroughputUpdateParameters] The RUs per # second of the parameters to provide for the current Gremlin graph. # @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. # def begin_update_gremlin_graph_throughput_async(resource_group_name, account_name, database_name, graph_name, update_throughput_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, 'database_name is nil' if database_name.nil? fail ArgumentError, 'graph_name is nil' if graph_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, 'update_throughput_parameters is nil' if update_throughput_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::V2015_04_08::Models::ThroughputUpdateParameters.mapper() request_content = @client.serialize(request_mapper, update_throughput_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}/apis/gremlin/databases/{databaseName}/graphs/{graphName}/settings/throughput' 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,'databaseName' => database_name,'graphName' => graph_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 == 202 || 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::V2015_04_08::Models::Throughput.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 end end