Class: ZBX::CLI::CLI
- Inherits:
-
Thor
- Object
- Thor
- ZBX::CLI::CLI
- Defined in:
- lib/zbx/cli.rb
Instance Method Summary collapse
Instance Method Details
#doc(method = '') ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/zbx/cli.rb', line 66 def doc method='' version = [:version] base = "https://www.zabbix.com/documentation/#{version}/" suffix = case version when 1.8 'api/' when 2.0 'manual/appendix/api/' when 2.2 'manual/api/reference/' end url = base << suffix << method.gsub('.', '/') say "browse #{url}" Helper.browse url end |
#send(method, data = '{}') ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/zbx/cli.rb', line 41 def send(method, data='{}') config_file = File.('~/.zbxconfig') default = File.exists?(config_file) ? YAML.load_file(config_file) : {} client = ZBX::API.new([:user] || default["user"], [:password] || default["password"], [:api_url] || default["api_url"]) # x = method.split('.') say client.request method, JSON.parse(data) # say client.send(x.first).send(x.last, JSON.parse(data)) end |