Class: Yao::Resources::Tenant

Inherits:
Base
  • Object
show all
Includes:
ServerUsageAssociationable
Defined in:
lib/yao/resources/tenant.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ServerUsageAssociationable

#server_usage

Methods inherited from Base

#[], #[]=, add_instantiation_name_list, #destroy, friendly_attributes, #id, #initialize, instantiation?, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, map_attributes_to_time, #to_hash, #update

Methods included from RestfullyAccessible

#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Class Method Details

.accessibleObject



39
40
41
# File 'lib/yao/resources/tenant.rb', line 39

def accessible
  as_member { self.list }
end

Instance Method Details

#metersYao::Resources::Meter



19
20
21
# File 'lib/yao/resources/tenant.rb', line 19

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

#meters_by_name(meter_name) ⇒ Array<Yao::Resources::Meter>

Returns:



29
30
31
# File 'lib/yao/resources/tenant.rb', line 29

def meters_by_name(meter_name)
  meters.select{|m| m.name == meter_name}
end

#portsYao::Resources::Port



24
25
26
# File 'lib/yao/resources/tenant.rb', line 24

def ports
  @ports ||= Yao::Port.list(tenant_id: id)
end

#role_assignmentYao::Resources::RoleAssignment



34
35
36
# File 'lib/yao/resources/tenant.rb', line 34

def role_assignment
  Yao::RoleAssignment.get(tenant: id)
end

#serversYao::Resources::Server



14
15
16
# File 'lib/yao/resources/tenant.rb', line 14

def servers
  @servers ||= Yao::Server.list(all_tenants: 1, project_id: id)
end