Sha256: 2c755544fed2cc2f38c40468d1fcac8f69cc4ef8da4ad050f7ce0b6c7e1ffb37

Contents?: true

Size: 1.37 KB

Versions: 32

Compression:

Stored size: 1.37 KB

Contents

module Aptible
  module Api
    class Database < Resource
      belongs_to :account
      belongs_to :database_image
      belongs_to :current_configuration
      embeds_one :last_operation
      embeds_one :disk
      has_one :service
      has_one :initialize_from
      has_many :operations
      has_many :backups
      has_many :dependents
      has_many :configurations
      has_many :aws_instances
      embeds_many :database_credentials

      field :id
      field :handle
      field :type
      field :passphrase
      field :connection_url
      field :created_at, type: Time
      field :updated_at, type: Time
      field :status
      field :docker_repo
      field :port_mapping

      def failed?
        # TODO: Add failed status at API level
        return false if provisioned?

        operations.select { |o| o.type == 'provision' }.all?(&:failed?)
      end

      def provisioned?
        status == 'provisioned'
      end

      def current_configuration_with_deleted
        id = links['current_configuration'].href.split('/').last
        Aptible::Api::Configuration.find(
          id, with_deleted: true, token: token, headers: headers
        )
      end

      def disk_with_deleted
        id = links['disk'].href.split('/').last
        Aptible::Api::Disk.find(
          id, with_deleted: true, token: token, headers: headers
        )
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
aptible-api-1.6.2 lib/aptible/api/database.rb
aptible-api-1.6.1 lib/aptible/api/database.rb
aptible-api-1.6.0 lib/aptible/api/database.rb
aptible-api-1.5.4 lib/aptible/api/database.rb
aptible-api-1.5.1 lib/aptible/api/database.rb
aptible-api-1.5.0 lib/aptible/api/database.rb
aptible-api-1.4.8 lib/aptible/api/database.rb
aptible-api-1.4.7 lib/aptible/api/database.rb
aptible-api-1.4.6 lib/aptible/api/database.rb
aptible-api-1.4.5 lib/aptible/api/database.rb
aptible-api-1.4.4 lib/aptible/api/database.rb
aptible-api-1.4.3 lib/aptible/api/database.rb
aptible-api-1.4.2 lib/aptible/api/database.rb
aptible-api-1.4.1 lib/aptible/api/database.rb
aptible-api-1.4.0 lib/aptible/api/database.rb
aptible-api-1.3.0 lib/aptible/api/database.rb
aptible-api-1.2.23 lib/aptible/api/database.rb
aptible-api-1.2.22 lib/aptible/api/database.rb
aptible-api-1.2.21 lib/aptible/api/database.rb
aptible-api-1.2.20 lib/aptible/api/database.rb