Class: KineticSdk::Agent
- Inherits:
-
Object
- Object
- KineticSdk::Agent
- Includes:
- Utils::KineticHttpUtils
- Defined in:
- lib/kinetic_sdk/agent/agent-sdk.rb,
lib/kinetic_sdk/agent/lib/bridges.rb,
lib/kinetic_sdk/agent/lib/handler.rb,
lib/kinetic_sdk/agent/lib/filestores.rb
Overview
Agent is a Ruby class that acts as a wrapper for the Kinetic Agent System REST API without having to make explicit HTTP requests. This is not to be confused with the Kinetic Agent Space REST API, which must go through the Kinetic Core Proxy API.
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#add_bridge(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Bridge.
-
#add_filestore(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Filestore.
-
#add_handler(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Handler.
-
#add_space_bridge(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Bridge to Space.
-
#add_space_filestore(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Filestore to Space.
-
#add_space_handler(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Handler to Space.
-
#delete_bridge(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Bridge.
-
#delete_filestore(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Filestore.
-
#delete_handler(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Handler.
-
#find_all_bridges(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all bridges in the system.
-
#find_all_filestores(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all filestores in the system.
-
#find_all_handlers(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers in the system.
-
#find_bridge(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a bridge.
-
#find_bridges(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all bridges in a space.
-
#find_filestore(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a filestore.
-
#find_filestores(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all filestores in a space.
-
#find_handler(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a handler.
-
#find_handlers(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers in a space.
-
#initialize(opts) ⇒ Agent
constructor
Initalize the Agent SDK with the web server URL and configuration user credentials, along with any custom option values.
-
#update_bridge(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a bridge.
-
#update_filestore(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a filestore.
-
#update_handler(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a handler.
Methods included from Utils::KineticHttpUtils
#default_headers, default_headers, #default_jwt_headers, default_jwt_headers, #delete, #encode, #gateway_retry_delay, #gateway_retry_limit, #get, #head, #header_accept_json, header_accept_json, #header_basic_auth, header_basic_auth, header_bearer_auth, #header_bearer_auth, #header_content_json, header_content_json, header_user_agent, #header_user_agent, #max_redirects, #mimetype, #patch, #post, #post_multipart, #put, #redirect_url, #stream_download_to_file
Constructor Details
#initialize(opts) ⇒ Agent
Initalize the Agent SDK with the web server URL and configuration user credentials, along with any custom option values.
Example: using a configuration file
KineticSdk::Agent.new({
config_file: "/opt/config1.yaml"
})
Example: using a properties hash
KineticSdk::Agent.new({
app_server_url: "http://localhost:8080/kinetic-agent",
username: "admin",
password: "admin",
options: {
log_level: "debug",
ssl_verify_mode: "peer",
ssl_ca_file: "/usr/local/self_signing_ca.pem"
}
})
If the +config_file+ option is present, it will be loaded first, and any additional options will overwrite any values in the config file
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 63 def initialize(opts) # initialize any variables = {} # process the configuration file if it was provided unless opts[:config_file].nil? .merge!(YAML::load_file opts[:config_file]) end # process the configuration hash if it was provided .merge!(opts) # process any individual options @options = .delete(:options) || {} # setup logging log_level = @options[:log_level] || @options["log_level"] log_output = @options[:log_output] || @options["log_output"] @logger = KineticSdk::Utils::KLogger.new(log_level, log_output) @username = [:username] @password = [:password] @server = [:app_server_url].chomp('/') @api_url = "#{@server}/app/api/v1" @version = 1 end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def api_url @api_url end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def username @username end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
15 16 17 |
# File 'lib/kinetic_sdk/agent/agent-sdk.rb', line 15 def version @version end |
Instance Method Details
#add_bridge(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Bridge
14 15 16 17 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 14 def add_bridge(space, body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" bridge in the \"#{space}\" space.") post("#{@api_url}/spaces/#{space}/bridges", body, headers) end |
#add_filestore(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Filestore
14 15 16 17 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 14 def add_filestore(space, body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" filestore in the \"#{space}\" space.") post("#{@api_url}/spaces/#{space}/filestores", body, headers) end |
#add_handler(space, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Handler
14 15 16 17 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 14 def add_handler(space, body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" handler in the \"#{space}\" space.") post("#{@api_url}/spaces/#{space}/handlers", body, headers) end |
#add_space_bridge(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Bridge to Space
75 76 77 78 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 75 def add_space_bridge(body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" bridge in the \"#{body['space']}\" space.") post("#{@api_url}/bridges", body, headers) end |
#add_space_filestore(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Filestore to Space
74 75 76 77 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 74 def add_space_filestore(body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" filestore in the \"#{body['space']}\" space.") post("#{@api_url}/filestores", body, headers) end |
#add_space_handler(body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add Handler to Space
74 75 76 77 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 74 def add_space_handler(body, headers=default_headers) @logger.info("Adding the \"#{body['name']}\" handler in the \"#{body['space']}\" space.") post("#{@api_url}/handlers", body, headers) end |
#delete_bridge(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Bridge
25 26 27 28 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 25 def delete_bridge(space, slug, headers=default_headers) @logger.info("Deleting the \"#{slug}\" bridge in the \"#{space}\" space.") delete("#{@api_url}/spaces/#{space}/bridges/#{slug}", headers) end |
#delete_filestore(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Filestore
25 26 27 28 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 25 def delete_filestore(space, slug, headers=default_headers) @logger.info("Deleting the \"#{slug}\" filestore in the \"#{space}\" space.") delete("#{@api_url}/spaces/#{space}/filestores/#{slug}", headers) end |
#delete_handler(space, slug, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Handler
25 26 27 28 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 25 def delete_handler(space, slug, headers=default_headers) @logger.info("Deleting the \"#{slug}\" handler in the \"#{space}\" space.") delete("#{@api_url}/spaces/#{space}/handlers/#{slug}", headers) end |
#find_all_bridges(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all bridges in the system
85 86 87 88 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 85 def find_all_bridges(params={}, headers=default_headers) @logger.info("Find all bridges.") get("#{@api_url}/bridges", params, headers) end |
#find_all_filestores(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all filestores in the system
84 85 86 87 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 84 def find_all_filestores(params={}, headers=default_headers) @logger.info("Find all filestores.") get("#{@api_url}/filestores", params, headers) end |
#find_all_handlers(params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers in the system
84 85 86 87 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 84 def find_all_handlers(params={}, headers=default_headers) @logger.info("Find all handlers.") get("#{@api_url}/handlers", params, headers) end |
#find_bridge(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a bridge
37 38 39 40 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 37 def find_bridge(space, slug, params={}, headers=default_headers) @logger.info("Finding the \"#{slug}\" bridge in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/bridges/#{slug}", params, headers) end |
#find_bridges(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all bridges in a space
60 61 62 63 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 60 def find_bridges(space, params={}, headers=default_headers) @logger.info("Find all bridges in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/bridges", params, headers) end |
#find_filestore(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a filestore
37 38 39 40 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 37 def find_filestore(space, slug, params={}, headers=default_headers) @logger.info("Finding the \"#{slug}\" filestore in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/filestores/#{slug}", params, headers) end |
#find_filestores(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all filestores in a space
60 61 62 63 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 60 def find_filestores(space, params={}, headers=default_headers) @logger.info("Find all filestores in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/filestores", params, headers) end |
#find_handler(space, slug, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a handler
37 38 39 40 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 37 def find_handler(space, slug, params={}, headers=default_headers) @logger.info("Finding the \"#{slug}\" handler in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/handlers/#{slug}", params, headers) end |
#find_handlers(space, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers in a space
60 61 62 63 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 60 def find_handlers(space, params={}, headers=default_headers) @logger.info("Find all handlers in the \"#{space}\" space.") get("#{@api_url}/spaces/#{space}/handlers", params, headers) end |
#update_bridge(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a bridge
49 50 51 52 |
# File 'lib/kinetic_sdk/agent/lib/bridges.rb', line 49 def update_bridge(space, slug, body={}, headers=default_headers) @logger.info("Updating the \"#{slug}\" bridge in the \"#{space}\" space.") put("#{@api_url}/spaces/#{space}/bridges/#{slug}", body, headers) end |
#update_filestore(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a filestore
49 50 51 52 |
# File 'lib/kinetic_sdk/agent/lib/filestores.rb', line 49 def update_filestore(space, slug, body={}, headers=default_headers) @logger.info("Updating the \"#{slug}\" filestore in the \"#{space}\" space.") put("#{@api_url}/spaces/#{space}/filestores/#{slug}", body, headers) end |
#update_handler(space, slug, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a handler
49 50 51 52 |
# File 'lib/kinetic_sdk/agent/lib/handler.rb', line 49 def update_handler(space, slug, body={}, headers=default_headers) @logger.info("Updating the \"#{slug}\" handler in the \"#{space}\" space.") put("#{@api_url}/spaces/#{space}/handlers/#{slug}", body, headers) end |