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
@@ -1,5 +1,5 @@
1
1
  module KineticSdk
2
- class RequestCe
2
+ class Core
3
3
 
4
4
  # Add a Submission
5
5
  #
@@ -25,7 +25,7 @@ module KineticSdk
25
25
  uri = URI.parse("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions")
26
26
  uri.query = URI.encode_www_form(parameters) unless parameters.empty?
27
27
  # Create the submission
28
- info("Adding a submission in the \"#{form_slug}\" Form.")
28
+ @logger.info("Adding a submission in the \"#{form_slug}\" Form.")
29
29
  post(uri.to_s, payload, headers)
30
30
  end
31
31
 
@@ -57,7 +57,7 @@ module KineticSdk
57
57
  uri = URI.parse("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions")
58
58
  uri.query = URI.encode_www_form(parameters)
59
59
  # Create the submission
60
- info("Adding a submission page in the \"#{form_slug}\" Form.")
60
+ @logger.info("Adding a submission page in the \"#{form_slug}\" Form.")
61
61
  post(uri.to_s, payload, headers)
62
62
  end
63
63
 
@@ -81,7 +81,7 @@ module KineticSdk
81
81
  # set parent hash if parent was passed as a string
82
82
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
83
83
  # Create the submission
84
- info("Patching a submission in the \"#{form_slug}\" Form.")
84
+ @logger.info("Patching a submission in the \"#{form_slug}\" Form.")
85
85
  patch("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions", payload, headers)
86
86
  end
87
87
 
@@ -104,7 +104,7 @@ module KineticSdk
104
104
  # set parent hash if parent was passed as a string
105
105
  payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
106
106
  # Create the submission
107
- info("Patching a submission with id \"#{submission_id}\"")
107
+ @logger.info("Patching a submission with id \"#{submission_id}\"")
108
108
  patch("#{@api_url}/submissions/#{submission_id}", payload, headers)
109
109
  end
110
110
 
@@ -122,7 +122,7 @@ module KineticSdk
122
122
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
123
123
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
124
124
  def find_all_form_submissions(kapp_slug, form_slug, params={}, headers=default_headers)
125
- info("Finding submissions for the \"#{form_slug}\" Form.")
125
+ @logger.info("Finding submissions for the \"#{form_slug}\" Form.")
126
126
  # Make the initial request of pages submissions
127
127
  response = find_form_submissions(kapp_slug, form_slug, params, headers)
128
128
  # Build the Messages Array
@@ -162,9 +162,9 @@ module KineticSdk
162
162
  # Get next page token
163
163
  token = params["pageToken"]
164
164
  if token.nil?
165
- info("Finding first page of submissions for the \"#{form_slug}\" Form.")
165
+ @logger.info("Finding first page of submissions for the \"#{form_slug}\" Form.")
166
166
  else
167
- info("Finding page of submissions starting with token \"#{token}\" for the \"#{form_slug}\" Form.")
167
+ @logger.info("Finding page of submissions starting with token \"#{token}\" for the \"#{form_slug}\" Form.")
168
168
  end
169
169
 
170
170
  # Build Submission URL
@@ -189,9 +189,9 @@ module KineticSdk
189
189
  # Get next page token
190
190
  token = params["pageToken"]
191
191
  if token.nil?
192
- info("Finding first page of submissions for the \"#{kapp_slug}\" Kapp.")
192
+ @logger.info("Finding first page of submissions for the \"#{kapp_slug}\" Kapp.")
193
193
  else
194
- info("Finding page of submissions starting with token \"#{token}\" for the \"#{kapp_slug}\" Kapp.")
194
+ @logger.info("Finding page of submissions starting with token \"#{token}\" for the \"#{kapp_slug}\" Kapp.")
195
195
  end
196
196
 
197
197
  # Build Submission URL
@@ -207,7 +207,7 @@ module KineticSdk
207
207
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
208
208
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
209
209
  def update_submission(submission_id, body={}, headers=default_headers)
210
- info("Updating Submission \"#{submission_id}\"")
210
+ @logger.info("Updating Submission \"#{submission_id}\"")
211
211
  put("#{@api_url}/submissions/#{encode(submission_id)}", body, headers)
212
212
  end
213
213
 
@@ -1,5 +1,5 @@
1
1
  module KineticSdk
2
- class RequestCe
2
+ class Core
3
3
 
4
4
  # Add a new Space
5
5
  #
@@ -9,7 +9,7 @@ module KineticSdk
9
9
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
10
10
  def add_space(name, slug, headers=default_headers)
11
11
  payload = { "name" => name, "slug" => slug }
12
- info("Creating Space \"#{name}\" with slug \"#{slug}\"")
12
+ @logger.info("Creating Space \"#{name}\" with slug \"#{slug}\"")
13
13
  post("#{@api_url}/spaces", payload, headers)
14
14
  end
15
15
 
@@ -20,7 +20,7 @@ module KineticSdk
20
20
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
21
21
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
22
22
  def delete_space(slug, headers=default_headers)
23
- info("Deleting Space \"#{slug}\"")
23
+ @logger.info("Deleting Space \"#{slug}\"")
24
24
  delete("#{@api_url}/spaces/#{slug}", headers)
25
25
  end
26
26
 
@@ -30,7 +30,7 @@ module KineticSdk
30
30
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
31
31
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
32
32
  def find_spaces(params={}, headers=default_headers)
33
- info("Finding Spaces")
33
+ @logger.info("Finding Spaces")
34
34
  get("#{@api_url}/spaces", params, headers)
35
35
  end
36
36
 
@@ -41,7 +41,7 @@ module KineticSdk
41
41
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
42
42
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
43
43
  def find_space_in_system(slug, params={}, headers=default_headers)
44
- info("Retrieving Space \"#{slug}\"")
44
+ @logger.info("Retrieving Space \"#{slug}\"")
45
45
  get("#{@api_url}/spaces/#{slug}", params, headers)
46
46
  end
47
47
 
@@ -52,7 +52,7 @@ module KineticSdk
52
52
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
53
53
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
54
54
  def update_space_in_system(slug, body, headers=default_headers)
55
- info("Updating Space \"#{slug}\"")
55
+ @logger.info("Updating Space \"#{slug}\"")
56
56
  put("#{@api_url}/spaces/#{slug}", body, headers)
57
57
  end
58
58
 
@@ -61,9 +61,21 @@ module KineticSdk
61
61
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
62
62
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
63
63
  def reset_license_count(headers=default_headers)
64
- info("Resetting License Count")
64
+ @logger.info("Resetting License Count")
65
65
  put("#{@api_url}/license/reset", {}, headers)
66
66
  end
67
67
 
68
+ # Find a user in a space (System API)
69
+ #
70
+ # @param space_slug [String] slug of the space
71
+ # @param username [String] the username to find
72
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
73
+ # @param headers [Hash] hash of headers to send, default is basic authentication and JSON content type
74
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
75
+ def find_user_in_system(space_slug, username, params={}, headers=default_headers)
76
+ @logger.info("Finding User #{username} in Space #{space_slug}")
77
+ get("#{@api_url}/spaces/#{space_slug}/users/#{encode(username)}", params, headers)
78
+ end
79
+
68
80
  end
69
81
  end
@@ -1,7 +1,7 @@
1
1
  require 'digest/md5'
2
2
 
3
3
  module KineticSdk
4
- class RequestCe
4
+ class Core
5
5
 
6
6
  # Add an attribute to a team
7
7
  #
@@ -18,7 +18,7 @@ module KineticSdk
18
18
  # either add or update the attribute value
19
19
  exists = false
20
20
  attributes.each do |attribute|
21
- info("Attribute: #{attribute.inspect}")
21
+ @logger.info("Attribute: #{attribute.inspect}")
22
22
  # if the attribute already exists, update it
23
23
  if attribute["name"] == attribute_name
24
24
  attribute["values"] = [ attribute_value ]
@@ -34,9 +34,9 @@ module KineticSdk
34
34
  # set the updated attributes list
35
35
  body = { "attributes" => attributes }
36
36
  if exists
37
- info("Updating attribute \"#{attribute_name}\" = \"#{attribute_value}\" in the \"#{team_name}\" team.")
37
+ @logger.info("Updating attribute \"#{attribute_name}\" = \"#{attribute_value}\" in the \"#{team_name}\" team.")
38
38
  else
