kinetic_sdk 0.1.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +5 -5
  2. data/.yardoc-includes/yard-helpers.rb +14 -0
  3. data/.yardopts +7 -0
  4. data/CHANGELOG.md +41 -0
  5. data/GettingStarted.md +6 -12
  6. data/README.md +85 -37
  7. data/Rakefile +13 -0
  8. data/kinetic_sdk.gemspec +33 -0
  9. data/lib/kinetic_sdk/agent/agent-sdk.rb +90 -0
  10. data/lib/kinetic_sdk/agent/lib/bridges.rb +92 -0
  11. data/lib/kinetic_sdk/agent/lib/filestores.rb +91 -0
  12. data/lib/kinetic_sdk/agent/lib/handler.rb +91 -0
  13. data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +11 -3
  14. data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +5 -5
  15. data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +5 -5
  16. data/lib/kinetic_sdk/{request_ce/request-ce-sdk.rb → core/core-sdk.rb} +30 -16
  17. data/lib/kinetic_sdk/core/lib/attribute_definitions.rb +500 -0
  18. data/lib/kinetic_sdk/core/lib/bridges.rb +141 -0
  19. data/lib/kinetic_sdk/{request_ce → core}/lib/categories.rb +3 -3
  20. data/lib/kinetic_sdk/{request_ce → core}/lib/datastore_form.rb +8 -8
  21. data/lib/kinetic_sdk/{request_ce → core}/lib/datastore_submissions.rb +20 -9
  22. data/lib/kinetic_sdk/{request_ce → core}/lib/form.rb +7 -7
  23. data/lib/kinetic_sdk/{request_ce → core}/lib/form_types.rb +4 -4
  24. data/lib/kinetic_sdk/{request_ce → core}/lib/jwt.rb +4 -4
  25. data/lib/kinetic_sdk/{request_ce → core}/lib/kapp.rb +7 -7
  26. data/lib/kinetic_sdk/{request_ce → core}/lib/meta.rb +3 -3
  27. data/lib/kinetic_sdk/{request_ce → core}/lib/oauth.rb +4 -4
  28. data/lib/kinetic_sdk/{request_ce → core}/lib/security_policy_definitions.rb +11 -11
  29. data/lib/kinetic_sdk/core/lib/space.rb +156 -0
  30. data/lib/kinetic_sdk/{request_ce → core}/lib/submissions.rb +11 -11
  31. data/lib/kinetic_sdk/{request_ce → core}/lib/system_api.rb +19 -7
  32. data/lib/kinetic_sdk/{request_ce → core}/lib/teams.rb +9 -9
  33. data/lib/kinetic_sdk/{request_ce → core}/lib/users.rb +15 -15
  34. data/lib/kinetic_sdk/{request_ce → core}/lib/webhook_jobs.rb +5 -5
  35. data/lib/kinetic_sdk/{request_ce → core}/lib/webhooks.rb +9 -9
  36. data/lib/kinetic_sdk/discussions/discussions-sdk.rb +12 -4
  37. data/lib/kinetic_sdk/discussions/lib/discussions.rb +8 -8
  38. data/lib/kinetic_sdk/discussions/lib/invitations.rb +9 -9
  39. data/lib/kinetic_sdk/discussions/lib/messages.rb +8 -8
  40. data/lib/kinetic_sdk/discussions/lib/meta.rb +1 -1
  41. data/lib/kinetic_sdk/discussions/lib/participants.rb +5 -5
  42. data/lib/kinetic_sdk/discussions/lib/related_items.rb +4 -4
  43. data/lib/kinetic_sdk/discussions/lib/websockets.rb +9 -9
  44. data/lib/kinetic_sdk/filehub/filehub-sdk.rb +11 -3
  45. data/lib/kinetic_sdk/filehub/lib/access_keys.rb +5 -5
  46. data/lib/kinetic_sdk/filehub/lib/filestores.rb +5 -5
  47. data/lib/kinetic_sdk/task/lib/access_keys.rb +35 -7
  48. data/lib/kinetic_sdk/task/lib/categories.rb +30 -17
  49. data/lib/kinetic_sdk/task/lib/config.rb +14 -14
  50. data/lib/kinetic_sdk/task/lib/engine.rb +1 -1
  51. data/lib/kinetic_sdk/task/lib/errors.rb +10 -10
  52. data/lib/kinetic_sdk/task/lib/export.rb +32 -0
  53. data/lib/kinetic_sdk/task/lib/groups.rb +23 -10
  54. data/lib/kinetic_sdk/task/lib/handlers.rb +27 -11
  55. data/lib/kinetic_sdk/task/lib/health.rb +11 -3
  56. data/lib/kinetic_sdk/task/lib/license.rb +4 -4
  57. data/lib/kinetic_sdk/task/lib/policy_rules.rb +25 -12
  58. data/lib/kinetic_sdk/task/lib/runs.rb +43 -0
  59. data/lib/kinetic_sdk/task/lib/setup.rb +2 -2
  60. data/lib/kinetic_sdk/task/lib/sources.rb +39 -8
  61. data/lib/kinetic_sdk/task/lib/tasks.rb +1 -1
  62. data/lib/kinetic_sdk/task/lib/trees.rb +84 -28
  63. data/lib/kinetic_sdk/task/lib/users.rb +6 -6
  64. data/lib/kinetic_sdk/task/task-sdk.rb +16 -4
  65. data/lib/kinetic_sdk/utils/kinetic-export-utils.rb +157 -0
  66. data/lib/kinetic_sdk/utils/kinetic-http.rb +388 -98
  67. data/lib/kinetic_sdk/utils/logger.rb +82 -46
  68. data/lib/kinetic_sdk/utils/prettier-xml-formatter.rb +60 -0
  69. data/lib/kinetic_sdk/version.rb +1 -1
  70. data/lib/kinetic_sdk.rb +5 -2
  71. metadata +41 -27
  72. data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +0 -153
  73. data/lib/kinetic_sdk/request_ce/lib/bridges.rb +0 -66
  74. data/lib/kinetic_sdk/request_ce/lib/space.rb +0 -89
@@ -7,7 +7,7 @@ module KineticSdk
7
7
  # @param headers [Hash] hash of headers to send, default is basic authentication
8
8
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
9
  def find_db(params={}, headers=header_basic_auth)
10
- info("Finding the database configuration")
10
+ @logger.info("Finding the database configuration")
11
11
  get("#{@api_url}/config/db", params, headers)
12
12
  end
13
13
 
@@ -18,7 +18,7 @@ module KineticSdk
18
18
  # @param headers [Hash] hash of headers to send, default is basic authentication
19
19
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
20
20
  def find_session_configuration(params={}, headers=header_basic_auth)
21
- info("Finding the session timeout")
21
+ @logger.info("Finding the session timeout")
22
22
  get("#{@api_url}/config/session", params, headers)
23
23
  end
24
24
 
@@ -35,14 +35,14 @@ module KineticSdk
35
35
  # "authenticator" => "com.kineticdata.core.v1.authenticators.ProxyAuthenticator",
36
36
  # "authenticationJsp" => "/WEB-INF/app/login.jsp",
37
37
  # "properties" => {
38
- # "Authenticator[Authentication Strategy]" => "Http Header",
39
- # "Authenticator[Header Name]" => "X-Login",
40
- # "Authenticator[Guest Access Enabled]" => "No"
38
+ # "Authentication Strategy" => "Http Header",
39
+ # "Header Name" => "X-Login",
40
+ # "Guest Access Enabled" => "No"
41
41
  # }
42
42
  # })
43
43
  #
44
44
  def update_authentication(settings, headers=default_headers)
45
- info("Updating the authentication properties")
45
+ @logger.info("Updating the authentication properties")
46
46
  put("#{@api_url}/config/auth", settings, headers)
47
47
  end
48
48
 
@@ -66,7 +66,7 @@ module KineticSdk
66
66
  # })
67
67
  #
68
68
  def update_db(settings, headers=default_headers)
69
- info("Updating the database properties")
69
+ @logger.info("Updating the database properties")
70
70
  put("#{@api_url}/config/db", settings, headers)
71
71
  end
72
72
 
@@ -86,12 +86,12 @@ module KineticSdk
86
86
  # })
87
87
  #
88
88
  def update_engine(settings, headers=default_headers)
89
- info("Updating the engine properties")
89
+ @logger.info("Updating the engine properties")
90
90
  put("#{@api_url}/config/engine", settings, headers)
91
91
 
92
92
  # start the task engine?
93
93
  if !settings['Sleep Delay'].nil? && settings['Sleep Delay'].to_i > 0
94
- info("Starting the engine")
94
+ @logger.info("Starting the engine")
95
95
  start_engine
96
96
  end
97
97
  end
@@ -116,7 +116,7 @@ module KineticSdk
116
116
  # })
117
117
  #
118
118
  def update_identity_store(settings, headers=default_headers)
119
- info("Updating the identity store properties")
119
+ @logger.info("Updating the identity store properties")
120
120
  put("#{@api_url}/config/identityStore", settings, headers)
121
121
  end
122
122
 
@@ -144,7 +144,7 @@ module KineticSdk
144
144
  # })
145
145
  #
146
146
  def update_properties(settings, headers=default_headers)
147
- info("Updating the web server properties")
147
+ @logger.info("Updating the web server properties")
148
148
  put("#{@api_url}/config/server", settings, headers)
149
149
 
150
150
  # reset the configuration user
@@ -168,7 +168,7 @@ module KineticSdk
168
168
  # })
169
169
  #
170
170
  def update_session_configuration(settings, headers=default_headers)
171
- info("Updating the session configuration settings")
171
+ @logger.info("Updating the session configuration settings")
172
172
  put("#{@api_url}/config/session", settings, headers)
173
173
  end
174
174
 
@@ -178,7 +178,7 @@ module KineticSdk
178
178
  # @param headers [Hash] hash of headers to send, default is basic authentication
179
179
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
180
180
  def find_system_policy_rule(params={}, headers=header_basic_auth)
181
- info("Finding the system policy rule")
181
+ @logger.info("Finding the system policy rule")
182
182
  get("#{@api_url}/config/systemPolicyRule", params, headers)
183
183
  end
184
184
 
@@ -193,7 +193,7 @@ module KineticSdk
193
193
  # update_system_policy_rule("Allow All")
194
194
  #
195
195
  def update_system_policy_rule(policy_rule_name, headers=default_headers)
196
- info("Updating the system policy rule")
196
+ @logger.info("Updating the system policy rule")
197
197
  payload = { "name" => policy_rule_name }
198
198
  put("#{@api_url}/config/systemPolicyRule", payload, headers)
199
199
  end
@@ -33,7 +33,7 @@ module KineticSdk
33
33
  # @param headers [Hash] hash of headers to send, default is basic authentication
34
34
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
35
35
  def engine_status(headers=header_basic_auth)
36
- response = engine_info({}, headers)
36
+ response = engine_@logger.info({}, headers)
37
37
  data = response.content
38
38
  data.nil? ? "Unknown" : data['status']
39
39
  end
@@ -8,7 +8,7 @@ module KineticSdk
8
8
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
9
  # @since Task v4.3.0
10
10
  def delete_error(id, headers=header_basic_auth)
11
- info("Deleting Error \"#{id}\"")
11
+ @logger.info("Deleting Error \"#{id}\"")
12
12
  delete("#{@api_url}/errors/#{id}", headers)
13
13
  end
14
14
 
@@ -26,7 +26,7 @@ module KineticSdk
26
26
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
27
27
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
28
28
  def resolve_errors(ids, action, resolution, headers=default_headers)
29
- info("Resolving errors #{ids}")
29
+ @logger.info("Resolving errors #{ids}")
30
30
  body = { "ids" => ids, "action" => action, "resolution" => resolution }
31
31
  post("#{@api_url}/errors/resolve", body, headers)
32
32
  end
@@ -57,7 +57,7 @@ module KineticSdk
57
57
  # @param headers [Hash] hash of headers to send, default is basic authentication
58
58
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
59
59
  def find_errors(params={}, headers=header_basic_auth)
60
- info("Finding errors")
60
+ @logger.info("Finding errors")
61
61
  get("#{@api_url}/errors", params, headers)
62
62
  end
63
63
 
@@ -68,7 +68,7 @@ module KineticSdk
68
68
  # @param headers [Hash] hash of headers to send, default is basic authentication
69
69
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
70
70
  def find_error(id, params={}, headers=header_basic_auth)
71
- info("Finding error #{id}")
71
+ @logger.info("Finding error #{id}")
72
72
  get("#{@api_url}/errors/#{id}", params, headers)
73
73
  end
74
74
 
@@ -79,7 +79,7 @@ module KineticSdk
79
79
  # @param headers [Hash] hash of headers to send, default is basic authentication
80
80
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
81
81
  def find_active_errors_by_handler(handler_id, params={}, headers=header_basic_auth)
82
- info("Finding active errors for handler #{handler_id}")
82
+ @logger.info("Finding active errors for handler #{handler_id}")
83
83
  params['handlerId'] = handler_id
84
84
  params['status'] = 'Active'
85
85
  find_errors(params, headers)
@@ -92,7 +92,7 @@ module KineticSdk
92
92
  # @param headers [Hash] hash of headers to send, default is basic authentication
93
93
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
94
94
  def find_active_errors_by_source(source_name, params={}, headers=header_basic_auth)
95
- info("Finding active errors for source \"#{source_name}\"")
95
+ @logger.info("Finding active errors for source \"#{source_name}\"")
96
96
  params['source'] = source_name
97
97
  params['status'] = 'Active'
98
98
  find_errors(params, headers)
@@ -106,7 +106,7 @@ module KineticSdk
106
106
  # @param headers [Hash] hash of headers to send, default is basic authentication
107
107
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
108
108
  def find_active_errors_by_source_group(source_name, group, params={}, headers=header_basic_auth)
109
- info("Finding active errors for source group \"#{source_name} :: #{group}\"")
109
+ @logger.info("Finding active errors for source group \"#{source_name} :: #{group}\"")
110
110
  params['group'] = group
111
111
  params['source'] = source_name
112
112
  params['status'] = 'Active'
@@ -122,7 +122,7 @@ module KineticSdk
122
122
  # @param headers [Hash] hash of headers to send, default is basic authentication
123
123
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
124
124
  def find_active_errors_by_tree(source_name, group, tree_name, params={}, headers=header_basic_auth)
125
- info("Finding active errors for tree \"#{source_name} :: #{group} :: #{tree_name}\"")
125
+ @logger.info("Finding active errors for tree \"#{source_name} :: #{group} :: #{tree_name}\"")
126
126
  params['tree'] = tree_name
127
127
  params['group'] = group
128
128
  params['source'] = source_name
@@ -140,7 +140,7 @@ module KineticSdk
140
140
  # @param headers [Hash] hash of headers to send, default is basic authentication
141
141
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
142
142
  def find_active_errors_by_node(source_name, group, tree_name, node_id, params={}, headers=header_basic_auth)
143
- info("Finding active errors for node \"#{source_name} :: #{group} :: #{tree_name} :: #{node_id}\"")
143
+ @logger.info("Finding active errors for node \"#{source_name} :: #{group} :: #{tree_name} :: #{node_id}\"")
144
144
  params['nodeId'] = node_id
145
145
  params['tree'] = tree_name
146
146
  params['group'] = group
@@ -156,7 +156,7 @@ module KineticSdk
156
156
  # @param headers [Hash] hash of headers to send, default is basic authentication
157
157
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
158
158
  def find_errors_by_run(run_id, params={}, headers=header_basic_auth)
159
- info("Finding active errors for run #{run_id}")
159
+ @logger.info("Finding active errors for run #{run_id}")
160
160
  params['runId'] = run_id
161
161
  find_errors(params, headers)
162
162
  end
@@ -0,0 +1,32 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Export all structure definitions to :source-slug.json file in
5
+ # `export_directory/sources`.
6
+ #
7
+ # Exports the following items:
8
+ #
9
+ # * sources
10
+ # * trees
11
+ # * routines
12
+ # * handlers
13
+ # * groups
14
+ # * policy rules
15
+ # * categories
16
+ # * access keys
17
+ #
18
+ # @param headers [Hash] hash of headers to send, default is basic authentication
19
+ # @return nil
20
+ def export(headers=header_basic_auth)
21
+ export_sources(headers)
22
+ export_trees(nil,headers) # Includes routines when nil passed
23
+ export_handlers(headers)
24
+ export_groups(headers)
25
+ export_policy_rules(headers)
26
+ export_categories(headers)
27
+ export_access_keys(headers)
28
+ end
29
+
30
+
31
+ end
32
+ end
@@ -7,7 +7,7 @@ module KineticSdk
7
7
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
8
8
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
9
  def add_group(name, headers=default_headers)
10
- info("Adding group \"#{name}\"")
10
+ @logger.info("Adding group \"#{name}\"")
11
11
  post("#{@api_url}/groups", { "name" => name }, headers)
12
12
  end
13
13
 
@@ -17,7 +17,7 @@ module KineticSdk
17
17
  # @param headers [Hash] hash of headers to send, default is basic authentication
18
18
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
19
19
  def delete_group(name, headers=header_basic_auth)
20
- info("Deleting Group \"#{name}\"")
20
+ @logger.info("Deleting Group \"#{name}\"")
21
21
  delete("#{@api_url}/groups/#{encode(name)}", headers)
22
22
  end
23
23
 
@@ -26,7 +26,7 @@ module KineticSdk
26
26
  # @param headers [Hash] hash of headers to send, default is basic authentication
27
27
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
28
28
  def delete_groups(headers=header_basic_auth)
29
- info("Deleting all groups")
29
+ @logger.info("Deleting all groups")
30
30
  (find_groups(headers).content['groups'] || []).each do |group|
31
31
  delete("#{@api_url}/groups/#{encode(group['name'])}", headers)
32
32
  end
@@ -43,20 +43,20 @@ module KineticSdk
43
43
  response = find_group(group, {}, headers)
44
44
  group = response.content
45
45
  end
46
- info("Exporting group \"#{group['name']}\" to #{@options[:export_directory]}.")
46
+ @logger.info("Exporting group \"#{group['name']}\" to #{@options[:export_directory]}.")
47
47
  # Create the groups directory if it doesn't yet exist
48
48
  group_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "groups"))
49
49
  group_file = File.join(group_dir, "#{group['name'].slugify}.json")
50
50
  # write the file
51
51
  responseObj = get("#{@api_url}/groups/#{encode(group['name'])}", {}, headers)
52
52
  File.write(group_file, JSON.pretty_generate(responseObj.content))
53
- info("Exported group: #{group['name']} to #{group_file}")
53
+ @logger.info("Exported group: #{group['name']} to #{group_file}")
54
54
  end
55
55
 
56
56
  # Export Groups
57
57
  #
58
58
  # @param headers [Hash] hash of headers to send, default is basic authentication
59
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
59
+ # @return nil
60
60
  def export_groups(headers=header_basic_auth)
61
61
  raise StandardError.new "An export directory must be defined to export groups." if @options[:export_directory].nil?
62
62
  (find_groups.content["groups"] || []).each do |group|
@@ -64,13 +64,26 @@ module KineticSdk
64
64
  end
65
65
  end
66
66
 
67
+ # Import Groups
68
+ #
69
+ # @param headers [Hash] hash of headers to send, default is basic authentication
70
+ # @return nil
71
+ def import_groups(headers=default_headers)
72
+ raise StandardError.new "An export directory must be defined to import groups from." if @options[:export_directory].nil?
73
+ @logger.info("Importing all Groups in Export Directory")
74
+ Dir["#{@options[:export_directory]}/groups/*.json"].sort.each do |file|
75
+ group = JSON.parse(File.read(file))
76
+ add_group(group["name"], headers)
77
+ end
78
+ end
79
+
67
80
  # Find all groups
68
81
  #
69
82
  # @param params [Hash] Query parameters that are added to the URL, such as +include+
70
83
  # @param headers [Hash] hash of headers to send, default is basic authentication
71
84
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
72
85
  def find_groups(params={}, headers=header_basic_auth)
73
- info("Finding all groups")
86
+ @logger.info("Finding all groups")
74
87
  get("#{@api_url}/groups", params, headers)
75
88
  end
76
89
 
@@ -81,7 +94,7 @@ module KineticSdk
81
94
  # @param headers [Hash] hash of headers to send, default is basic authentication
82
95
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
83
96
  def find_group(name, params={}, headers=header_basic_auth)
84
- info("Finding the #{name} group")
97
+ @logger.info("Finding the #{name} group")
85
98
  get("#{@api_url}/groups/#{encode(name)}", params, headers)
86
99
  end
87
100
 
@@ -93,7 +106,7 @@ module KineticSdk
93
106
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
94
107
  def add_user_to_group(login_id, group_name, headers=default_headers)
95
108
  body = { "loginId" => login_id }
96
- info("Adding user \"#{login_id}\" to group \"#{group_name}\"")
109
+ @logger.info("Adding user \"#{login_id}\" to group \"#{group_name}\"")
97
110
  post("#{@api_url}/groups/#{encode(group_name)}/users", body, headers)
98
111
  end
99
112
 
@@ -104,7 +117,7 @@ module KineticSdk
104
117
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
105
118
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
106
119
  def remove_user_from_group(login_id, group_name, headers=default_headers)
107
- info("Removing user \"#{login_id}\" from group \"#{group_name}\"")
120
+ @logger.info("Removing user \"#{login_id}\" from group \"#{group_name}\"")
108
121
  post("#{@api_url}/groups/#{encode(group_name)}/users/#{encode(login_id)}", headers)
109
122
  end
110
123
 
@@ -7,7 +7,7 @@ module KineticSdk
7
7
  # @param headers [Hash] hash of headers to send, default is basic authentication
8
8
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
9
  def delete_handler(definition_id, headers=header_basic_auth)
10
- info("Deleting Handler \"#{definition_id}\"")
10
+ @logger.info("Deleting Handler \"#{definition_id}\"")
11
11
  delete("#{@api_url}/handlers/#{definition_id}", headers)
12
12
  end
13
13
 
@@ -16,7 +16,7 @@ module KineticSdk
16
16
  # @param headers [Hash] hash of headers to send, default is basic authentication
17
17
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
18
18
  def delete_handlers(headers=header_basic_auth)
19
- info("Deleting all handlers")
19
+ @logger.info("Deleting all handlers")
20
20
  (find_handlers(headers).content['handlers'] || []).each do |handler|
21
21
  delete("#{@api_url}/handlers/#{handler['definition_id']}", headers)
22
22
  end
@@ -28,7 +28,7 @@ module KineticSdk
28
28
  # @param headers [Hash] hash of headers to send, default is basic authentication
29
29
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
30
30
  def find_handlers(params={}, headers=header_basic_auth)
31
- info("Find all handlers")
31
+ @logger.info("Find all handlers")
32
32
  get("#{@api_url}/handlers", params, headers)
33
33
  end
34
34
 
@@ -39,7 +39,7 @@ module KineticSdk
39
39
  # @param headers [Hash] hash of headers to send, default is basic authentication
40
40
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
41
41
  def find_handler(definition_id, params={}, headers=header_basic_auth)
42
- info("Finding handler \"#{definition_id}\"")
42
+ @logger.info("Finding handler \"#{definition_id}\"")
43
43
  get("#{@api_url}/handlers/#{definition_id}", params, headers)
44
44
  end
45
45
 
@@ -53,10 +53,26 @@ module KineticSdk
53
53
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
54
54
  def import_handler(handler, force_overwrite=false, headers=header_basic_auth)
55
55
  body = { "package" => handler }
56
- info("Importing Handler #{File.basename(handler)}")
56
+ @logger.info("Importing Handler #{File.basename(handler)}")
57
57
  post_multipart("#{@api_url}/handlers?force=#{force_overwrite}", body, headers)
58
58
  end
59
59
 
60
+ # Import handlers from export directory
61
+ #
62
+ # If the handlers already exists on the server, this will fail unless forced to overwrite.
63
+ #
64
+ # @param force_overwrite [Boolean] whether to overwrite handlers if they exist, default is false
65
+ # @param headers [Hash] hash of headers to send, default is basic authentication
66
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
67
+ def import_handlers(force_overwrite=false, headers=header_basic_auth)
68
+ raise StandardError.new "An export directory must be defined to import handlers from." if @options[:export_directory].nil?
69
+ @logger.info("Importing all Handlers from Export Directory")
70
+ Dir["#{@options[:export_directory]}/handlers/*.zip"].sort.each do |file|
71
+ handler_file = File.new(file, "rb")
72
+ import_handler(handler_file, force_overwrite, headers)
73
+ end
74
+ end
75
+
60
76
  # Modifies the properties and info values for a handler
61
77
  #
62
78
  # @param definition_id [String] the definition id of the handler
@@ -64,7 +80,7 @@ module KineticSdk
64
80
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
65
81
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
66
82
  def update_handler(definition_id, body, headers=default_headers)
67
- info("Updating handler #{definition_id}")
83
+ @logger.info("Updating handler #{definition_id}")
68
84
  put("#{@api_url}/handlers/#{definition_id}", body, headers)
69
85
  end
70
86
 
@@ -72,10 +88,10 @@ module KineticSdk
72
88
  #
73
89
  # @param definition_id [String] the definition id of the handler
74
90
  # @param headers [Hash] hash of headers to send, default is basic authentication
75
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
91
+ # @return nil
76
92
  def export_handler(definition_id, headers=header_basic_auth)
77
93
  raise StandardError.new "An export directory must be defined to export a handler." if @options[:export_directory].nil?
78
- info("Exporting handler \"#{definition_id}\" to #{@options[:export_directory]}.")
94
+ @logger.info("Exporting handler \"#{definition_id}\" to #{@options[:export_directory]}.")
79
95
  # Create the handler directory if it doesn't yet exist
80
96
  handler_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "handlers"))
81
97
  handler_file = File.join(handler_dir, "#{definition_id}.zip")
@@ -83,16 +99,16 @@ module KineticSdk
83
99
  File.open(handler_file, "wb") do |file|
84
100
  file.write get("#{@api_url}/handlers/#{definition_id}/zip", {}, headers).content_string
85
101
  end
86
- info("Exported handler: #{definition_id} to #{handler_file}")
102
+ @logger.info("Exported handler: #{definition_id} to #{handler_file}")
87
103
  end
88
104
 
89
105
  # Export all handlers
90
106
  #
91
107
  # @param headers [Hash] hash of headers to send, default is basic authentication
92
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
108
+ # @return nil
93
109
  def export_handlers(headers=header_basic_auth)
94
110
  raise StandardError.new "An export directory must be defined to export handlers." if @options[:export_directory].nil?
95
- info("Exporting handlers to #{@options[:export_directory]}.")
111
+ @logger.info("Exporting handlers to #{@options[:export_directory]}.")
96
112
  # Get the handler metadata to geta all handler_ids
97
113
  response = find_handlers(headers)
98
114
  # Parse the response and export each handler
@@ -5,7 +5,7 @@ module KineticSdk
5
5
  #
6
6
  # @param url [String] the url to query for a 200 response code
7
7
  # @param headers [Hash] hash of headers to send, default is basic authentication
8
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
8
+ # @return [Boolean] true if server responded with OK (status 200)
9
9
  def is_alive?(url, headers=header_basic_auth)
10
10
  response = get(url, {}, headers)
11
11
  response.status == 200
@@ -15,14 +15,22 @@ module KineticSdk
15
15
  #
16
16
  # @param url [String] the url to query for a 200 response code
17
17
  # @param headers [Hash] hash of headers to send, default is basic authentication
18
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
18
+ # @return nil
19
19
  def wait_until_alive(url, headers=header_basic_auth)
20
20
  url = url[1..-1] if url.start_with?("/")
21
21
  while !is_alive?("#{@api_url}/#{url}", headers) do
22
- info("Web server \"#{@api_url}/#{url}\" is not ready, waiting...")
22
+ @logger.info("Web server \"#{@api_url}/#{url}\" is not ready, waiting...")
23
23
  sleep 3
24
24
  end
25
25
  end
26
26
 
27
+ # Get the server info
28
+ #
29
+ # @param headers [Hash] hash of headers to send, default is none
30
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
31
+ def server_info(headers={})
32
+ get(@api_url, {}, headers)
33
+ end
34
+
27
35
  end
28
36
  end
@@ -6,7 +6,7 @@ module KineticSdk
6
6
  # @param headers [Hash] hash of headers to send, default is basic authentication
7
7
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
8
8
  def delete_license(headers=header_basic_auth)
9
- info("Deleting the license")
9
+ @logger.info("Deleting the license")
10
10
  delete("#{@api_url}/config/license", {}, headers)
11
11
  end
12
12
 
@@ -16,7 +16,7 @@ module KineticSdk
16
16
  # @param headers [Hash] hash of headers to send, default is basic authentication
17
17
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
18
18
  def find_license(params={}, headers=header_basic_auth)
19
- info("Finding the license")
19
+ @logger.info("Finding the license")
20
20
  get("#{@api_url}/config/license", params, headers)
21
21
  end
22
22
 
@@ -27,7 +27,7 @@ module KineticSdk
27
27
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
28
28
  def update_license(license_content, headers=default_headers)
29
29
  body = { "licenseContent" => license_content }
30
- info("Updating license")
30
+ @logger.info("Updating license")
31
31
  post("#{@api_url}/config/license", body, headers)
32
32
  end
33
33
 
@@ -43,7 +43,7 @@ module KineticSdk
43
43
  if File.exists? license
44
44
  update_license(File.read(license), headers)
45
45
  else
46
- info(" * License file \"#{license}\" does not exist.")
46
+ @logger.info(" * License file \"#{license}\" does not exist.")
47
47
  end
48
48
  end
49
49
  end
@@ -6,7 +6,7 @@ module KineticSdk
6
6
  # @param policy [Hash] hash of properties for the new policy rule
7
7
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
8
8
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
- #
9
+ #
10
10
  # Example
11
11
  #
12
12
  # add_policy_rule({
@@ -17,7 +17,7 @@ module KineticSdk
17
17
  # })
18
18
  #
19
19
  def add_policy_rule(policy, headers=default_headers)
20
- info("Adding policy rule \"#{policy['type']} - #{policy['name']}\"")
20
+ @logger.info("Adding policy rule \"#{policy['type']} - #{policy['name']}\"")
21
21
  post("#{@api_url}/policyRules/#{encode(policy['type'])}", policy, headers)
22
22
  end
23
23
 
@@ -37,7 +37,7 @@ module KineticSdk
37
37
  # })
38
38
  #
39
39
  def delete_policy_rule(policy, headers=header_basic_auth)
40
- info("Deleting policy rule \"#{policy['type']} - #{policy['name']}\"")
40
+ @logger.info("Deleting policy rule \"#{policy['type']} - #{policy['name']}\"")
41
41
  delete("#{@api_url}/policyRules/#{encode(policy['type'])}/#{encode(policy['name'])}", headers)
42
42
  end
43
43
 
@@ -46,7 +46,7 @@ module KineticSdk
46
46
  # @param headers [Hash] hash of headers to send, default is basic authentication
47
47
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
48
48
  def delete_policy_rules(headers=header_basic_auth)
