Class: Fog::Rackspace::Monitoring::Entities

Inherits:
Collection
  • Object
show all
Defined in:
lib/fog/rackspace/models/monitoring/entities.rb

Instance Attribute Summary

Attributes inherited from Collection

#service

Instance Method Summary collapse

Methods inherited from Collection

#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Collection

Instance Method Details

#all(options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/fog/rackspace/models/monitoring/entities.rb', line 14

def all(options={})
  data = service.list_entities(options).body
  self.marker = data['metadata']['next_marker']

  load(data['values'])
end

#get(entity_id) ⇒ Object



21
22
23
24
25
26
# File 'lib/fog/rackspace/models/monitoring/entities.rb', line 21

def get(entity_id)
  data = service.get_entity(entity_id).body
  new(data)
rescue Fog::Rackspace::Monitoring::NotFound
  nil
end

#load_all(objects) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace/models/monitoring/entities.rb', line 35

def load_all(objects)
  clear
  for object in objects
    en = new(object['entity'])
    self << en
    en.checks.load(object['checks'])
    en.alarms.load(object['alarms'])
  end
  self
end

#overview(options = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/fog/rackspace/models/monitoring/entities.rb', line 28

def overview(options={})
  body = service.list_overview(options).body
  marker = body['metadata']['next_marker']

  load_all(body['values'])
end