Sha256: fd05a5a5f2c86bc024b4a194e676ff46870c8a790e372d0dd610050c05109c0d

Contents?: true

Size: 907 Bytes

Versions: 5

Compression:

Stored size: 907 Bytes

Contents

class ZabbixApi
  class Hosts < Basic

    def array_flag
      true
    end

    def method_name
      "host"
    end

    def indentify
      "host"
    end

    def default_options
      {
        :host => nil,
        :interfaces => [],
        :status => 0,
        :available => 1,
        :groups => [],
        :proxy_hostid => nil
      }
    end

    def unlink_templates(data)
      result = @client.api_request(
        :method => "host.massRemove",
        :params => {
          :hostids => data[:hosts_id],
          :templates => data[:templates_id]
        }
      )
      result.empty? ? false : true
    end

    def create_or_update(data)
      hostid = get_id(:host => data[:host])
      hostid ? update(data.merge(:hostid => hostid)) : create(data)
    end

    # to make delete call idempotent for all resources
    def delete(hostid)
      super(:hostid => hostid)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zabbixapi-2.2.3 lib/zabbixapi/classes/hosts.rb
zabbixapi-2.2.2 lib/zabbixapi/classes/hosts.rb
zabbixapi-2.2.1 lib/zabbixapi/classes/hosts.rb
zabbixapi-2.2.0 lib/zabbixapi/classes/hosts.rb
zabbixapi-2.0.0 lib/zabbixapi/classes/hosts.rb