Class: Aws::CloudWatch::Resource
- Inherits:
-
Object
- Object
- Aws::CloudWatch::Resource
- Defined in:
- lib/aws-sdk-cloudwatch/resource.rb
Associations collapse
- #alarm(name) ⇒ Alarm
- #alarms(options = {}) ⇒ Alarm::Collection
- #metric(namespace, name) ⇒ Metric
- #metrics(options = {}) ⇒ Metric::Collection
Instance Method Summary collapse
- #client ⇒ Client
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Method Details
#alarm(name) ⇒ Alarm
26 27 28 29 30 31 |
# File 'lib/aws-sdk-cloudwatch/resource.rb', line 26 def alarm(name) Alarm.new( name: name, client: @client ) end |
#alarms(options = {}) ⇒ Alarm::Collection
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/aws-sdk-cloudwatch/resource.rb', line 52 def alarms( = {}) batches = Enumerator.new do |y| resp = @client.describe_alarms() resp.each_page do |page| batch = [] page.data.metric_alarms.each do |m| batch << Alarm.new( name: m.alarm_name, data: m, client: @client ) end y.yield(batch) end end Alarm::Collection.new(batches) end |
#client ⇒ Client
18 19 20 |
# File 'lib/aws-sdk-cloudwatch/resource.rb', line 18 def client @client end |
#metric(namespace, name) ⇒ Metric
73 74 75 76 77 78 79 |
# File 'lib/aws-sdk-cloudwatch/resource.rb', line 73 def metric(namespace, name) Metric.new( namespace: namespace, name: name, client: @client ) end |
#metrics(options = {}) ⇒ Metric::Collection
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/aws-sdk-cloudwatch/resource.rb', line 101 def metrics( = {}) batches = Enumerator.new do |y| resp = @client.list_metrics() resp.each_page do |page| batch = [] page.data.metrics.each do |m| batch << Metric.new( namespace: m.namespace, name: m.metric_name, data: m, client: @client ) end y.yield(batch) end end Metric::Collection.new(batches) end |