lib/zabbixapi/client.rb in zabbixapi-4.1.2 vs lib/zabbixapi/client.rb in zabbixapi-4.2.0
- old
+ new
@@ -16,10 +16,11 @@
# Returns the API version from the Zabbix Server
#
# @return [String]
def api_version
@api_version ||= api_request(method: 'apiinfo.version', params: {})
+ @api_version
end
# Log in to the Zabbix Server and generate an auth token using the API
#
# @return [Hash]
@@ -31,10 +32,17 @@
password: @options[:password]
}
)
end
+ # ZabbixApi::Basic.log does not like @client.options[:debug]
+ #
+ # @return [boolean]
+ def debug?
+ return ! @options || @options[:debug]
+ end
+
# Initializes a new Client object
#
# @param options [Hash]
# @option opts [String] :url The url of zabbixapi(example: 'http://localhost/zabbix/api_jsonrpc.php')
# @option opts [String] :user
@@ -50,11 +58,12 @@
@proxy_uri = URI.parse(ENV['http_proxy'])
@proxy_host = @proxy_uri.host
@proxy_port = @proxy_uri.port
@proxy_user, @proxy_pass = @proxy_uri.userinfo.split(/:/) if @proxy_uri.userinfo
end
- unless api_version =~ %r{^4.[0|2]\.\d+$}
- puts "[WARN] Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
+ unless api_version =~ %r{^4.[0|4]\.\d+$}
+ message = "Zabbix API version: #{api_version} is not supported by this version of zabbixapi"
+ raise ZabbixApi::ApiError.new(message)
end
@auth_hash = auth
end