Class: KineticSdk::Task
- Inherits:
-
Object
- Object
- KineticSdk::Task
- Includes:
- Utils::KineticExportUtils, Utils::KineticHttpUtils
- Defined in:
- lib/kinetic_sdk/task/task-sdk.rb,
lib/kinetic_sdk/task/lib/runs.rb,
lib/kinetic_sdk/task/lib/setup.rb,
lib/kinetic_sdk/task/lib/tasks.rb,
lib/kinetic_sdk/task/lib/trees.rb,
lib/kinetic_sdk/task/lib/users.rb,
lib/kinetic_sdk/task/lib/config.rb,
lib/kinetic_sdk/task/lib/engine.rb,
lib/kinetic_sdk/task/lib/errors.rb,
lib/kinetic_sdk/task/lib/export.rb,
lib/kinetic_sdk/task/lib/groups.rb,
lib/kinetic_sdk/task/lib/health.rb,
lib/kinetic_sdk/task/lib/license.rb,
lib/kinetic_sdk/task/lib/sources.rb,
lib/kinetic_sdk/task/lib/handlers.rb,
lib/kinetic_sdk/task/lib/categories.rb,
lib/kinetic_sdk/task/lib/access_keys.rb,
lib/kinetic_sdk/task/lib/environment.rb,
lib/kinetic_sdk/task/lib/policy_rules.rb,
lib/kinetic_sdk/task/lib/system_errors.rb
Overview
Task is a Ruby class that acts as a wrapper for the Kinetic Task REST API without having to make explicit HTTP requests.
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#api_v1_url ⇒ Object
readonly
Returns the value of attribute api_v1_url.
-
#config_user ⇒ Object
readonly
Returns the value of attribute config_user.
-
#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_access_key(access_key = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add an access key.
-
#add_category(category, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a category.
-
#add_group(name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a group.
-
#add_handler_to_category(handler_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a handler to a category.
-
#add_policy_rule(policy, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a policy Rule.
-
#add_policy_rule_to_category(policy_rule_type, policy_rule_name, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a policy rule to a category.
-
#add_policy_rule_to_source(policy_rule_type, policy_rule_name, source_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add policy rule to source.
-
#add_routine_to_category(routine_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a global routine to a category.
-
#add_source(source, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a source.
-
#add_user(user, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a user.
-
#add_user_to_group(login_id, group_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add user to group.
-
#complete_deferred_task(source_name, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Complete a Deferred Task.
-
#delete_access_key(identifier, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an access key.
-
#delete_access_keys(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all access keys.
-
#delete_categories(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Categories.
-
#delete_category(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Category.
-
#delete_error(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Error.
-
#delete_group(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Group.
-
#delete_groups(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Groups.
-
#delete_handler(definition_id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Handler.
-
#delete_handlers(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Handlers.
-
#delete_license(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete the license.
-
#delete_policy_rule(policy, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Policy Rule.
-
#delete_policy_rules(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Policy Rules.
-
#delete_run(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Run.
-
#delete_source(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Source.
-
#delete_sources(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Sources.
-
#delete_system_error(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a system error.
-
#delete_tree(tree, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a tree.
-
#delete_trees(source_name = nil, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete trees.
-
#delete_user(login_id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a User.
-
#delete_users(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Users.
-
#engine_info(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the engine info.
-
#engine_status(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the engine status.
-
#environment(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the web server environment.
-
#export(headers = header_basic_auth, export_opts = {}) ⇒ Object
Export all structure definitions to
export_directory
. -
#export_access_keys(headers = header_basic_auth) ⇒ Object
Export all access keys to :identifier.json file in export_directory/access-keys.
-
#export_all_except_trees(headers = header_basic_auth) ⇒ Object
Export all structure definitions except trees and routines to
export_directory
. -
#export_categories(headers = header_basic_auth) ⇒ Object
Export Categories.
-
#export_category(category, headers = header_basic_auth) ⇒ Object
Export a Category.
-
#export_group(group, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Export a Group.
-
#export_groups(headers = header_basic_auth) ⇒ Object
Export Groups.
-
#export_handler(definition_id, headers = header_basic_auth) ⇒ Object
Export a single handler.
-
#export_handlers(headers = header_basic_auth) ⇒ Object
Export all handlers.
-
#export_policy_rule(policy_rule, headers = header_basic_auth) ⇒ Object
Export a Policy Rule.
-
#export_policy_rules(headers = header_basic_auth) ⇒ Object
Export Policy Rules.
-
#export_routines(headers = header_basic_auth) ⇒ Object
Export all global routines.
-
#export_sources(headers = header_basic_auth) ⇒ Object
Export all sources to :source-slug.json file in export_directory/sources.
-
#export_tree(title, headers = header_basic_auth, export_opts = {}) ⇒ Object
Export a single tree or routine.
-
#export_trees(source_name = nil, headers = header_basic_auth, export_opts = {}) ⇒ Object
Export trees and local routines for a source, and global routines.
-
#find_access_key(identifier, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an access key.
-
#find_access_keys(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all access keys.
-
#find_active_errors_by_handler(handler_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Handler Id.
-
#find_active_errors_by_node(source_name, group, tree_name, node_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Node.
-
#find_active_errors_by_source(source_name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Source.
-
#find_active_errors_by_source_group(source_name, group, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Finding Active Errors by Source Group.
-
#find_active_errors_by_tree(source_name, group, tree_name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Tree Name.
-
#find_categories(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all categories.
-
#find_category(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a category.
-
#find_db(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the database configuration.
-
#find_engine_configuration(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the engine configuration properties.
-
#find_error(id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Error.
-
#find_errors(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a list of errors.
-
#find_errors_by_run(run_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Errors by Run Id.
-
#find_group(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Group.
-
#find_groups(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all groups.
-
#find_handler(definition_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a handler.
-
#find_handlers(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers.
-
#find_license(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the license.
-
#find_policy_rule(policy_rule, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a policy rule.
-
#find_policy_rules(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Policy Rules.
-
#find_routines(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find routines.
-
#find_runs(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find runs.
-
#find_session_configuration(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the session configuration properties.
-
#find_source(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a source.
-
#find_sources(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all sources.
-
#find_system_error(id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a system error.
-
#find_system_errors(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a list of system errors.
-
#find_system_policy_rule(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the system policy rule.
-
#find_tree(title, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a single tree by title (Source Name :: Group Name :: Tree Name).
-
#find_tree_by_id(tree_id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a tree by Id.
-
#find_trees(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find trees.
-
#find_users(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all users.
-
#import_access_keys(headers = default_headers) ⇒ Object
Import all access keys from :identifier.json file in export_directory/access-keys.
-
#import_categories(headers = default_headers) ⇒ Object
Import Categories.
-
#import_groups(headers = default_headers) ⇒ Object
Import Groups.
-
#import_handler(handler, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a handler file.
-
#import_handlers(force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import handlers from export directory.
-
#import_license(license, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Imports the license file.
-
#import_policy_rules(headers = default_headers) ⇒ Object
Import Policy Rules.
-
#import_routine(routine, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a routine.
-
#import_routines(force_overwrite = false, headers = header_basic_auth) ⇒ Object
Import routines.
-
#import_sources(headers = default_headers) ⇒ Object
Import all sources from :source-slug.json file in export_directory/sources.
-
#import_tree(tree, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a tree.
-
#import_trees(force_overwrite = false, headers = header_basic_auth) ⇒ Object
Import trees.
-
#initialize(opts) ⇒ Task
constructor
Initalize the Task SDK with the web server URL and user credentials, along with any custom option values.
-
#is_alive?(url, headers = header_basic_auth) ⇒ Boolean
Checks if the web application is alive.
-
#migrate_db(db = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Run the database migrations.
-
#remove_handler_from_category(handler_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a handler from a category.
-
#remove_policy_rule_from_category(policy_rule_type, policy_rule_name, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a policy rule from a category.
-
#remove_policy_rule_from_source(policy_rule_type, policy_rule_name, source_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove policy rule from source.
-
#remove_routine_from_category(routine_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a global routine from a category.
-
#remove_user_from_group(login_id, group_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove user from group.
-
#resolve_errors(ids, action, resolution, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resolve multiple errors with the same action and resolution notes.
-
#resolve_system_errors(ids, resolution, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resolve multiple system errors with the same resolution notes.
-
#run_tree(title, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Create a new run of a tree.
-
#server_info(headers = {}) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the server info.
-
#start_engine(headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Start the task engine.
-
#stop_engine(headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Stop the task engine.
-
#test_db_connection(db = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Test the database connection.
-
#update_access_key(identifier, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update an access key.
-
#update_authentication(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the authentication settings.
-
#update_category(original_name, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a category.
-
#update_db(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the database configuration.
-
#update_engine(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the engine settings.
-
#update_handler(definition_id, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Modifies the properties and info values for a handler.
-
#update_identity_store(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the identity store settings.
-
#update_license(license_content, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the license.
-
#update_policy_rule(policy_rule, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Policy Rule.
-
#update_properties(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the web server and default configuration user settings.
-
#update_session_configuration(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the session configuration settings.
-
#update_source(source, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a source.
-
#update_system_policy_rule(policy_rule_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the system policy rule.
-
#update_tree(title, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a tree.
-
#update_user(login_id, user, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a user.
-
#wait_until_alive(url, headers = header_basic_auth) ⇒ Object
Waits until the web server is alive.
Methods included from Utils::KineticExportUtils
#get_variable_property, #prepare_shape, #process_export, #should_extract, #write_object_to_file
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) ⇒ Task
Initalize the Task SDK with the web server URL and user credentials, along with any custom option values.
Example: using a configuration file
KineticSdk::Task.new({
config_file: "/opt/config1.yaml"
})
Example: using a properties hash
KineticSdk::Task.new({
app_server_url: "http://localhost:8080/kinetic-task",
username: "admin",
password: "admin",
options: {
log_level: "debug",
export_directory: "/opt/exports/task-server-a",
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
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 67 def initialize(opts) # initialize any variables = {} @config_user = {} @server = nil # 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) @config_user[:username] = [:username] @config_user[:password] = [:password] @server = [:app_server_url].chomp('/') @username = @config_user[:username] @password = @config_user[:password] # TODO: Better separation of APIv1 and APIv2 @api_v1_url = "#{@server}/app/api/v1" @api_v2_url = "#{@server}/app/api/v2" # set any constants or calculated values @api_url = @api_v2_url @version = 2 end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def api_url @api_url end |
#api_v1_url ⇒ Object (readonly)
Returns the value of attribute api_v1_url.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def api_v1_url @api_v1_url end |
#config_user ⇒ Object (readonly)
Returns the value of attribute config_user.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def config_user @config_user end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def password @password end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def server @server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def username @username end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
16 17 18 |
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16 def version @version end |
Instance Method Details
#add_access_key(access_key = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add an access key
Example
add_access_key({
"description" => "Description",
"identifier" => "X54DLNU",
"secret" => "xyz"
})
Example
add_access_key({
"description" => "Description"
})
Example
add_access_key()
28 29 30 31 32 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 28 def add_access_key(access_key={}, headers=default_headers) @logger.info("Adding access key " + (access_key.has_key?('identifier') ? access_key['identifier'] : "")) access_key["secret"] = "SETME" if access_key["secret"].nil? post("#{@api_url}/access-keys", access_key, headers) end |
#add_category(category, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a category
13 14 15 16 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 13 def add_category(category, headers=default_headers) @logger.info("Add category \"#{category['name']}\"") post("#{@api_url}/categories", category, headers) end |
#add_group(name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a group
9 10 11 12 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 9 def add_group(name, headers=default_headers) @logger.info("Adding group \"#{name}\"") post("#{@api_url}/groups", { "name" => name }, headers) end |
#add_handler_to_category(handler_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a handler to a category
137 138 139 140 141 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 137 def add_handler_to_category(handler_id, category_name, headers=default_headers) body = { "definitionId" => handler_id } @logger.info("Adding handler \"#{handler_id}\" to category \"#{category_name}\"") post("#{@api_url}/categories/#{encode(category_name)}/handlers", body, headers) end |
#add_policy_rule(policy, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a policy Rule
Example
add_policy_rule({
"name" => "Foo",
"type" => "Console Access | Category Access | API Access | System Default",
"rule" => "...",
"message" => "..."
})
19 20 21 22 23 24 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 19 def add_policy_rule(policy, headers=default_headers) @logger.info("Adding policy rule \"#{policy['type']} - #{policy['name']}\"") payload = policy payload["consolePolicyRules"] = consoleNames(payload) if payload.has_key?("consolePolicyRules") post("#{@api_url}/policyRules/#{encode(policy['type'])}", payload, headers) end |
#add_policy_rule_to_category(policy_rule_type, policy_rule_name, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a policy rule to a category
184 185 186 187 188 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 184 def add_policy_rule_to_category(policy_rule_type, policy_rule_name, category_name, headers=default_headers) body = { "type" => policy_rule_type, "name" => policy_rule_name } @logger.info("Adding policy rule \"#{policy_rule_type} - #{policy_rule_name}\" to category \"#{category_name}\"") post("#{@api_url}/categories/#{encode(category_name)}/policyRules", body, headers) end |
#add_policy_rule_to_source(policy_rule_type, policy_rule_name, source_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add policy rule to source
146 147 148 149 150 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 146 def add_policy_rule_to_source(policy_rule_type, policy_rule_name, source_name, headers=default_headers) body = { "type" => policy_rule_type, "name" => policy_rule_name } @logger.info("Adding policy rule \"#{policy_rule_type} - #{policy_rule_name}\" to source \"#{source_name}\"") post("#{@api_url}/sources/#{encode(source_name)}/policyRules", body, headers) end |
#add_routine_to_category(routine_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a global routine to a category
160 161 162 163 164 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 160 def add_routine_to_category(routine_id, category_name, headers=default_headers) body = { "definitionId" => routine_id } @logger.info("Adding routine \"#{routine_id}\" to category \"#{category_name}\"") post("#{@api_url}/categories/#{encode(category_name)}/routines", body, headers) end |
#add_source(source, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a source
Example
add_source({
"name" => "Source Name",
"status" => "Active",
"type" => "Kinetic Request CE",
"properties" => {
"Space Slug" => "foo",
"Web Server" => "http://localhost:8080/kinetic",
"Proxy Username" => "integration-user",
"Proxy Password" => "integration-password"
},
"policyRules" => []
})
30 31 32 33 34 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 30 def add_source(source, headers=default_headers) name = source['name'] @logger.info("Adding the #{name} source") post("#{@api_url}/sources", source, headers) end |
#add_user(user, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a user
Example
add_user({
"loginId" => "foo",
"password" => "bar",
"email" => "[email protected]"
})
18 19 20 21 |
# File 'lib/kinetic_sdk/task/lib/users.rb', line 18 def add_user(user, headers=default_headers) @logger.info("Add user \"#{user['loginId']}\"") post("#{@api_url}/users", user, headers) end |
#add_user_to_group(login_id, group_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add user to group
107 108 109 110 111 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 107 def add_user_to_group(login_id, group_name, headers=default_headers) body = { "loginId" => login_id } @logger.info("Adding user \"#{login_id}\" to group \"#{group_name}\"") post("#{@api_url}/groups/#{encode(group_name)}/users", body, headers) end |
#complete_deferred_task(source_name, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Complete a Deferred Task
11 12 13 14 |
# File 'lib/kinetic_sdk/task/lib/tasks.rb', line 11 def complete_deferred_task(source_name, body, headers=default_headers) @logger.info("Completing deferred task for the \"#{source_name}\" Source.") post("#{@api_v1_url}/complete-deferred-task/#{encode(source_name)}", body, headers) end |
#delete_access_key(identifier, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an access key
39 40 41 42 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 39 def delete_access_key(identifier, headers=header_basic_auth) @logger.info("Deleting access key \"#{identifier}\"") delete("#{@api_url}/access-keys/#{encode(identifier)}", headers) end |
#delete_access_keys(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all access keys
48 49 50 51 52 53 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 48 def delete_access_keys(headers=header_basic_auth) @logger.info("Deleting all access keys") (find_access_keys(headers).content["accessKeys"] || []).each do |access_key| delete("#{@api_url}/access_keys/#{encode(access_key['identifier'])}", headers) end end |
#delete_categories(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Categories
32 33 34 35 36 37 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 32 def delete_categories(headers=header_basic_auth) @logger.info("Deleting all categories") (find_categories(headers).content["categories"] || []).each do |category| delete_category(category['name'], headers) end end |
#delete_category(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Category
23 24 25 26 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 23 def delete_category(name, headers=header_basic_auth) @logger.info("Deleting Category \"#{name}\"") delete("#{@api_url}/categories/#{encode(name)}", headers) end |
#delete_error(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an Error
10 11 12 13 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 10 def delete_error(id, headers=header_basic_auth) @logger.info("Deleting Error \"#{id}\"") delete("#{@api_url}/errors/#{id}", headers) end |
#delete_group(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Group
19 20 21 22 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 19 def delete_group(name, headers=header_basic_auth) @logger.info("Deleting Group \"#{name}\"") delete("#{@api_url}/groups/#{encode(name)}", headers) end |
#delete_groups(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Groups
28 29 30 31 32 33 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 28 def delete_groups(headers=header_basic_auth) @logger.info("Deleting all groups") (find_groups(headers).content['groups'] || []).each do |group| delete("#{@api_url}/groups/#{encode(group['name'])}", headers) end end |
#delete_handler(definition_id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Handler
9 10 11 12 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 9 def delete_handler(definition_id, headers=header_basic_auth) @logger.info("Deleting Handler \"#{definition_id}\"") delete("#{@api_url}/handlers/#{definition_id}", headers) end |
#delete_handlers(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Handlers
18 19 20 21 22 23 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 18 def delete_handlers(headers=header_basic_auth) @logger.info("Deleting all handlers") (find_handlers(headers).content['handlers'] || []).each do |handler| delete("#{@api_url}/handlers/#{handler['definitionId']}", headers) end end |
#delete_license(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete the license
8 9 10 11 |
# File 'lib/kinetic_sdk/task/lib/license.rb', line 8 def delete_license(headers=header_basic_auth) @logger.info("Deleting the license") delete("#{@api_url}/config/license", {}, headers) end |
#delete_policy_rule(policy, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Policy Rule.
Example
delete_policy_rule({
"type" => "API Access",
"name" => "Company Network"
})
41 42 43 44 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 41 def delete_policy_rule(policy, headers=header_basic_auth) @logger.info("Deleting policy rule \"#{policy['type']} - #{policy['name']}\"") delete("#{@api_url}/policyRules/#{encode(policy['type'])}/#{encode(policy['name'])}", headers) end |
#delete_policy_rules(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Policy Rules.
50 51 52 53 54 55 56 57 58 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 50 def delete_policy_rules(headers=header_basic_auth) @logger.info("Deleting all policy rules") (find_policy_rules(headers).content["policyRules"] || []).each do |policy_rule| delete_policy_rule({ "type" => policy_rule['type'], "name" => policy_rule['name'] }, headers) end end |
#delete_run(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Run.
Example
delete_run(24548)
14 15 16 17 |
# File 'lib/kinetic_sdk/task/lib/runs.rb', line 14 def delete_run(id, headers=header_basic_auth) @logger.info("Deleting run \"#{id}\"") delete("#{@api_url}/runs/#{id}", headers) end |
#delete_source(name, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Source
41 42 43 44 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 41 def delete_source(name, headers=header_basic_auth) @logger.info("Deleting Source \"#{name}\"") delete("#{@api_url}/sources/#{encode(name)}", headers) end |
#delete_sources(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Sources
50 51 52 53 54 55 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 50 def delete_sources(headers=header_basic_auth) @logger.info("Deleting all sources") (find_sources(headers).content["sourceRoots"] || []).each do |source| delete("#{@api_url}/sources/#{encode(source['name'])}", headers) end end |
#delete_system_error(id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a system error
9 10 11 12 |
# File 'lib/kinetic_sdk/task/lib/system_errors.rb', line 9 def delete_system_error(id, headers=header_basic_auth) @logger.info("Deleting system error \"#{id}\"") delete("#{@api_url}/systemErrors/#{id}", headers) end |
#delete_tree(tree, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a tree.
Example
delete_tree("Kinetic Request CE :: Win a Car :: Complete")
Example
delete_tree({
"source_name" => "Kinetic Request CE",
"group_name" => "Win a Car",
"tree_name" => "Complete"
})
22 23 24 25 26 27 28 29 30 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 22 def delete_tree(tree, headers=header_basic_auth) if tree.is_a? Hash title = "#{tree['source_name']} :: #{tree['group_name']} :: #{tree['tree_name']}" else title = "#{tree.to_s}" end @logger.info("Deleting Tree \"#{title}\"") delete("#{@api_url}/trees/#{encode(title)}", headers) end |
#delete_trees(source_name = nil, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete trees.
If the source_name is provided, only trees that belong to the source will be deleted, otherwise all trees will be deleted.
Example
delete_trees("Kinetic Request CE")
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 45 def delete_trees(source_name=nil, headers=header_basic_auth) if source_name.nil? @logger.info("Deleting all trees") params = {} else @logger.info("Deleting trees for Source \"#{source_name}\"") params = { "source" => source_name } end (find_trees(params, headers).content['trees'] || []).each do |tree| @logger.info("Deleting tree \"#{tree['title']}\"") delete("#{@api_url}/trees/#{encode(tree['title'])}", headers) end end |
#delete_user(login_id, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a User
28 29 30 31 |
# File 'lib/kinetic_sdk/task/lib/users.rb', line 28 def delete_user(login_id, headers=header_basic_auth) @logger.info("Deleting User \"#{login_id}\"") delete("#{@api_url}/users/#{encode(login_id)}", headers) end |
#delete_users(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete all Users
37 38 39 40 41 42 |
# File 'lib/kinetic_sdk/task/lib/users.rb', line 37 def delete_users(headers=header_basic_auth) @logger.info("Deleting all users") (find_users(headers).content["users"] || []).each do |user| delete_user(user['loginId'], headers) end end |
#engine_info(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the engine info
27 28 29 |
# File 'lib/kinetic_sdk/task/lib/engine.rb', line 27 def engine_info(params={}, headers=header_basic_auth) get("#{@api_url}/engine", params, headers) end |
#engine_status(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the engine status
35 36 37 38 39 |
# File 'lib/kinetic_sdk/task/lib/engine.rb', line 35 def engine_status(headers=header_basic_auth) response = @logger.info({}, headers) data = response.content data.nil? ? "Unknown" : data['status'] end |
#environment(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the web server environment
9 10 11 |
# File 'lib/kinetic_sdk/task/lib/environment.rb', line 9 def environment(params={}, headers=header_basic_auth) get("#{@api_url}/environment", params, headers) end |
#export(headers = header_basic_auth, export_opts = {}) ⇒ Object
Export all structure definitions to export_directory
.
Exports the following items:
- sources
- trees
- routines
- handlers
- groups
- policy rules
- categories
- access keys
21 22 23 24 25 26 27 28 29 |
# File 'lib/kinetic_sdk/task/lib/export.rb', line 21 def export(headers=header_basic_auth, export_opts={}) export_sources(headers) export_trees(nil,headers,export_opts) # Includes routines when nil passed export_handlers(headers) export_groups(headers) export_policy_rules(headers) export_categories(headers) export_access_keys(headers) end |
#export_access_keys(headers = header_basic_auth) ⇒ Object
Export all access keys to :identifier.json file in export_directory/access-keys
59 60 61 62 63 64 65 66 67 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 59 def export_access_keys(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export access keys." if @options[:export_directory].nil? response = find_access_keys access_keys_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "access-keys")) (response.content["accessKeys"] || []).each do |access_key| access_key_file = File.join(access_keys_dir, "#{access_key['identifier'].slugify}.json") write_object_to_file(access_key_file, access_key) end end |
#export_all_except_trees(headers = header_basic_auth) ⇒ Object
Export all structure definitions except trees and routines to export_directory
.
Exports the following items:
- sources
- handlers
- groups
- policy rules
- categories
- access keys
45 46 47 48 49 50 51 52 |
# File 'lib/kinetic_sdk/task/lib/export.rb', line 45 def export_all_except_trees(headers=header_basic_auth) export_sources(headers) export_handlers(headers) export_groups(headers) export_policy_rules(headers) export_categories(headers) export_access_keys(headers) end |
#export_categories(headers = header_basic_auth) ⇒ Object
Export Categories
73 74 75 76 77 78 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 73 def export_categories(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export categories." if @options[:export_directory].nil? (find_categories({ "include" => "handlers,trees,policyRules" }).content["categories"] || []).each do |category| export_category(category) end end |
#export_category(category, headers = header_basic_auth) ⇒ Object
Export a Category
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 48 def export_category(category, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export a category." if @options[:export_directory].nil? if category.is_a? String response = find_category(category, { "include" => "handlers,trees,policyRules" }, headers) category = response.content end @logger.info("Exporting category \"#{category['name']}\" to #{@options[:export_directory]}.") # Create the category directory if it doesn't yet exist category_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "categories")) category_file = File.join(category_dir, "#{category['name'].slugify}.json") # Just export the associated key values category['handlers'].collect! { |h| h['definitionId'] }.sort! category['trees'].collect! { |t| t['definitionId'] }.sort! category['policyRules'].collect! { |pr| pr['name'] }.sort! # write the file File.write(category_file, JSON.pretty_generate(category)) @logger.info("Exported category: #{category['name']} to #{category_file}") end |
#export_group(group, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Export a Group
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 40 def export_group(group, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export a group." if @options[:export_directory].nil? if group.is_a? String response = find_group(group, {}, headers) group = response.content end @logger.info("Exporting group \"#{group['name']}\" to #{@options[:export_directory]}.") # Create the groups directory if it doesn't yet exist group_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "groups")) group_file = File.join(group_dir, "#{group['name'].slugify}.json") # write the file responseObj = get("#{@api_url}/groups/#{encode(group['name'])}", {}, headers) File.write(group_file, JSON.pretty_generate(responseObj.content)) @logger.info("Exported group: #{group['name']} to #{group_file}") end |
#export_groups(headers = header_basic_auth) ⇒ Object
Export Groups
60 61 62 63 64 65 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 60 def export_groups(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export groups." if @options[:export_directory].nil? (find_groups.content["groups"] || []).each do |group| export_group(group) end end |
#export_handler(definition_id, headers = header_basic_auth) ⇒ Object
Export a single handler
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 92 def export_handler(definition_id, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export a handler." if @options[:export_directory].nil? @logger.info("Exporting handler \"#{definition_id}\" to #{@options[:export_directory]}.") # Create the handler directory if it doesn't yet exist handler_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "handlers")) handler_file = File.join(handler_dir, "#{definition_id}.zip") # write the file File.open(handler_file, "wb") do |file| file.write get("#{@api_url}/handlers/#{definition_id}/zip", {}, headers).content_string end @logger.info("Exported handler: #{definition_id} to #{handler_file}") end |
#export_handlers(headers = header_basic_auth) ⇒ Object
Export all handlers
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 109 def export_handlers(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export handlers." if @options[:export_directory].nil? @logger.info("Exporting handlers to #{@options[:export_directory]}.") # Setup the parameters sent to the find_handlers method. # limit and offset are used for pagination. limit, offset, count = 10, 0, nil params = { "limit" => limit } # Paginate through all the handlers while (count.nil? || offset < count) # Get the handler metadata to geta all handler_ids response = find_handlers(params, headers) count = response.content["count"].to_i # Export each handler (response.content["handlers"] || []).each do |handler| export_handler(handler['definitionId'], headers) end # Increment the offset to the next page offset += limit params["offset"] = offset end end |
#export_policy_rule(policy_rule, headers = header_basic_auth) ⇒ Object
Export a Policy Rule
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 67 def export_policy_rule(policy_rule, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export a policy rule." if @options[:export_directory].nil? @logger.info("Exporting policy rule \"policy_rule['type']\" : \"#{policy_rule['name']}\" to #{@options[:export_directory]}.") # Create the policy rules directory if it doesn't yet exist dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "policyRules")) file = File.join(dir, "#{policy_rule['type'].slugify}-#{policy_rule['name'].slugify}.json") unless policy_rule.has_key?("consolePolicyRules") response = find_policy_rule( { "type" => policy_rule['type'], "name" => policy_rule['name'] }, { "include" => "consolePolicyRules" }, headers ) if response.status != 200 @logger.info("Failed to export policy rule: #{policy_rule['type']} - #{policy_rule['name']}: #{response.inspect}") policy_rule = nil else policy_rule = response.content end end unless policy_rule.nil? # write the file File.write(file, JSON.pretty_generate(policy_rule)) @logger.info("Exported policy rule: #{policy_rule['type']} - #{policy_rule['name']} to #{file}") end end |
#export_policy_rules(headers = header_basic_auth) ⇒ Object
Export Policy Rules
99 100 101 102 103 104 105 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 99 def export_policy_rules(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export policy rules." if @options[:export_directory].nil? response = find_policy_rules({"include" => "consolePolicyRules"}, headers) (response.content["policyRules"] || []).each do |policy_rule| export_policy_rule(policy_rule, headers) end end |
#export_routines(headers = header_basic_auth) ⇒ Object
Export all global routines
321 322 323 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 321 def export_routines(headers=header_basic_auth) export_trees("-", headers) end |
#export_sources(headers = header_basic_auth) ⇒ Object
Export all sources to :source-slug.json file in export_directory/sources
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 61 def export_sources(headers=header_basic_auth) raise StandardError.new "An export directory must be defined to export sources." if @options[:export_directory].nil? response = find_sources({"include" => "policyRules, properties"}) (response.content["sourceRoots"] || []).each do |source| # determine which directory to write the file to if source['name'] != "-" # create the directory if it doesn't yet exist sources_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "sources")) source_file = File.join(sources_dir, "#{source['name'].slugify}.json") write_object_to_file(source_file, source) end end end |
#export_tree(title, headers = header_basic_auth, export_opts = {}) ⇒ Object
Export a single tree or routine. This method will not export Kinetic Core
workflows unless export_opts[:include_workflows] => true
export option
is provided.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 226 def export_tree(title, headers=header_basic_auth, export_opts={}) raise StandardError.new "An export directory must be defined to export a tree." if @options[:export_directory].nil? @logger.info("Exporting tree \"#{title}\" to #{@options[:export_directory]}.") # Get the tree response = find_tree(title, { "include" => "details,export" }) # Parse the response and export the tree tree = response.content if export_opts[:include_workflows] || (!tree.has_key?("event") || tree["event"].nil?) # determine which directory to write the file to if tree['sourceGroup'] == "-" # Create the directory if it doesn't yet exist routine_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "routines")) tree_file = File.join(routine_dir, "#{tree['name'].slugify}.xml") else # Create the directory if it doesn't yet exist tree_dir = FileUtils::mkdir_p(File.join(@options[:export_directory],"sources", tree['sourceName'].slugify , "trees")) tree_file = File.join(tree_dir, "#{tree['sourceGroup'].slugify}.#{tree['name'].slugify}.xml") end # write the file server_version = server_info(headers).content["version"] if server_version > "04.03.0z" File.write(tree_file, tree['export']) else xml_doc = REXML::Document.new(tree["export"]) xml_doc.context[:attribute_quote] = :quote xml_formatter = Prettier.new xml_formatter.write(xml_doc, File.open(tree_file, "w")) end @logger.info("Exported #{tree['type']}: #{tree['title']} to #{tree_file}") else @logger.info("Did not export #{tree['type']}: #{tree['title']} because it is a Core linked workflow") end end |
#export_trees(source_name = nil, headers = header_basic_auth, export_opts = {}) ⇒ Object
Export trees and local routines for a source, and global routines. This method will
not export Kinetic Core workflows unless export_opts[:include_workflows] => true
export option is provided.
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 272 def export_trees(source_name=nil, headers=header_basic_auth, export_opts={}) raise StandardError.new "An export directory must be defined to export trees." if @options[:export_directory].nil? if source_name.nil? if export_opts[:include_workflows] @logger.info("Exporting all trees, routines, and workflows to #{@options[:export_directory]}.") else @logger.info("Exporting all trees and routines to #{@options[:export_directory]}.") end export_routines(headers) (find_sources({}, headers).content["sourceRoots"] || []).each do |sourceRoot| export_trees(sourceRoot['name'], headers, export_opts) end return elsif source_name == "-" @logger.info("Exporting global routines to #{@options[:export_directory]}.") else @logger.info("Exporting trees and local routines for source \"#{source_name}\" to #{@options[:export_directory]}.") end # Setup the parameters sent to the find_trees method. # limit and offset are used for pagination. limit, offset, count = 10, 0, nil params = { "source" => source_name, "include" => "details", "limit" => limit } # Paginate through all the trees and routines for the source while (count.nil? || offset < count) response = find_trees(params, headers) count = response.content["count"].to_i # Export each tree (response.content["trees"] || []).each do |tree| if export_opts[:include_workflows] || (!tree.has_key?("event") || tree["event"].nil?) export_tree(tree['title'], headers, export_opts) end end # Increment the offset to the next page offset += limit params["offset"] = offset end end |
#find_access_key(identifier, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an access key
98 99 100 101 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 98 def find_access_key(identifier, params={}, headers=default_headers) @logger.info("Finding access key \"#{identifier}\"") get("#{@api_url}/access-keys/#{encode(identifier)}", params, headers) end |
#find_access_keys(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all access keys
87 88 89 90 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 87 def find_access_keys(params={}, headers=header_basic_auth) @logger.info("Finding all access keys") get("#{@api_url}/access-keys", params, headers) end |
#find_active_errors_by_handler(handler_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Handler Id
81 82 83 84 85 86 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 81 def find_active_errors_by_handler(handler_id, params={}, headers=header_basic_auth) @logger.info("Finding active errors for handler #{handler_id}") params['handlerId'] = handler_id params['status'] = 'Active' find_errors(params, headers) end |
#find_active_errors_by_node(source_name, group, tree_name, node_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Node
142 143 144 145 146 147 148 149 150 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 142 def find_active_errors_by_node(source_name, group, tree_name, node_id, params={}, headers=header_basic_auth) @logger.info("Finding active errors for node \"#{source_name} :: #{group} :: #{tree_name} :: #{node_id}\"") params['nodeId'] = node_id params['tree'] = tree_name params['group'] = group params['source'] = source_name params['status'] = 'Active' find_errors(params, headers) end |
#find_active_errors_by_source(source_name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Source
94 95 96 97 98 99 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 94 def find_active_errors_by_source(source_name, params={}, headers=header_basic_auth) @logger.info("Finding active errors for source \"#{source_name}\"") params['source'] = source_name params['status'] = 'Active' find_errors(params, headers) end |
#find_active_errors_by_source_group(source_name, group, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Finding Active Errors by Source Group
108 109 110 111 112 113 114 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 108 def find_active_errors_by_source_group(source_name, group, params={}, headers=header_basic_auth) @logger.info("Finding active errors for source group \"#{source_name} :: #{group}\"") params['group'] = group params['source'] = source_name params['status'] = 'Active' find_errors(params, headers) end |
#find_active_errors_by_tree(source_name, group, tree_name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Active Errors by Tree Name
124 125 126 127 128 129 130 131 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 124 def find_active_errors_by_tree(source_name, group, tree_name, params={}, headers=header_basic_auth) @logger.info("Finding active errors for tree \"#{source_name} :: #{group} :: #{tree_name}\"") params['tree'] = tree_name params['group'] = group params['source'] = source_name params['status'] = 'Active' find_errors(params, headers) end |
#find_categories(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all categories
98 99 100 101 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 98 def find_categories(params={}, headers=header_basic_auth) @logger.info("Finding all categories") get("#{@api_url}/categories", params, headers) end |
#find_category(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a category
109 110 111 112 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 109 def find_category(name, params={}, headers=header_basic_auth) @logger.info("Finding Category \"#{name}\"") get("#{@api_url}/categories/#{encode(name)}", params, headers) end |
#find_db(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the database configuration
9 10 11 12 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 9 def find_db(params={}, headers=header_basic_auth) @logger.info("Finding the database configuration") get("#{@api_url}/config/db", params, headers) end |
#find_engine_configuration(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the engine configuration properties
31 32 33 34 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 31 def find_engine_configuration(params={}, headers=header_basic_auth) @logger.info("Finding the engine configuration") get("#{@api_url}/config/engine", params, headers) end |
#find_error(id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an Error
70 71 72 73 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 70 def find_error(id, params={}, headers=header_basic_auth) @logger.info("Finding error #{id}") get("#{@api_url}/errors/#{id}", params, headers) end |
#find_errors(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a list of errors.
59 60 61 62 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 59 def find_errors(params={}, headers=header_basic_auth) @logger.info("Finding errors") get("#{@api_url}/errors", params, headers) end |
#find_errors_by_run(run_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Errors by Run Id
158 159 160 161 162 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 158 def find_errors_by_run(run_id, params={}, headers=header_basic_auth) @logger.info("Finding active errors for run #{run_id}") params['runId'] = run_id find_errors(params, headers) end |
#find_group(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Group
96 97 98 99 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 96 def find_group(name, params={}, headers=header_basic_auth) @logger.info("Finding the #{name} group") get("#{@api_url}/groups/#{encode(name)}", params, headers) end |
#find_groups(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all groups
85 86 87 88 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 85 def find_groups(params={}, headers=header_basic_auth) @logger.info("Finding all groups") get("#{@api_url}/groups", params, headers) end |
#find_handler(definition_id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a handler
41 42 43 44 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 41 def find_handler(definition_id, params={}, headers=header_basic_auth) @logger.info("Finding handler \"#{definition_id}\"") get("#{@api_url}/handlers/#{definition_id}", params, headers) end |
#find_handlers(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all handlers
30 31 32 33 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 30 def find_handlers(params={}, headers=header_basic_auth) @logger.info("Find all handlers") get("#{@api_url}/handlers", params, headers) end |
#find_license(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the license
18 19 20 21 |
# File 'lib/kinetic_sdk/task/lib/license.rb', line 18 def find_license(params={}, headers=header_basic_auth) @logger.info("Finding the license") get("#{@api_url}/config/license", params, headers) end |
#find_policy_rule(policy_rule, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a policy rule
Exammple
find_policy_rule({ "type" => "API Access", "name" => "Allow All"})
157 158 159 160 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 157 def find_policy_rule(policy_rule, params={}, headers=header_basic_auth) @logger.info("Finding the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule") get("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", params, headers) end |
#find_policy_rules(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Policy Rules.
129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 129 def find_policy_rules(params={}, headers=header_basic_auth) @logger.info("Finding Policy Rules") policy_rules = [] response = nil ["API Access", "Category Access", "Console Access", "System Default"].each do |type| response = get("#{@api_url}/policyRules/#{encode(type)}", params, headers) policy_rules.concat(response.content["policyRules"] || []) end final_content = { "policyRules" => policy_rules } response.content= final_content response.content_string= final_content.to_json response end |
#find_routines(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find routines.
Example
find_routines({ "source" => "Kinetic Request CE" })
Example
find_routines({ "include" => "details" })
Example
find_routines({ "source" => "Kinetic Request CE", "include" => "details" })
102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 102 def find_routines(params={}, headers=header_basic_auth) @logger.info("Finding Routines") response = get("#{@api_url}/trees", params, headers) routines = [] (response.content["trees"] || []).each do |tree| routines.push(tree) unless tree['definitionId'].nil? end final_content = { "trees" => routines } response.content= final_content response.content_string= final_content.to_json response end |
#find_runs(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find runs.
Example
find_runs({ "source" => "Kinetic Request CE" })
Example
find_runs({ "include" => "details" })
Example
find_runs({ "source" => "Kinetic Request CE", "include" => "details" })
37 38 39 40 |
# File 'lib/kinetic_sdk/task/lib/runs.rb', line 37 def find_runs(params={}, headers=header_basic_auth) @logger.info("Finding Runs") get("#{@api_url}/runs", params, headers) end |
#find_session_configuration(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the session configuration properties
20 21 22 23 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 20 def find_session_configuration(params={}, headers=header_basic_auth) @logger.info("Finding the session timeout") get("#{@api_url}/config/session", params, headers) end |
#find_source(name, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a source
104 105 106 107 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 104 def find_source(name, params={}, headers=header_basic_auth) @logger.info("Finding source named \"#{name}\"") get("#{@api_url}/sources/#{encode(name)}", params, headers) end |
#find_sources(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all sources
93 94 95 96 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 93 def find_sources(params={}, headers=header_basic_auth) @logger.info("Finding all sources") get("#{@api_url}/sources", params, headers) end |
#find_system_error(id, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a system error
55 56 57 58 |
# File 'lib/kinetic_sdk/task/lib/system_errors.rb', line 55 def find_system_error(id, params={}, headers=header_basic_auth) @logger.info("Finding system error #{id}") get("#{@api_url}/systemErrors/#{id}", params, headers) end |
#find_system_errors(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a list of system errors.
44 45 46 47 |
# File 'lib/kinetic_sdk/task/lib/system_errors.rb', line 44 def find_system_errors(params={}, headers=header_basic_auth) @logger.info("Finding system errors") get("#{@api_url}/systemErrors", params, headers) end |
#find_system_policy_rule(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find the system policy rule
191 192 193 194 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 191 def find_system_policy_rule(params={}, headers=header_basic_auth) @logger.info("Finding the system policy rule") get("#{@api_url}/config/systemPolicyRule", params, headers) end |
#find_tree(title, params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a single tree by title (Source Name :: Group Name :: Tree Name)
Example
find_tree(
"Kinetic Request CE :: Win a Car :: Complete",
{ "include" => "details" }
)
200 201 202 203 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 200 def find_tree(title, params={}, headers=header_basic_auth) @logger.info("Finding the \"#{title}\" Tree") get("#{@api_url}/trees/#{encode(title)}", params, headers) end |
#find_tree_by_id(tree_id, params = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a tree by Id
211 212 213 214 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 211 def find_tree_by_id(tree_id, params={}, headers=default_headers) @logger.info("Find tree by id") get("#{@api_url}/trees/guid/#{tree_id}", params, headers) end |
#find_trees(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find trees.
Example
find_trees({ "source" => "Kinetic Request CE" })
Example
find_trees({ "include" => "details" })
Example
find_trees({ "source" => "Kinetic Request CE", "include" => "details" })
79 80 81 82 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 79 def find_trees(params={}, headers=header_basic_auth) @logger.info("Finding Trees") get("#{@api_url}/trees", params, headers) end |
#find_users(params = {}, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Find all users
49 50 51 52 |
# File 'lib/kinetic_sdk/task/lib/users.rb', line 49 def find_users(params={}, headers=header_basic_auth) @logger.info("Finding all users") get("#{@api_url}/users", params, headers) end |
#import_access_keys(headers = default_headers) ⇒ Object
Import all access keys from :identifier.json file in export_directory/access-keys
73 74 75 76 77 78 79 80 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 73 def import_access_keys(headers=default_headers) raise StandardError.new "An export directory must be defined to import access keys from." if @options[:export_directory].nil? @logger.info("Importing all Access Keys in Export Directory") Dir["#{@options[:export_directory]}/access-keys/*.json"].sort.each do |file| access_key = JSON.parse(File.read(file)) add_access_key(access_key, headers) end end |
#import_categories(headers = default_headers) ⇒ Object
Import Categories
84 85 86 87 88 89 90 91 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 84 def import_categories(headers=default_headers) raise StandardError.new "An export directory must be defined to import categories from." if @options[:export_directory].nil? @logger.info("Importing all Categories in Export Directory") Dir["#{@options[:export_directory]}/categories/*.json"].sort.each do |file| category = JSON.parse(File.read(file)) add_category(category, headers) end end |
#import_groups(headers = default_headers) ⇒ Object
Import Groups
71 72 73 74 75 76 77 78 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 71 def import_groups(headers=default_headers) raise StandardError.new "An export directory must be defined to import groups from." if @options[:export_directory].nil? @logger.info("Importing all Groups in Export Directory") Dir["#{@options[:export_directory]}/groups/*.json"].sort.each do |file| group = JSON.parse(File.read(file)) add_group(group["name"], headers) end end |
#import_handler(handler, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a handler file
If the handler already exists on the server, this will fail unless forced to overwrite.
54 55 56 57 58 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 54 def import_handler(handler, force_overwrite=false, headers=header_basic_auth) body = { "package" => handler } @logger.info("Importing Handler #{File.basename(handler)}") post_multipart("#{@api_url}/handlers?force=#{force_overwrite}", body, headers) end |
#import_handlers(force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import handlers from export directory
If the handlers already exists on the server, this will fail unless forced to overwrite.
67 68 69 70 71 72 73 74 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 67 def import_handlers(force_overwrite=false, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to import handlers from." if @options[:export_directory].nil? @logger.info("Importing all Handlers from Export Directory") Dir["#{@options[:export_directory]}/handlers/*.zip"].sort.each do |file| handler_file = File.new(file, "rb") import_handler(handler_file, force_overwrite, headers) end end |
#import_license(license, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Imports the license file
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kinetic_sdk/task/lib/license.rb', line 39 def import_license(license, headers=default_headers) if license.is_a? File update_license(license.read, headers) else if File.exists? license update_license(File.read(license), headers) else @logger.info(" * License file \"#{license}\" does not exist.") end end end |
#import_policy_rules(headers = default_headers) ⇒ Object
Import Policy Rules
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 111 def import_policy_rules(headers=default_headers) raise StandardError.new "An export directory must be defined to import policy rules from." if @options[:export_directory].nil? @logger.info("Importing all Policy Rules in Export Directory") Dir["#{@options[:export_directory]}/policyRules/*.json"].sort.each do |file| policy_rule = JSON.parse(File.read(file)) if find_policy_rule({ "type" => policy_rule["type"], "name" => policy_rule["name"] }).status == 200 update_policy_rule({ "type" => policy_rule["type"], "name" => policy_rule["name"] }, policy_rule, headers) else add_policy_rule(policy_rule, headers) end end end |
#import_routine(routine, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a routine
If the routine already exists on the server, this will fail unless forced to overwrite.
163 164 165 166 167 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 163 def import_routine(routine, force_overwrite=false, headers=header_basic_auth) body = { "content" => routine } @logger.info("Importing Routine #{File.basename(routine)}") post_multipart("#{@api_url}/trees?force=#{force_overwrite}", body, headers) end |
#import_routines(force_overwrite = false, headers = header_basic_auth) ⇒ Object
Import routines
If the routines already exists on the server, this will fail unless forced to overwrite.
177 178 179 180 181 182 183 184 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 177 def import_routines(force_overwrite=false, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to import trees from." if @options[:export_directory].nil? @logger.info("Importing all Routines from Export Directory") Dir["#{@options[:export_directory]}/routines/*.xml"].sort.each do |file| routine_file = File.new(file, "rb") import_routine(routine_file, force_overwrite, headers) end end |
#import_sources(headers = default_headers) ⇒ Object
Import all sources from :source-slug.json file in export_directory/sources
79 80 81 82 83 84 85 86 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 79 def import_sources(headers=default_headers) raise StandardError.new "An export directory must be defined to import sources." if @options[:export_directory].nil? @logger.info("Importing all Sources in Export Directory") Dir["#{@options[:export_directory]}/sources/*.json"].sort.each do |file| source = JSON.parse(File.read(file)) add_source(source, headers) end end |
#import_tree(tree, force_overwrite = false, headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Import a tree
If the tree already exists on the server, this will fail unless forced to overwrite.
The source named in the tree content must also exist on the server, or the import will fail.
128 129 130 131 132 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 128 def import_tree(tree, force_overwrite=false, headers=header_basic_auth) body = { "content" => tree } @logger.info("Importing Tree #{File.basename(tree)}") post_multipart("#{@api_url}/trees?force=#{force_overwrite}", body, headers) end |
#import_trees(force_overwrite = false, headers = header_basic_auth) ⇒ Object
Import trees
If the trees already exists on the server, this will fail unless forced to overwrite.
The source named in the trees content must also exist on the server, or the import will fail.
145 146 147 148 149 150 151 152 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 145 def import_trees(force_overwrite=false, headers=header_basic_auth) raise StandardError.new "An export directory must be defined to import trees from." if @options[:export_directory].nil? @logger.info("Importing all Trees from Export Directory") Dir["#{@options[:export_directory]}/sources/**/*.xml"].sort.each do |file| tree_file = File.new(file, "rb") import_tree(tree_file, force_overwrite, headers) end end |
#is_alive?(url, headers = header_basic_auth) ⇒ Boolean
Checks if the web application is alive
9 10 11 12 |
# File 'lib/kinetic_sdk/task/lib/health.rb', line 9 def is_alive?(url, headers=header_basic_auth) response = get(url, {}, headers) response.status == 200 end |
#migrate_db(db = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Run the database migrations
Example
{
"type": "PostgreSQL",
"properties": {
"host": "mydbserver.company.com",
"port": "5432",
"database": "kinetictask",
"username": "TaskUser",
"password": "TaskPassword1"
}
}
49 50 51 52 53 |
# File 'lib/kinetic_sdk/task/lib/setup.rb', line 49 def migrate_db(db={}, headers=default_headers) @logger.info("Running database migrations") response = post("#{@api_url}/setup/db/migrate", db, headers) response.content end |
#remove_handler_from_category(handler_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a handler from a category
149 150 151 152 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 149 def remove_handler_from_category(handler_id, category_name, headers=default_headers) @logger.info("Removing handler \"#{handler_id}\" from category \"#{category_name}\"") delete("#{@api_url}/categories/#{encode(category_name)}/handlers/#{encode(handler_id)}", headers) end |
#remove_policy_rule_from_category(policy_rule_type, policy_rule_name, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a policy rule from a category
197 198 199 200 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 197 def remove_policy_rule_from_category(policy_rule_type, policy_rule_name, category_name, headers=default_headers) @logger.info("Removing policy rule \"#{policy_rule_type} - #{policy_rule_name}\" from category \"#{category_name}\"") delete("#{@api_url}/categories/#{encode(category_name)}/policyRules/#{encode(policy_rule_type)}/#{encode(policy_rule_name)}", headers) end |
#remove_policy_rule_from_source(policy_rule_type, policy_rule_name, source_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove policy rule from source
159 160 161 162 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 159 def remove_policy_rule_from_source(policy_rule_type, policy_rule_name, source_name, headers=default_headers) @logger.info("Removing policy rule \"#{policy_rule_type} - #{policy_rule_name}\" from source \"#{source_name}\"") delete("#{@api_url}/sources/#{encode(source_name)}/policyRules/#{encode(policy_rule_type)}/#{encode(policy_rule_name)}", headers) end |
#remove_routine_from_category(routine_id, category_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove a global routine from a category
172 173 174 175 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 172 def remove_routine_from_category(routine_id, category_name, headers=default_headers) @logger.info("Removing routine \"#{routine_id}\" from category \"#{category_name}\"") delete("#{@api_url}/categories/#{encode(category_name)}/routines/#{encode(routine_id)}", headers) end |
#remove_user_from_group(login_id, group_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Remove user from group
119 120 121 122 |
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 119 def remove_user_from_group(login_id, group_name, headers=default_headers) @logger.info("Removing user \"#{login_id}\" from group \"#{group_name}\"") post("#{@api_url}/groups/#{encode(group_name)}/users/#{encode(login_id)}", headers) end |
#resolve_errors(ids, action, resolution, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resolve multiple errors with the same action and resolution notes.
28 29 30 31 32 |
# File 'lib/kinetic_sdk/task/lib/errors.rb', line 28 def resolve_errors(ids, action, resolution, headers=default_headers) @logger.info("Resolving errors #{ids}") body = { "ids" => ids, "action" => action, "resolution" => resolution } post("#{@api_url}/errors/resolve", body, headers) end |
#resolve_system_errors(ids, resolution, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resolve multiple system errors with the same resolution notes.
20 21 22 23 24 |
# File 'lib/kinetic_sdk/task/lib/system_errors.rb', line 20 def resolve_system_errors(ids, resolution, headers=default_headers) @logger.info("Resolving system errors #{ids}") body = { "ids" => ids, "resolution" => resolution } post("#{@api_url}/systemErrors/resolve", body, headers) end |
#run_tree(title, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Create a new run of a tree
332 333 334 335 336 337 338 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 332 def run_tree(title, body={}, headers=default_headers) @logger.info("Running tree #{title}") parts = title.split(" :: ") raise StandardError.new "Title is invalid: #{title}" if parts.size != 3 url = "#{@api_v1_url}/run-tree/#{encode(parts[0])}/#{encode(parts[1])}/#{encode(parts[2])}" post(url, body, headers) end |
#server_info(headers = {}) ⇒ KineticSdk::Utils::KineticHttpResponse
Get the server info
31 32 33 |
# File 'lib/kinetic_sdk/task/lib/health.rb', line 31 def server_info(headers={}) get(@api_url, {}, headers) end |
#start_engine(headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Start the task engine
8 9 10 11 |
# File 'lib/kinetic_sdk/task/lib/engine.rb', line 8 def start_engine(headers=default_headers) body = { "action" => "start" } post("#{@api_url}/engine", body, headers) end |
#stop_engine(headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Stop the task engine
17 18 19 20 |
# File 'lib/kinetic_sdk/task/lib/engine.rb', line 17 def stop_engine(headers=default_headers) body = { "action" => "stop" } post("#{@api_url}/engine", body, headers) end |
#test_db_connection(db = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Test the database connection
Example
{
"type": "PostgreSQL",
"properties": {
"host": "mydbserver.company.com",
"port": "5432",
"database": "kinetictask",
"username": "TaskUser",
"password": "TaskPassword1"
}
}
23 24 25 26 27 |
# File 'lib/kinetic_sdk/task/lib/setup.rb', line 23 def test_db_connection(db={}, headers=default_headers) @logger.info("Testing database connection") response = post("#{@api_url}/setup/db/test", db, headers) response.content end |
#update_access_key(identifier, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update an access key
Example
update_identifier("X54DLNU", {
"description": "Updated access key"
})
116 117 118 119 |
# File 'lib/kinetic_sdk/task/lib/access_keys.rb', line 116 def update_access_key(identifier, body={}, headers=default_headers) @logger.info("Updating the \"#{identifier}\" access key") put("#{@api_url}/access-keys/#{encode(identifier)}", body, headers) end |
#update_authentication(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the authentication settings
Example
update_authentication({
"authenticator" => "com.kineticdata.core.v1.authenticators.ProxyAuthenticator",
"authenticationJsp" => "/WEB-INF/app/login.jsp",
"properties" => {
"Authentication Strategy" => "Http Header",
"Header Name" => "X-Login",
"Guest Access Enabled" => "No"
}
})
55 56 57 58 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 55 def update_authentication(settings, headers=default_headers) @logger.info("Updating the authentication properties") put("#{@api_url}/config/auth", settings, headers) end |
#update_category(original_name, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a category
Example
update_category("Foo", { "name" => "Bar" })
125 126 127 128 |
# File 'lib/kinetic_sdk/task/lib/categories.rb', line 125 def update_category(original_name, body={}, headers=default_headers) @logger.info("Updating Category \"#{original_name}\"") put("#{@api_url}/categories/#{encode(original_name)}", body, headers) end |
#update_db(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the database configuration
This assumes the database has already been created on the dbms.
Example
update_db({
"hibernate.connection.driver_class" => "org.postgresql.Driver",
"hibernate.connection.url" => "jdbc:postgresql://192.168.0.1:5432",
"hibernate.connection.username" => "my-db-user",
"hibernate.connection.password" => "my-db-password",
"hibernate.dialect" => "com.kineticdata.task.adapters.dbms.KineticPostgreSQLDialect"
})
79 80 81 82 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 79 def update_db(settings, headers=default_headers) @logger.info("Updating the database properties") put("#{@api_url}/config/db", settings, headers) end |
#update_engine(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the engine settings
Example
update_engine({
"Max Threads" => "1",
"Sleep Delay" => "10",
"Trigger Query" => "'Selection Criterion'=null"
})
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 99 def update_engine(settings, headers=default_headers) @logger.info("Updating the engine properties") put("#{@api_url}/config/engine", settings, headers) # start the task engine? if !settings['Sleep Delay'].nil? && settings['Sleep Delay'].to_i > 0 @logger.info("Starting the engine") start_engine end end |
#update_handler(definition_id, body, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Modifies the properties and info values for a handler
82 83 84 85 |
# File 'lib/kinetic_sdk/task/lib/handlers.rb', line 82 def update_handler(definition_id, body, headers=default_headers) @logger.info("Updating handler #{definition_id}") put("#{@api_url}/handlers/#{definition_id}", body, headers) end |
#update_identity_store(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the identity store settings
Example
update_identity_store({
"Identity Store" => "com.kineticdata.authentication.kineticcore.KineticCoreIdentityStore",
"properties" => {
"Kinetic Core Space Url" => "http://server:port/kinetic/space",
"Group Attribute Name" => "Group",
"Proxy Username" => "admin",
"Proxy Password" => "admin"
}
})
129 130 131 132 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 129 def update_identity_store(settings, headers=default_headers) @logger.info("Updating the identity store properties") put("#{@api_url}/config/identityStore", settings, headers) end |
#update_license(license_content, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the license
28 29 30 31 32 |
# File 'lib/kinetic_sdk/task/lib/license.rb', line 28 def update_license(license_content, headers=default_headers) body = { "licenseContent" => license_content } @logger.info("Updating license") post("#{@api_url}/config/license", body, headers) end |
#update_policy_rule(policy_rule, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Policy Rule
Exammple
update_policy_rule(
{ "type" => "API Access", "name" => "Allow All" },
{ "rule" => "false" }
)
179 180 181 182 183 184 185 186 |
# File 'lib/kinetic_sdk/task/lib/policy_rules.rb', line 179 def update_policy_rule(policy_rule, body={}, headers=default_headers) @logger.info("Updating the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule") payload = body payload["consolePolicyRules"] = consoleNames(payload) if payload.has_key?("consolePolicyRules") @logger.info("UPDATE: #{payload}") put("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", payload, headers) end |
#update_properties(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the web server and default configuration user settings
Example
update_properties({
"Configurator Username" => "my-admin-user",
"Configurator Password" => "my-admin-pass",
"Log Level" => "DEBUG",
"Log Size (MB)" => "20"
})
Example
update_properties({
"Configurator Username" => "my-admin-user",
"Configurator Password" => "my-admin-pass"
})
157 158 159 160 161 162 163 164 165 166 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 157 def update_properties(settings, headers=default_headers) @logger.info("Updating the web server properties") put("#{@api_url}/config/server", settings, headers) # reset the configuration user @config_user = { username: settings["Configurator Username"], password: settings["Configurator Password"] } end |
#update_session_configuration(settings, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the session configuration settings
Example
update_session_configuration({
"timeout" => "30"
})
181 182 183 184 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 181 def update_session_configuration(settings, headers=default_headers) @logger.info("Updating the session configuration settings") put("#{@api_url}/config/session", settings, headers) end |
#update_source(source, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a source
Exammple
update_source(
{ "name" => "Kinetic Request CE" },
{
"name": "Possible New Source Name",
"status": "Active|Unconfigured",
"type": "Adhoc|...",
"properties": {},
"policyRules": [
{ "type": "API Access", "name": "Super User" },
{ "type": "API Access", "name": "Info User" },
{ "type": "Console Access", "name": "Super User" }
]
}
)
134 135 136 137 |
# File 'lib/kinetic_sdk/task/lib/sources.rb', line 134 def update_source(source, body={}, headers=default_headers) @logger.info("Updating the \"#{source['name']}\" Source") put("#{@api_url}/sources/#{encode(source['name'])}", body, headers) end |
#update_system_policy_rule(policy_rule_name, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update the system policy rule
Example
update_system_policy_rule("Allow All")
206 207 208 209 210 |
# File 'lib/kinetic_sdk/task/lib/config.rb', line 206 def update_system_policy_rule(policy_rule_name, headers=default_headers) @logger.info("Updating the system policy rule") payload = { "name" => policy_rule_name } put("#{@api_url}/config/systemPolicyRule", payload, headers) end |
#update_tree(title, body = {}, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a tree
346 347 348 349 |
# File 'lib/kinetic_sdk/task/lib/trees.rb', line 346 def update_tree(title, body={}, headers=default_headers) @logger.info("Updating the \"#{title}\" Tree") put("#{@api_url}/trees/#{encode(title)}", body, headers) end |
#update_user(login_id, user, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a user
Example
update_user({
"loginId" => "foo",
"password" => "bar",
"email" => "[email protected]"
})
69 70 71 72 |
# File 'lib/kinetic_sdk/task/lib/users.rb', line 69 def update_user(login_id, user, headers=default_headers) @logger.info("Updating user \"#{login_id}\"") put("#{@api_url}/users/#{encode(login_id)}", user, headers) end |
#wait_until_alive(url, headers = header_basic_auth) ⇒ Object
Waits until the web server is alive
19 20 21 22 23 24 25 |
# File 'lib/kinetic_sdk/task/lib/health.rb', line 19 def wait_until_alive(url, headers=header_basic_auth) url = url[1..-1] if url.start_with?("/") while !is_alive?("#{@api_url}/#{url}", headers) do @logger.info("Web server \"#{@api_url}/#{url}\" is not ready, waiting...") sleep 3 end end |