Sha256: 08c95f59f3d5fc78736e1c4afa416d83d76b38b6490e0c7f791160f070963a47

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Yao::Resources
  class OldSample < Base
    include TenantAssociationable

    friendly_attributes :counter_name, :counter_type, :counter_unit, :counter_volume,
                        :message_id, :resource_id, :timestamp, :resource_metadata, :user_id,
                        :source

    def recorded_at
      Time.parse(self["recorded_at"] || self["timestamp"])
    end
    alias timestamp recorded_at

    def id
      message_id
    end

    def resource
      @resource ||= Yao::Resource.get(resource_id)
    end

    def user
      @user ||= Yao::User.get(user_id)
    end

    self.service        = "metering"
    self.api_version    = "v2"

    # get /v2/meters/{id} returns samples!
    def self.list(meter_name, query={})
      cache_key = [meter_name, *query].join
      cache[cache_key] = GET("#{self.api_version}/meters/#{meter_name}", query).body unless cache[cache_key]
      new(cache[cache_key])
    end

    def self.cache
      @@_cache ||= {}
    end

    # TODO: implement `def self.create'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yao-0.9.1 lib/yao/resources/old_sample.rb
yao-0.9.0 lib/yao/resources/old_sample.rb
yao-0.8.0 lib/yao/resources/old_sample.rb