Sha256: 42f938d3c29d4fb3e8a10a74071d78c3e598541f5fbd2299fb59d928baff8dcb

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

require 'rackspace-fog/core/model'
require 'rackspace-monitoring/monitoring/models/base'

module Fog
  module Monitoring
    class Rackspace
      class Check < Fog::Monitoring::Rackspace::Base

        identity :id
        attribute :entity
        attribute :entity_id

        attribute :label
        attribute :metadata
        attribute :target_alias
        attribute :target_resolver
        attribute :target_hostname
        attribute :period
        attribute :timeout
        attribute :type
        attribute :details
        attribute :disabled
        attribute :monitoring_zones_poll

        def prep
          options = {
            'label'       => label,
            'metadata'    => 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
          }
          options = options.reject {|key, value| value.nil?}
          options
        end

        def save
          begin
            requires :entity
            entity_id = entity.identity
          rescue
            requires :entity_id
          end
          options = prep
          if identity then
            data = connection.update_check(entity_id, identity, options)
          else
            requires :type
            options['type'] = type
            data = connection.create_check(entity_id, options)
          end
          true
        end

      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rackspace-monitoring-0.2.15 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.14 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.13 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.12 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.11 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.10 lib/rackspace-monitoring/monitoring/models/check.rb
rackspace-monitoring-0.2.9 lib/rackspace-monitoring/monitoring/models/check.rb