kinetic_sdk 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1e8eb050d18a73811319295d6d60794a3683ae95
4
- data.tar.gz: 51ce513d4a3e2d38fe12d356e3d70f528db8dac4
2
+ SHA256:
3
+ metadata.gz: 2d9d1454174a1ad6358bfa3c1dd12d52cd24eef89c5a1464bca51c7a96829152
4
+ data.tar.gz: 4b0ef0d1c31e02566d8f00cc6aee0b796046e90284a5fef271280f4f9b587230
5
5
  SHA512:
6
- metadata.gz: febab2779f3d476d60b287770512635813bf7b8f9a45ffbf1f9c2d24ece8c2526ebf79218f4341c20d4e966579f9003d9097774751e2ab35d9b0eafaadeb7336
7
- data.tar.gz: 9b368596ac22f72c2a175ce7fe36033cc46918ab371f76c49a230c7d4fd582e3aa72516e5f6be7c313cc5823bbcf340b40e604ca7dbd1215fb3468bad7b049f2
6
+ metadata.gz: a4a0b0aef4fd8f4be9897d083b93c4370cfaeb82c6e8c39d7a98af40ecbe60b883fc5ac9699f8b4eba0d8df18306663445079a6073d8f2fe4d1243a1b9b93744
7
+ data.tar.gz: 8f4fa17ba3124ed7d2d6386670d4bf695f07a3babd4284d831436067baba2b90811e86ef5b294b5d9991eaf509d3d326bc28ec699e122697ced2547521fe4f9d
@@ -0,0 +1,14 @@
1
+ require 'yard'
2
+
3
+ # Template helper to modify processing of links in HTML generated from our
4
+ # markdown files.
5
+ module LocalLinkHelper
6
+ # Rewrites links to (assumed local) markdown files so they're processed as
7
+ # {file: } directives.
8
+ def resolve_links(text)
9
+ text = text.gsub(%r{<a href="([^"]*.md)">([^<]*)</a>}, '{file:\1 \2}')
10
+ super text
11
+ end
12
+ end
13
+
14
+ YARD::Templates::Template.extra_includes << LocalLinkHelper
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --title Kinetic SDK
2
+ --charset utf-8
3
+ --markup markdown
4
+ --output-dir doc
5
+ --readme README.md
6
+ --load .yardoc-includes/yard-helpers.rb
7
+ 'lib/**/*.rb' - '*.md'
data/CHANGELOG.md ADDED
@@ -0,0 +1,41 @@
1
+ # Change Log
2
+
3
+ ## [1.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/1.0.0) (2019-06-13)
4
+
5
+ ** 0.x to 1.x Upgrade Warning **
6
+
7
+ Export methods have been updated to reflect the folder structure
8
+ of their respective API routes.
9
+
10
+ For Example: in the 0.x versions of the SDK, the `export_trees` method would
11
+ place the exported trees inside export_directory/trees. Starting in version 1.0.0, trees are exported to export_directory/sources/:source-name/trees
12
+
13
+ The logger was changed from the `KineticSdk::Utils::Logger` module to the `KineticSdk::Utils::KLogger` class. This shouldn't have any effect on external scripts unless referencing the kinetic logger directly, which is unlikely. If that is the case however, you will need to update your scripts to reference the `logger` SDK variable instead of the static `KineticSDK::Utils::Logger` module.
14
+
15
+ ```ruby
16
+ # 0.x example of logging in a script:
17
+ sdk = KineticSdk::Core.new({
18
+ app_server_url: "http://localhost:8080/kinetic",
19
+ space_slug: "foo",
20
+ username: "space-user-1",
21
+ password: "password"
22
+ })
23
+ KineticSdk::Utils::Logger.info("foo")
24
+
25
+
26
+ # 1.0 example of logging in a script
27
+ sdk = KineticSdk::Core.new({
28
+ app_server_url: "http://localhost:8080/kinetic",
29
+ space_slug: "foo",
30
+ username: "space-user-1",
31
+ password: "password"
32
+ })
33
+ sdk.logger.info("foo")
34
+ ```
35
+
36
+ **Implemented enhancements:**
37
+
38
+ - Ability to export a space in one step using the `export_space` method.
39
+ - Gateway errors (HTTP codes [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502), [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503), and [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504)) will automatically be retried, and may be controlled by the following options:
40
+ - :gateway_retry_limit (default 5), set to -1 to disable retrying gateway errors
41
+ - :gateway_retry_delay (default 1.0)
data/GettingStarted.md CHANGED
@@ -18,32 +18,27 @@ If you do not have git and don't want to install it, you can download a zip file
18
18
 
