Sha256: 6732987ac844286c53d7ca16f0d2ad83bdcec0237807317028a05eeeb158980a

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

module Yao::Resources
  class OldSample < Base
    friendly_attributes :counter_name, :counter_type, :counter_unit, :counter_volume,
                        :message_id, :project_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
      meter_id
    end

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

    def tenant
      @tenant ||= Yao::Tenant.get(project_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("meters/#{meter_name}", query).body unless cache[cache_key]
      return_resources(cache[cache_key])
    end

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
yao-0.3.5 lib/yao/resources/old_sample.rb
yao-0.3.4 lib/yao/resources/old_sample.rb
yao-0.3.3 lib/yao/resources/old_sample.rb
yao-0.3.2 lib/yao/resources/old_sample.rb
yao-0.3.1 lib/yao/resources/old_sample.rb
yao-0.3.0 lib/yao/resources/old_sample.rb
yao-0.2.13 lib/yao/resources/old_sample.rb
yao-0.2.12 lib/yao/resources/old_sample.rb
yao-0.2.11 lib/yao/resources/old_sample.rb
yao-0.2.10 lib/yao/resources/old_sample.rb
yao-0.2.9 lib/yao/resources/old_sample.rb
yao-0.2.8 lib/yao/resources/old_sample.rb
yao-0.2.7 lib/yao/resources/old_sample.rb
yao-0.2.6 lib/yao/resources/old_sample.rb
yao-0.2.5 lib/yao/resources/old_sample.rb