Sha256: 9a0658f38df80d0672ffeec04b67078ca664d631f9f565b4c42240ed77b3d513

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

require 'acquia/cloud/entity'

module Acquia
  class Cloud
    class Database < Entity
      def initialize(cloud, site, database)
        @cloud = cloud
        @site = site
        @data = database
        @url = "/sites/#{@site}/dbs/#{@data['name']}"
      end

      def name
        data['name']
      end

      def on_environment(environment)
        DatabaseEnvironment.new(@cloud, @site, environment, {'name' => name}).refresh
      end

      def copy(from, to)
        from = standardise_env(from)
        to = standardise_env(to)
        task = @cloud.api.post("/sites/#{@site}/dbs/#{name}/db-copy/#{from}/#{to}")
        Task.new @cloud, @site, task
      end

      def backup_on(environment)
        task = @cloud.api.post("/sites/#{@site}/envs/#{environment}/dbs/#{name}/backups")
        Task.new @cloud, @site, task
      end

      private

      def standardise_env(env)
        case (env)
          when Environment
            env.name
          when String
            env
          else
            env.to_s
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
acquia-cloud-0.5.8 lib/acquia/cloud/database.rb
acquia-cloud-0.5.7 lib/acquia/cloud/database.rb
acquia-cloud-0.5.6 lib/acquia/cloud/database.rb
acquia-cloud-0.5.5 lib/acquia/cloud/database.rb
acquia-cloud-0.5.4 lib/acquia/cloud/database.rb
acquia-cloud-0.6.0.dev lib/acquia/cloud/database.rb
acquia-cloud-0.5.3 lib/acquia/cloud/database.rb
acquia-cloud-0.5.2 lib/acquia/cloud/database.rb
acquia-cloud-0.5.1 lib/acquia/cloud/database.rb
acquia-cloud-0.5.0 lib/acquia/cloud/database.rb