Sha256: 722fc44d56df49cf17dc52735055cd0002ea721723078d37efead48a2be00325

Contents?: true

Size: 1.31 KB

Versions: 40

Compression:

Stored size: 1.31 KB

Contents

module Fog
  module Metering
    class OpenStack
      class Real
        def get_statistics(meter_id, options={})
          data = {
            'period' => options['period'],
            'q'      => Array.new
          }

          options['q'].each do |opt|
            filter = {}

            ['field', 'op', 'value'].each do |key|
              filter[key] = opt[key] if opt[key]
            end

            data['q'] << filter unless filter.empty?
          end if options['q'].is_a? Array

          request(
            :body     => Fog::JSON.encode(data),
            :expects  => 200,
            :method   => 'GET',
            :path     => "meters/#{meter_id}/statistics"
          )
        end
      end

      class Mock
        def get_statistics(meter_id, options={})
          response = Excon::Response.new
          response.status = 200
          response.body = [{
            'count'=>143,
            'duration_start'=>'2013-04-03T23:44:21',
            'min'=>10.0,
            'max'=>10.0,
            'duration_end'=>'2013-04-04T23:24:21',
            'period'=>0,
            'period_end'=>'2013-04-04T23:24:21',
            'duration'=>85200.0,
            'period_start'=>'2013-04-03T23:44:21',
            'avg'=>10.0,
            'sum'=>1430.0}]
          response
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.9 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.8 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.7 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.6 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.5 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.4 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.3 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.2 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.1 lib/fog/openstack/requests/metering/get_statistics.rb
fog-openstack-0.1.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.37.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.36.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.35.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-2.0.0.pre.0 lib/fog/openstack/requests/metering/get_statistics.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.34.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.33.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.32.0 lib/fog/openstack/requests/metering/get_statistics.rb
fog-1.31.0 lib/fog/openstack/requests/metering/get_statistics.rb