Sha256: 5066003e1104c9fa7c68730267276ba99937a31629f7a2f4f8784b04840f16b7

Contents?: true

Size: 1.45 KB

Versions: 7

Compression:

Stored size: 1.45 KB

Contents

require 'acquia/cloud/entity'

module Acquia
  class Cloud
    class Site < Entity
      attr_reader :name

      def initialize(cloud, name)
        @cloud = cloud
        @name = name
        @url = "/sites/#{name}"
      end

      def name
        data['name']
      end

      def vcs_type
        data['vcs_type'].to_sym
      end

      def vcs_url
        data['vcs_url']
      end

      def production_mode
        data['production_mode'].to_i != 0
      end

      def unix_username
        data['unix_username']
      end

      def title
        data['title']
      end

      def uuid
        data['uuid']
      end

      def copy_files(from, to)
        Task.new @cloud, @name, @cloud.api.post("#{@url}/files-copy/#{from}/#{to}")
      end

      def environments
        @cloud.api.get("#{@url}/envs").map do |environment|
          Environment.new(@cloud, @name, environment)
        end
      end

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

      def databases
        @cloud.api.get("#{@url}/dbs").map do |db|
          Database.new(@cloud, @name, db)
        end
      end

      def database(name)
        Database.new(@cloud, @name, {'name' => name}).refresh
      end

      def tasks
        @cloud.api.get("#{@url}/tasks").map do |task|
          Task.new(@cloud, @name, task)
        end
      end

      def task(id)
        Task.new(@cloud, @name, {'id' => id}).refresh
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
acquia-cloud-0.5.8 lib/acquia/cloud/site.rb
acquia-cloud-0.5.7 lib/acquia/cloud/site.rb
acquia-cloud-0.5.6 lib/acquia/cloud/site.rb
acquia-cloud-0.5.5 lib/acquia/cloud/site.rb
acquia-cloud-0.5.4 lib/acquia/cloud/site.rb
acquia-cloud-0.6.0.dev lib/acquia/cloud/site.rb
acquia-cloud-0.5.3 lib/acquia/cloud/site.rb