Class: Fog::Rackspace::Monitoring::Entity

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Base

#compare?, #entity_id, #hash

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

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::Model

Instance Method Details

#alarmsObject



47
48
49
50
51
52
53
54
# File 'lib/fog/rackspace/models/monitoring/entity.rb', line 47

def alarms
  @alarms ||= begin
    Fog::Rackspace::Monitoring::Alarms.new(
      :entity     => self,
      :service => service
    )
  end
end

#checksObject



38
39
40
41
42
43
44
45
# File 'lib/fog/rackspace/models/monitoring/entity.rb', line 38

def checks
  @checks ||= begin
    Fog::Rackspace::Monitoring::Checks.new(
      :entity     => self,
      :service => service
    )
  end
end

#destroyObject



56
57
58
59
# File 'lib/fog/rackspace/models/monitoring/entity.rb', line 56

def destroy
  requires :id
  service.delete_entity(id)
end

#paramsObject



18
19
20
21
22
23
24
25
26
# File 'lib/fog/rackspace/models/monitoring/entity.rb', line 18

def params
  options = {
    'label'       => label,
    'metadata'    => ,
    'ip_addresses'=> ip_addresses,
    'agent_id'    => agent_id
  }
  options.reject {|key, value| value.nil?}
end

#saveObject



28
29
30
31
32
33
34
35
36
# File 'lib/fog/rackspace/models/monitoring/entity.rb', line 28

def save
  if identity
    data = service.update_entity(identity, params)
  else
    data = service.create_entity(params)
    self.id = data.headers['X-Object-ID']
  end
  true
end