Sha256: 4a0dc9149faa0601fee738a85ff2fc2ddfd1d2dd2fdb7e4527bfa5a70e63381d

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

module Fog
  module Storage
    class AzureRM
      # This class provides the actual implemention for service calls.
      class Real
        def check_storage_account_name_availability(params)
          Fog::Logger.debug "Checking Name availability: #{params.name}."
          begin
            promise = @storage_mgmt_client.storage_accounts.check_name_availability(params)
            result = promise.value!
            name_available_obj = Azure::ARM::Storage::Models::CheckNameAvailabilityResult.serialize_object(result.body)
            if name_available_obj['nameAvailable'] == true
              Fog::Logger.debug "Name: #{params.name} is available."
              return true
            else
              Fog::Logger.debug "Name: #{params.name} is not available."
              Fog::Logger.debug "Reason: #{name_available_obj['reason']}."
              return false
            end
          rescue MsRestAzure::AzureOperationError => e
            msg = "Exception checking name availability: #{e.body['error']['message']}"
            raise msg if e.body['error']['code'] == 'ResourceGroupNotFound'
          end
        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."
          return true
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.2 lib/fog/azurerm/requests/storage/check_storage_account_name_availability.rb