Class: ZabbixManager::ValueMaps

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

Instance Method Summary collapse

Methods inherited from Basic

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

Constructor Details

This class inherits a constructor from ZabbixManager::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:

  • (ManagerError)

    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.



47
48
49
50
# File 'lib/zabbix_manager/classes/valuemaps.rb', line 47

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:

  • (ManagerError)

    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.



32
33
34
35
36
37
38
39
# File 'lib/zabbix_manager/classes/valuemaps.rb', line 32

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

#identifyString

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

Returns:

  • (String)


22
23
24
# File 'lib/zabbix_manager/classes/valuemaps.rb', line 22

def identify
  "name"
end

#keyString

The key field name used for ValueMap objects via Zabbix API

Returns:

  • (String)


15
16
17
# File 'lib/zabbix_manager/classes/valuemaps.rb', line 15

def key
  "valuemapid"
end

#method_nameString

The method name used for interacting with ValueMaps via Zabbix API

Returns:

  • (String)


8
9
10
# File 'lib/zabbix_manager/classes/valuemaps.rb', line 8

def method_name
  "valuemap"
end