Class: Orchestrate::API::Wrapper
- Inherits:
-
Object
- Object
- Orchestrate::API::Wrapper
- Includes:
- Procedural
- Defined in:
- lib/orchestrate_api/wrapper.rb
Overview
Ruby wrapper for the Orchestrate.io REST API.
The primary entry point is the #send_request method, which generates a Request, and returns the Response to the caller. examples for each HTTP request[Procedural.html] are documented in the Procedural interface module.
Instance Attribute Summary collapse
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(config_file) ⇒ Wrapper
constructor
Loads settings from the configuration file and returns the client handle to be used for subsequent requests.
-
#send_request(method, args) ⇒ Object
Creates the Request object and sends it via the perform method, which generates and returns the Response object.
Methods included from Procedural
#delete_collection, #delete_graph, #delete_key, #get_by_ref, #get_events, #get_graph, #get_key, #list, #purge_key, #put_event, #put_graph, #put_key, #put_key_if_match, #put_key_if_none_match, #search
Constructor Details
#initialize(config_file) ⇒ Wrapper
Loads settings from the configuration file and returns the client handle to be used for subsequent requests.
Example config file: "./lib/orch_config.json"
{
"base_url":"https://api.orchestrate.io/v0",
"user":"<user-key-from-orchestrate.io>",
"verbose":"false"
}
29 30 31 32 33 34 35 |
# File 'lib/orchestrate_api/wrapper.rb', line 29 def initialize(config_file) orch_config = ::ActiveSupport::JSON.decode open(config_file).read @base_url = orch_config['base_url'] @user = orch_config['user'] @verbose = orch_config['verbose'] && orch_config['verbose'] == 'true' ? true : false end |
Instance Attribute Details
#verbose ⇒ Object
Returns the value of attribute verbose.
16 17 18 |
# File 'lib/orchestrate_api/wrapper.rb', line 16 def verbose @verbose end |
Instance Method Details
#send_request(method, args) ⇒ Object
Creates the Request object and sends it via the perform method, which generates and returns the Response object.
40 41 42 43 44 45 46 47 |
# File 'lib/orchestrate_api/wrapper.rb', line 40 def send_request(method, args) request = Orchestrate::API::Request.new(method, build_url(method, args), @user) do |r| r.data = args[:json] if args[:json] r.ref = args[:ref] if args[:ref] r.verbose = verbose end request.perform end |