19
19
  Prepare your Ruby program/script to use the Kinetic SDK.
20
20
 
21
- ```bash
21
+ ```sh
22
22
  # create the project directory
23
-
24
23
  mkdir my_project
25
24
 
26
25
  # clone the kinetic-sdk-rb repository from GitHub
27
26
  # see above to download the zip file if you don't have the git client
28
-
29
27
  git clone https://github.com/kineticdata/kinetic-sdk-rb.git my_project/vendor/kinetic-sdk-rb
30
28
 
31
29
  # copy the sample driver to your project's root directory
32
-
33
30
  cp my_project/vendor/kinetic-sdk-rb/samples/driver/driver.rb my_project/driver.rb
34
31
  ```
35
32
 
36
33
  ### Try the driver
37
34
 
38
- Modify the sample driver program with your Kinetic Request CE (or other Kinetic Application) information, and try it out.
35
+ Modify the sample driver program with your Kinetic Core (or other Kinetic Application) information, and try it out.
39
36
 
40
- ```bash
37
+ ```sh
41
38
  # make sure to change back to the project root directory
42
-
43
39
  cd my_project
44
40
 
45
41
  # run the driver file
46
-
47
42
  ruby driver.rb
48
43
  ```
49
44
 
@@ -51,14 +46,13 @@ ruby driver.rb
51
46
 
52
47
  If you would like to generate the inline documentation for this SDK, perform the following steps.
53
48
 
54
- ```bash
49
+ ```sh
55
50
  # install the bundler gem, and then then necessary documentation gems
56
51
  cd my_project/vendor/kinetic-sdk-rb
57
52
  gem install bundler
58
53
  bundle install
59
54
 
60
55
  # generate and open the inline Ruby documentation for the SDK
61
-
62
- bundle exec rake doc
63
- open rdoc/index.html
56
+ bundle exec rake rdoc
57
+ open doc/index.html
64
58
  ```
data/README.md CHANGED
@@ -10,11 +10,12 @@ The Kinetic Ruby SDK is a library that consists of and SDK for each supported Ki
10
10
 
11
11
  The following Kinetic Data applications are supported in this SDK library:
12
12
 
13
- * Kinetic Request CE 1.0.4+
14
- * Kinetic Task 4.0+
13
+ * Kinetic Core 1.0.4+
14
+ * Kinetic Agent 1.0.0+
15
15
  * Kinetic Bridgehub 1.0+
16
- * Kinetic Filehub 1.0+
17
16
  * Kinetic Discussions 1.0+
17
+ * Kinetic Filehub 1.0+
18
+ * Kinetic Task 4.0+
18
19
 
19
20
  ## Getting Started
20
21
 
@@ -28,7 +29,7 @@ The following are a list of requirements to use this SDK:
28
29
 
29
30
  The Kinetic Ruby SDK requires Ruby 2.2+, which includes JRuby 9.0+. You can determine the version of Ruby you are using with the following command:
30
31
 
31
- ```bash
32
+ ```sh
32
33
  ruby -v
33
34
  ```
34
35
 
@@ -44,17 +45,21 @@ All of the HTTP methods return a {KineticSdk::Utils::KineticHttpResponse} object
44
45
 
45
46
  If you are using Bundler, add this line to your application's Gemfile:
46
47
 
47
- ```ruby
48
+ ```sh
48
49
  gem 'kinetic_sdk'
49
50
  ```
50
51
 
51
52
  And then execute:
52
53
 
53
- $ bundle
54
+ ```sh
55
+ bundle
56
+ ```
54
57
 
55
58
  Or install it yourself as:
56
59
 
57
- $ gem install kinetic_sdk
60
+ ```sh
61
+ gem install kinetic_sdk
62
+ ```
58
63
 
59
64
  Then in your application, include the SDK with the following code:
60
65
 
@@ -70,6 +75,27 @@ the SDK with the following code.
70
75
  require File.join(File.expand_path(File.dirname(__FILE__)), 'vendor', 'kinetic-sdk-rb', 'kinetic-sdk')
71
76
  ```
72
77
 
