Class: Yao::Resources::Resource
- Inherits:
-
Base
- Object
- Base
- Yao::Resources::Resource
show all
- Defined in:
- lib/yao/resources/resource.rb
Instance Attribute Summary
#api_version, #service
Instance Method Summary
collapse
Methods inherited from Base
#[], #[]=, #created, friendly_attributes, #initialize, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, #updated
#admin=, #as_member, #client, #create, #destroy, extended, #get, #list, #list_detail, #resources_path, #resources_path=, #return_single_on_querying=, #update, #with_resources_path
Instance Method Details
#first_sampled_at ⇒ Object
25
26
27
|
# File 'lib/yao/resources/resource.rb', line 25
def first_sampled_at
Time.parse first_sample_timestamp
end
|
#get_meter(name) ⇒ Object
29
30
31
32
33
|
# File 'lib/yao/resources/resource.rb', line 29
def get_meter(name)
if link = links.find{|l| l["rel"] == name }
Yao::Sample.list(link["href"])
end
end
|
#id ⇒ Object
9
10
11
|
# File 'lib/yao/resources/resource.rb', line 9
def id
resource_id
end
|
#last_sampled_at ⇒ Object
21
22
23
|
# File 'lib/yao/resources/resource.rb', line 21
def last_sampled_at
Time.parse last_sample_timestamp
end
|
#meters ⇒ Object
35
36
37
|
# File 'lib/yao/resources/resource.rb', line 35
def meters
links.map{|l| l["rel"] }.delete_if{|n| n == 'self' }
end
|
#tenant ⇒ Object
13
14
15
|
# File 'lib/yao/resources/resource.rb', line 13
def tenant
@tenant ||= Yao::User.get(project_id)
end
|
#user ⇒ Object
17
18
19
|
# File 'lib/yao/resources/resource.rb', line 17
def user
@user ||= Yao::User.get(user_id)
end
|