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

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

Instance Method Summary collapse

Methods inherited from Base

#compare?, #hash

Instance Method Details

#destroyObject



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

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

#entity=(obj) ⇒ Object



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

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

#metricsObject



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

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

#params(options = {}) ⇒ Object



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

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



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

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