Class: Threatstack::Client
- Inherits:
-
Object
- Object
- Threatstack::Client
- Defined in:
- lib/threatstack/client.rb
Constant Summary collapse
- THREATSTACK_API =
'https://app.threatstack.com/api/v1'
Instance Attribute Summary collapse
-
#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) ⇒ 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) ⇒ Client
Returns a new instance of Client.
20 21 22 |
# File 'lib/threatstack/client.rb', line 20 def initialize(token) @token = token end |
Instance Attribute Details
#org_id ⇒ Object (readonly)
Returns the value of attribute org_id.
18 19 20 |
# File 'lib/threatstack/client.rb', line 18 def org_id @org_id end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
18 19 20 |
# File 'lib/threatstack/client.rb', line 18 def token @token end |
Instance Method Details
#agent(agent_id, params = {}) ⇒ Object
40 41 42 43 44 |
# File 'lib/threatstack/client.rb', line 40 def agent(agent_id, params = {}) raise ThreatstackError, "Must specify agent id" unless agent_id response = do_request(:get, "agents/#{agent_id}", params) Agent::Agent.new(response) end |
#agents(params = {}) ⇒ Object
35 36 37 38 |
# File 'lib/threatstack/client.rb', line 35 def agents(params = {}) response = do_request(:get, 'agents', params) Agent::Response.new(response).agents end |
#alert(alert_id, params = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/threatstack/client.rb', line 29 def alert(alert_id, params = {}) raise ThreatstackError, "Must specify alert id" unless alert_id response = do_request(:get, "alerts/#{alert_id}", params) Alert::Alert.new(response) end |
#alerts(params = {}) ⇒ Object
24 25 26 27 |
# File 'lib/threatstack/client.rb', line 24 def alerts(params = {}) response = do_request(:get, 'alerts', params) Alert::Response.new(response).alerts end |
#logs(params = {}) ⇒ Object
62 63 64 65 |
# File 'lib/threatstack/client.rb', line 62 def logs(params = {}) response = do_request(:get, 'logs', params) Log::Response.new(response).logs end |
#organizations(params = {}) ⇒ Object
57 58 59 60 |
# File 'lib/threatstack/client.rb', line 57 def organizations(params = {}) response = do_request(:get, 'organizations', params) Organization::Response.new(response).organizations end |
#policies(params = {}) ⇒ Object
46 47 48 49 |
# File 'lib/threatstack/client.rb', line 46 def policies(params = {}) response = do_request(:get, 'policies', params) Policy::Response.new(response).policies end |
#policy(policy_id, params = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/threatstack/client.rb', line 51 def policy(policy_id, params = {}) raise ThreatstackError, "Must specify policy id" unless policy_id response = do_request(:get, "policies/#{policy_id}", params) Policy::Policy.new(response) end |
#search(query, params = {}) ⇒ Object
67 68 69 |
# File 'lib/threatstack/client.rb', line 67 def search(query, params = {}) logs(params.merge(q: query)) end |