Class: IntrigueApi
- Inherits:
-
Object
- Object
- IntrigueApi
- Defined in:
- lib/intrigue_api_client.rb
Instance Method Summary collapse
-
#create_project(project_name) ⇒ Object
create a new project.
-
#info(task_name) ⇒ Object
Show detailed about a task.
-
#initialize(uri = "http://127.0.0.1:7777/v1", key = "") ⇒ IntrigueApi
constructor
A new instance of IntrigueApi.
-
#list ⇒ Object
List all tasks.
-
#start(project_name, task_name, entity_hash, depth = 1, options_list = nil, handler_list = nil, strategy_name = "disovery") ⇒ Object
Start a task and wait for the result.
Constructor Details
#initialize(uri = "http://127.0.0.1:7777/v1", key = "") ⇒ IntrigueApi
Returns a new instance of IntrigueApi.
7 8 9 10 |
# File 'lib/intrigue_api_client.rb', line 7 def initialize(uri="http://127.0.0.1:7777/v1",key="") @intrigue_basedir = File.dirname(__FILE__) @server_uri = uri end |
Instance Method Details
#create_project(project_name) ⇒ Object
create a new project
23 24 25 |
# File 'lib/intrigue_api_client.rb', line 23 def create_project(project_name) RestClient.post "#{@server_uri}/project", { "project" => project_name } end |
#info(task_name) ⇒ Object
Show detailed about a task
18 19 20 |
# File 'lib/intrigue_api_client.rb', line 18 def info(task_name) _get_json_result "tasks/#{task_name}.json" end |
#list ⇒ Object
List all tasks
13 14 15 |
# File 'lib/intrigue_api_client.rb', line 13 def list _get_json_result "tasks.json" end |
#start(project_name, task_name, entity_hash, depth = 1, options_list = nil, handler_list = nil, strategy_name = "disovery") ⇒ Object
Start a task and wait for the result
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/intrigue_api_client.rb', line 28 def start(project_name,task_name,entity_hash,depth=1,=nil,handler_list=nil, strategy_name="disovery") # Construct the request task_id = _start_and_background(project_name,task_name,entity_hash,depth,,handler_list, strategy_name) if task_id == "" # technically a nil is returned , but becomes an empty string #puts "[-] Task not started. Unknown Error. Exiting" #raise "Problem getting result" return nil end ### XXX - wait to collect the response complete = false until complete sleep 1 begin check_uri = "#{@server_uri}/#{project_name}/results/#{task_id}/complete" response = RestClient.get check_uri complete = true if response == "true" return nil if response == "" rescue URI::InvalidURIError => e puts "[-] Invalid URI: #{check_uri}" return nil end end ### Get the response response = _get_json_result "#{project_name}/results/#{task_id}.json" #puts response response end |