78
+ ### Kinetic Agent SDK example
79
+
80
+ ```ruby
81
+ agent_sdk = KineticSdk::Agent.new({
82
+ app_server_url: "http://localhost:8080/kinetic-agent",
83
+ username: "configuration-user",
84
+ password: "password",
85
+ options: {
86
+ log_level: "info",
87
+ max_redirects: 3
88
+ }
89
+ })
90
+ response = agent_sdk.find_all_bridges()
91
+ bridges = response.content['bridges']
92
+
93
+ puts response.code # String value of HTTP response code ("200", "400", "500", etc...)
94
+ puts response.status # Ruby Fixnum value of response.code (200, 400, 500, etc...)
95
+ puts response.content # Ruby Hash
96
+ puts response.content_string # JSON formatted response body
97
+ ```
98
+
73
99
  ### Kinetic BridgeHub SDK example
74
100
 
75
101
  ```ruby
@@ -112,10 +138,10 @@ puts response.content # Ruby Hash
112
138
  puts response.content_string # JSON formatted response body
113
139
  ```
114
140
 
115
- ### Kinetic Request CE SDK example of a Space User
141
+ ### Kinetic Core SDK example of a Space User
116
142
 
117
143
  ```ruby
118
- space_sdk = KineticSdk::RequestCe.new({
144
+ space_sdk = KineticSdk::Core.new({
119
145
  app_server_url: "http://localhost:8080/kinetic",
120
146
  space_slug: "foo",
121
147
  username: "space-user-1",
@@ -134,10 +160,10 @@ puts response.content # Ruby Hash
134
160
  puts response.content_string # JSON formatted response body
135
161
  ```
136
162
 
137
- ### Kinetic Request CE SDK example of a System User
163
+ ### Kinetic Core SDK example of a System User
138
164
 
139
165
  ```ruby
140
- system_sdk = KineticSdk::RequestCe.new({
166
+ system_sdk = KineticSdk::Core.new({
141
167
  app_server_url: "http://localhost:8080/kinetic",
142
168
  username: "configuration-user",
143
169
  password: "password",
@@ -154,12 +180,12 @@ puts response.content # Ruby Hash
154
180
  puts response.content_string # JSON formatted response body
155
181
  ```
156
182
 
157
- ### Kinetic Request CE SDK example of a Subdomain
183
+ ### Kinetic Core SDK example of a Subdomain
158
184
 
159
- This example requires a proxy server configured to rewrite the space slug subdomain to the expected Request CE API route.
185
+ This example requires a proxy server configured to rewrite the space slug subdomain to the expected Core API route.
160
186
 
161
187
  ```ruby
162
- space_sdk = KineticSdk::RequestCe.new({
188
+ space_sdk = KineticSdk::Core.new({
163
189
  space_server_url: "https://foo.myapp.io",
164
190
  space_slug: "foo",
165
191
  username: "space-user-1",
@@ -262,19 +288,19 @@ Beginning with version 0.0.2, there are now two additional options that can be p
262
288
 
263
289
  May be used with all application SDKs.
264
290
 
265
- **Example 1 using Kinetic Request CE without server certificate validation:**
291
+ **Example 1 using Kinetic Core without server certificate validation:**
266
292
 
267
293
  ```ruby
268
- space_sdk = KineticSdk::RequestCe.new({
294
+ space_sdk = KineticSdk::Core.new({
269
295
  ...
270
296
  options: {}
271
297
  })
272
298
  ```
273
299
 
274
- **Example 2 using Kinetic Request CE without server certificate validation:**
300
+ **Example 2 using Kinetic Core without server certificate validation:**
275
301
 
276
302
  ```ruby
277
- space_sdk = KineticSdk::RequestCe.new({
303
+ space_sdk = KineticSdk::Core.new({
278
304
  ...
279
305
  options: {
280
306
  ssl_verify_mode: "none"
@@ -282,10 +308,10 @@ space_sdk = KineticSdk::RequestCe.new({
282
308
  })
283
309
  ```
284
310
 
285
- **Example using Kinetic Request CE with server certificate validation and known CAs:**
311
+ **Example using Kinetic Core with server certificate validation and known CAs:**
286
312
 
287
313
  ```ruby
288
- space_sdk = KineticSdk::RequestCe.new({
314
+ space_sdk = KineticSdk::Core.new({
289
315
  ...
290
316
  options: {
291
317
  ssl_verify_mode: "peer"
@@ -293,10 +319,10 @@ space_sdk = KineticSdk::RequestCe.new({
293
319
  })
294
320
  ```
295
321
 
296
- **Example using Kinetic Request CE with server certificate validation and a self-signing CA:**
322
+ **Example using Kinetic Core with server certificate validation and a self-signing CA:**
297
323
 
298
324
  ```ruby
299
- space_sdk = KineticSdk::RequestCe.new({
325
+ space_sdk = KineticSdk::Core.new({
300
326
  ...
301
327
  options: {
302
328
  ssl_verify_mode: "peer",
@@ -309,14 +335,32 @@ space_sdk = KineticSdk::RequestCe.new({
309
335
 
310
336
  If you need to make a custom HTTP call for some reason, there is a class that allows you to do that. Simply make sure the KineticSdk is required in your program. See the [Getting Started Guide](GettingStarted.md) for details.
311
337
 
312
- Then you need to instantiate a new instance of the {KineticSdk::Utils::KineticHttp} class, and call the desired HTTP method with the appropriate information. Each response will be returned as a {KineticSdk::Utils::KineticHttpResponse} object.
338
+ Then you need to instantiate a new instance of the {KineticSdk::CustomHttp} class, and call the desired HTTP method with the appropriate information. Each response will be returned as a {KineticSdk::Utils::KineticHttpResponse} object.
313
339
 
314
340
  ```ruby
315
- # instantiate the KineticHttp class without authentication
316
- http = KineticSdk::Utils::KineticHttp.new
341
+ # instantiate the CustomHttp class without authentication
342
+ http = KineticSdk::CustomHttp.new
317
343
 
318
- # instantiate the KineticHttp class with Basic authentication
319
- http = KineticSdk::Utils::KineticHttp.new("john.doe@company.com", "s3cretP@ssw0rd")
344
+ # instantiate the CustomHttp class with Basic authentication
345
+ http = KineticSdk::CustomHttp.new({
346
+ username: "john.doe@company.com",
347
+ password: "s3cretP@ssw0rd"
348
+ })
349
+
350
+ # instantiate the CustomHttp class with Basic authentication, and custom options
351
+ http = KineticSdk::CustomHttp.new({
352
+ username: "john.doe@company.com",
353
+ password: "s3cretP@ssw0rd",
354
+ options: {
355
+ log_level: "debug",
356
+ log_output: "stderr",
357
+ max_redirects: 3,
358
+ gateway_retry_delay: 1.0,
359
+ gateway_retry_limit: 5,
360
+ ssl_verify_mode: "peer",
361
+ ssl_ca_file: "/path/to/self-signing-ca.pem"
362
+ }
363
+ })
320
364
 
321
365
  # call the appropriate method
322
366
 
@@ -356,28 +400,32 @@ response = http.put(
356
400
 
357
401
  ## Additional Documentation
358
402
 
359
- The RDoc documentation for the SDK can be generated by running a rake command. This will provide detailed information for each module, class, and method. The output can be found in the generated `rdoc` directory.
403
+ The RDoc documentation for the SDK can be generated by running a rake command. This will provide detailed information for each module, class, and method. The output can be found in the generated `doc` directory.
360
404
 
361
405
  In order to do this however, the `yard` gem is required and must first be installed.
362
406
 
363
- This SDK includes a [Gemfile](./Gemfile) that can be used with the `bundler` gem to ensure the proper version is installed.
407
+ This SDK includes a Gemfile that can be used with the `bundler` gem to ensure the proper version is installed.
364
408
 
365
409
  Install the Bundler gem:
366
410
 
367
- gem install bundler
411
+ ```sh
412
+ gem install bundler
413
+ ```
368
414
 
369
415
  _IMPORTANT NOTE_: If using [rbenv](https://github.com/rbenv/rbenv) to manage Ruby versions, run the following command.
370
416
 
371
- rbenv rehash
417
+ ```sh
418
+ rbenv rehash
419
+ ```
372
420
 
373
421
  Finally, install the dependency gems:
374
422
 
375
- bundle install
423
+ ```sh
424
+ bundle install
425
+ ```
376
426
 
377
- Now that the required documentation generation gem is installed, a simple Rake command can be run to generate the inline documentation. For this SDK, the following commands are all equivalent:
427
+ Now that the required documentation generation gem is installed, a simple Rake command can be run to generate the inline documentation.
378
428
 
379
- ```ruby
380
- bundle exec rake
381
- bundle exec rake doc
382
- bundle exec rake yard
429
+ ```sh
430
+ bundle exec rake rdoc
383
431
  ```
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require 'yard'
3
+
4
+ desc "Generate Documentation"
5
+ YARD::Rake::YardocTask.new do |t|
6
+ # see .yardopts
7
+ t.stats_options = %w( --list-undoc )
8
+ end
9
+
10
+ # Generate Yard documentation
11
+ task :doc => [:yard]
12
+ task :rdoc => [:yard]
13
+ task :default => [:doc]
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "kinetic_sdk/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kinetic_sdk"
8
+ spec.version = KineticSdk::VERSION
9
+ spec.authors = ["Kinetic Data"]
10
+ spec.email = ["support@kineticdata.com"]
11
+
12
+ spec.summary = %q{Ruby SDK for Kinetic Data application APIs}
13
+ spec.homepage = "https://github.com/kineticdata/kinetic-sdk-rb"
14
+
15
+ spec.files = Dir.glob("{bin,lib,gems,.yardoc-includes}/**/*") + %w(kinetic_sdk.gemspec .yardopts CHANGELOG.md GettingStarted.md README.md Rakefile)
16
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+
20
+ spec.add_dependency "slugify", "1.0.7"
21
+ spec.add_dependency "multipart-post", "2.0.0"
22
+ spec.add_dependency "mime-types", "3.1"
23
+ spec.add_dependency "parallel", "1.12.1"
24
+ spec.add_dependency "ruby-progressbar", "1.9.0"
25
+
26
+ spec.add_development_dependency "kontena-websocket-client", "0.1.1"
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.16"
29
+ spec.add_development_dependency "rake", "~> 12.3.0"
30
+ spec.add_development_dependency "yard", "~> 0.9.20"
31
+
32
+ spec.metadata["yard.run"] = "yri"
33
+ end
@@ -0,0 +1,90 @@
1
+ Dir[File.join(File.dirname(File.expand_path(__FILE__)), "lib", "**", "*.rb")].each {|file| require file }
2
+
3
+ module KineticSdk
4
+
5
+ # Agent is a Ruby class that acts as a wrapper for the Kinetic Agent System
6
+ # REST API without having to make explicit HTTP requests. This is not to be
7
+ # confused with the Kinetic Agent Space REST API, which must go through the
8
+ # Kinetic Core Proxy API.
9
+ #
10
+ class Agent
11
+
12
+ # Include the KineticHttpUtils module
13
+ include KineticSdk::Utils::KineticHttpUtils
14
+
15
+ attr_reader :api_url, :username, :options, :password, :server, :version, :logger
16
+
17
+ # Initalize the Agent SDK with the web server URL and configuration user
18
+ # credentials, along with any custom option values.
19
+ #
20
+ # @param opts [Hash] Kinetic Agent properties
21
+ # @option opts [String] :config_file optional - path to the YAML configuration file
22
+ #
23
+ # * Ex: /opt/config/agent-configuration1.yaml
24
+ #
25
+ # @option opts [String] :app_server_url the URL to the Kinetic Agent web application.
26
+ #
27
+ # * Ex: <http://192.168.0.1:8080/kinetic-agent>
28
+ #
29
+ # @option opts [String] :username the username for the user
30
+ # @option opts [String] :password the password for the user
31
+ # @option opts [Hash<Symbol, Object>] :options ({}) optional settings
32
+ #
33
+ # * :gateway_retry_limit (FixNum) (_defaults to: 5_) max number of times to retry a bad gateway
34
+ # * :gateway_retry_delay (Float) (_defaults to: 1.0_) number of seconds to delay before retrying a bad gateway
35
+ # * :log_level (String) (_defaults to: off_) level of logging - off | error | warn | info | debug
36
+ # * :log_output (String) (_defaults to: STDOUT_) where to send output - STDOUT | STDERR
37
+ # * :max_redirects (Fixnum) (_defaults to: 5_) maximum number of redirects to follow
38
+ # * :ssl_ca_file (String) full path to PEM certificate used to verify the server
39
+ # * :ssl_verify_mode (String) (_defaults to: none_) - none | peer
40
+ #
41
+ # Example: using a configuration file
42
+ #
43
+ # KineticSdk::Agent.new({
44
+ # config_file: "/opt/config1.yaml"
45
+ # })
46
+ #
47
+ # Example: using a properties hash
48
+ #
49
+ # KineticSdk::Agent.new({
50
+ # app_server_url: "http://localhost:8080/kinetic-agent",
51
+ # username: "admin",
52
+ # password: "admin",
53
+ # options: {
54
+ # log_level: "debug",
55
+ # ssl_verify_mode: "peer",
56
+ # ssl_ca_file: "/usr/local/self_signing_ca.pem"
57
+ # }
58
+ # })
59
+ #
60
+ # If the +config_file+ option is present, it will be loaded first, and any additional
61
+ # options will overwrite any values in the config file
62
+ #
63
+ def initialize(opts)
64
+ # initialize any variables
65
+ options = {}
66
+
67
+ # process the configuration file if it was provided
68
+ unless opts[:config_file].nil?
69
+ options.merge!(YAML::load_file opts[:config_file])
70
+ end
71
+
72
+ # process the configuration hash if it was provided
73
+ options.merge!(opts)
74
+
75
+ # process any individual options
76
+ @options = options.delete(:options) || {}
77
+ # setup logging
78
+ log_level = @options[:log_level] || @options["log_level"]
79
+ log_output = @options[:log_output] || @options["log_output"]
80
+ @logger = KineticSdk::Utils::KLogger.new(log_level, log_output)
81
+
82
+ @username = options[:username]
83
+ @password = options[:password]
84
+ @server = options[:app_server_url].chomp('/')
85
+ @api_url = "#{@server}/app/api/v1"
86
+ @version = 1
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,92 @@
1
+ module KineticSdk
2
+ class Agent
3
+
4
+ # Add Bridge
5
+ #
6
+ # @param space [String] slug of the space
7
+ # @param body [Hash] properties associated to the Bridge
8
+ # - +adapterClass+
9
+ # - +name+
10
+ # - +slug+
11
+ # - +properties+
12
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
13
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
14
+ def add_bridge(space, body, headers=default_headers)
15
+ @logger.info("Adding the \"#{body['name']}\" bridge in the \"#{space}\" space.")
16
+ post("#{@api_url}/spaces/#{space}/bridges", body, headers)
17
+ end
18
+
19
+ # Delete a Bridge
20
+ #
21
+ # @param space [String] slug of the space
22
+ # @param slug [String] slug of the Bridge
23
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
24
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
25
+ def delete_bridge(space, slug, headers=default_headers)
26
+ @logger.info("Deleting the \"#{slug}\" bridge in the \"#{space}\" space.")
27
+ delete("#{@api_url}/spaces/#{space}/bridges/#{slug}", headers)
28
+ end
29
+
30
+ # Find a bridge
31
+ #
32
+ # @param space [String] slug of the space
33
+ # @param slug [String] slug of the bridge
34
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
35
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
36
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
37
+ def find_bridge(space, slug, params={}, headers=default_headers)
38
+ @logger.info("Finding the \"#{slug}\" bridge in the \"#{space}\" space.")
39
+ get("#{@api_url}/spaces/#{space}/bridges/#{slug}", params, headers)
40
+ end
41
+
42
+ # Update a bridge
43
+ #
44
+ # @param space [String] slug of the space
45
+ # @param slug [String] slug of the bridge
46
+ # @param body [Hash] properties of the bridge to update
47
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
48
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
49
+ def update_bridge(space, slug, body={}, headers=default_headers)
50
+ @logger.info("Updating the \"#{slug}\" bridge in the \"#{space}\" space.")
51
+ put("#{@api_url}/spaces/#{space}/bridges/#{slug}", body, headers)
52
+ end
53
+
54
+ # Find all bridges in a space
55
+ #
56
+ # @param space [String] slug of the space
57
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
58
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
59
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
60
+ def find_bridges(space, params={}, headers=default_headers)
61
+ @logger.info("Find all bridges in the \"#{space}\" space.")
62
+ get("#{@api_url}/spaces/#{space}/bridges", params, headers)
63
+ end
64
+
65
+ # Add Bridge to Space
66
+ #
67
+ # @param space [String] slug of the space
68
+ # @param body [Hash] properties associated to the Bridge
69
+ # - +space+
70
+ # - +adapterClass+
71
+ # - +name+
72
+ # - +slug+
73
+ # - +properties+
74
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
75
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
76
+ def add_space_bridge(body, headers=default_headers)
77
+ @logger.info("Adding the \"#{body['name']}\" bridge in the \"#{body['space']}\" space.")
78
+ post("#{@api_url}/bridges", body, headers)
79
+ end
80
+
81
+ # Find all bridges in the system
82
+ #
83
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
84
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
85
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
86
+ def find_all_bridges(params={}, headers=default_headers)
87
+ @logger.info("Find all bridges.")
88
+ get("#{@api_url}/bridges", params, headers)
89
+ end
90
+
91
+ end
92
+ end