kinetic_sdk 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. checksums.yaml +7 -0
  2. data/GettingStarted.md +64 -0
  3. data/README.md +383 -0
  4. data/bin/console +12 -0
  5. data/bin/setup +8 -0
  6. data/gems/kontena-websocket-client-0.1.1/Gemfile +4 -0
  7. data/gems/kontena-websocket-client-0.1.1/LICENSE +190 -0
  8. data/gems/kontena-websocket-client-0.1.1/README.md +138 -0
  9. data/gems/kontena-websocket-client-0.1.1/Rakefile +6 -0
  10. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-client.rb +45 -0
  11. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-em.rb +66 -0
  12. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.rb +161 -0
  13. data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.sh +17 -0
  14. data/gems/kontena-websocket-client-0.1.1/benchmark/websocket-echo-server.go +207 -0
  15. data/gems/kontena-websocket-client-0.1.1/examples/websocket-echo-client.rb +80 -0
  16. data/gems/kontena-websocket-client-0.1.1/kontena-websocket-client.gemspec +24 -0
  17. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/connection.rb +119 -0
  18. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/version.rb +13 -0
  19. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client.rb +848 -0
  20. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb +81 -0
  21. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb +55 -0
  22. data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/openssl_patch.rb +10 -0
  23. data/gems/kontena-websocket-client-0.1.1/lib/kontena-websocket-client.rb +15 -0
  24. data/gems/mime-types-3.1/Code-of-Conduct.rdoc +74 -0
  25. data/gems/mime-types-3.1/Contributing.rdoc +130 -0
  26. data/gems/mime-types-3.1/History.rdoc +658 -0
  27. data/gems/mime-types-3.1/Licence.rdoc +25 -0
  28. data/gems/mime-types-3.1/Manifest.txt +31 -0
  29. data/gems/mime-types-3.1/README.rdoc +202 -0
  30. data/gems/mime-types-3.1/Rakefile +254 -0
  31. data/gems/mime-types-3.1/lib/mime/type/columnar.rb +55 -0
  32. data/gems/mime-types-3.1/lib/mime/type.rb +573 -0
  33. data/gems/mime-types-3.1/lib/mime/types/_columnar.rb +135 -0
  34. data/gems/mime-types-3.1/lib/mime/types/cache.rb +56 -0
  35. data/gems/mime-types-3.1/lib/mime/types/columnar.rb +1 -0
  36. data/gems/mime-types-3.1/lib/mime/types/container.rb +30 -0
  37. data/gems/mime-types-3.1/lib/mime/types/deprecations.rb +32 -0
  38. data/gems/mime-types-3.1/lib/mime/types/full.rb +17 -0
  39. data/gems/mime-types-3.1/lib/mime/types/loader.rb +148 -0
  40. data/gems/mime-types-3.1/lib/mime/types/logger.rb +37 -0
  41. data/gems/mime-types-3.1/lib/mime/types/registry.rb +81 -0
  42. data/gems/mime-types-3.1/lib/mime/types.rb +228 -0
  43. data/gems/mime-types-3.1/lib/mime-types.rb +1 -0
  44. data/gems/mime-types-3.1/test/bad-fixtures/malformed +9 -0
  45. data/gems/mime-types-3.1/test/fixture/json.json +1 -0
  46. data/gems/mime-types-3.1/test/fixture/old-data +9 -0
  47. data/gems/mime-types-3.1/test/fixture/yaml.yaml +55 -0
  48. data/gems/mime-types-3.1/test/minitest_helper.rb +13 -0
  49. data/gems/mime-types-3.1/test/test_mime_type.rb +603 -0
  50. data/gems/mime-types-3.1/test/test_mime_types.rb +161 -0
  51. data/gems/mime-types-3.1/test/test_mime_types_cache.rb +109 -0
  52. data/gems/mime-types-3.1/test/test_mime_types_class.rb +155 -0
  53. data/gems/mime-types-3.1/test/test_mime_types_lazy.rb +43 -0
  54. data/gems/mime-types-3.1/test/test_mime_types_loader.rb +32 -0
  55. data/gems/mime-types-data-3.2016.0521/Code-of-Conduct.md +75 -0
  56. data/gems/mime-types-data-3.2016.0521/Contributing.md +157 -0
  57. data/gems/mime-types-data-3.2016.0521/History.md +351 -0
  58. data/gems/mime-types-data-3.2016.0521/Licence.md +25 -0
  59. data/gems/mime-types-data-3.2016.0521/Manifest.txt +18 -0
  60. data/gems/mime-types-data-3.2016.0521/README.md +61 -0
  61. data/gems/mime-types-data-3.2016.0521/Rakefile +80 -0
  62. data/gems/mime-types-data-3.2016.0521/data/mime-types.json +1 -0
  63. data/gems/mime-types-data-3.2016.0521/data/mime.content_type.column +1964 -0
  64. data/gems/mime-types-data-3.2016.0521/data/mime.docs.column +1964 -0
  65. data/gems/mime-types-data-3.2016.0521/data/mime.encoding.column +1964 -0
  66. data/gems/mime-types-data-3.2016.0521/data/mime.flags.column +1964 -0
  67. data/gems/mime-types-data-3.2016.0521/data/mime.friendly.column +1964 -0
  68. data/gems/mime-types-data-3.2016.0521/data/mime.pext.column +1964 -0
  69. data/gems/mime-types-data-3.2016.0521/data/mime.use_instead.column +1964 -0
  70. data/gems/mime-types-data-3.2016.0521/data/mime.xrefs.column +1964 -0
  71. data/gems/mime-types-data-3.2016.0521/lib/mime/types/data.rb +21 -0
  72. data/gems/mime-types-data-3.2016.0521/lib/mime-types-data.rb +3 -0
  73. data/gems/multipart-post-2.0.0/Gemfile +14 -0
  74. data/gems/multipart-post-2.0.0/History.txt +60 -0
  75. data/gems/multipart-post-2.0.0/Manifest.txt +9 -0
  76. data/gems/multipart-post-2.0.0/README.md +77 -0
  77. data/gems/multipart-post-2.0.0/Rakefile +9 -0
  78. data/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
  79. data/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
  80. data/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
  81. data/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
  82. data/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
  83. data/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
  84. data/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
  85. data/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
  86. data/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
  87. data/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
  88. data/gems/parallel-1.12.1/MIT-LICENSE.txt +20 -0
  89. data/gems/parallel-1.12.1/lib/parallel/processor_count.rb +93 -0
  90. data/gems/parallel-1.12.1/lib/parallel/version.rb +3 -0
  91. data/gems/parallel-1.12.1/lib/parallel.rb +500 -0
  92. data/gems/ruby-progressbar-1.9.0/LICENSE.txt +19 -0
  93. data/gems/ruby-progressbar-1.9.0/README.md +38 -0
  94. data/gems/ruby-progressbar-1.9.0/Rakefile +2 -0
  95. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/base.rb +183 -0
  96. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/length.rb +99 -0
  97. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/running_average.rb +9 -0
  98. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/bar.rb +96 -0
  99. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/percentage.rb +29 -0
  100. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb +43 -0
  101. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/time.rb +107 -0
  102. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/title.rb +13 -0
  103. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components.rb +5 -0
  104. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
  105. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/formatter.rb +27 -0
  106. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/molecule.rb +59 -0
  107. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/string.rb +36 -0
  108. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format.rb +3 -0
  109. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/output.rb +68 -0
  110. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
  111. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/null.rb +33 -0
  112. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/tty.rb +32 -0
  113. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/progress.rb +118 -0
  114. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb +25 -0
  115. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements.rb +1 -0
  116. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb +25 -0
  117. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/time.rb +30 -0
  118. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/timer.rb +72 -0
  119. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/version.rb +3 -0
  120. data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar.rb +18 -0
  121. data/gems/slugify-1.0.7/README +18 -0
  122. data/gems/slugify-1.0.7/lib/slugify.rb +1012 -0
  123. data/gems/slugify-1.0.7/lib/slugify_string.rb +11 -0
  124. data/gems/slugify-1.0.7/tests/slugify_test.rb +116 -0
  125. data/gems/slugify-1.0.7/tests/string_slugify_test.rb +23 -0
  126. data/gems/websocket-driver-0.6.5/CHANGELOG.md +123 -0
  127. data/gems/websocket-driver-0.6.5/LICENSE.md +22 -0
  128. data/gems/websocket-driver-0.6.5/README.md +369 -0
  129. data/gems/websocket-driver-0.6.5/examples/tcp_server.rb +28 -0
  130. data/gems/websocket-driver-0.6.5/ext/websocket-driver/Makefile +264 -0
  131. data/gems/websocket-driver-0.6.5/ext/websocket-driver/WebsocketMaskService.java +55 -0
  132. data/gems/websocket-driver-0.6.5/ext/websocket-driver/extconf.rb +4 -0
  133. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.bundle +0 -0
  134. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.c +41 -0
  135. data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.o +0 -0
  136. data/gems/websocket-driver-0.6.5/lib/websocket/driver/client.rb +140 -0
  137. data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft75.rb +102 -0
  138. data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft76.rb +96 -0
  139. data/gems/websocket-driver-0.6.5/lib/websocket/driver/event_emitter.rb +54 -0
  140. data/gems/websocket-driver-0.6.5/lib/websocket/driver/headers.rb +45 -0
  141. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/frame.rb +20 -0
  142. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/message.rb +31 -0
  143. data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi.rb +406 -0
  144. data/gems/websocket-driver-0.6.5/lib/websocket/driver/proxy.rb +68 -0
  145. data/gems/websocket-driver-0.6.5/lib/websocket/driver/server.rb +80 -0
  146. data/gems/websocket-driver-0.6.5/lib/websocket/driver/stream_reader.rb +55 -0
  147. data/gems/websocket-driver-0.6.5/lib/websocket/driver.rb +199 -0
  148. data/gems/websocket-driver-0.6.5/lib/websocket/http/headers.rb +112 -0
  149. data/gems/websocket-driver-0.6.5/lib/websocket/http/request.rb +45 -0
  150. data/gems/websocket-driver-0.6.5/lib/websocket/http/response.rb +29 -0
  151. data/gems/websocket-driver-0.6.5/lib/websocket/http.rb +15 -0
  152. data/gems/websocket-driver-0.6.5/lib/websocket/mask.rb +14 -0
  153. data/gems/websocket-driver-0.6.5/lib/websocket/websocket_mask.rb +2 -0
  154. data/gems/websocket-driver-0.6.5/lib/websocket_mask.bundle +0 -0
  155. data/gems/websocket-driver-0.6.5-java/CHANGELOG.md +123 -0
  156. data/gems/websocket-driver-0.6.5-java/LICENSE.md +22 -0
  157. data/gems/websocket-driver-0.6.5-java/README.md +369 -0
  158. data/gems/websocket-driver-0.6.5-java/examples/tcp_server.rb +28 -0
  159. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/WebsocketMaskService.java +55 -0
  160. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/extconf.rb +4 -0
  161. data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/websocket_mask.c +41 -0
  162. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/client.rb +140 -0
  163. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft75.rb +102 -0
  164. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft76.rb +96 -0
  165. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/event_emitter.rb +54 -0
  166. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/headers.rb +45 -0
  167. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/frame.rb +20 -0
  168. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/message.rb +31 -0
  169. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi.rb +406 -0
  170. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/proxy.rb +68 -0
  171. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/server.rb +80 -0
  172. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/stream_reader.rb +55 -0
  173. data/gems/websocket-driver-0.6.5-java/lib/websocket/driver.rb +199 -0
  174. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/headers.rb +112 -0
  175. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/request.rb +45 -0
  176. data/gems/websocket-driver-0.6.5-java/lib/websocket/http/response.rb +29 -0
  177. data/gems/websocket-driver-0.6.5-java/lib/websocket/http.rb +15 -0
  178. data/gems/websocket-driver-0.6.5-java/lib/websocket/mask.rb +14 -0
  179. data/gems/websocket-driver-0.6.5-java/lib/websocket/websocket_mask.rb +2 -0
  180. data/gems/websocket-driver-0.6.5-java/lib/websocket_mask.jar +0 -0
  181. data/gems/websocket-extensions-0.1.3/CHANGELOG.md +15 -0
  182. data/gems/websocket-extensions-0.1.3/LICENSE.md +20 -0
  183. data/gems/websocket-extensions-0.1.3/README.md +313 -0
  184. data/gems/websocket-extensions-0.1.3/lib/websocket/extensions/parser.rb +111 -0
  185. data/gems/websocket-extensions-0.1.3/lib/websocket/extensions.rb +181 -0
  186. data/lib/kinetic-sdk.rb +1 -0
  187. data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +80 -0
  188. data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +67 -0
  189. data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +69 -0
  190. data/lib/kinetic_sdk/discussions/discussions-sdk.rb +165 -0
  191. data/lib/kinetic_sdk/discussions/lib/discussions.rb +107 -0
  192. data/lib/kinetic_sdk/discussions/lib/invitations.rb +120 -0
  193. data/lib/kinetic_sdk/discussions/lib/messages.rb +190 -0
  194. data/lib/kinetic_sdk/discussions/lib/meta.rb +14 -0
  195. data/lib/kinetic_sdk/discussions/lib/participants.rb +64 -0
  196. data/lib/kinetic_sdk/discussions/lib/related_items.rb +54 -0
  197. data/lib/kinetic_sdk/discussions/lib/websockets.rb +96 -0
  198. data/lib/kinetic_sdk/filehub/filehub-sdk.rb +80 -0
  199. data/lib/kinetic_sdk/filehub/lib/access_keys.rb +67 -0
  200. data/lib/kinetic_sdk/filehub/lib/filestores.rb +67 -0
  201. data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +153 -0
  202. data/lib/kinetic_sdk/request_ce/lib/bridges.rb +66 -0
  203. data/lib/kinetic_sdk/request_ce/lib/categories.rb +34 -0
  204. data/lib/kinetic_sdk/request_ce/lib/datastore_form.rb +110 -0
  205. data/lib/kinetic_sdk/request_ce/lib/datastore_submissions.rb +157 -0
  206. data/lib/kinetic_sdk/request_ce/lib/form.rb +99 -0
  207. data/lib/kinetic_sdk/request_ce/lib/form_types.rb +51 -0
  208. data/lib/kinetic_sdk/request_ce/lib/jwt.rb +55 -0
  209. data/lib/kinetic_sdk/request_ce/lib/kapp.rb +93 -0
  210. data/lib/kinetic_sdk/request_ce/lib/meta.rb +14 -0
  211. data/lib/kinetic_sdk/request_ce/lib/oauth.rb +37 -0
  212. data/lib/kinetic_sdk/request_ce/lib/security_policy_definitions.rb +157 -0
  213. data/lib/kinetic_sdk/request_ce/lib/space.rb +89 -0
  214. data/lib/kinetic_sdk/request_ce/lib/submissions.rb +215 -0
  215. data/lib/kinetic_sdk/request_ce/lib/system_api.rb +69 -0
  216. data/lib/kinetic_sdk/request_ce/lib/teams.rb +113 -0
  217. data/lib/kinetic_sdk/request_ce/lib/users.rb +245 -0
  218. data/lib/kinetic_sdk/request_ce/lib/webhook_jobs.rb +142 -0
  219. data/lib/kinetic_sdk/request_ce/lib/webhooks.rb +192 -0
  220. data/lib/kinetic_sdk/request_ce/request-ce-sdk.rb +153 -0
  221. data/lib/kinetic_sdk/task/lib/access_keys.rb +94 -0
  222. data/lib/kinetic_sdk/task/lib/categories.rb +190 -0
  223. data/lib/kinetic_sdk/task/lib/config.rb +202 -0
  224. data/lib/kinetic_sdk/task/lib/engine.rb +42 -0
  225. data/lib/kinetic_sdk/task/lib/environment.rb +14 -0
  226. data/lib/kinetic_sdk/task/lib/errors.rb +165 -0
  227. data/lib/kinetic_sdk/task/lib/groups.rb +112 -0
  228. data/lib/kinetic_sdk/task/lib/handlers.rb +105 -0
  229. data/lib/kinetic_sdk/task/lib/health.rb +28 -0
  230. data/lib/kinetic_sdk/task/lib/license.rb +52 -0
  231. data/lib/kinetic_sdk/task/lib/policy_rules.rb +166 -0
  232. data/lib/kinetic_sdk/task/lib/setup.rb +56 -0
  233. data/lib/kinetic_sdk/task/lib/sources.rb +134 -0
  234. data/lib/kinetic_sdk/task/lib/tasks.rb +17 -0
  235. data/lib/kinetic_sdk/task/lib/trees.rb +274 -0
  236. data/lib/kinetic_sdk/task/lib/users.rb +75 -0
  237. data/lib/kinetic_sdk/task/task-sdk.rb +92 -0
  238. data/lib/kinetic_sdk/utils/kinetic-http-headers.rb +150 -0
  239. data/lib/kinetic_sdk/utils/kinetic-http-response.rb +75 -0
  240. data/lib/kinetic_sdk/utils/kinetic-http.rb +552 -0
  241. data/lib/kinetic_sdk/utils/logger.rb +70 -0
  242. data/lib/kinetic_sdk/utils/random.rb +30 -0
  243. data/lib/kinetic_sdk/version.rb +7 -0
  244. data/lib/kinetic_sdk.rb +57 -0
  245. metadata +414 -0
