Sha256: 2781a80fa2e38246d979d65d4627b909273b56e336fb991937fa5cd999c9a1b9

Contents?: true

Size: 1.55 KB

Versions: 45

Compression:

Stored size: 1.55 KB

Contents

module Fog
  module Storage
    class AzureRM
      # This class provides the actual implementation for service calls.
      class Real
        def check_storage_account_name_availability(storage_account_name, storage_account_type)
          msg = "Checking Storage Account Name availability: #{storage_account_name}."
          Fog::Logger.debug msg

          storage_account_params = create_storage_account_params(storage_account_name, storage_account_type)
          begin
            name_available_obj = @storage_mgmt_client.storage_accounts.check_name_availability(storage_account_params)
          rescue MsRestAzure::AzureOperationError => e
            raise_azure_exception(e, msg)
          end
          if name_available_obj.name_available
            Fog::Logger.debug "Name: #{storage_account_name} is available."
            true
          else
            Fog::Logger.debug "Name: #{storage_account_type} is not available."
            Fog::Logger.debug "Reason: #{name_available_obj.reason}."
            false
          end
        end

        private

        def create_storage_account_params(name, type)
          params = Azure::ARM::Storage::Models::StorageAccountCheckNameAvailabilityParameters.new
          params.name = name
          params.type = type
          params
        end
      end
      # This class provides the mock implementation for unit tests.
      class Mock
        def check_storage_account_name_availability(params)
          Fog::Logger.debug "Name: #{params.name} is available."
          true
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 4 rubygems

Version Path
fog-azure-rm-0.6.0 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.6 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.5 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.4 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.3 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.9 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.8 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.7 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.6 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.5 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.5 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.4 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.3 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
far-gem-0.5.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb