Class: ZabbixApi::Users

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

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #create_or_update, #default_options, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_or_create, #get_raw, #hash_equals?, #initialize, #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

#add_medias(data) ⇒ Integer

Add media to users using Zabbix API

Parameters:

  • data (Hash)

    Needs to include userids and media to mass add media to users

Returns:

  • (Integer)

    Zabbix object id (media)

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.



37
38
39
40
41
42
43
44
45
46
# File 'lib/zabbixapi/classes/users.rb', line 37

def add_medias(data)
  result = @client.api_request(
    :method => 'user.addMedia',
    :params => {
      :users => data[:userids].map { |t| {:userid => t} },
      :medias => data[:media],
    }
  )
  result ? result['mediaids'][0].to_i : nil
end

#indentifyString

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

Returns:

  • (String)


27
28
29
# File 'lib/zabbixapi/classes/users.rb', line 27

def indentify
  'alias'
end

#keyString

The key field name used for User objects via Zabbix API

Returns:

  • (String)


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

def key
  'userid'
end

#keysString

The keys field name used for User objects via Zabbix API

Returns:

  • (String)


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

def keys
  'userids'
end

#method_nameString

The method name used for interacting with Users via Zabbix API

Returns:

  • (String)


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

def method_name
  'user'
end

#update_medias(data) ⇒ Integer

Update media for users using Zabbix API

Parameters:

  • data (Hash)

    Needs to include userids and media to mass update media for users

Returns:

  • (Integer)

    Zabbix object id (user)

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.



54
55
56
57
58
59
60
61
62
63
# File 'lib/zabbixapi/classes/users.rb', line 54

def update_medias(data)
  result = @client.api_request(
    :method => 'user.updateMedia',
    :params => {
      :users => data[:userids].map { |t| {:userid => t} },
      :medias => data[:media],
    }
  )
  result ? result['userids'][0].to_i : nil
end