Class: Threatstack::Client
- Inherits:
-
Object
- Object
- Threatstack::Client
- Defined in:
- lib/threatstack/client.rb
Constant Summary collapse
- THREATSTACK_API =
'https://app.threatstack.com/api'.freeze
Instance Attribute Summary collapse
-
#api_version ⇒ Object
readonly
Returns the value of attribute api_version.
-
#org_id ⇒ Object
readonly
Returns the value of attribute org_id.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #agent(agent_id, params = {}) ⇒ Object
- #agents(params = {}) ⇒ Object
- #alert(alert_id, params = {}) ⇒ Object
- #alerts(params = {}) ⇒ Object
-
#initialize(token, api_version = 'v1') ⇒ Client
constructor
A new instance of Client.
- #logs(params = {}) ⇒ Object
- #organizations(params = {}) ⇒ Object
- #policies(params = {}) ⇒ Object
- #policy(policy_id, params = {}) ⇒ Object
- #search(query, params = {}) ⇒ Object
Constructor Details
#initialize(token, api_version = 'v1') ⇒ Client
Returns a new instance of Client.
18 19 20 21 |
# File 'lib/threatstack/client.rb', line 18 def initialize(token, api_version = 'v1') @api_version = api_version @token = token end |
Instance Attribute Details
#api_version ⇒ Object (readonly)
Returns the value of attribute api_version.
16 17 18 |
# File 'lib/threatstack/client.rb', line 16 def api_version @api_version end |
#org_id ⇒ Object (readonly)
Returns the value of attribute org_id.
16 17 18 |
# File 'lib/threatstack/client.rb', line 16 def org_id @org_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
16 17 18 |
# File 'lib/threatstack/client.rb', line 16 def token @token end |
Instance Method Details
#agent(agent_id, params = {}) ⇒ Object
28 29 30 31 32 |
# File 'lib/threatstack/client.rb', line 28 def agent(agent_id, params = {}) raise ThreatstackError, "Must specify agent id" unless agent_id response = do_request(:get, "agents/#{agent_id}", params) Agent.new(response) end |
#agents(params = {}) ⇒ Object
23 24 25 26 |
# File 'lib/threatstack/client.rb', line 23 def agents(params = {}) response = do_request(:get, 'agents', params) Response.new(:agent, response).agents end |
#alert(alert_id, params = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/threatstack/client.rb', line 39 def alert(alert_id, params = {}) raise ThreatstackError, "Must specify alert id" unless alert_id response = do_request(:get, "alerts/#{alert_id}", params) Alert.new(response) end |
#alerts(params = {}) ⇒ Object
34 35 36 37 |
# File 'lib/threatstack/client.rb', line 34 def alerts(params = {}) response = do_request(:get, 'alerts', params) Response.new(:alert, response).alerts end |
#logs(params = {}) ⇒ Object
61 62 63 64 |
# File 'lib/threatstack/client.rb', line 61 def logs(params = {}) response = do_request(:get, 'logs', params) Response.new(:log, response).logs end |
#organizations(params = {}) ⇒ Object
56 57 58 59 |
# File 'lib/threatstack/client.rb', line 56 def organizations(params = {}) response = do_request(:get, 'organizations', params) Response.new(:organization, response).organizations end |
#policies(params = {}) ⇒ Object
45 46 47 48 |
# File 'lib/threatstack/client.rb', line 45 def policies(params = {}) response = do_request(:get, 'policies', params) Response.new(:policy, response).policies end |
#policy(policy_id, params = {}) ⇒ Object
50 51 52 53 54 |
# File 'lib/threatstack/client.rb', line 50 def policy(policy_id, params = {}) raise ThreatstackError, "Must specify policy id" unless policy_id response = do_request(:get, "policies/#{policy_id}", params) Policy.new(response) end |
#search(query, params = {}) ⇒ Object
66 67 68 |
# File 'lib/threatstack/client.rb', line 66 def search(query, params = {}) logs(params.merge(q: query)) end |