Sha256: 94cd30bed84c129d8d1a7671521f8581d3287f4710c641effb3e947c20f951fa

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

module Yao::Resources
  class Tenant < Base
    include ServerUsageAssociationable

    friendly_attributes :id, :name, :description, :enabled

    self.service        = "identity"
    self.resource_name  = "tenant"
    self.resources_name = "tenants"
    self.admin          = true
    self.return_single_on_querying = true

    # @return [Yao::Resources::Server]
    def servers
      @servers ||= Yao::Server.list(all_tenants: 1, project_id: id)
    end

    # @return [Yao::Resources::Meter]
    def meters
      @meters ||= Yao::Meter.list({'q.field' => 'project_id', 'q.op' => 'eq', 'q.value' => id})
    end

    # @return [Yao::Resources::Port]
    def ports
      @ports ||= Yao::Port.list(tenant_id: id)
    end

    # @return [Array<Yao::Resources::Meter>]
    def meters_by_name(meter_name)
      meters.select{|m| m.name == meter_name}
    end

    # @return [Yao::Resources::RoleAssignment]
    def role_assignment
      Yao::RoleAssignment.get(tenant: id)
    end

    class << self
      def accessible
        as_member { self.list }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/tenant.rb
yao-0.20.0 lib/yao/resources/tenant.rb
yao-0.19.0 lib/yao/resources/tenant.rb
yao-0.18.0 lib/yao/resources/tenant.rb
yao-0.17.0 lib/yao/resources/tenant.rb
yao-0.16.0 lib/yao/resources/tenant.rb
yao-0.15.0 lib/yao/resources/tenant.rb