diff --git a/lib/zabbixapi.rb b/lib/zabbixapi.rb index 4b9df72..c83ed32 100755 --- a/lib/zabbixapi.rb +++ b/lib/zabbixapi.rb @@ -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' @@ -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) diff --git a/lib/zabbixapi/classes/hosts.rb b/lib/zabbixapi/classes/hosts.rb index 9d4794f..d2e3665 100755 --- a/lib/zabbixapi/classes/hosts.rb +++ b/lib/zabbixapi/classes/hosts.rb @@ -30,7 +30,7 @@ def dump_by_id(data) key.to_sym => data[key.to_sym] }, output: 'extend', - selectGroups: 'shorten' + selectHostGroups: 'extend' } ) end @@ -44,8 +44,7 @@ def default_options interfaces: [], status: 0, available: 1, - groups: [], - proxy_hostid: nil + groups: [] } end diff --git a/lib/zabbixapi/classes/proxies.rb b/lib/zabbixapi/classes/proxies.rb index 50cf7af..51244e8 100755 --- a/lib/zabbixapi/classes/proxies.rb +++ b/lib/zabbixapi/classes/proxies.rb @@ -11,7 +11,7 @@ def method_name # # @return [String] def identify - 'host' + 'name' end # Delete Proxy object using Zabbix API diff --git a/lib/zabbixapi/classes/proxygroup.rb b/lib/zabbixapi/classes/proxygroup.rb new file mode 100755 index 0000000..e4c58cb --- /dev/null +++ b/lib/zabbixapi/classes/proxygroup.rb @@ -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 diff --git a/lib/zabbixapi/client.rb b/lib/zabbixapi/client.rb index 53c6f28..828508b 100755 --- a/lib/zabbixapi/client.rb +++ b/lib/zabbixapi/client.rb @@ -28,7 +28,7 @@ def auth api_request( method: 'user.login', params: { - user: @options[:user], + username: @options[:user], password: @options[:password] } ) diff --git a/lib/zabbixapi/version.rb b/lib/zabbixapi/version.rb index 6c3cdc8..c59b15b 100755 --- a/lib/zabbixapi/version.rb +++ b/lib/zabbixapi/version.rb @@ -1,3 +1,3 @@ class ZabbixApi - VERSION = '5.0.0-alpha1'.freeze + VERSION = '6.0.0-alpha4'.freeze end