Sha256: a3101ce4ebe00b325dafb4f044807c67cc31b42f6a095f35991bb7fea22616f0

Contents?: true

Size: 884 Bytes

Versions: 15

Compression:

Stored size: 884 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 $config.using_application?
        conn.accounts.all
      else
        [conn.account]
      end
    end

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

      if a && a.id == id
        a
      else
        nil
      end
    end

    def self.default_field_order
      [: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-2.2.0 lib/brightbox-cli/accounts.rb
brightbox-cli-2.1.2 lib/brightbox-cli/accounts.rb
brightbox-cli-2.1.1 lib/brightbox-cli/accounts.rb
brightbox-cli-2.1.0 lib/brightbox-cli/accounts.rb
brightbox-cli-2.0.0 lib/brightbox-cli/accounts.rb
brightbox-cli-1.6.0 lib/brightbox-cli/accounts.rb
brightbox-cli-1.5.0 lib/brightbox-cli/accounts.rb
brightbox-cli-1.4.3 lib/brightbox-cli/accounts.rb
brightbox-cli-1.4.2 lib/brightbox-cli/accounts.rb
brightbox-cli-1.4.1 lib/brightbox-cli/accounts.rb
brightbox-cli-1.4.0 lib/brightbox-cli/accounts.rb
brightbox-cli-1.3.0 lib/brightbox-cli/accounts.rb
brightbox-cli-1.2.2 lib/brightbox-cli/accounts.rb
brightbox-cli-1.2.1 lib/brightbox-cli/accounts.rb
brightbox-cli-1.2.0 lib/brightbox-cli/accounts.rb