Sha256: af68c1c1bd0be3ac8cf6c95c9e4b541c2ab17036c5641cffee8b2d568ad5a938

Contents?: true

Size: 896 Bytes

Versions: 15

Compression:

Stored size: 896 Bytes

Contents

module Brightbox
  class Account < Api
    def ram_free
      [ram_limit.to_i - ram_used.to_i, 0].max
    end

    def cloud_ip_limit
      attributes[:cloud_ips_limit]
    end

    def lb_limit
      attributes[:load_balancers_limit]
    end

    def to_row
      attributes.merge(:ram_free => ram_free, :cloud_ip_limit => cloud_ip_limit, :lb_limit => lb_limit)
    end

    def self.all
      if Brightbox.config.using_application?
        conn.accounts.all
      else
        [conn.account]
      end
    end

    def self.get(id)
      acc = if Brightbox.config.using_application?
              conn.accounts.get(id)
            else
              conn.account
            end

      return unless acc && acc.id == id

      acc
    end

    def self.default_field_order
      %i[id name cloud_ips_limit lb_limit ram_limit ram_used ram_free]
    end

    def to_s
      @id
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.alpha lib/brightbox-cli/accounts.rb
brightbox-cli-4.8.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.7.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.6.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.5.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/accounts.rb
brightbox-cli-4.4.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.3.2 lib/brightbox-cli/accounts.rb
brightbox-cli-4.3.1 lib/brightbox-cli/accounts.rb
brightbox-cli-4.3.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.2.1 lib/brightbox-cli/accounts.rb
brightbox-cli-4.2.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.1.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.0.0 lib/brightbox-cli/accounts.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/accounts.rb