39
- info("Adding attribute \"#{attribute_name}\" = \"#{attribute_value}\" to the \"#{team_name}\" team.")
39
+ @logger.info("Adding attribute \"#{attribute_name}\" = \"#{attribute_value}\" to the \"#{team_name}\" team.")
40
40
  end
41
41
  # Update the space
42
42
  put("#{@api_url}/teams/#{team['slug']}", body, headers)
@@ -51,7 +51,7 @@ module KineticSdk
51
51
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
52
52
  def add_team(team_properties, headers=default_headers)
53
53
  raise StandardError.new "Team properties is not valid, must be a Hash." unless team_properties.is_a? Hash
54
- info("Adding Team \"#{team_properties['name']}\"")
54
+ @logger.info("Adding Team \"#{team_properties['name']}\"")
55
55
  post("#{@api_url}/teams", team_properties, headers)
56
56
  end
57
57
 
@@ -70,7 +70,7 @@ module KineticSdk
70
70
  "username" => username
71
71
  }
72
72
  }
73
- info("Adding user: \"#{username}\" to \"#{team_name}\" team")
73
+ @logger.info("Adding user: \"#{username}\" to \"#{team_name}\" team")
74
74
  post("#{@api_url}/memberships/", body, headers)
75
75
  end
76
76
 
@@ -80,7 +80,7 @@ module KineticSdk
80
80
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
81
81
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
82
82
  def find_teams(params={}, headers=default_headers)
83
- info("Finding Teams")
83
+ @logger.info("Finding Teams")
84
84
  get("#{@api_url}/teams", params, headers)
85
85
  end
86
86
 
@@ -91,7 +91,7 @@ module KineticSdk
91
91
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
92
92
  def export_team(team_name, headers=default_headers)
93
93
  team_slug = Digest::MD5.hexdigest(team_name)
94
- info("Exporting the \"#{team_name}\" (#{team_slug}) Team.")
94
+ @logger.info("Exporting the \"#{team_name}\" (#{team_slug}) Team.")
95
95
  get("#{@api_url}/teams/#{team_slug}", { 'export' => true}, headers)
96
96
  end
97
97
 
@@ -105,7 +105,7 @@ module KineticSdk
105
105
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
106
106
  def find_team(team_name, params={}, headers=default_headers)
107
107
  team_slug = Digest::MD5.hexdigest(team_name)
108
- info("Finding the \"#{team_name}\" (#{team_slug}) Team.")
108
+ @logger.info("Finding the \"#{team_name}\" (#{team_slug}) Team.")
109
109
  get("#{@api_url}/teams/#{team_slug}", params, headers)
110
110
  end
111
111
 
@@ -1,5 +1,5 @@
1
1
  module KineticSdk
2
- class RequestCe
2
+ class Core
3
3
 
4
4
  # Add a user in a space.
5
5
  #
@@ -28,11 +28,11 @@ module KineticSdk
28
28
  #
29
29
  def add_user(user, headers=default_headers)
30
30
  if !@space_slug.nil?
31
- info("Adding user \"#{user['username']}\" for Space \"#{@space_slug}\" as system user.")
31
+ @logger.info("Adding user \"#{user['username']}\" for Space \"#{@space_slug}\" as system user.")
32
32
  post("#{@api_url}/users", user, headers)
33
33
  elsif !user['space_slug'].nil?
34
34
  space_slug = user.delete('space_slug')
35
- info("Adding user \"#{user['username']}\" for Space \"#{space_slug}\".")
35
+ @logger.info("Adding user \"#{user['username']}\" for Space \"#{space_slug}\".")
36
36
  post("#{@api_url}/spaces/#{space_slug}/users", user, headers)
37
37
  else
38
38
  raise StandardError.new "The space slug must be supplied to add the user."
@@ -68,11 +68,11 @@ module KineticSdk
68
68
  #
69
69
  def delete_user(user, headers=default_headers)
70
70
  if !@space_slug.nil?
71
- info("Deleting user \"#{user['username']}\" for Space \"#{@space_slug}\" as system user.")
71
+ @logger.info("Deleting user \"#{user['username']}\" for Space \"#{@space_slug}\" as system user.")
72
72
  delete("#{@api_url}/users/#{encode(user['username'])}", headers)
73
73
  elsif !user['space_slug'].nil?
74
74
  space_slug = user.delete('space_slug')
75
- info("Deleting user \"#{user['username']}\" for Space \"#{space_slug}\".")
75
+ @logger.info("Deleting user \"#{user['username']}\" for Space \"#{space_slug}\".")
76
76
  delete("#{@api_url}/spaces/#{space_slug}/users/#{encode(user['username'])}", headers)
77
77
  else
78
78
  raise StandardError.new "The space slug must be supplied to add the user."
@@ -109,9 +109,9 @@ module KineticSdk
109
109
  # set the updated attributes list
110
110
  body = { "attributes" => attributes }
111
111
  if exists
112
- info("Updating attribute \"#{attribute_name}\" on user \"#{username}\".")
112
+ @logger.info("Updating attribute \"#{attribute_name}\" on user \"#{username}\".")
113
113
  else
114
- info("Adding attribute \"#{attribute_name}\" to user \"#{username}\".")
114
+ @logger.info("Adding attribute \"#{attribute_name}\" to user \"#{username}\".")
115
115
  end
116
116
  # Update the user
117
117
  put("#{@api_url}/users/#{encode(username)}", body, headers)
@@ -152,9 +152,9 @@ module KineticSdk
152
152
  # set the updated attributes list
153
153
  body = { "attributes" => attributes }
154
154
  if exists
155
- info("Updating attribute \"#{attribute_name}\" on user \"#{username}\".")
155
+ @logger.info("Updating attribute \"#{attribute_name}\" on user \"#{username}\".")
156
156
  else
157
- info("Adding attribute \"#{attribute_name}\" to user \"#{username}\".")
157
+ @logger.info("Adding attribute \"#{attribute_name}\" to user \"#{username}\".")
158
158
  end
159
159
  # Update the user
160
160
  put("#{@api_url}/users/#{encode(username)}", body, headers)
@@ -166,7 +166,7 @@ module KineticSdk
166
166
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
167
167
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
168
168
  def find_users(params={}, headers=default_headers)
169
- info("Finding Users \"#{username}\"")
169
+ @logger.info("Finding Users \"#{username}\"")
170
170
  get("#{@api_url}/users", params, headers)
171
171
  end
172
172
 
@@ -177,7 +177,7 @@ module KineticSdk
177
177
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
178
178
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
179
179
  def find_user(username, params={}, headers=default_headers)
180
- info("Finding User \"#{username}\"")
180
+ @logger.info("Finding User \"#{username}\"")
181
181
  get("#{@api_url}/users/#{encode(username)}", params, headers)
182
182
  end
183
183
 
@@ -209,11 +209,11 @@ module KineticSdk
209
209
  #
210
210
  def update_user(username, user, headers=default_headers)
211
211
  if !@space_slug.nil?
212
- info("Updating user \"#{username}\" for Space \"#{@space_slug}\" as system user.")
212
+ @logger.info("Updating user \"#{username}\" for Space \"#{@space_slug}\" as system user.")
213
213
  put("#{@api_url}/users/#{encode(username)}", user, headers)
214
214
  elsif !user['space_slug'].nil?
215
215
  space_slug = user.delete('space_slug')
216
- info("Updating user \"#{username}\" for Space \"#{space_slug}\".")
216
+ @logger.info("Updating user \"#{username}\" for Space \"#{space_slug}\".")
217
217
  put("#{@api_url}/spaces/#{space_slug}/users/#{encode(username)}", user, headers)
218
218
  else
219
219
  raise StandardError.new "The space slug must be supplied to update the user."
@@ -227,7 +227,7 @@ module KineticSdk
227
227
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
228
228
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
229
229
  def generate_password_token(username, body={}, headers=default_headers)
230
- info("Generating PW Token for \"#{username}\"")
230
+ @logger.info("Generating PW Token for \"#{username}\"")
231
231
  post("#{@api_url}/users/#{encode(username)}/passwordResetToken", body, headers)
232
232
  end
233
233
 
@@ -237,7 +237,7 @@ module KineticSdk
237
237
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
238
238
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
239
239
  def me(params={}, headers=default_headers)
240
- info("Finding Me")
240
+ @logger.info("Finding Me")
241
241
  get("#{@api_url}/me", params, headers)
242
242
  end
243
243
 
@@ -1,5 +1,5 @@
1
1
  module KineticSdk
2
- class RequestCe
2
+ class Core
3
3
 
4
4
  # Find space webhook jobs
5
5
  #
@@ -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 find_space_webhook_jobs(params={}, headers=default_headers)
10
- info("Finding webhook jobs in the Space")
10
+ @logger.info("Finding webhook jobs in the Space")
11
11
  get("#{@api_url}/webhookJobs", params, headers)
12
12
  end
13
13
 
@@ -49,7 +49,7 @@ module KineticSdk
49
49
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
50
50
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
51
51
  def find_kapp_webhook_jobs(kapp_slug, params={}, headers=default_headers)
52
- info("Finding webhook jobs in the \"#{kapp_slug}\" Kapp")
52
+ @logger.info("Finding webhook jobs in the \"#{kapp_slug}\" Kapp")
53
53
  get("#{@api_url}/kapps/#{kapp_slug}/webhookJobs", params, headers)
54
54
  end
55
55
 
@@ -106,7 +106,7 @@ module KineticSdk
106
106
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
107
107
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
108
108
  def update_space_webhook_job(job_id, job_properties={}, headers=default_headers)
109
- info("Updating the webhook job #{job_id} in Space")
109
+ @logger.info("Updating the webhook job #{job_id} in Space")
110
110
  put("#{@api_url}/webhookJobs/#{job_id}", job_properties, headers)
111
111
  end
112
112
 
@@ -134,7 +134,7 @@ module KineticSdk
134
134
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
135
135
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
136
136
  def update_kapp_webhook_job(kapp_slug, job_id, job_properties={}, headers=default_headers)
137
- info("Updating the webhook job #{job_id} in the \"#{kapp_slug}\" Kapp")
137
+ @logger.info("Updating the webhook job #{job_id} in the \"#{kapp_slug}\" Kapp")
138
138
  put("#{@api_url}/kapps/#{kapp_slug}/webhookJobs/#{job_id}", job_properties, headers)
139
139
  end
140
140
 
@@ -1,5 +1,5 @@
1
1
  module KineticSdk
2
- class RequestCe
2
+ class Core
3
3
 
4
4
  # Add form webhook
5
5
  #
@@ -79,7 +79,7 @@ module KineticSdk
79
79
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
80
80
  def add_webhook_on_kapp(kapp_slug, webhook_properties, headers=default_headers)
81
81
  raise StandardError.new "Webhook properties is not valid, must be a Hash." unless webhook_properties.is_a? Hash
82
- info("Adding a \"#{webhook_properties['event']}\" \"#{webhook_properties['type']}\" webhook for #{kapp_slug}")
82
+ @logger.info("Adding a \"#{webhook_properties['event']}\" \"#{webhook_properties['type']}\" webhook for #{kapp_slug}")
83
83
  post("#{@api_url}/kapps/#{kapp_slug}/webhooks", webhook_properties, headers)
84
84
  end
85
85
 
@@ -98,7 +98,7 @@ module KineticSdk
98
98
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
99
99
  def add_webhook_on_space(webhook_properties, headers=default_headers)
100
100
  raise StandardError.new "Webhook properties is not valid, must be a Hash." unless webhook_properties.is_a? Hash
101
- info("Adding a \"#{webhook_properties['event']}\" \"#{webhook_properties['type']}\" webhook")
101
+ @logger.info("Adding a \"#{webhook_properties['event']}\" \"#{webhook_properties['type']}\" webhook")
102
102
  post("#{@api_url}/webhooks", webhook_properties, headers)
103
103
  end
104
104
 
@@ -109,7 +109,7 @@ module KineticSdk
109
109
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
110
110
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
111
111
  def find_webhooks_on_kapp(kapp_slug, params={}, headers=default_headers)
112
- info("Finding all webhooks on the \"#{kapp_slug}\" Kapp")
112
+ @logger.info("Finding all webhooks on the \"#{kapp_slug}\" Kapp")
113
113
  get("#{@api_url}/kapps/#{kapp_slug}/webhooks", params, headers)
114
114
  end
115
115
 
@@ -119,7 +119,7 @@ module KineticSdk
119
119
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
120
120
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
121
121
  def find_webhooks_on_space(params={}, headers=default_headers)
122
- info("Finding all webhooks on the Space")
122
+ @logger.info("Finding all webhooks on the Space")
123
123
  get("#{@api_url}/webhooks", params, headers)
124
124
  end
125
125
 
@@ -131,7 +131,7 @@ module KineticSdk
131
131
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
132
132
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
133
133
  def find_webhook_on_kapp(kapp_slug, name, params={}, headers=default_headers)
134
- info("Finding the \"#{name}\" webhook on the \"#{kapp_slug}\" Kapp")
134
+ @logger.info("Finding the \"#{name}\" webhook on the \"#{kapp_slug}\" Kapp")
135
135
  get("#{@api_url}/kapps/#{kapp_slug}/webhooks/#{encode(name)}", params, headers)
136
136
  end
137
137
 
@@ -142,7 +142,7 @@ module KineticSdk
142
142
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
143
143
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
144
144
  def finding_webhook_on_space(name, params={}, headers=default_headers)
145
- info("Finding the \"#{name}\" webhook on the Space")
145
+ @logger.info("Finding the \"#{name}\" webhook on the Space")
146
146
  get("#{@api_url}/webhooks/#{encode(name)}", params, headers)
147
147
  end
148
148
 
@@ -163,7 +163,7 @@ module KineticSdk
163
163
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
164
164
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
165
165
  def update_webhook_on_kapp(kapp_slug, name, webhook_properties, headers=default_headers)
166
- info("Updating the \"#{name}\" webhook on the \"#{kapp_slug}\" Kapp")
166
+ @logger.info("Updating the \"#{name}\" webhook on the \"#{kapp_slug}\" Kapp")
167
167
  put("#{@api_url}/kapps/#{kapp_slug}/webhooks/#{encode(name)}", webhook_properties, headers)
168
168
  end
169
169
 
@@ -184,7 +184,7 @@ module KineticSdk
184
184
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
185
185
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
186
186
  def update_webhook_on_space(name, webhook_properties, headers=default_headers)
187
- info("Updating the \"#{name}\" webhook on the Space")
187
+ @logger.info("Updating the \"#{name}\" webhook on the Space")
188
188
  put("#{@api_url}/webhooks/#{encode(name)}", webhook_properties, headers)
189
189
  end
190
190
 
@@ -11,7 +11,7 @@ module KineticSdk
11
11
  include KineticSdk::Utils::KineticHttpUtils
12
12
 
13
13
  attr_reader :api_url, :username, :jwt, :options, :space_slug,
14
- :server, :topics_ws_server, :version
14
+ :server, :topics_ws_server, :version, :logger
15
15
 
16
16
  # Initalize the Discussions SDK with the web server URL and configuration user
17
17
  # credentials, along with any custom option values.
@@ -31,9 +31,12 @@ module KineticSdk
31
31
  # @option opts [String] :password the password for the user
32
32
  # @option opts [Hash<Symbol, Object>] :options ({}) optional settings
33
33
  #
34
- # * :log_level (String) (_defaults to: off_) level of logging - off | info | debug | trace
35
- # * :export_directory (String) (_example: /opt/exports/kinetic-task) directory to write file attachments when exporting,
36
- # * :max_redirects (Fixnum) (_defaults to: 10_) maximum number of redirects to follow
34
+ # * :export_directory (String) (_example: /opt/exports/discussions_) directory to write file attachments when exporting,
35
+ # * :gateway_retry_limit (FixNum) (_defaults to: 5_) max number of times to retry a bad gateway
36
+ # * :gateway_retry_delay (Float) (_defaults to: 1.0_) number of seconds to delay before retrying a bad gateway
37
+ # * :log_level (String) (_defaults to: off_) level of logging - off | error | warn | info | debug
38
+ # * :log_output (String) (_defaults to: STDOUT_) where to send output - STDOUT | STDERR
39
+ # * :max_redirects (Fixnum) (_defaults to: 5_) maximum number of redirects to follow
37
40
  # * :oauth_client_id (String) id of the Kinetic Core oauth client
38
41
  # * :oauth_client_secret (String) secret of the Kinetic Core oauth client
39
42
  # * :ssl_ca_file (String) full path to PEM certificate used to verify the server
@@ -104,6 +107,11 @@ module KineticSdk
104
107
 
105
108
  # process any individual options
106
109
  @options = options[:options] || {}
110
+ # setup logging
111
+ log_level = @options[:log_level] || @options["log_level"]
112
+ log_output = @options[:log_output] || @options["log_output"]
113
+ @logger = KineticSdk::Utils::KLogger.new(log_level, log_output)
114
+
107
115
  @username = options[:username]
108
116
  @space_slug = options[:space_slug]
109
117
 
@@ -12,7 +12,7 @@ module KineticSdk
12
12
  # @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
13
13
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
14
14
  def add_discussion(properties={}, headers=default_jwt_headers)
15
- info("Adding the #{properties['title']} discussion")
15
+ @logger.info("Adding the #{properties['title']} discussion")
16
16
  post("#{@api_url}/discussions", properties, headers)
17
17
  end
18
18
 
@@ -22,7 +22,7 @@ module KineticSdk
22
22
  # @param headers [Hash] hash of headers to send, default is bearer authentication
23
23
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
24
24
  def delete_discussion(discussion_id, headers=header_bearer_auth)
25
- info("Deleting Discussion \"#{discussion_id}\"")
25
+ @logger.info("Deleting Discussion \"#{discussion_id}\"")
26
26
  delete("#{@api_url}/discussions/#{discussion_id}", headers)
27
27
  end
28
28
 
@@ -32,7 +32,7 @@ module KineticSdk
32
32
  # @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
33
33
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
34
34
  def find_discussions(params={}, headers=default_jwt_headers)
35
- info("Finding Discussions.")
35
+ @logger.info("Finding Discussions.")
36
36
  get("#{@api_url}/discussions", params, headers)
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ module KineticSdk
43
43
  # @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
44
44
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
45
45
  def find_discussion(discussion_id, params={}, headers=default_jwt_headers)
46
- info("Finding the \"#{discussion_id}\" Discussion.")
46
+ @logger.info("Finding the \"#{discussion_id}\" Discussion.")
47
47
  get("#{@api_url}/discussions/#{discussion_id}", params, headers)
48
48
  end
49
49
 
@@ -60,7 +60,7 @@ module KineticSdk
60
60
  # @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
61
61
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
62
62
  def update_discussion(discussion_id, properties={}, headers=default_jwt_headers)
63
- info("Updating the \"#{discussion_id}\" Discussion.")
63
+ @logger.info("Updating the \"#{discussion_id}\" Discussion.")
64
64
  put("#{@api_url}/discussions/#{discussion_id}", properties, headers)
65
65
  end
66
66
 
@@ -81,8 +81,8 @@ module KineticSdk
81
81
  # @param headers [Hash] hash of headers to send, default is bearer authentication
82
82
  def export_discussion_attachments(discussion_id, params={}, headers=header_bearer_auth)
83
83
  raise StandardError.new "An export directory must be defined to export a file attachment." if @options[:export_directory].nil?
84
- info("Exporting all file attachments in the #{discussion_id} Discussion.")
85
- info("This may take a while.")
84
+ @logger.info("Exporting all file attachments in the #{discussion_id} Discussion.")
85
+ @logger.info("This may take a while.")
86
86
  # File Counter
87
87
  counter = 0
88
88
  # write the files
@@ -100,7 +100,7 @@ module KineticSdk
100
100
  end
101
101
  end
102
102
  end
103
- info("Exported #{counter} file attachments for the #{discussion_id} Discussion")
103
+ @logger.info("Exported #{counter} file attachments for the #{discussion_id} Discussion")
104
104
  end
105
105
 
106
106
  end
@@ -11,7 +11,7 @@ module KineticSdk
11
11
  def add_invitation_by_email(discussion_id, email, message=nil, headers=default_jwt_headers)
12
12
  payload = { "email" => email }
13
13
  payload["message"] = message unless message.nil?
