Class: Fog::Rackspace::Monitoring::Check

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Base

#compare?, #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

#destroyObject



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

def destroy
  requires :id
  service.delete_check(entity.id, id)
end

#entity=(obj) ⇒ Object



24
25
26
# File 'lib/fog/rackspace/models/monitoring/check.rb', line 24

def entity=(obj)
  attributes[:entity] = obj.is_a?(String) ? Entity.new(:id => obj) : obj
end

#metricsObject



62
63
64
65
66
67
68
69
# File 'lib/fog/rackspace/models/monitoring/check.rb', line 62

def metrics
  @metrics ||= begin
    Fog::Rackspace::Monitoring::Metrics.new(
      :check      => self,
      :service => service
    )
  end
end

#params(options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/rackspace/models/monitoring/check.rb', line 28

def params(options={})
  h = {
    'label'       => label,
    'metadata'    => ,
    'target_alias'=> target_alias,
    'target_resolver' => target_resolver,
    'target_hostname' => target_hostname,
    'period' => period,
    'timeout'=> timeout,
    'details'=> details,
    'monitoring_zones_poll'=> monitoring_zones_poll,
    'disabled'=> disabled
  }.merge(options)

  h.reject {|key, value| value.nil?}
end

#saveObject



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

def save
  if identity
    data = service.update_check(entity.id, identity, params)
  else
    requires :type
    options = params('type' => type)
    data = service.create_check(entity.id, options)
    self.id = data.headers['X-Object-ID']
  end
  true
end