Sha256: 41919a352cfef45e9e41de84bba2672845a2bf9480d8cbcb343526d10c92cd28

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

require 'aptible/auth'

module Aptible
  module Api
    class Account < Resource
      belongs_to :stack

      has_many :apps
      has_many :backups
      has_many :certificates
      has_many :databases
      has_many :disks
      has_many :services
      has_many :permissions
      embeds_many :log_drains

      field :id
      field :type
      field :name
      field :handle
      field :number
      field :type
      field :activated, type: Aptible::Resource::Boolean
      field :syslog_host
      field :syslog_port
      field :created_at, type: Time
      field :updated_at, type: Time
      field :gentlemanjerry_endpoint
      field :gentlemanjerry_certificate
      field :gentlemanjerry_docker_name
      field :gentlemanjerry_instance_id

      def production?
        type == 'production'
      end

      def operations
        # TODO: Implement /accounts/:id/operations
        []
      end

      def dumptruck_port
        # TODO: Fetch from API
        45022
      end

      def organization_url
        links['organization'].href
      end

      def organization
        return @organization if @organization
        auth = Aptible::Auth::Organization.new(token: token, headers: headers)
        @organization = auth.find_by_url(organization_url)
      end

      def self.generate_handle(organization_name, plan_id)
        rand = ('a'..'z').to_a.sample(8).join
        "#{organization_name.parameterize}-#{plan_id}-#{rand}"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
aptible-api-1.0.2 lib/aptible/api/account.rb
aptible-api-1.0.1 lib/aptible/api/account.rb
aptible-api-1.0.0 lib/aptible/api/account.rb
aptible-api-0.11.0 lib/aptible/api/account.rb
aptible-api-0.10.0 lib/aptible/api/account.rb
aptible-api-0.9.27 lib/aptible/api/account.rb
aptible-api-0.9.26 lib/aptible/api/account.rb
aptible-api-0.9.25 lib/aptible/api/account.rb
aptible-api-0.9.24 lib/aptible/api/account.rb
aptible-api-0.9.23 lib/aptible/api/account.rb
aptible-api-0.9.22 lib/aptible/api/account.rb
aptible-api-0.9.21 lib/aptible/api/account.rb
aptible-api-0.9.20 lib/aptible/api/account.rb
aptible-api-0.9.19 lib/aptible/api/account.rb
aptible-api-0.9.18 lib/aptible/api/account.rb
aptible-api-0.9.17 lib/aptible/api/account.rb
aptible-api-0.9.16 lib/aptible/api/account.rb