Class: Seer::Hosts
- Inherits:
-
Object
- Object
- Seer::Hosts
- Defined in:
- lib/seer/hosts.rb
Overview
Hosts API controller
Instance Method Summary collapse
-
#aggs(query, fields) ⇒ Hash
Aggregations by query and field.
-
#initialize(token: '', version: '2.0', host: '') ⇒ Hosts
constructor
Initialize a Hosts object.
-
#ip(ip, minify: false) ⇒ Hash
Get host by ip.
-
#port(port, page: 1, minify: false) ⇒ Hash
Get hosts by port.
-
#search(query, page: 1, minify: false) ⇒ Hash
Get hosts by custom search.
-
#service(service, page: 1, minify: false) ⇒ Hash
Get hosts by service.
Constructor Details
#initialize(token: '', version: '2.0', host: '') ⇒ Hosts
Initialize a Hosts object
8 9 10 11 12 13 14 15 |
# File 'lib/seer/hosts.rb', line 8 def initialize(token: '', version: '2.0', host: '') @host = host + '/hosts' @header = { content_type: 'application/json', x_seer_token: token, x_seer_version: version } end |
Instance Method Details
#aggs(query, fields) ⇒ Hash
Aggregations by query and field
83 84 85 86 87 88 89 90 91 |
# File 'lib/seer/hosts.rb', line 83 def aggs(query, fields) body = { query: query, fields: fields } url = @host + '/aggs' Seer.request(url, body, @header) end |
#ip(ip, minify: false) ⇒ Hash
Get host by ip
21 22 23 24 25 26 27 28 29 |
# File 'lib/seer/hosts.rb', line 21 def ip(ip, minify: false) body = { ip: ip, minify: minify } url = @host + '/ip' Seer.request(url, body, @header) end |
#port(port, page: 1, minify: false) ⇒ Hash
Get hosts by port
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/seer/hosts.rb', line 36 def port(port, page: 1, minify: false) body = { port: port, page: page, minify: minify } url = @host + '/port' Seer.request(url, body, @header) end |