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.4.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.4.0 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.9 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.8 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.7 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.6 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.5 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.4 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.4 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.3 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.3 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-temp-0.0.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-downgraded-0.3.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.1 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-downgraded-0.3.0 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.3.0 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.2.7 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb
fog-azure-rm-0.2.6 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb