Class: KineticSdk::Task

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

Parameters:

  • opts (Hash)

    Kinetic Task properties

Options Hash (opts):

  • :config_file (String)

    optional - path to the YAML configuration file

    • Ex: /opt/config/task-configuration1.yaml
  • :app_server_url (String)

    the URL to the Kinetic Task web application.

  • :username (String)

    the username for the user

  • :password (String)

    the password for the user

  • :options (Hash<Symbol, Object>) — default: {}

    optional settings

    • :export_directory (String) (example: /opt/exports/kinetic-task) directory to write files when exporting,
    • :gateway_retry_limit (FixNum) (defaults to: 5) max number of times to retry a bad gateway
    • :gateway_retry_delay (Float) (defaults to: 1.0) number of seconds to delay before retrying a bad gateway
    • :log_level (String) (defaults to: off) level of logging - off | error | warn | info | debug
    • :log_output (String) (defaults to: STDOUT) where to send output - STDOUT | STDERR
    • :max_redirects (Fixnum) (defaults to: 5) maximum number of redirects to follow
    • :ssl_ca_file (String) full path to PEM certificate used to verify the server
    • :ssl_verify_mode (String) (defaults to: none) - none | peer


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
  options = {}
  @config_user = {}
  @server = nil

  # process the configuration file if it was provided
  unless opts[:config_file].nil?
    options.merge!(YAML::load_file opts[:config_file])
  end

  # process the configuration hash if it was provided
  options.merge!(opts)

  # process any individual options
  @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] = options[:username]
  @config_user[:password] = options[:password]
  @server = options[: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_urlObject (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_urlObject (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_userObject (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

#loggerObject (readonly)

Returns the value of attribute logger.



16
17
18
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16

def logger
  @logger
end

#optionsObject (readonly)

Returns the value of attribute options.



16
17
18
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16

def options
  @options
end

#passwordObject (readonly)

Returns the value of attribute password.



16
17
18
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16

def password
  @password
end

#serverObject (readonly)

Returns the value of attribute server.



16
17
18
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16

def server
  @server
end

#usernameObject (readonly)

Returns the value of attribute username.



16
17
18
# File 'lib/kinetic_sdk/task/task-sdk.rb', line 16

def username
  @username
end

#versionObject (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()

Parameters:

  • access_key (Hash) (defaults to: {})

    properties for the access key

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • category (Hash)

    Category properties

    • +name+ - name of the category
    • +handlers+ - array of handler definitionIds associated to the category
    • +policyRules+ - array of policy rule names associated to the category
    • +trees+ - array of tree (routine) definitionIds associated to the category
  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • name (String)

    name of the group

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • handler_id (String)

    the handler id to add

  • category_name (String)

    name of the category to associate the handler

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" => "..."
})

Parameters:

  • policy (Hash)

    hash of properties for the new policy rule

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • policy_rule_type (String)

    the type of policy rule

  • policy_rule_name (String)

    the name of policy rule

  • category_name (String)

    name of the category to associate the policy rule

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • policy_rule_type (String)

    the type of policy rule

  • policy_rule_name (String)

    the name of the policy rule

  • source_name (String)

    name of the source to add the policy rule to

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • routine_id (String)

    the global routine id to add

  • category_name (String)

    name of the category to associate the global routine

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" => []
})

Parameters:

  • source (Hash)

    Source properties

    • +name+ - name of the source
    • +status+ - initial status of the source (Active | Inactive)
    • +type+ - name of one of the source consumers registered in the task engine
    • +properties+ - hash of properties specific to the source consumer
    • +policyRules+ - array of policy rules to associate with the source
  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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]"
})

Parameters:

  • user (Hash)

    user properties

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • login_id (String)

    login id of the user

  • group_name (String)

    name of the group

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



107
108
109
110
111
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 107

def add_user_to_group(, group_name, headers=default_headers)
  body = { "loginId" =>  }
  @logger.info("Adding user \"#{}\" 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

Parameters:

  • source_name (String)
    • name of the source
  • body (Hash)

    properties that are sent to update the task

    • +token+ - the token linked to the deferred task
  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • identifier (String)

    access key identifier

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • name (String)

    Category name

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • id (Integer)

    id of the error

  • headers (Hash) (defaults to: header_basic_auth)

    headers to send with the request, default is basic authentication

Returns:

Since:

  • Task v4.3.0



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

Parameters:

  • name (String)

    name of the group

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • definition_id (String)

    the handler definition id

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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"
})

Parameters:

  • policy (Hash)

    hash of policy type and name

    • +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
    • +name+ - Policy Rule name
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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)

Parameters:

  • id

    the id of the run to delete

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • name (String)

    name of the source

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • id (Integer)

    id of the system error

  • headers (Hash) (defaults to: header_basic_auth)

    headers to send with the request, default is basic authentication

Returns:



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"
})

Parameters:

  • tree (String|Hash)

    either the tree title, or a hash consisting of component names

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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")

Parameters:

  • source_name (String) (defaults to: nil)

    the name of the source, or nil to delete all trees

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • login_id (String)

    login id of the user

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



28
29
30
31
# File 'lib/kinetic_sdk/task/lib/users.rb', line 28

def delete_user(, headers=header_basic_auth)
  @logger.info("Deleting User \"#{}\"")
  delete("#{@api_url}/users/#{encode()}", headers)
end

#delete_users(headers = header_basic_auth) ⇒ KineticSdk::Utils::KineticHttpResponse

Delete all Users

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

  • export_opts (Hash) (defaults to: {})

    hash of export options

    • :include_workflows => true|false (default: false)

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • category (String|Hash)

    Category name, or hash of category properties

    • +name+ - name of the category
    • +handlers+ - array of handler definitionIds associated to the category
    • +policyRules+ - array of policy rule names associated to the category
    • +trees+ - array of tree (routine) definitionIds associated to the category
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • group (String)

    name of the group

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • definition_id (String)

    the definition id of the handler

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • policy_rule (Hash)

    Policy Rule properties that must contain at least the name and type

    • +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
    • +name+ - Policy Rule name to export
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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.

Parameters:

  • title (String)

    the title of the tree or routine

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

  • export_opts (Hash) (defaults to: {})

    hash of export options

    • :include_workflows => true|false (default: false)

Returns:

  • nil



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.

Parameters:

  • source_name (String) (defaults to: nil)

    Name of the source to export trees and local routines

    • Leave blank or pass nil to export all trees and global routines
    • Pass "-" to export only global routines
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

  • export_opts (Hash) (defaults to: {})

    hash of export options

    • :include_workflows => true|false (default: false)

Returns:

  • nil



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

Parameters:

  • identifier (String)

    access key identifier

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • handler_id (String)

    handler identifier

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • source_name (String)

    Source name

  • group (String)

    Source group

  • tree_name (String)

    Tree name

  • node_id (String)

    Node id in the tree

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • source_name (String)

    Source name

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • source_name (String)

    Source name

  • group (String)

    Source group

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • source_name (String)

    Source name

  • group (String)

    Source group

  • tree_name (String)

    Tree name

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • name (String)

    name of the category

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • id (Integer)

    id of the error

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL

    • +timeline+ - either "createdAt" or "updatedAt". Default: createdAt
    • +direction+ - DESC or ASC (default: DESC)
    • +start+ - 2017-07-27 or 2017-07-27T15:00:00.000Z
    • +end+ - 2017-07-27 or 2017-07-27T15:00:00.000Z
    • +source+ - name of the source
    • +sourceId+ - only if source is provided
    • +group+ - only if source is provided
    • +tree+ - only if source and group are provided
    • +nodeId+ - only if source, group, and tree are provided
    • +handlerId+
    • +runId+
    • +type+
    • +status+
    • +relatedItem1Id+
    • +relatedItem1Type+
    • +relatedItem2Id+
    • +relatedItem2Type+
    • +limit+
    • +offset+
    • +include+
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • run_id (Integer)

    Run id

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • name (String)

    name of the group

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • definition_id (String)

    the definition id of the handler

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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"})

Parameters:

  • policy_rule (Hash)

    Policy Rule properties that must contain at least the name and type

    • +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
    • +name+ - Policy Rule name to export
  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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" })

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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" })

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • name (String)

    name of the source

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • id (Integer)

    id of the system error

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL

    • +timeline+ - either "createdAt" or "updatedAt". Default: createdAt
    • +direction+ - DESC or ASC (default: DESC)
    • +start+ - 2017-07-27 or 2017-07-27T15:00:00.000Z
    • +end+ - 2017-07-27 or 2017-07-27T15:00:00.000Z
    • +type+
    • +status+
    • +relatedItem1Id+
    • +relatedItem1Type+
    • +relatedItem2Id+
    • +relatedItem2Type+
    • +limit+
    • +offset+
    • +include+
  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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" }
)

Parameters:

  • title (String)

    The tree title

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • tree_id (UUID)

    the tree UUID

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" })

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • params (Hash) (defaults to: {})

    Query parameters that are added to the URL, such as +include+

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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.

Parameters:

  • handler (File)

    handler zip package file

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite a handler if it exists, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite handlers if they exist, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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

Parameters:

  • license (String|File)

    Either the license file path (String), or the license file (File)

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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.

Parameters:

  • routine (String)

    content from routine file

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite a routine if it exists, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite routines if they exist, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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.

Parameters:

  • tree (String)

    content from tree file

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite a tree if it exists, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:



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.

Parameters:

  • force_overwrite (Boolean) (defaults to: false)

    whether to overwrite a tree if it exists, default is false

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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

Parameters:

  • url (String)

    the url to query for a 200 response code

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • (Boolean)

    true if server responded with OK (status 200)



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"
  }
}