14
- info("Inviting #{email} to the #{discussion_id} Discussion")
14
+ @logger.info("Inviting #{email} to the #{discussion_id} Discussion")
15
15
  post("#{@api_url}/discussions/#{discussion_id}/invitations", payload, headers)
16
16
  end
17
17
 
@@ -25,7 +25,7 @@ module KineticSdk
25
25
  def add_invitation_by_username(discussion_id, username, message=nil, headers=default_jwt_headers)
26
26
  payload = { "user" => { "username" => username } }
27
27
  payload["message"] = message unless message.nil?
28
- info("Inviting #{username} to the #{discussion_id} Discussion")
28
+ @logger.info("Inviting #{username} to the #{discussion_id} Discussion")
29
29
  post("#{@api_url}/discussions/#{discussion_id}/invitations", payload, headers)
30
30
  end
31
31
 
@@ -36,7 +36,7 @@ module KineticSdk
36
36
  # @param headers [Hash] hash of headers to send, default is bearer authentication
37
37
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
38
38
  def delete_invitation_by_email(discussion_id, email, headers=header_bearer_auth)
39
- info("Deleting the email invitation to the #{discussion_id} Discussion for #{email}")
39
+ @logger.info("Deleting the email invitation to the #{discussion_id} Discussion for #{email}")
40
40
  delete("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}?email=true", headers)
41
41
  end
42
42
 
@@ -47,7 +47,7 @@ module KineticSdk
47
47
  # @param headers [Hash] hash of headers to send, default is bearer authentication
48
48
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
49
49
  def delete_invitation_by_username(discussion_id, username, headers=header_bearer_auth)
50
- info("Deleting the user invitation to the #{discussion_id} Discussion for #{username}")
50
+ @logger.info("Deleting the user invitation to the #{discussion_id} Discussion for #{username}")
51
51
  delete("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", headers)
52
52
  end
53
53
 
@@ -58,7 +58,7 @@ module KineticSdk
58
58
  # @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
59
59
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
60
60
  def find_invitations(discussion_id, params={}, headers=default_jwt_headers)
61
- info("Finding Invitations in the #{discussion_id} Discussion")
61
+ @logger.info("Finding Invitations in the #{discussion_id} Discussion")
62
62
  get("#{@api_url}/discussions/#{discussion_id}/invitations", params, headers)
63
63
  end
64
64
 
@@ -71,7 +71,7 @@ module KineticSdk
71
71
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
72
72
  def find_invitation_by_email(discussion_id, email, params={}, headers=default_jwt_headers)
73
73
  params['email'] = 'true' if params['email'].nil?
74
- info("Finding the Invitation for email #{email} in the #{discussion_id} Discussion")
74
+ @logger.info("Finding the Invitation for email #{email} in the #{discussion_id} Discussion")
75
75
  get("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}", params, headers)
76
76
  end
77
77
 
@@ -84,7 +84,7 @@ module KineticSdk
84
84
  # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
85
85
  def find_invitation_by_username(discussion_id, username, params={}, headers=default_jwt_headers)
86
86
  params.delete('email')
87
- info("Finding the Invitation for user #{username} in the #{discussion_id} Discussion")
87
+ @logger.info("Finding the Invitation for user #{username} in the #{discussion_id} Discussion")
88
88
  get("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", params, headers)
89
89
  end
90
90
 
@@ -98,7 +98,7 @@ module KineticSdk
98
98
  def resend_invitation_by_email(discussion_id, email, message, headers=default_jwt_headers)
99
99
  payload = {}
100
100
  payload["message"] = message unless message.nil?
101
- info("Reinviting #{email} to the #{discussion_id} Discussion")
101
+ @logger.info("Reinviting #{email} to the #{discussion_id} Discussion")
102
102
  put("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}?email=true", payload, headers)
103
103
  end
104
104
 
@@ -112,7 +112,7 @@ module KineticSdk
112
112
  def resend_invitation_by_username(discussion_id, username, message, headers=default_jwt_headers)
113
113
  payload = {}
114
114
  payload["message"] = message unless message.nil?
115
- info("Reinviting #{username} to the #{discussion_id} Discussion")
115
+ @logger.info("Reinviting #{username} to the #{discussion_id} Discussion")
116
116
  put("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", payload, headers)
117
117
  end
118
118