Class: Yao::Resources::Tenant

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

Instance Attribute Summary

Attributes included from RestfullyAccessible

#api_version, #service

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#[], #[]=, #created, friendly_attributes, #id, #initialize, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, #updated

Methods included from RestfullyAccessible

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

Constructor Details

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

Class Method Details

.accessibleObject



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

def accessible
  as_member { self.list }
end

.get_by_name(name) ⇒ Object Also known as: find_by_name



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

def get_by_name(name)
  self.list(name: name)
end

Instance Method Details

#metersObject



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

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

#meters_by_name(meter_name) ⇒ Object



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

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

#portsObject



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

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

#serversObject



11
12
13
# File 'lib/yao/resources/tenant.rb', line 11

def servers
  @servers ||= Yao::Server.list_detail(all_tenants: 1).select{|s| s.tenant_id == id }
end