Sha256: 2554dd3f01bee8c45084ba658c069865a9699bb7fcf4adb204a4f4ceb3a47cb0

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module Rubix
  
  class Script < Model

    # Numeric codes of the access types a script can require to run on
    # a host.
    #
    # Default is 'read'.
    zabbix_define :ACCESS, {
      :read  => 2,
      :write => 3
    }

    #
    # == Properties & Finding ==
    #

    zabbix_attr :name,    :required => true
    zabbix_attr :command, :required => true
    zabbix_attr :access,  :default => :read

    #
    # == Requests ==
    #

    def create_params
      {
        :name        => name,
        :command     => command,
        :host_access => self.class::ACCESS_CODES[access]
      }
    end

    def self.find_params options={}
      get_params.merge(:filter => {id_field => options[:id], :name => options[:name]})
    end

    def self.build script
      new({
            :id          => script[id_field].to_i,
            :name        => script['name'],
            :command     => script['command'],
            :access      => self::ACCESS_NAMES[script['host_access'].to_i]
          })
    end
    
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubix-0.5.14 lib/rubix/models/script.rb
rubix-0.5.13 lib/rubix/models/script.rb
rubix-0.5.9 lib/rubix/models/script.rb
rubix-0.5.8 lib/rubix/models/script.rb
rubix-0.5.7 lib/rubix/models/script.rb
rubix-0.5.6 lib/rubix/models/script.rb
rubix-0.5.5 lib/rubix/models/script.rb
rubix-0.5.4 lib/rubix/models/script.rb
rubix-0.5.3 lib/rubix/models/script.rb
rubix-0.5.2 lib/rubix/models/script.rb