@@ -0,0 +1,112 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Add a group
5
+ #
6
+ # @param name [String] name of the group
7
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
8
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
+ def add_group(name, headers=default_headers)
10
+ info("Adding group \"#{name}\"")
11
+ post("#{@api_url}/groups", { "name" => name }, headers)
12
+ end
13
+
14
+ # Delete a Group
15
+ #
16
+ # @param name [String] name of the group
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
19
+ def delete_group(name, headers=header_basic_auth)
20
+ info("Deleting Group \"#{name}\"")
21
+ delete("#{@api_url}/groups/#{encode(name)}", headers)
22
+ end
23
+
24
+ # Delete all Groups
25
+ #
26
+ # @param headers [Hash] hash of headers to send, default is basic authentication
27
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
28
+ def delete_groups(headers=header_basic_auth)
29
+ info("Deleting all groups")
30
+ (find_groups(headers).content['groups'] || []).each do |group|
31
+ delete("#{@api_url}/groups/#{encode(group['name'])}", headers)
32
+ end
33
+ end
34
+
35
+ # Export a Group
36
+ #
37
+ # @param group [String] name of the group
38
+ # @param headers [Hash] hash of headers to send, default is basic authentication
39
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
40
+ def export_group(group, headers=header_basic_auth)
41
+ raise StandardError.new "An export directory must be defined to export a group." if @options[:export_directory].nil?
42
+ if group.is_a? String
43
+ response = find_group(group, {}, headers)
44
+ group = response.content
45
+ end
46
+ info("Exporting group \"#{group['name']}\" to #{@options[:export_directory]}.")
47
+ # Create the groups directory if it doesn't yet exist
48
+ group_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "groups"))
49
+ group_file = File.join(group_dir, "#{group['name'].slugify}.json")
50
+ # write the file
51
+ responseObj = get("#{@api_url}/groups/#{encode(group['name'])}", {}, headers)
52
+ File.write(group_file, JSON.pretty_generate(responseObj.content))
53
+ info("Exported group: #{group['name']} to #{group_file}")
54
+ end
55
+
56
+ # Export Groups
57
+ #
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
60
+ def export_groups(headers=header_basic_auth)
61
+ raise StandardError.new "An export directory must be defined to export groups." if @options[:export_directory].nil?
62
+ (find_groups.content["groups"] || []).each do |group|
63
+ export_group(group)
64
+ end
65
+ end
66
+
67
+ # Find all groups
68
+ #
69
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
70
+ # @param headers [Hash] hash of headers to send, default is basic authentication
71
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
72
+ def find_groups(params={}, headers=header_basic_auth)
73
+ info("Finding all groups")
74
+ get("#{@api_url}/groups", params, headers)
75
+ end
76
+
77
+ # Find Group
78
+ #
79
+ # @param name [String] name of the group
80
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
81
+ # @param headers [Hash] hash of headers to send, default is basic authentication
82
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
83
+ def find_group(name, params={}, headers=header_basic_auth)
84
+ info("Finding the #{name} group")
85
+ get("#{@api_url}/groups/#{encode(name)}", params, headers)
86
+ end
87
+
88
+ # Add user to group
89
+ #
90
+ # @param login_id [String] login id of the user
91
+ # @param group_name [String] name of the group
92
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
93
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
94
+ def add_user_to_group(login_id, group_name, headers=default_headers)
95
+ body = { "loginId" => login_id }
96
+ info("Adding user \"#{login_id}\" to group \"#{group_name}\"")
97
+ post("#{@api_url}/groups/#{encode(group_name)}/users", body, headers)
98
+ end
99
+
100
+ # Remove user from group
101
+ #
102
+ # @param login_id [String] login id of the user
103
+ # @param group_name [String] name of the group
104
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
105
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
106
+ def remove_user_from_group(login_id, group_name, headers=default_headers)
107
+ info("Removing user \"#{login_id}\" from group \"#{group_name}\"")
108
+ post("#{@api_url}/groups/#{encode(group_name)}/users/#{encode(login_id)}", headers)
109
+ end
110
+
111
+ end
112
+ end
@@ -0,0 +1,105 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Delete a Handler
5
+ #
6
+ # @param definition_id [String] the handler definition id
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
9
+ def delete_handler(definition_id, headers=header_basic_auth)
10
+ info("Deleting Handler \"#{definition_id}\"")
11
+ delete("#{@api_url}/handlers/#{definition_id}", headers)
12
+ end
13
+
14
+ # Delete all Handlers
15
+ #
16
+ # @param headers [Hash] hash of headers to send, default is basic authentication
17
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
18
+ def delete_handlers(headers=header_basic_auth)
19
+ info("Deleting all handlers")
20
+ (find_handlers(headers).content['handlers'] || []).each do |handler|
21
+ delete("#{@api_url}/handlers/#{handler['definition_id']}", headers)
22
+ end
23
+ end
24
+
25
+ # Find all handlers
26
+ #
27
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
28
+ # @param headers [Hash] hash of headers to send, default is basic authentication
29
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
30
+ def find_handlers(params={}, headers=header_basic_auth)
31
+ info("Find all handlers")
32
+ get("#{@api_url}/handlers", params, headers)
33
+ end
34
+
35
+ # Find a handler
36
+ #
37
+ # @param definition_id [String] the definition id of the handler
38
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
39
+ # @param headers [Hash] hash of headers to send, default is basic authentication
40
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
41
+ def find_handler(definition_id, params={}, headers=header_basic_auth)
42
+ info("Finding handler \"#{definition_id}\"")
43
+ get("#{@api_url}/handlers/#{definition_id}", params, headers)
44
+ end
45
+
46
+ # Import a handler file
47
+ #
48
+ # If the handler already exists on the server, this will fail unless forced to overwrite.
49
+ #
50
+ # @param handler [File] handler zip package file
51
+ # @param force_overwrite [Boolean] whether to overwrite a handler if it exists, default is false
52
+ # @param headers [Hash] hash of headers to send, default is basic authentication
53
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
54
+ def import_handler(handler, force_overwrite=false, headers=header_basic_auth)
55
+ body = { "package" => handler }
56
+ info("Importing Handler #{File.basename(handler)}")
57
+ post_multipart("#{@api_url}/handlers?force=#{force_overwrite}", body, headers)
58
+ end
59
+
60
+ # Modifies the properties and info values for a handler
61
+ #
62
+ # @param definition_id [String] the definition id of the handler
63
+ # @param body [Hash] the properties to update
64
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
65
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
66
+ def update_handler(definition_id, body, headers=default_headers)
67
+ info("Updating handler #{definition_id}")
68
+ put("#{@api_url}/handlers/#{definition_id}", body, headers)
69
+ end
70
+
71
+ # Export a single handler
72
+ #
73
+ # @param definition_id [String] the definition id of the handler
74
+ # @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
76
+ def export_handler(definition_id, headers=header_basic_auth)
77
+ 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]}.")
79
+ # Create the handler directory if it doesn't yet exist
80
+ handler_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "handlers"))
81
+ handler_file = File.join(handler_dir, "#{definition_id}.zip")
82
+ # write the file
83
+ File.open(handler_file, "wb") do |file|
84
+ file.write get("#{@api_url}/handlers/#{definition_id}/zip", {}, headers).content_string
85
+ end
86
+ info("Exported handler: #{definition_id} to #{handler_file}")
87
+ end
88
+
89
+ # Export all handlers
90
+ #
91
+ # @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
93
+ def export_handlers(headers=header_basic_auth)
94
+ 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]}.")
96
+ # Get the handler metadata to geta all handler_ids
97
+ response = find_handlers(headers)
98
+ # Parse the response and export each handler
99
+ (response.content["handlers"] || []).each do |handler|
100
+ export_handler(handler['definitionId'], headers)
101
+ end
102
+ end
103
+
104
+ end
105
+ end
@@ -0,0 +1,28 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Checks if the web application is alive
5
+ #
6
+ # @param url [String] the url to query for a 200 response code
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
9
+ def is_alive?(url, headers=header_basic_auth)
10
+ response = get(url, {}, headers)
11
+ response.status == 200
12
+ end
13
+
14
+ # Waits until the web server is alive
15
+ #
16
+ # @param url [String] the url to query for a 200 response code
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
19
+ def wait_until_alive(url, headers=header_basic_auth)
20
+ url = url[1..-1] if url.start_with?("/")
21
+ while !is_alive?("#{@api_url}/#{url}", headers) do
22
+ info("Web server \"#{@api_url}/#{url}\" is not ready, waiting...")
23
+ sleep 3
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,52 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Delete the license
5
+ #
6
+ # @param headers [Hash] hash of headers to send, default is basic authentication
7
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
8
+ def delete_license(headers=header_basic_auth)
9
+ info("Deleting the license")
10
+ delete("#{@api_url}/config/license", {}, headers)
11
+ end
12
+
13
+ # Find the license
14
+ #
15
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
16
+ # @param headers [Hash] hash of headers to send, default is basic authentication
17
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
18
+ def find_license(params={}, headers=header_basic_auth)
19
+ info("Finding the license")
20
+ get("#{@api_url}/config/license", params, headers)
21
+ end
22
+
23
+ # Update the license
24
+ #
25
+ # @param license_content [String] the content of the license file
26
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
27
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
28
+ def update_license(license_content, headers=default_headers)
29
+ body = { "licenseContent" => license_content }
30
+ info("Updating license")
31
+ post("#{@api_url}/config/license", body, headers)
32
+ end
33
+
34
+ # Imports the license file
35
+ #
36
+ # @param license [String|File] Either the license file path (String), or the license file (File)
37
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
38
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
39
+ def import_license(license, headers=default_headers)
40
+ if license.is_a? File
41
+ update_license(license.read, headers)
42
+ else
43
+ if File.exists? license
44
+ update_license(File.read(license), headers)
45
+ else
46
+ info(" * License file \"#{license}\" does not exist.")
47
+ end
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,166 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Add a policy Rule
5
+ #
6
+ # @param policy [Hash] hash of properties for the new policy rule
7
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
8
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
+ #
10
+ # Example
11
+ #
12
+ # add_policy_rule({
13
+ # "name" => "Foo",
14
+ # "type" => "Console Access | Category Access | API Access | System Default",
15
+ # "rule" => "...",
16
+ # "message" => "..."
17
+ # })
18
+ #
19
+ def add_policy_rule(policy, headers=default_headers)
20
+ info("Adding policy rule \"#{policy['type']} - #{policy['name']}\"")
21
+ post("#{@api_url}/policyRules/#{encode(policy['type'])}", policy, headers)
22
+ end
23
+
24
+ # Delete a Policy Rule.
25
+ #
26
+ # @param policy [Hash] hash of policy type and name
27
+ # - +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
28
+ # - +name+ - Policy Rule name
29
+ # @param headers [Hash] hash of headers to send, default is basic authentication
30
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
31
+ #
32
+ # Example
33
+ #
34
+ # delete_policy_rule({
35
+ # "type" => "API Access",
36
+ # "name" => "Company Network"
37
+ # })
38
+ #
39
+ def delete_policy_rule(policy, headers=header_basic_auth)
40
+ info("Deleting policy rule \"#{policy['type']} - #{policy['name']}\"")
41
+ delete("#{@api_url}/policyRules/#{encode(policy['type'])}/#{encode(policy['name'])}", headers)
42
+ end
43
+
44
+ # Delete all Policy Rules.
45
+ #
46
+ # @param headers [Hash] hash of headers to send, default is basic authentication
47
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
48
+ def delete_policy_rules(headers=header_basic_auth)
49
+ info("Deleting all policy rules")
50
+ (find_policy_rules(headers).content["policyRules"] || []).each do |policy_rule|
51
+ delete_policy_rule({
52
+ "type" => policy_rule['type'],
53
+ "name" => policy_rule['name']
54
+ }, headers)
55
+ end
56
+ end
57
+
58
+ # Export a Policy Rule
59
+ #
60
+ # @param policy_rule [Hash] Policy Rule properties that must contain at least the name and type
61
+ # - +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
62
+ # - +name+ - Policy Rule name to export
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
65
+ def export_policy_rule(policy_rule, headers=header_basic_auth)
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]}.")
68
+ # Create the policy rules directory if it doesn't yet exist
69
+ dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "policyRules"))
70
+ file = File.join(dir, "#{policy_rule['type'].slugify}-#{policy_rule['name'].slugify}.json")
71
+
72
+ unless policy_rule.has_key?("consolePolicyRules")
73
+ response = find_policy_rule(
74
+ { "type" => policy_rule['type'], "name" => policy_rule['name'] },
75
+ { "include" => "consolePolicyRules" },
76
+ headers
77
+ )
78
+ if response.status != 200
79
+ info("Failed to export policy rule: #{policy_rule['type']} - #{policy_rule['name']}: #{response.inspect}")
80
+ policy_rule = nil
81
+ else
82
+ policy_rule = response.content
83
+ end
84
+ end
85
+
86
+ unless policy_rule.nil?
87
+ # write the file
88
+ File.write(file, JSON.pretty_generate(policy_rule))
89
+ info("Exported policy rule: #{policy_rule['type']} - #{policy_rule['name']} to #{file}")
90
+ end
91
+ end
92
+
93
+ # Export Policy Rules
94
+ #
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
97
+ def export_policy_rules(headers=header_basic_auth)
98
+ raise StandardError.new "An export directory must be defined to export policy rules." if @options[:export_directory].nil?
99
+ response = find_policy_rules({"include" => "consolePolicyRules"}, headers)
100
+ (response.content["policyRules"] || []).each do |policy_rule|
101
+ export_policy_rule(policy_rule, headers)
102
+ end
103
+ end
104
+
105
+ # Find Policy Rules.
106
+ #
107
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
108
+ # @param headers [Hash] hash of headers to send, default is basic authentication
109
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
110
+ def find_policy_rules(params={}, headers=header_basic_auth)
111
+ info("Finding Policy Rules")
112
+ policy_rules = []
113
+ response = nil
114
+ ["API Access", "Category Access", "Console Access", "System Default"].each do |type|
115
+ response = get("#{@api_url}/policyRules/#{encode(type)}", params, headers)
116
+ policy_rules.concat(response.content["policyRules"] || [])
117
+ end
118
+ final_content = { "policyRules" => policy_rules }
119
+ response.content= final_content
120
+ response.content_string= final_content.to_json
121
+ response
122
+ end
123
+
124
+
125
+ # Find a policy rule
126
+ #
127
+ # @param policy_rule [Hash] Policy Rule properties that must contain at least the name and type
128
+ # - +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
129
+ # - +name+ - Policy Rule name to export
130
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
131
+ # @param headers [Hash] hash of headers to send, default is basic authentication
132
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
133
+ #
134
+ # Exammple
135
+ #
136
+ # find_policy_rule({ "type" => "API Access", "name" => "Allow All"})
137
+ #
138
+ def find_policy_rule(policy_rule, params={}, headers=header_basic_auth)
139
+ info("Finding the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
140
+ get("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", params, headers)
141
+ end
142
+
143
+
144
+ # Update a Policy Rule
145
+ #
146
+ # @param policy_rule [Hash] Policy Rule properties that must contain the name and type
147
+ # - +type+ - Policy Rule type ( API Access | Console Access | Category Access | System Default )
148
+ # - +name+ - Policy Rule name to export
149
+ # @param body [Hash] Policy rule properties to update
150
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
151
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
152
+ #
153
+ # Exammple
154
+ #
155
+ # update_policy_rule(
156
+ # { "type" => "API Access", "name" => "Allow All" },
157
+ # { "rule" => "false" }
158
+ # )
159
+ #
160
+ def update_policy_rule(policy_rule, body={}, headers=default_headers)
161
+ info("Updating the \"#{policy_rule['type']} - #{policy_rule['name']}\" Policy Rule")
162
+ put("#{@api_url}/policyRules/#{encode(policy_rule['type'])}/#{encode(policy_rule['name'])}", body, headers)
163
+ end
164
+
165
+ end
166
+ end
@@ -0,0 +1,56 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Test the database connection
5
+ #
6
+ # @param db [Hash] Database configuration seettings to send as the request body
7
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
8
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
9
+ #
10
+ # Example
11
+ #
12
+ # {
13
+ # "type": "PostgreSQL",
14
+ # "properties": {
15
+ # "host": "mydbserver.company.com",
16
+ # "port": "5432",
17
+ # "database": "kinetictask",
18
+ # "username": "TaskUser",
19
+ # "password": "TaskPassword1"
20
+ # }
21
+ # }
22
+ #
23
+ def test_db_connection(db={}, headers=default_headers)
24
+ info("Testing database connection")
25
+ response = post("#{@api_url}/setup/db/test", db, headers)
26
+ response.content
27
+ end
28
+
29
+
30
+ # Run the database migrations
31
+ #
32
+ # @param db [Hash] Database configuration seettings to send as the request body
33
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
34
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
35
+ #
36
+ # Example
37
+ #
38
+ # {
39
+ # "type": "PostgreSQL",
40
+ # "properties": {
41
+ # "host": "mydbserver.company.com",
42
+ # "port": "5432",
43
+ # "database": "kinetictask",
44
+ # "username": "TaskUser",
45
+ # "password": "TaskPassword1"
46
+ # }
47
+ # }
48
+ #
49
+ def migrate_db(db={}, headers=default_headers)
50
+ info("Running database migrations")
51
+ response = post("#{@api_url}/setup/db/migrate", db, headers)
52
+ response.content
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,134 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Add a source
5
+ #
6
+ # @param source [Hash] Source properties
7
+ # - +name+ - name of the source
8
+ # - +status+ - initial status of the source (Active | Inactive)
9
+ # - +type+ - name of one of the source consumers registered in the task engine
10
+ # - +properties+ - hash of properties specific to the source consumer
11
+ # - +policyRules+ - array of policy rules to associate with the source
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
+ #
15
+ # Example
16
+ #
17
+ # add_source({
18
+ # "name" => "Source Name",
19
+ # "status" => "Active",
20
+ # "type" => "Kinetic Request CE",
21
+ # "properties" => {
22
+ # "Space Slug" => "foo",
23
+ # "Web Server" => "http://localhost:8080/kinetic",
24
+ # "Proxy Username" => "integration-user",
25
+ # "Proxy Password" => "integration-password"
26
+ # },
27
+ # "policyRules" => []
28
+ # })
29
+ #
30
+ def add_source(source, headers=default_headers)
31
+ name = source['name']
32
+ info("Adding the #{name} source")
33
+ post("#{@api_url}/sources", source, headers)
34
+ end
35
+
36
+ # Delete a Source
37
+ #
38
+ # @param name [String] name of the source
39
+ # @param headers [Hash] hash of headers to send, default is basic authentication
40
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
41
+ def delete_source(name, headers=header_basic_auth)
42
+ info("Deleting Source \"#{name}\"")
43
+ delete("#{@api_url}/sources/#{encode(name)}", headers)
44
+ end
45
+
46
+ # Delete all Sources
47
+ #
48
+ # @param headers [Hash] hash of headers to send, default is basic authentication
49
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
50
+ def delete_sources(headers=header_basic_auth)
51
+ info("Deleting all sources")
52
+ (find_sources(headers).content['sources'] || []).each do |source|
53
+ delete("#{@api_url}/sources/#{encode(source['name'])}", headers)
54
+ end
55
+ end
56
+
57
+ # Find all sources
58
+ #
59
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
60
+ # @param headers [Hash] hash of headers to send, default is basic authentication
61
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
62
+ def find_sources(params={}, headers=header_basic_auth)
63
+ info("Finding all sources")
64
+ get("#{@api_url}/sources", params, headers)
65
+ end
66
+
67
+ # Find a source
68
+ #
69
+ # @param name [String] name of the source
70
+ # @param params [Hash] Query parameters that are added to the URL, such as +include+
71
+ # @param headers [Hash] hash of headers to send, default is basic authentication
72
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
73
+ def find_source(name, params={}, headers=header_basic_auth)
74
+ info("Finding source named \"#{name}\"")
75
+ get("#{@api_url}/sources/#{encode(name)}", params, headers)
76
+ end
77
+
78
+ # Update a source
79
+ #
80
+ # @param source [Hash] hash of existing source properties that must contain 'name'
81
+ # - +name+ - name of the source
82
+ # @param body [Hash] - source properties to update
83
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
84
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
85
+ #
86
+ # Exammple
87
+ #
88
+ # update_source(
89
+ # { "name" => "Kinetic Request CE" },
90
+ # {
91
+ # "name": "Possible New Source Name",
92
+ # "status": "Active|Unconfigured",
93
+ # "type": "Adhoc|...",
94
+ # "properties": {},
95
+ # "policyRules": [
96
+ # { "type": "API Access", "name": "Super User" },
97
+ # { "type": "API Access", "name": "Info User" },
98
+ # { "type": "Console Access", "name": "Super User" }
99
+ # ]
100
+ # }
101
+ # )
102
+ #
103
+ def update_source(source, body={}, headers=default_headers)
104
+ info("Updating the \"#{source['name']}\" Source")
105
+ put("#{@api_url}/sources/#{encode(source['name'])}", body, headers)
106
+ end
107
+
108
+ # Add policy rule to source
109
+ #
110
+ # @param policy_rule_type [String] the type of policy rule
111
+ # @param policy_rule_name [String] the name of the policy rule
112
+ # @param source_name [String] name of the source to add the policy rule to
113
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
114
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
115
+ def add_policy_rule_to_source(policy_rule_type, policy_rule_name, source_name, headers=default_headers)
116
+ body = { "type" => policy_rule_type, "name" => policy_rule_name }
117
+ info("Adding policy rule \"#{policy_rule_type} - #{policy_rule_name}\" to source \"#{source_name}\"")
118
+ post("#{@api_url}/sources/#{encode(source_name)}/policyRules", body, headers)
119
+ end
120
+
121
+ # Remove policy rule from source
122
+ #
123
+ # @param policy_rule_type [String] the type of policy rule
124
+ # @param policy_rule_name [String] the name of the policy rule
125
+ # @param source_name [String] name of the source to add the policy rule to
126
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
127
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
128
+ def remove_policy_rule_from_source(policy_rule_type, policy_rule_name, source_name, headers=default_headers)
129
+ info("Removing policy rule \"#{policy_rule_type} - #{policy_rule_name}\" from source \"#{source_name}\"")
130
+ delete("#{@api_url}/sources/#{encode(source_name)}/policyRules/#{encode(policy_rule_type)}/#{encode(policy_rule_name)}", headers)
131
+ end
132
+
133
+ end
134
+ end
@@ -0,0 +1,17 @@
1
+ module KineticSdk
2
+ class Task
3
+
4
+ # Complete a Deferred Task
5
+ #
6
+ # @param source_name [String] - name of the source
7
+ # @param body [Hash] properties that are sent to update the task
8
+ # - +token+ - the token linked to the deferred task
9
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
10
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
11
+ def complete_deferred_task(source_name, body, headers=default_headers)
12
+ info("Completing deferred task for the \"#{source_name}\" Source.")
13
+ post("#{@api_v1_url}/complete-deferred-task/#{encode(source_name)}", body, headers)
14
+ end
15
+
16
+ end
17
+ end