Sha256: 24e16c121c95a6a799980eb4192276146d87451256d47f7fd8b8044650214c5b

Contents?: true

Size: 878 Bytes

Versions: 65

Compression:

Stored size: 878 Bytes

Contents

require 'fog/core/collection'
require 'fog/aws/models/cloud_watch/metric_statistic'

module Fog
  module AWS
    class CloudWatch
      class MetricStatistics < Fog::Collection
        model Fog::AWS::CloudWatch::MetricStatistic

        def all(conditions)
          metricName = conditions['MetricName']
          namespace = conditions['Namespace']
          dimensions = conditions['Dimensions']
          get_metric_opts = {"StartTime" => (Time.now-3600).iso8601, "EndTime" => Time.now.iso8601, "Period" => 300}.merge(conditions)
          data = service.get_metric_statistics(get_metric_opts).body['GetMetricStatisticsResult']['Datapoints']
          data.collect! { |datum| datum.merge('MetricName' => metricName, 'Namespace' => namespace, 'Dimensions' => dimensions) }
          load(data) # data is an array of attribute hashes
        end

      end
    end
  end
end

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-1.10.0 lib/fog/aws/models/cloud_watch/metric_statistics.rb
fog-1.9.0 lib/fog/aws/models/cloud_watch/metric_statistics.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/aws/models/cloud_watch/metric_statistics.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/aws/models/cloud_watch/metric_statistics.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/aws/models/cloud_watch/metric_statistics.rb