Parameters:

  • db (Hash) (defaults to: {})

    Database configuration seettings to send as the request body

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • handler_id (String)

    the handler id to remove

  • category_name (String)

    name of the category to remove the handler from

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • policy_rule_type (String)

    the type of policy rule

  • policy_rule_name (String)

    the name of policy rule

  • category_name (String)

    name of the category to remove the policy rule from

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • policy_rule_type (String)

    the type of policy rule

  • policy_rule_name (String)

    the name of the policy rule

  • source_name (String)

    name of the source to add the policy rule to

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • routine_id (String)

    the global routine id to remove

  • category_name (String)

    name of the category to remove the global routine from

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • login_id (String)

    login id of the user

  • group_name (String)

    name of the group

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



119
120
121
122
# File 'lib/kinetic_sdk/task/lib/groups.rb', line 119

def remove_user_from_group(, group_name, headers=default_headers)
  @logger.info("Removing user \"#{}\" from group \"#{group_name}\"")
  post("#{@api_url}/groups/#{encode(group_name)}/users/#{encode()}", headers)
end

#resolve_errors(ids, action, resolution, headers = default_headers) ⇒ KineticSdk::Utils::KineticHttpResponse

Resolve multiple errors with the same action and resolution notes.

Parameters:

  • ids (Array<Integer>)

    Array of error ids to resolve

  • action (String)

    type of action to perform

    • +Cancel Branch+ - resolve the error and cancel the branch (connector error)
    • +Continue Branch+ - resolve the error and continue the branch (connector error)
    • +Do Nothing+ - resolve the error and do nothing more
    • +Retry+ - resolve the error and retry the connector that caused the error (connector error)
    • +Retry Task+ - resolve the error and retry the task that caused the error (node error)
    • +Skip Task+ - resolve the error and continue after the task that caused the error (node error)
  • resolution (String)

    resolution notes

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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.

Parameters:

  • ids (Array<Integer>)

    Array of system error ids to resolve

  • resolution (String)

    resolution notes

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • title (String)

    title of the tree: Source Name, Group Name, Tree Name

  • body (Hash) (defaults to: {})

    properties to pass to the tree, what can be used/accepted depends on the source.

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • headers (Hash) (defaults to: {})

    hash of headers to send, default is none

Returns:



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
  }
}

Parameters:

  • db (Hash) (defaults to: {})

    Database configuration seettings to send as the request body

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
})

Parameters:

  • identifier (String)

    access key identifier

  • body (Hash) (defaults to: {})

    properties to update, all optional

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
  }
})

Parameters:

  • settings (Hash)

    Settings for the authenticator

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" })

Parameters:

  • original_name (String)

    name of the category before updating

  • body (Hash) (defaults to: {})

    the updated property values

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
})

Parameters:

  • settings (Hash)

    Setting sfor the selected type of dbms

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
})

Parameters:

  • settings (Hash)

    Settings for the selected type of dbms

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • definition_id (String)

    the definition id of the handler

  • body (Hash)

    the properties to update

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
  }
})

Parameters:

  • settings (Hash)

    Settings for the identity store

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • license_content (String)

    the content of the license file

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" }
)

Parameters:

  • policy_rule (Hash)

    Policy Rule properties that must contain the name and type

    • +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
    • +name+ - Policy Rule name to export
  • body (Hash) (defaults to: {})

    Policy rule properties to update

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
})

Parameters:

  • settings (Hash)

    Settings for the web server and configurator user

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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"
})

Parameters:

  • settings (Hash)

    Settings for the session configuration

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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" }
    ]
  }
)

Parameters:

  • source (Hash)

    hash of existing source properties that must contain 'name'

    • +name+ - name of the source
  • body (Hash) (defaults to: {})
    • source properties to update
  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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")

Parameters:

  • policy_rule_name (String)

    name of the policy rule to use

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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

Parameters:

  • title (String)

    title of the tree: Source Name, Group Name, Tree Name

  • body (Hash) (defaults to: {})

    properties to pass to the tree

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



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]"
})

Parameters:

  • login_id (String)

    Login Id for the user

  • user (Hash)

    updated properties of the user

  • headers (Hash) (defaults to: default_headers)

    hash of headers to send, default is basic authentication and accept JSON content type

Returns:



69
70
71
72
# File 'lib/kinetic_sdk/task/lib/users.rb', line 69

def update_user(, user, headers=default_headers)
  @logger.info("Updating user \"#{}\"")
  put("#{@api_url}/users/#{encode()}", user, headers)
end

#wait_until_alive(url, headers = header_basic_auth) ⇒ Object

Waits until the web server is alive

Parameters:

  • url (String)

    the url to query for a 200 response code

  • headers (Hash) (defaults to: header_basic_auth)

    hash of headers to send, default is basic authentication

Returns:

  • nil



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