Class: Aptible::Api::Account

Inherits:
Resource
  • Object
show all
Defined in:
lib/aptible/api/account.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#namespace, #root_url

Class Method Details

.generate_handle(organization_name, plan_id) ⇒ Object



66
67
68
69
# File 'lib/aptible/api/account.rb', line 66

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

Instance Method Details

#dumptruck_portObject



50
51
52
53
# File 'lib/aptible/api/account.rb', line 50

def dumptruck_port
  # TODO: Fetch from API
  45022
end

#each_orphaned_backupObject



71
72
73
74
75
76
77
# File 'lib/aptible/api/account.rb', line 71

def each_orphaned_backup
  base_href = "#{links['backups'].base_href}?orphaned=true"
  Backup.each_page(href: base_href, headers: headers,
                   token: token) do |page|
    page.each { |entry| yield entry }
  end
end

#operationsObject



45
46
47
48
# File 'lib/aptible/api/account.rb', line 45

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

#organizationObject



59
60
61
62
63
64
# File 'lib/aptible/api/account.rb', line 59

def organization
  return @organization if @organization

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

#organization_urlObject



55
56
57
# File 'lib/aptible/api/account.rb', line 55

def organization_url
  links['organization'].href
end

#production?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/aptible/api/account.rb', line 41

def production?
  type == 'production'
end