# 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::Storage::Mgmt::V2021_01_01 # # The Azure Storage Management API. # class StorageAccounts include MsRestAzure # # Creates and initializes a new instance of the StorageAccounts class. # @param client service class for accessing basic functionality. # def initialize(client) @client = client end # @return [StorageManagementClient] reference to the StorageManagementClient attr_reader :client # # Checks that the storage account name is valid and is not already in use. # # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name # of the storage account within the specified resource group. Storage account # names must be between 3 and 24 characters in length and use numbers and # lower-case letters only. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [CheckNameAvailabilityResult] operation results. # def check_name_availability(account_name, custom_headers:nil) response = check_name_availability_async(account_name, custom_headers:custom_headers).value! response.body unless response.nil? end # # Checks that the storage account name is valid and is not already in use. # # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name # of the storage account within the specified resource group. Storage account # names must be between 3 and 24 characters in length and use numbers and # lower-case letters only. # @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_availability_with_http_info(account_name, custom_headers:nil) check_name_availability_async(account_name, custom_headers:custom_headers).value! end # # Checks that the storage account name is valid and is not already in use. # # @param account_name [StorageAccountCheckNameAvailabilityParameters] The name # of the storage account within the specified resource group. Storage account # names must be between 3 and 24 characters in length and use numbers and # lower-case letters only. # @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_availability_async(account_name, custom_headers:nil) fail ArgumentError, 'account_name is nil' if account_name.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountCheckNameAvailabilityParameters.mapper() request_content = @client.serialize(request_mapper, account_name) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability' 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}, 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 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::Storage::Mgmt::V2021_01_01::Models::CheckNameAvailabilityResult.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 # # Asynchronously creates a new storage account with the specified parameters. # If an account is already created and a subsequent create request is issued # with different properties, the account properties will be updated. If an # account is already created and a subsequent create or update request is # issued with the exact same set of properties, the request will succeed. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountCreateParameters] The parameters to provide # for the created account. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccount] operation results. # def create(resource_group_name, account_name, parameters, custom_headers:nil) response = create_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountCreateParameters] The parameters to provide # for the created 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_async(resource_group_name, account_name, parameters, custom_headers:nil) # Send request promise = begin_create_async(resource_group_name, account_name, parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::StorageAccount.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 a storage account in Microsoft Azure. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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 # # Deletes a storage account in Microsoft Azure. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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 delete_with_http_info(resource_group_name, account_name, custom_headers:nil) delete_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Deletes a storage account in Microsoft Azure. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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 delete_async(resource_group_name, account_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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts/{accountName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:delete, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 || status_code == 204 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? result end promise.execute end # # Returns the properties for the specified storage account including but not # limited to name, SKU name, location, and account status. The ListKeys # operation should be used to retrieve storage keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [StorageAccountExpand] May be used to expand the properties # within account's properties. By default, data is not included when fetching # properties. Currently we only support geoReplicationStats and # blobRestoreStatus. Possible values include: 'geoReplicationStats', # 'blobRestoreStatus' # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccount] operation results. # def get_properties(resource_group_name, account_name, expand:nil, custom_headers:nil) response = get_properties_async(resource_group_name, account_name, expand:expand, custom_headers:custom_headers).value! response.body unless response.nil? end # # Returns the properties for the specified storage account including but not # limited to name, SKU name, location, and account status. The ListKeys # operation should be used to retrieve storage keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [StorageAccountExpand] May be used to expand the properties # within account's properties. By default, data is not included when fetching # properties. Currently we only support geoReplicationStats and # blobRestoreStatus. Possible values include: 'geoReplicationStats', # 'blobRestoreStatus' # @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_properties_with_http_info(resource_group_name, account_name, expand:nil, custom_headers:nil) get_properties_async(resource_group_name, account_name, expand:expand, custom_headers:custom_headers).value! end # # Returns the properties for the specified storage account including but not # limited to name, SKU name, location, and account status. The ListKeys # operation should be used to retrieve storage keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [StorageAccountExpand] May be used to expand the properties # within account's properties. By default, data is not included when fetching # properties. Currently we only support geoReplicationStats and # blobRestoreStatus. Possible values include: 'geoReplicationStats', # 'blobRestoreStatus' # @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_properties_async(resource_group_name, account_name, expand:nil, custom_headers:nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90 fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1 fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil? fail ArgumentError, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts/{accountName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version,'$expand' => expand}, 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::Storage::Mgmt::V2021_01_01::Models::StorageAccount.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 # # The update operation can be used to update the SKU, encryption, access tier, # or tags for a storage account. It can also be used to map the account to a # custom domain. Only one custom domain is supported per storage account; the # replacement/change of custom domain is not supported. In order to replace an # old custom domain, the old value must be cleared/unregistered before a new # value can be set. The update of multiple properties is supported. This call # does not change the storage keys for the account. If you want to change the # storage account keys, use the regenerate keys operation. The location and # name of the storage account cannot be changed after creation. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountUpdateParameters] The parameters to provide # for the updated account. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccount] operation results. # def update(resource_group_name, account_name, parameters, custom_headers:nil) response = update_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # The update operation can be used to update the SKU, encryption, access tier, # or tags for a storage account. It can also be used to map the account to a # custom domain. Only one custom domain is supported per storage account; the # replacement/change of custom domain is not supported. In order to replace an # old custom domain, the old value must be cleared/unregistered before a new # value can be set. The update of multiple properties is supported. This call # does not change the storage keys for the account. If you want to change the # storage account keys, use the regenerate keys operation. The location and # name of the storage account cannot be changed after creation. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountUpdateParameters] The parameters to provide # for the updated 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 update_with_http_info(resource_group_name, account_name, parameters, custom_headers:nil) update_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! end # # The update operation can be used to update the SKU, encryption, access tier, # or tags for a storage account. It can also be used to map the account to a # custom domain. Only one custom domain is supported per storage account; the # replacement/change of custom domain is not supported. In order to replace an # old custom domain, the old value must be cleared/unregistered before a new # value can be set. The update of multiple properties is supported. This call # does not change the storage keys for the account. If you want to change the # storage account keys, use the regenerate keys operation. The location and # name of the storage account cannot be changed after creation. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountUpdateParameters] The parameters to provide # for the updated 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 update_async(resource_group_name, account_name, parameters, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, 'parameters is nil' if parameters.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountUpdateParameters.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(: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::Storage::Mgmt::V2021_01_01::Models::StorageAccount.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 storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def list(custom_headers:nil) first_page = list_as_lazy(custom_headers:custom_headers) first_page.get_all_items end # # Lists all the storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @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 storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @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.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts' 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountListResult.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 storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [Array] operation results. # def list_by_resource_group(resource_group_name, custom_headers:nil) first_page = list_by_resource_group_as_lazy(resource_group_name, custom_headers:custom_headers) first_page.get_all_items end # # Lists all the storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @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 storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @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.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts' 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountListResult.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 or Kerberos keys (if active directory enabled) for the # specified storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [ListKeyExpand] Specifies type of the key to be listed. # Possible value is kerb. Possible values include: 'kerb' # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListKeysResult] operation results. # def list_keys(resource_group_name, account_name, expand:nil, custom_headers:nil) response = list_keys_async(resource_group_name, account_name, expand:expand, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists the access keys or Kerberos keys (if active directory enabled) for the # specified storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [ListKeyExpand] Specifies type of the key to be listed. # Possible value is kerb. Possible values include: 'kerb' # @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, expand:nil, custom_headers:nil) list_keys_async(resource_group_name, account_name, expand:expand, custom_headers:custom_headers).value! end # # Lists the access keys or Kerberos keys (if active directory enabled) for the # specified storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param expand [ListKeyExpand] Specifies type of the key to be listed. # Possible value is kerb. Possible values include: 'kerb' # @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, expand:nil, custom_headers:nil) fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil? fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MaxLength': '90'" if !resource_group_name.nil? && resource_group_name.length > 90 fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'MinLength': '1'" if !resource_group_name.nil? && resource_group_name.length < 1 fail ArgumentError, "'resource_group_name' should satisfy the constraint - 'Pattern': '^[-\w\._\(\)]+$'" if !resource_group_name.nil? && resource_group_name.match(Regexp.new('^^[-\w\._\(\)]+$$')).nil? fail ArgumentError, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts/{accountName}/listKeys' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version,'$expand' => expand}, 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountListKeysResult.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 one of the access keys or Kerberos keys for the specified storage # account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name # of the key which should be regenerated -- key1, key2, kerb1, kerb2. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListKeysResult] operation results. # def regenerate_key(resource_group_name, account_name, regenerate_key, custom_headers:nil) response = regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers:custom_headers).value! response.body unless response.nil? end # # Regenerates one of the access keys or Kerberos keys for the specified storage # account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name # of the key which should be regenerated -- key1, key2, kerb1, kerb2. # @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 regenerate_key_with_http_info(resource_group_name, account_name, regenerate_key, custom_headers:nil) regenerate_key_async(resource_group_name, account_name, regenerate_key, custom_headers:custom_headers).value! end # # Regenerates one of the access keys or Kerberos keys for the specified storage # account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param regenerate_key [StorageAccountRegenerateKeyParameters] Specifies name # of the key which should be regenerated -- key1, key2, kerb1, kerb2. # @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 regenerate_key_async(resource_group_name, account_name, regenerate_key, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, 'regenerate_key is nil' if regenerate_key.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountRegenerateKeyParameters.mapper() request_content = @client.serialize(request_mapper, regenerate_key) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(: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::Storage::Mgmt::V2021_01_01::Models::StorageAccountListKeysResult.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # List SAS credentials of a storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [AccountSasParameters] The parameters to provide to list # SAS credentials for the storage account. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [ListAccountSasResponse] operation results. # def list_account_sas(resource_group_name, account_name, parameters, custom_headers:nil) response = list_account_sas_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # List SAS credentials of a storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [AccountSasParameters] The parameters to provide to list # SAS credentials for the storage 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 list_account_sas_with_http_info(resource_group_name, account_name, parameters, custom_headers:nil) list_account_sas_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! end # # List SAS credentials of a storage account. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [AccountSasParameters] The parameters to provide to list # SAS credentials for the storage 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 list_account_sas_async(resource_group_name, account_name, parameters, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, 'parameters is nil' if parameters.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::AccountSasParameters.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(: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::Storage::Mgmt::V2021_01_01::Models::ListAccountSasResponse.mapper() result.body = @client.deserialize(result_mapper, parsed_response) rescue Exception => e fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result) end end result end promise.execute end # # List service SAS credentials of a specific resource. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [ServiceSasParameters] The parameters to provide to list # service SAS credentials. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [ListServiceSasResponse] operation results. # def list_service_sas(resource_group_name, account_name, parameters, custom_headers:nil) response = list_service_sas_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # List service SAS credentials of a specific resource. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [ServiceSasParameters] The parameters to provide to list # service SAS credentials. # @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_service_sas_with_http_info(resource_group_name, account_name, parameters, custom_headers:nil) list_service_sas_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! end # # List service SAS credentials of a specific resource. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [ServiceSasParameters] The parameters to provide to list # service SAS credentials. # @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_service_sas_async(resource_group_name, account_name, parameters, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, 'parameters is nil' if parameters.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::ServiceSasParameters.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(: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::Storage::Mgmt::V2021_01_01::Models::ListServiceSasResponse.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 # # Failover request can be triggered for a storage account in case of # availability issues. The failover occurs from the storage account's primary # cluster to secondary cluster for RA-GRS accounts. The secondary cluster will # become primary after failover. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # def failover(resource_group_name, account_name, custom_headers:nil) response = failover_async(resource_group_name, account_name, custom_headers:custom_headers).value! nil end # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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_async(resource_group_name, account_name, custom_headers:nil) # Send request promise = begin_failover_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, FinalStateVia::LOCATION) end promise end # # Restore blobs in the specified blob ranges # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [BlobRestoreParameters] The parameters to provide for # restore blob ranges. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [BlobRestoreStatus] operation results. # def restore_blob_ranges(resource_group_name, account_name, parameters, custom_headers:nil) response = restore_blob_ranges_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [BlobRestoreParameters] The parameters to provide for # restore blob ranges. # @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 restore_blob_ranges_async(resource_group_name, account_name, parameters, custom_headers:nil) # Send request promise = begin_restore_blob_ranges_async(resource_group_name, account_name, parameters, custom_headers:custom_headers) promise = promise.then do |response| # Defining deserialization method. deserialize_method = lambda do |parsed_response| result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::BlobRestoreStatus.mapper() parsed_response = @client.deserialize(result_mapper, parsed_response) end # Waiting for response. @client.get_long_running_operation_result(response, deserialize_method, FinalStateVia::LOCATION) end promise end # # Revoke user delegation keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def revoke_user_delegation_keys(resource_group_name, account_name, custom_headers:nil) response = revoke_user_delegation_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value! nil end # # Revoke user delegation keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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 revoke_user_delegation_keys_with_http_info(resource_group_name, account_name, custom_headers:nil) revoke_user_delegation_keys_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Revoke user delegation keys. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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 revoke_user_delegation_keys_async(resource_group_name, account_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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_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(: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? result end promise.execute end # # Asynchronously creates a new storage account with the specified parameters. # If an account is already created and a subsequent create request is issued # with different properties, the account properties will be updated. If an # account is already created and a subsequent create or update request is # issued with the exact same set of properties, the request will succeed. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountCreateParameters] The parameters to provide # for the created account. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccount] operation results. # def begin_create(resource_group_name, account_name, parameters, custom_headers:nil) response = begin_create_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Asynchronously creates a new storage account with the specified parameters. # If an account is already created and a subsequent create request is issued # with different properties, the account properties will be updated. If an # account is already created and a subsequent create or update request is # issued with the exact same set of properties, the request will succeed. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountCreateParameters] The parameters to provide # for the created 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_with_http_info(resource_group_name, account_name, parameters, custom_headers:nil) begin_create_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! end # # Asynchronously creates a new storage account with the specified parameters. # If an account is already created and a subsequent create request is issued # with different properties, the account properties will be updated. If an # account is already created and a subsequent create or update request is # issued with the exact same set of properties, the request will succeed. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [StorageAccountCreateParameters] The parameters to provide # for the created 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_async(resource_group_name, account_name, parameters, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, 'parameters is nil' if parameters.nil? fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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::Storage::Mgmt::V2021_01_01::Models::StorageAccountCreateParameters.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:put, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::StorageAccount.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 # # Failover request can be triggered for a storage account in case of # availability issues. The failover occurs from the storage account's primary # cluster to secondary cluster for RA-GRS accounts. The secondary cluster will # become primary after failover. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # def begin_failover(resource_group_name, account_name, custom_headers:nil) response = begin_failover_async(resource_group_name, account_name, custom_headers:custom_headers).value! nil end # # Failover request can be triggered for a storage account in case of # availability issues. The failover occurs from the storage account's primary # cluster to secondary cluster for RA-GRS accounts. The secondary cluster will # become primary after failover. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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_with_http_info(resource_group_name, account_name, custom_headers:nil) begin_failover_async(resource_group_name, account_name, custom_headers:custom_headers).value! end # # Failover request can be triggered for a storage account in case of # availability issues. The failover occurs from the storage account's primary # cluster to secondary cluster for RA-GRS accounts. The secondary cluster will # become primary after failover. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @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_async(resource_group_name, account_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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 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.Storage/storageAccounts/{accountName}/failover' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_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(: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 # # Restore blobs in the specified blob ranges # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [BlobRestoreParameters] The parameters to provide for # restore blob ranges. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [BlobRestoreStatus] operation results. # def begin_restore_blob_ranges(resource_group_name, account_name, parameters, custom_headers:nil) response = begin_restore_blob_ranges_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! response.body unless response.nil? end # # Restore blobs in the specified blob ranges # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [BlobRestoreParameters] The parameters to provide for # restore blob ranges. # @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_restore_blob_ranges_with_http_info(resource_group_name, account_name, parameters, custom_headers:nil) begin_restore_blob_ranges_async(resource_group_name, account_name, parameters, custom_headers:custom_headers).value! end # # Restore blobs in the specified blob ranges # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param account_name [String] The name of the storage account within the # specified resource group. Storage account names must be between 3 and 24 # characters in length and use numbers and lower-case letters only. # @param parameters [BlobRestoreParameters] The parameters to provide for # restore blob ranges. # @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_restore_blob_ranges_async(resource_group_name, account_name, parameters, 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, 'account_name is nil' if account_name.nil? fail ArgumentError, "'account_name' should satisfy the constraint - 'MaxLength': '24'" if !account_name.nil? && account_name.length > 24 fail ArgumentError, "'account_name' should satisfy the constraint - 'MinLength': '3'" if !account_name.nil? && account_name.length < 3 fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil? fail ArgumentError, "'@client.api_version' should satisfy the constraint - 'MinLength': '1'" if !@client.api_version.nil? && @client.api_version.length < 1 fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil? fail ArgumentError, "'@client.subscription_id' should satisfy the constraint - 'MinLength': '1'" if !@client.subscription_id.nil? && @client.subscription_id.length < 1 fail ArgumentError, 'parameters is nil' if 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::Storage::Mgmt::V2021_01_01::Models::BlobRestoreParameters.mapper() request_content = @client.serialize(request_mapper, parameters) request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil path_template = 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], path_params: {'resourceGroupName' => resource_group_name,'accountName' => account_name,'subscriptionId' => @client.subscription_id}, query_params: {'api-version' => @client.api_version}, body: request_content, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(: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? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::BlobRestoreStatus.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 # Deserialize Response if status_code == 202 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::BlobRestoreStatus.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 storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListResult] operation results. # def list_next(next_page_link, custom_headers:nil) response = list_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists all the storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def list_next_with_http_info(next_page_link, custom_headers:nil) list_next_async(next_page_link, custom_headers:custom_headers).value! end # # Lists all the storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def list_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '{nextLink}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::StorageAccountListResult.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 storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListResult] operation results. # def list_by_resource_group_next(next_page_link, custom_headers:nil) response = list_by_resource_group_next_async(next_page_link, custom_headers:custom_headers).value! response.body unless response.nil? end # # Lists all the storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [MsRestAzure::AzureOperationResponse] HTTP response information. # def list_by_resource_group_next_with_http_info(next_page_link, custom_headers:nil) list_by_resource_group_next_async(next_page_link, custom_headers:custom_headers).value! end # # Lists all the storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param next_page_link [String] The NextLink from the previous successful call # to List operation. # @param [Hash{String => String}] A hash of custom headers that will be added # to the HTTP request. # # @return [Concurrent::Promise] Promise object which holds the HTTP response. # def list_by_resource_group_next_async(next_page_link, custom_headers:nil) fail ArgumentError, 'next_page_link is nil' if next_page_link.nil? request_headers = {} request_headers['Content-Type'] = 'application/json; charset=utf-8' # Set Headers request_headers['x-ms-client-request-id'] = SecureRandom.uuid request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil? path_template = '{nextLink}' request_url = @base_url || @client.base_url options = { middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]], skip_encoding_path_params: {'nextLink' => next_page_link}, headers: request_headers.merge(custom_headers || {}), base_url: request_url } promise = @client.make_request_async(:get, path_template, options) promise = promise.then do |result| http_response = result.response status_code = http_response.status response_content = http_response.body unless status_code == 200 error_model = JSON.load(response_content) fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model) end result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil? result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil? result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil? # Deserialize Response if status_code == 200 begin parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content) result_mapper = Azure::Storage::Mgmt::V2021_01_01::Models::StorageAccountListResult.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 storage accounts available under the subscription. Note that # storage keys are not returned; use the ListKeys operation for this. # # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListResult] which provide lazy access to pages of the # response. # def list_as_lazy(custom_headers:nil) response = list_async(custom_headers:custom_headers).value! unless response.nil? page = response.body page.next_method = Proc.new do |next_page_link| list_next_async(next_page_link, custom_headers:custom_headers) end page end end # # Lists all the storage accounts available under the given resource group. Note # that storage keys are not returned; use the ListKeys operation for this. # # @param resource_group_name [String] The name of the resource group within the # user's subscription. The name is case insensitive. # @param custom_headers [Hash{String => String}] A hash of custom headers that # will be added to the HTTP request. # # @return [StorageAccountListResult] which provide lazy access to pages of the # response. # def list_by_resource_group_as_lazy(resource_group_name, custom_headers:nil) response = list_by_resource_group_async(resource_group_name, custom_headers:custom_headers).value! unless response.nil? page = response.body page.next_method = Proc.new do |next_page_link| list_by_resource_group_next_async(next_page_link, custom_headers:custom_headers) end page end end end end