Sha256: 491d8f6f09d9d33a802d2697082cbbc439d2a62fccc57322313fa31efe505c3c
Contents?: true
Size: 1.64 KB
Versions: 5
Compression:
Stored size: 1.64 KB
Contents
class ZabbixApi class Drules < Basic # The method name used for interacting with Drules via Zabbix API # # @return [String] def method_name 'drule' end # The id field name used for identifying specific Drule objects via Zabbix API # # @return [String] def identify 'name' end # The default options used when creating Drule objects via Zabbix API # # @return [Hash] def default_options { name: nil, iprange: nil, delay: 3600, status: 0, } end # Get or Create Drule object using Zabbix API # # @param data [Hash] Needs to include name to properly identify Drule via Zabbix API # @raise [ApiError] Error returned when there is a problem with the Zabbix API call. # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK. # @return [Integer] Zabbix object id def get_or_create(data) log "[DEBUG] Call get_or_create with parameters: #{data.inspect}" unless (id = get_id(name: data[:name])) id = create(data) end id end # Create or update Drule object using Zabbix API # # @param data [Hash] Needs to include name to properly identify Drules via Zabbix API # @raise [ApiError] Error returned when there is a problem with the Zabbix API call. # @raise [HttpError] Error raised when HTTP status from Zabbix Server response is not a 200 OK. # @return [Integer] Zabbix object id def create_or_update(data) druleid = get_id(name: data[:name]) druleid ? update(data.merge(druleid: druleid)) : create(data) end end end
Version data entries
5 entries across 5 versions & 2 rubygems