Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/zabbixapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
require 'zabbixapi/classes/maintenance'
require 'zabbixapi/classes/mediatypes'
require 'zabbixapi/classes/proxies'
require 'zabbixapi/classes/proxygroup'
require 'zabbixapi/classes/problems'
require 'zabbixapi/classes/roles'
require 'zabbixapi/classes/screens'
Expand Down Expand Up @@ -137,6 +138,10 @@ def proxies
@proxies ||= Proxies.new(@client)
end

# @return [ZabbixApi::Proxygroup]
def proxygroup
@proxygroup ||= Proxygroup.new(@client)
end
# @return [ZabbixApi::Roles]
def roles
@roles ||= Roles.new(@client)
Expand Down
5 changes: 2 additions & 3 deletions lib/zabbixapi/classes/hosts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def dump_by_id(data)
key.to_sym => data[key.to_sym]
},
output: 'extend',
selectGroups: 'shorten'
selectHostGroups: 'extend'
}
)
end
Expand All @@ -44,8 +44,7 @@ def default_options
interfaces: [],
status: 0,
available: 1,
groups: [],
proxy_hostid: nil
groups: []
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/zabbixapi/classes/proxies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def method_name
#
# @return [String]
def identify
'host'
'name'
end

# Delete Proxy object using Zabbix API
Expand Down
55 changes: 55 additions & 0 deletions lib/zabbixapi/classes/proxygroup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class ZabbixApi
class Proxygroup < Basic
# The method name used for interacting with Proxygroup via Zabbix API
#
# @return [String]
def method_name
'proxygroup'
end

# The id field name used for identifying specific Proxygroup objects via Zabbix API
#
# @return [String]
def identify
'name'
end

# The key field name used for proxygroup objects via Zabbix API
#
# @return [String]
def key
'proxy_groupid'
end

# Delete Proxygroup object using Zabbix API
#
# @param data [Array] Should include array of Proxygroupid's
# @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] The Proxygroup object id that was deleted
def delete(data)
result = @client.api_request(method: 'proxygroup.delete', params: data)
result.empty? ? nil : result['proxyids'][0].to_i
end

# Check if a Proxygroup object is readable using Zabbix API
#
# @param data [Array] Should include array of Proxygroupid's
# @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 [Boolean] Returns true if the given Proxygroupgroup are readable
def isreadable(data)
@client.api_request(method: 'proxygroup.isreadable', params: data)
end

# Check if a Proxygroup object is writable using Zabbix API
#
# @param data [Array] Should include array of Proxygroupid's
# @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 [Boolean] Returns true if the given Proxygroup are writable
def iswritable(data)
@client.api_request(method: 'proxygroup.iswritable', params: data)
end
end
end
2 changes: 1 addition & 1 deletion lib/zabbixapi/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def auth
api_request(
method: 'user.login',
params: {
user: @options[:user],
username: @options[:user],
password: @options[:password]
}
)
Expand Down
2 changes: 1 addition & 1 deletion lib/zabbixapi/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ZabbixApi
VERSION = '5.0.0-alpha1'.freeze
VERSION = '6.0.0-alpha4'.freeze
end