49
- info("Deleting all policy rules")
49
+ @logger.info("Deleting all policy rules")
50
50
  (find_policy_rules(headers).content["policyRules"] || []).each do |policy_rule|
51
51
  delete_policy_rule({
52
52
  "type" => policy_rule['type'],
@@ -61,10 +61,10 @@ module KineticSdk
61
61
  # - +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
62
62
  # - +name+ - Policy Rule name to export
63
63
  # @param headers [Hash] hash of headers to send, default is basic authentication
64
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
64
+ # @return nil
65
65
  def export_policy_rule(policy_rule, headers=header_basic_auth)
66
66
  raise StandardError.new "An export directory must be defined to export a policy rule." if @options[:export_directory].nil?
67
- info("Exporting policy rule \"policy_rule['type']\" : \"#{policy_rule['name']}\" to #{@options[:export_directory]}.")
67
+ @logger.info("Exporting policy rule \"policy_rule['type']\" : \"#{policy_rule['name']}\" to #{@options[:export_directory]}.")
68
68
  # Create the policy rules directory if it doesn't yet exist
69
69
  dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "policyRules"))
70
70
  file = File.join(dir, "#{policy_rule['type'].slugify}-#{policy_rule['name'].slugify}.json")
@@ -76,7 +76,7 @@ module KineticSdk
76
76
  headers
77
77
  )
78
78
  if response.status != 200
79
- info("Failed to export policy rule: #{policy_rule['type']} - #{policy_rule['name']}: #{response.inspect}")
79
+ @logger.info("Failed to export policy rule: #{policy_rule['type']} - #{policy_rule['name']}: #{response.inspect}")
80
80
  policy_rule = nil
81
81
  else
82
82
  policy_rule = response.content
@@ -86,14 +86,14 @@ module KineticSdk
86
86
  unless policy_rule.nil?
87
87
  # write the file
88
88
  File.write(file, JSON.pretty_generate(policy_rule))
89
- info("Exported policy rule: #{policy_rule['type']} - #{policy_rule['name']} to #{file}")
89
+ @logger.info("Exported policy rule: #{policy_rule['type']} - #{policy_rule['name']} to #{file}")
90
90
  end
91
91
  end
92
92
 
93
93
  # Export Policy Rules
94
94
  #
95
95
  # @param headers [Hash] hash of headers to send, default is basic authentication
96
- # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
96
+ # @return nil
97
97
  def export_policy_rules(headers=header_basic_auth)
98
98
  raise StandardError.new "An export directory must be defined to export policy rules." if @options[:export_directory].nil?
99
99
  response = find_policy_rules({"include" => "consolePolicyRules"}, headers)
@@ -102,13 +102,26 @@ module KineticSdk
102
102
  end
103
103
  end
104
104
 
105
+ # Import Policy Rules
106
+ #
107
+ # @param headers [Hash] hash of headers to send, default is basic authentication
108
+ # @return nil
109
+ def import_policy_rules(headers=default_headers)
110
+ raise StandardError.new "An export directory must be defined to import policy rules from." if @options[:export_directory].nil?
111
+ @logger.info("Importing all Policy Rules in Export Directory")
112
+ Dir["#{@options[:export_directory]}/policyRules/*.json"].sort.each do |file|
113
+ policy_rule = JSON.parse(File.read(file))
114
+ add_policy_rule(policy_rule, headers)
115
+ end
116
+ end
117
+
105
118
  # Find Policy Rules.
106
119
  #
107
120
  # @param params [Hash] Query parameters that are added to the URL, such as +include+
108
121
  # @param headers [Hash] hash of headers to send, default is basic authentication
109
122
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
110
123
  def find_policy_rules(params={}, headers=header_basic_auth)
111
- info("Finding Policy Rules")
124
+ @logger.info("Finding Policy Rules")
112
125
  policy_rules = []
113
126
  response = nil
114
127
  ["API Access", "Category Access", "Console Access", "System Default"].each do |type|
@@ -136,7 +149,7 @@ module KineticSdk
136
149
  # find_policy_rule({ "type" => "API Access", "name" => "Allow All"})
137
150
  #
138
151
  def find_policy_rule(policy_rule, params={}, headers=header_basic_auth)
139
- info("Finding the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
152
+ @logger.info("Finding the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
140
153
  get("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", params, headers)
141
154
  end
142
155
 
@@ -158,7 +171,7 @@ module KineticSdk
158
171
  # )
159
172
  #
160
173
  def update_policy_rule(policy_rule, body={}, headers=default_headers)
161
- info("Updating the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
174
+ @logger.info("Updating the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
162
175
  put("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", body, headers)
163
176
  end
164
177