Sha256: b117aac252c28f78888d01592e97aaf8e9c75d517328a98b87b7708822c6e981

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Fog
  module Storage
    class AzureRM
      # This class is giving implementation of all/list, get and
      # check name availability for storage account.
      class StorageAccounts < Fog::Collection
        model Fog::Storage::AzureRM::StorageAccount
        attribute :resource_group

        def all
          accounts = []
          if !resource_group.nil?
            requires :resource_group
            hash_of_storage_accounts = service.list_storage_account_for_rg(resource_group)
          else
            hash_of_storage_accounts = service.list_storage_accounts
          end
          hash_of_storage_accounts.each do |account|
            accounts << Fog::Storage::AzureRM::StorageAccount.parse(account)
          end
          load(accounts)
        end

        def get(resource_group_name, storage_account_name)
          storage_account = service.get_storage_account(resource_group_name, storage_account_name)
          storage_account_fog = Fog::Storage::AzureRM::StorageAccount.new(service: service)
          storage_account_fog.merge_attributes(Fog::Storage::AzureRM::StorageAccount.parse(storage_account))
        end

        def check_name_availability(name)
          params = Azure::ARM::Storage::Models::StorageAccountCheckNameAvailabilityParameters.new
          params.name = name
          params.type = 'Microsoft.Storage/storageAccounts'
          service.check_storage_account_name_availability(params)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.1.1 lib/fog/azurerm/models/storage/storage_accounts.rb