Sha256: 0111621fa0c37f01af89ce68d2fc4a517d74f0f4cee607ffdf3cd49f8aa84f62
Contents?: true
Size: 1.27 KB
Versions: 15
Compression:
Stored size: 1.27 KB
Contents
require 'time' module Yao::Resources class Resource < Base include TenantAssociationable friendly_attributes :user_id, :resource_id, :last_sample_timestamp, :first_sample_timestamp, :metadata, :links def id resource_id end def user @user ||= Yao::User.get(user_id) end def last_sampled_at Time.parse last_sample_timestamp end def first_sampled_at Time.parse first_sample_timestamp end def get_meter(name) if link = links.find{|l| l["rel"] == name } Yao::Sample.list(link["href"]) end end def meters links.map{|l| l["rel"] }.delete_if{|n| n == 'self' } end self.service = "metering" self.api_version = "v2" self.resources_name = "resources" class << self private # override Yao::Resources::RestfullyAccessible.resource_from_json # @param [Hash] # @return [Yao::Resources::Resource] def resource_from_json(json) new(json) end # override Yao::Resources::RestfullyAccessible.resources_from_json # @param [Hash] # @return [Yao::Resources::Resource] def resources_from_json(json) new(json) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems