Class: ZabbixApi::ValueMaps

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbixapi/classes/valuemaps.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #default_options, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_raw, #hash_equals?, #initialize, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixApi::Basic

Instance Method Details

#create_or_update(data) ⇒ Integer

Create or update Item object using Zabbix API

Parameters:

  • data (Hash)

    Needs to include valuemapids to properly identify ValueMaps via Zabbix API

Returns:

  • (Integer)

    Zabbix object id

Raises:

  • (ApiError)

    Error returned when there is a problem with the Zabbix API call.

  • (HttpError)

    Error raised when HTTP status from Zabbix Server response is not a 200 OK.


45
46
47
48
# File 'lib/zabbixapi/classes/valuemaps.rb', line 45

def create_or_update(data)
  valuemapid = get_id(name: data[:name])
  valuemapid ? update(data.merge(valuemapids: [:valuemapid])) : create(data)
end

#get_or_create(data) ⇒ Integer

Get or Create ValueMap object using Zabbix API

Parameters:

  • data (Hash)

    Needs to include valuemapids [List] to properly identify ValueMaps via Zabbix API

Returns:

  • (Integer)

    Zabbix object id

Raises:

  • (ApiError)

    Error returned when there is a problem with the Zabbix API call.

  • (HttpError)

    Error raised when HTTP status from Zabbix Server response is not a 200 OK.


30
31
32
33
34
35
36
37
# File 'lib/zabbixapi/classes/valuemaps.rb', line 30

def get_or_create(data)
  log "[DEBUG] Call get_or_create with parameters: #{data.inspect}"

  unless (id = get_id(valuemapids: data[:valuemapids]))
    id = create(data)
  end
  id
end

#indentifyString

The id field name used for identifying specific ValueMap objects via Zabbix API

Returns:

  • (String)

20
21
22
# File 'lib/zabbixapi/classes/valuemaps.rb', line 20

def indentify
  'name'
end

#keyString

The key field name used for ValueMap objects via Zabbix API

Returns:

  • (String)

13
14
15
# File 'lib/zabbixapi/classes/valuemaps.rb', line 13

def key
  'valuemapid'
end

#method_nameString

The method name used for interacting with ValueMaps via Zabbix API

Returns:

  • (String)

6
7
8
# File 'lib/zabbixapi/classes/valuemaps.rb', line 6

def method_name
  'valuemap'
end