Sha256: 9a9d2204b2e01db9e877ccdc9f9ffe8a8c4482a6bc4835bc5157a5da4b540ef6

Contents?: true

Size: 1.41 KB

Versions: 20

Compression:

Stored size: 1.41 KB

Contents

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

          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'].kind_of? 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

20 entries across 20 versions & 3 rubygems

Version Path
fog-openstack-1.1.3 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.1.2 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-fork-99 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.1.0 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.1.0.pre lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-apibank-1.0.102 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.11 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-apibank-1.0.101 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.10 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.9 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.8 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.7 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.6 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.5 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.4 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.3 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.2 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.1 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-1.0.0 lib/fog/openstack/metering/requests/get_statistics.rb
fog-openstack-0.3.1 lib/fog/openstack/metering/requests/get_statistics.rb