Sha256: 8553f3080f6a8c255add0d54c53d60fe66f29982eba6752e201cbe86c28bc48a

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

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

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

        identity :id

        attribute :label
        attribute :metadata
        attribute :ip_addresses
        attribute :agent_id
        attribute :managed, :default => false
        attribute :uri

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

        def save
          options = prep
          if identity then
            data = connection.update_entity(identity, options)
          else
            data = connection.create_entity(options)
          end
          true
        end

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

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

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

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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