kinetic_sdk 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/GettingStarted.md +64 -0
- data/README.md +383 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/gems/kontena-websocket-client-0.1.1/Gemfile +4 -0
- data/gems/kontena-websocket-client-0.1.1/LICENSE +190 -0
- data/gems/kontena-websocket-client-0.1.1/README.md +138 -0
- data/gems/kontena-websocket-client-0.1.1/Rakefile +6 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-client.rb +45 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark-em.rb +66 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.rb +161 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/benchmark.sh +17 -0
- data/gems/kontena-websocket-client-0.1.1/benchmark/websocket-echo-server.go +207 -0
- data/gems/kontena-websocket-client-0.1.1/examples/websocket-echo-client.rb +80 -0
- data/gems/kontena-websocket-client-0.1.1/kontena-websocket-client.gemspec +24 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/connection.rb +119 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client/version.rb +13 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/client.rb +848 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/error.rb +81 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/logging.rb +55 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena/websocket/openssl_patch.rb +10 -0
- data/gems/kontena-websocket-client-0.1.1/lib/kontena-websocket-client.rb +15 -0
- data/gems/mime-types-3.1/Code-of-Conduct.rdoc +74 -0
- data/gems/mime-types-3.1/Contributing.rdoc +130 -0
- data/gems/mime-types-3.1/History.rdoc +658 -0
- data/gems/mime-types-3.1/Licence.rdoc +25 -0
- data/gems/mime-types-3.1/Manifest.txt +31 -0
- data/gems/mime-types-3.1/README.rdoc +202 -0
- data/gems/mime-types-3.1/Rakefile +254 -0
- data/gems/mime-types-3.1/lib/mime/type/columnar.rb +55 -0
- data/gems/mime-types-3.1/lib/mime/type.rb +573 -0
- data/gems/mime-types-3.1/lib/mime/types/_columnar.rb +135 -0
- data/gems/mime-types-3.1/lib/mime/types/cache.rb +56 -0
- data/gems/mime-types-3.1/lib/mime/types/columnar.rb +1 -0
- data/gems/mime-types-3.1/lib/mime/types/container.rb +30 -0
- data/gems/mime-types-3.1/lib/mime/types/deprecations.rb +32 -0
- data/gems/mime-types-3.1/lib/mime/types/full.rb +17 -0
- data/gems/mime-types-3.1/lib/mime/types/loader.rb +148 -0
- data/gems/mime-types-3.1/lib/mime/types/logger.rb +37 -0
- data/gems/mime-types-3.1/lib/mime/types/registry.rb +81 -0
- data/gems/mime-types-3.1/lib/mime/types.rb +228 -0
- data/gems/mime-types-3.1/lib/mime-types.rb +1 -0
- data/gems/mime-types-3.1/test/bad-fixtures/malformed +9 -0
- data/gems/mime-types-3.1/test/fixture/json.json +1 -0
- data/gems/mime-types-3.1/test/fixture/old-data +9 -0
- data/gems/mime-types-3.1/test/fixture/yaml.yaml +55 -0
- data/gems/mime-types-3.1/test/minitest_helper.rb +13 -0
- data/gems/mime-types-3.1/test/test_mime_type.rb +603 -0
- data/gems/mime-types-3.1/test/test_mime_types.rb +161 -0
- data/gems/mime-types-3.1/test/test_mime_types_cache.rb +109 -0
- data/gems/mime-types-3.1/test/test_mime_types_class.rb +155 -0
- data/gems/mime-types-3.1/test/test_mime_types_lazy.rb +43 -0
- data/gems/mime-types-3.1/test/test_mime_types_loader.rb +32 -0
- data/gems/mime-types-data-3.2016.0521/Code-of-Conduct.md +75 -0
- data/gems/mime-types-data-3.2016.0521/Contributing.md +157 -0
- data/gems/mime-types-data-3.2016.0521/History.md +351 -0
- data/gems/mime-types-data-3.2016.0521/Licence.md +25 -0
- data/gems/mime-types-data-3.2016.0521/Manifest.txt +18 -0
- data/gems/mime-types-data-3.2016.0521/README.md +61 -0
- data/gems/mime-types-data-3.2016.0521/Rakefile +80 -0
- data/gems/mime-types-data-3.2016.0521/data/mime-types.json +1 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.content_type.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.docs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.encoding.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.flags.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.friendly.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.pext.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.use_instead.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/data/mime.xrefs.column +1964 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime/types/data.rb +21 -0
- data/gems/mime-types-data-3.2016.0521/lib/mime-types-data.rb +3 -0
- data/gems/multipart-post-2.0.0/Gemfile +14 -0
- data/gems/multipart-post-2.0.0/History.txt +60 -0
- data/gems/multipart-post-2.0.0/Manifest.txt +9 -0
- data/gems/multipart-post-2.0.0/README.md +77 -0
- data/gems/multipart-post-2.0.0/Rakefile +9 -0
- data/gems/multipart-post-2.0.0/lib/composite_io.rb +108 -0
- data/gems/multipart-post-2.0.0/lib/multipart_post.rb +9 -0
- data/gems/multipart-post-2.0.0/lib/multipartable.rb +29 -0
- data/gems/multipart-post-2.0.0/lib/net/http/post/multipart.rb +27 -0
- data/gems/multipart-post-2.0.0/lib/parts.rb +96 -0
- data/gems/multipart-post-2.0.0/multipart-post.gemspec +22 -0
- data/gems/multipart-post-2.0.0/test/multibyte.txt +1 -0
- data/gems/multipart-post-2.0.0/test/net/http/post/test_multipart.rb +110 -0
- data/gems/multipart-post-2.0.0/test/test_composite_io.rb +115 -0
- data/gems/multipart-post-2.0.0/test/test_parts.rb +86 -0
- data/gems/parallel-1.12.1/MIT-LICENSE.txt +20 -0
- data/gems/parallel-1.12.1/lib/parallel/processor_count.rb +93 -0
- data/gems/parallel-1.12.1/lib/parallel/version.rb +3 -0
- data/gems/parallel-1.12.1/lib/parallel.rb +500 -0
- data/gems/ruby-progressbar-1.9.0/LICENSE.txt +19 -0
- data/gems/ruby-progressbar-1.9.0/README.md +38 -0
- data/gems/ruby-progressbar-1.9.0/Rakefile +2 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/base.rb +183 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/length.rb +99 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/calculators/running_average.rb +9 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/bar.rb +96 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/percentage.rb +29 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/rate.rb +43 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/time.rb +107 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components/title.rb +13 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/components.rb +5 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/errors/invalid_progress_error.rb +4 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/formatter.rb +27 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/molecule.rb +59 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format/string.rb +36 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/format.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/output.rb +68 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/non_tty.rb +47 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/null.rb +33 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/outputs/tty.rb +32 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/progress.rb +118 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements/enumerator.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/refinements.rb +1 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/throttle.rb +25 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/time.rb +30 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/timer.rb +72 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar/version.rb +3 -0
- data/gems/ruby-progressbar-1.9.0/lib/ruby-progressbar.rb +18 -0
- data/gems/slugify-1.0.7/README +18 -0
- data/gems/slugify-1.0.7/lib/slugify.rb +1012 -0
- data/gems/slugify-1.0.7/lib/slugify_string.rb +11 -0
- data/gems/slugify-1.0.7/tests/slugify_test.rb +116 -0
- data/gems/slugify-1.0.7/tests/string_slugify_test.rb +23 -0
- data/gems/websocket-driver-0.6.5/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5/README.md +369 -0
- data/gems/websocket-driver-0.6.5/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/Makefile +264 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5/ext/websocket-driver/websocket_mask.o +0 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5/lib/websocket_mask.bundle +0 -0
- data/gems/websocket-driver-0.6.5-java/CHANGELOG.md +123 -0
- data/gems/websocket-driver-0.6.5-java/LICENSE.md +22 -0
- data/gems/websocket-driver-0.6.5-java/README.md +369 -0
- data/gems/websocket-driver-0.6.5-java/examples/tcp_server.rb +28 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/WebsocketMaskService.java +55 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/extconf.rb +4 -0
- data/gems/websocket-driver-0.6.5-java/ext/websocket-driver/websocket_mask.c +41 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/client.rb +140 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft75.rb +102 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/draft76.rb +96 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/event_emitter.rb +54 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/headers.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/frame.rb +20 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi/message.rb +31 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/hybi.rb +406 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/proxy.rb +68 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/server.rb +80 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver/stream_reader.rb +55 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/driver.rb +199 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/headers.rb +112 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/request.rb +45 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http/response.rb +29 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/http.rb +15 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/mask.rb +14 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket/websocket_mask.rb +2 -0
- data/gems/websocket-driver-0.6.5-java/lib/websocket_mask.jar +0 -0
- data/gems/websocket-extensions-0.1.3/CHANGELOG.md +15 -0
- data/gems/websocket-extensions-0.1.3/LICENSE.md +20 -0
- data/gems/websocket-extensions-0.1.3/README.md +313 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions/parser.rb +111 -0
- data/gems/websocket-extensions-0.1.3/lib/websocket/extensions.rb +181 -0
- data/lib/kinetic-sdk.rb +1 -0
- data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +69 -0
- data/lib/kinetic_sdk/discussions/discussions-sdk.rb +165 -0
- data/lib/kinetic_sdk/discussions/lib/discussions.rb +107 -0
- data/lib/kinetic_sdk/discussions/lib/invitations.rb +120 -0
- data/lib/kinetic_sdk/discussions/lib/messages.rb +190 -0
- data/lib/kinetic_sdk/discussions/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/discussions/lib/participants.rb +64 -0
- data/lib/kinetic_sdk/discussions/lib/related_items.rb +54 -0
- data/lib/kinetic_sdk/discussions/lib/websockets.rb +96 -0
- data/lib/kinetic_sdk/filehub/filehub-sdk.rb +80 -0
- data/lib/kinetic_sdk/filehub/lib/access_keys.rb +67 -0
- data/lib/kinetic_sdk/filehub/lib/filestores.rb +67 -0
- data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +153 -0
- data/lib/kinetic_sdk/request_ce/lib/bridges.rb +66 -0
- data/lib/kinetic_sdk/request_ce/lib/categories.rb +34 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_form.rb +110 -0
- data/lib/kinetic_sdk/request_ce/lib/datastore_submissions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/form.rb +99 -0
- data/lib/kinetic_sdk/request_ce/lib/form_types.rb +51 -0
- data/lib/kinetic_sdk/request_ce/lib/jwt.rb +55 -0
- data/lib/kinetic_sdk/request_ce/lib/kapp.rb +93 -0
- data/lib/kinetic_sdk/request_ce/lib/meta.rb +14 -0
- data/lib/kinetic_sdk/request_ce/lib/oauth.rb +37 -0
- data/lib/kinetic_sdk/request_ce/lib/security_policy_definitions.rb +157 -0
- data/lib/kinetic_sdk/request_ce/lib/space.rb +89 -0
- data/lib/kinetic_sdk/request_ce/lib/submissions.rb +215 -0
- data/lib/kinetic_sdk/request_ce/lib/system_api.rb +69 -0
- data/lib/kinetic_sdk/request_ce/lib/teams.rb +113 -0
- data/lib/kinetic_sdk/request_ce/lib/users.rb +245 -0
- data/lib/kinetic_sdk/request_ce/lib/webhook_jobs.rb +142 -0
- data/lib/kinetic_sdk/request_ce/lib/webhooks.rb +192 -0
- data/lib/kinetic_sdk/request_ce/request-ce-sdk.rb +153 -0
- data/lib/kinetic_sdk/task/lib/access_keys.rb +94 -0
- data/lib/kinetic_sdk/task/lib/categories.rb +190 -0
- data/lib/kinetic_sdk/task/lib/config.rb +202 -0
- data/lib/kinetic_sdk/task/lib/engine.rb +42 -0
- data/lib/kinetic_sdk/task/lib/environment.rb +14 -0
- data/lib/kinetic_sdk/task/lib/errors.rb +165 -0
- data/lib/kinetic_sdk/task/lib/groups.rb +112 -0
- data/lib/kinetic_sdk/task/lib/handlers.rb +105 -0
- data/lib/kinetic_sdk/task/lib/health.rb +28 -0
- data/lib/kinetic_sdk/task/lib/license.rb +52 -0
- data/lib/kinetic_sdk/task/lib/policy_rules.rb +166 -0
- data/lib/kinetic_sdk/task/lib/setup.rb +56 -0
- data/lib/kinetic_sdk/task/lib/sources.rb +134 -0
- data/lib/kinetic_sdk/task/lib/tasks.rb +17 -0
- data/lib/kinetic_sdk/task/lib/trees.rb +274 -0
- data/lib/kinetic_sdk/task/lib/users.rb +75 -0
- data/lib/kinetic_sdk/task/task-sdk.rb +92 -0
- data/lib/kinetic_sdk/utils/kinetic-http-headers.rb +150 -0
- data/lib/kinetic_sdk/utils/kinetic-http-response.rb +75 -0
- data/lib/kinetic_sdk/utils/kinetic-http.rb +552 -0
- data/lib/kinetic_sdk/utils/logger.rb +70 -0
- data/lib/kinetic_sdk/utils/random.rb +30 -0
- data/lib/kinetic_sdk/version.rb +7 -0
- data/lib/kinetic_sdk.rb +57 -0
- metadata +414 -0
@@ -0,0 +1,190 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Discussions
|
3
|
+
|
4
|
+
# Add a Message without attachments
|
5
|
+
#
|
6
|
+
# If message parameter is a Hash, it assumes the message contains the
|
7
|
+
# `content` property set to an array of the expected tokens (`type`
|
8
|
+
# and `value` properties).
|
9
|
+
#
|
10
|
+
# If message parameter is an Array, it assumes the message contains
|
11
|
+
# the array of expected tokens (`type` and `value` properties).
|
12
|
+
#
|
13
|
+
# If message parameter is a string, it builds up the message `content`
|
14
|
+
# property as a single `text` token with the value of the message
|
15
|
+
# parameter.
|
16
|
+
#
|
17
|
+
# @param discussion_id [String] id of the discussion
|
18
|
+
# @param message [String | Hash | Array] message
|
19
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
20
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
21
|
+
def add_message(discussion_id, message, headers=default_jwt_headers)
|
22
|
+
payload = message_content(message)
|
23
|
+
info("Adding a message to the #{discussion_id} Discussion")
|
24
|
+
post("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Add a Message with attachments
|
28
|
+
#
|
29
|
+
# If properties['message'] parameter is a Hash, it assumes the message
|
30
|
+
# contains the `content` property set to an array of the expected tokens
|
31
|
+
# (`type` and `value` properties).
|
32
|
+
#
|
33
|
+
# If properties['message'] parameter is an Array, it assumes the message
|
34
|
+
# contains the array of expected tokens (`type` and `value` properties).
|
35
|
+
#
|
36
|
+
# If properties['message'] parameter is a string, it builds up the message
|
37
|
+
# `content` property as a single `text` token with the value of the
|
38
|
+
# properties['message'] parameter.
|
39
|
+
#
|
40
|
+
# @param discussion_id [String] id of the discussion
|
41
|
+
# @param properties [Hash] message properties
|
42
|
+
# - +message+ [String | Hash | Array] message
|
43
|
+
# - +attachments+ [File[]]
|
44
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
45
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
46
|
+
def add_message_with_attachments(discussion_id, properties={}, headers=default_jwt_headers)
|
47
|
+
payload = message_content(properties['message'])
|
48
|
+
payload["attachments"] = properties['attachments']
|
49
|
+
info("Adding a message to the #{discussion_id} Discussion")
|
50
|
+
post_multipart("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Find Messages in a Discussion
|
54
|
+
#
|
55
|
+
# @param discussion_id [String] id of the discussion
|
56
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
57
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
58
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
59
|
+
def find_messages(discussion_id, params={}, headers=default_jwt_headers)
|
60
|
+
info("Finding messages in the #{discussion_id} Discussion")
|
61
|
+
get("#{@api_url}/discussions/#{discussion_id}/messages", params, headers)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Find a Message in a Discussion
|
65
|
+
#
|
66
|
+
# @param discussion_id [String] id of the discussion
|
67
|
+
# @param message_id [String] id of the message
|
68
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
69
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
70
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
71
|
+
def find_message(discussion_id, message_id, params={}, headers=default_jwt_headers)
|
72
|
+
info("Finding the #{message_id} message in the #{discussion_id} Discussion")
|
73
|
+
get("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", params, headers)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Update a Message without new attachments
|
77
|
+
#
|
78
|
+
# If message parameter is a Hash, it assumes the message contains the
|
79
|
+
# `content` property set to an array of the expected tokens (`type`
|
80
|
+
# and `value` properties).
|
81
|
+
#
|
82
|
+
# If message parameter is an Array, it assumes the message contains
|
83
|
+
# the array of expected tokens (`type` and `value` properties).
|
84
|
+
#
|
85
|
+
# If message parameter is a string, it builds up the message `content`
|
86
|
+
# property as a single `text` token with the value of the message
|
87
|
+
# parameter.
|
88
|
+
#
|
89
|
+
# @param discussion_id [String] id of the discussion
|
90
|
+
# @param message_id [String] id of the message
|
91
|
+
# @param message [String | Hash | Array] updated content of the message
|
92
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
93
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
94
|
+
def update_message(discussion_id, message_id, message, headers=default_jwt_headers)
|
95
|
+
payload = message_content(message)
|
96
|
+
info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
97
|
+
put("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", payload, headers)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Update a Message with new attachments
|
101
|
+
#
|
102
|
+
# If message parameter is a Hash, it assumes the message contains the
|
103
|
+
# `content` property set to an array of the expected tokens (`type`
|
104
|
+
# and `value` properties).
|
105
|
+
#
|
106
|
+
# If message parameter is an Array, it assumes the message contains
|
107
|
+
# the array of expected tokens (`type` and `value` properties).
|
108
|
+
#
|
109
|
+
# If message parameter is a string, it builds up the message `content`
|
110
|
+
# property as a single `text` token with the value of the message
|
111
|
+
# parameter.
|
112
|
+
#
|
113
|
+
# @param discussion_id [String] id of the discussion
|
114
|
+
# @param message_id [String] id of the message
|
115
|
+
# @param message [String | Hash | Array] updated content of the message
|
116
|
+
# @param attachments [File[]] new attachments to add to the message
|
117
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
118
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
119
|
+
def update_message_with_attachments(discussion_id, message_id, message, attachments=[], headers=header_bearer_auth)
|
120
|
+
payload = { "message" => message_content(message).to_json, "attachments" => attachments }
|
121
|
+
info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
122
|
+
post_multipart("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", payload, headers)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Download a message attachment
|
126
|
+
#
|
127
|
+
# **WARNING** This method downloads the entire attachment into memory. This
|
128
|
+
# may cause problems with large files. To stream the attachment in chunks to
|
129
|
+
# avoid consuming large amounts of memory, see the
|
130
|
+
# {export_message_attachment} method.
|
131
|
+
#
|
132
|
+
# @param discussion_id [String] id of the discussion
|
133
|
+
# @param message_id [String] id of the message
|
134
|
+
# @param document_id [String] id of the document in the filestore
|
135
|
+
# @param filename [String] default name to use for the downloaded file
|
136
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
137
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
138
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
139
|
+
def download_message_attachment(discussion_id, message_id, document_id, filename, params={}, headers=header_bearer_auth)
|
140
|
+
info("Downloading the #{filename} file attachment in the #{discussion_id} Discussion")
|
141
|
+
get("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}/files/#{document_id}/#{filename}", params, headers)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Export a message attachment
|
145
|
+
#
|
146
|
+
# This method streams the attachment in chunks to avoid consuming large
|
147
|
+
# amounts of memory.
|
148
|
+
#
|
149
|
+
# The message attachment will be saved to the
|
150
|
+
# `{export_directory}/{discussion_id}/files/{message_id}` directory, where:
|
151
|
+
#
|
152
|
+
# * +export_directory+: the directory specified in the SDK configuration
|
153
|
+
# * +discussion_id+: the id of the discussion
|
154
|
+
# * +message_id+: the id of the message that contains the attachment
|
155
|
+
#
|
156
|
+
# If you want to work with the attachment in code rather than automatically
|
157
|
+
# save it to a file, see the {download_message_attachment} method.
|
158
|
+
#
|
159
|
+
# @param discussion_id [String] id of the discussion
|
160
|
+
# @param message_id [String] id of the message
|
161
|
+
# @param document_id [String] id of the document in the filestore
|
162
|
+
# @param filename [String] default name to use for the downloaded file
|
163
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
164
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
165
|
+
def export_message_attachment(discussion_id, message_id, document_id, filename, params={}, headers=header_bearer_auth)
|
166
|
+
raise StandardError.new "An export directory must be defined to export a file attachment." if @options[:export_directory].nil?
|
167
|
+
info("Exporting the #{filename} file attachment in the #{discussion_id} Discussion")
|
168
|
+
# Create the export directory if it doesn't yet exist
|
169
|
+
export_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], discussion_id, "files", message_id))
|
170
|
+
export_file = File.join(export_dir, filename)
|
171
|
+
url = "#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}/files/#{document_id}/#{filename}"
|
172
|
+
stream_download_to_file(export_file, url, params, headers)
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
private
|
177
|
+
|
178
|
+
def message_content(message)
|
179
|
+
case message.class.name
|
180
|
+
when 'Hash'
|
181
|
+
message
|
182
|
+
when 'Array'
|
183
|
+
{ "content" => message }
|
184
|
+
else
|
185
|
+
{ "content" => [{ "type": "text", "value": message }] }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
190
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Discussions
|
3
|
+
|
4
|
+
# Retrieve Discussions application version
|
5
|
+
#
|
6
|
+
# @param headers [Hash] hash of headers to send, default is accept JSON content type
|
7
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
8
|
+
def app_version(headers=header_accept_json)
|
9
|
+
info("Retrieving Discussions application version.")
|
10
|
+
get("#{@api_url}/version", {}, headers)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Discussions
|
3
|
+
|
4
|
+
# Create a participant for an existing user
|
5
|
+
#
|
6
|
+
# @param discussion_id [String] id of the discussion
|
7
|
+
# @param username [String] username of the user
|
8
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
9
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
10
|
+
def add_participant(discussion_id, username, headers=default_jwt_headers)
|
11
|
+
payload = { "username" => username }
|
12
|
+
info("Participant #{username} joining the #{discussion_id} Discussion")
|
13
|
+
post("#{@api_url}/discussions/#{discussion_id}/participants", payload, headers)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Delete a participant
|
17
|
+
#
|
18
|
+
# @param discussion_id [String] id of the discussion
|
19
|
+
# @param username [String] username of the participant
|
20
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
21
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
22
|
+
def delete_participant(discussion_id, username, headers=header_bearer_auth)
|
23
|
+
info("Participant #{username} is leaving the #{discussion_id} Discussion")
|
24
|
+
delete("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Find participants in a discussion
|
28
|
+
#
|
29
|
+
# @param discussion_id [String] id of the discussion
|
30
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
31
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
32
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
33
|
+
def find_participants(discussion_id, params={}, headers=default_jwt_headers)
|
34
|
+
info("Finding Participants in the #{discussion_id} Discussion")
|
35
|
+
get("#{@api_url}/discussions/#{discussion_id}/participants", params, headers)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Find a participant in a discussion
|
39
|
+
#
|
40
|
+
# @param discussion_id [String] id of the discussion
|
41
|
+
# @param username [String] username of the participant
|
42
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
43
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
44
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
45
|
+
def find_participant(discussion_id, username, params={}, headers=default_jwt_headers)
|
46
|
+
info("Finding the #{username} Participant in the #{discussion_id} Discussion")
|
47
|
+
get("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", params, headers)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Update a participant in a discussion
|
51
|
+
#
|
52
|
+
# @param discussion_id [String] id of the discussion
|
53
|
+
# @param username [String] username of the participant
|
54
|
+
# @param properties [Hash] participant properties to update
|
55
|
+
# - +isMuted+
|
56
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
57
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
58
|
+
def update_participant(discussion_id, username, properties={}, headers=default_jwt_headers)
|
59
|
+
info("Updating the #{username} Participant in the #{discussion_id} Discussion")
|
60
|
+
put("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", properties, headers)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Discussions
|
3
|
+
|
4
|
+
# Add a Related Item to a discussion
|
5
|
+
#
|
6
|
+
# @param discussion_id [String] id of the discussion
|
7
|
+
# @param type [String] type of related item
|
8
|
+
# @param key [String] key that identifies the related item
|
9
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
10
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
11
|
+
def add_related_item(discussion_id, type, key, headers=default_jwt_headers)
|
12
|
+
payload = {"type": type, "key": key}
|
13
|
+
info("Adding a related item of type #{type} and key #{key} to the #{discussion_id} Discussion")
|
14
|
+
post("#{@api_url}/discussions/#{discussion_id}/relatedItems", payload, headers)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Delete a Related Item from a discussion
|
18
|
+
#
|
19
|
+
# @param discussion_id [String] id of the discussion
|
20
|
+
# @param type [String] type of related item
|
21
|
+
# @param key [String] key that identifies the related item
|
22
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
23
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
|
+
def delete_related_item(discussion_id, type, key, headers=header_bearer_auth)
|
25
|
+
info("Deleting related item of type #{type} and key #{key} from the #{discussion_id} Discussion")
|
26
|
+
delete("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", payload, headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Find Related Items in a Discussion
|
30
|
+
#
|
31
|
+
# @param discussion_id [String] id of the discussion
|
32
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
33
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
34
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
35
|
+
def find_related_items(discussion_id, params={}, headers=default_jwt_headers)
|
36
|
+
info("Finding related items in the #{discussion_id} Discussion")
|
37
|
+
get("#{@api_url}/discussions/#{discussion_id}/relatedItems", params, headers)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find a Related Item in a Discussion
|
41
|
+
#
|
42
|
+
# @param discussion_id [String] id of the discussion
|
43
|
+
# @param type [String] type of the related item
|
44
|
+
# @param key [String] key that identifies the related item
|
45
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
46
|
+
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
47
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
48
|
+
def find_related_item(discussion_id, type, key, params={}, headers=default_jwt_headers)
|
49
|
+
info("Finding the related item of type #{type} and key #{key} in the #{discussion_id} Discussion")
|
50
|
+
get("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", params, headers)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'kontena-websocket-client'
|
2
|
+
|
3
|
+
################################################################################
|
4
|
+
#
|
5
|
+
# NOTE: All of the Discussion Web Socket methods are experimental.
|
6
|
+
#
|
7
|
+
# Websocket status codes
|
8
|
+
# https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes
|
9
|
+
#
|
10
|
+
################################################################################
|
11
|
+
|
12
|
+
module KineticSdk
|
13
|
+
class Discussions
|
14
|
+
|
15
|
+
# Subscribes an existing user or invited user to the specified discussion.
|
16
|
+
#
|
17
|
+
# @param discussion_id [String] id of the discussion to subscribe the person to
|
18
|
+
# @param invitation_token [String] UUID of the invitation user token,
|
19
|
+
# nil for an existing user
|
20
|
+
def subscribe(discussion_id, invitation_token=nil)
|
21
|
+
ws_client(join_msg(discussion_id, invitation_token))
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def identify_msg
|
28
|
+
{
|
29
|
+
"action": "identify",
|
30
|
+
"payload": { "token": @jwt },
|
31
|
+
"ref": "identify-ref",
|
32
|
+
"topic": "topichub"
|
33
|
+
}.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def join_msg(discussion_id, invitation_token)
|
37
|
+
{
|
38
|
+
"action": "subscribe",
|
39
|
+
"payload": {
|
40
|
+
"topic": "discussions/discussion/#{discussion_id}",
|
41
|
+
"userInvitationToken": invitation_token
|
42
|
+
},
|
43
|
+
"ref": "subscription-ref",
|
44
|
+
"topic": "topichub"
|
45
|
+
}.to_json
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def ws_writer(ws, msg)
|
50
|
+
info("Websocket send message: #{msg}")
|
51
|
+
ws.send(msg)
|
52
|
+
end
|
53
|
+
|
54
|
+
def ws_reader(ws, send_msg=nil)
|
55
|
+
ws.read do |msg|
|
56
|
+
info("Websocket read: #{msg}")
|
57
|
+
o = JSON.parse(msg)
|
58
|
+
if ("error$".match(o['event']))
|
59
|
+
info("Websocket failure: #{o['payload']}")
|
60
|
+
elsif (o['event'] == "participant:updated")
|
61
|
+
info("Websocket close: EOF")
|
62
|
+
ws.close(1000, "EOF")
|
63
|
+
break
|
64
|
+
else
|
65
|
+
unless send_msg.nil?
|
66
|
+
ws_writer(ws, send_msg)
|
67
|
+
send_msg = nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def ws_client(message)
|
74
|
+
write_thread = nil
|
75
|
+
info("Websocket connecting to #{@topics_ws_server}")
|
76
|
+
Kontena::Websocket::Client.connect(@topics_ws_server) do |ws|
|
77
|
+
info("Websocket connected to #{ws.url}")
|
78
|
+
write_thread = Thread.new {
|
79
|
+
ws_writer(ws, identify_msg())
|
80
|
+
}
|
81
|
+
ws_reader(ws, message)
|
82
|
+
info("Websocket client closed connection with code #{ws.close_code}: #{ws.close_reason}")
|
83
|
+
end
|
84
|
+
rescue Kontena::Websocket::CloseError => e
|
85
|
+
info(e)
|
86
|
+
rescue Kontena::Websocket::Error => e
|
87
|
+
info(e)
|
88
|
+
ensure
|
89
|
+
if write_thread
|
90
|
+
write_thread.kill
|
91
|
+
write_thread.join
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
Dir[File.join(File.dirname(File.expand_path(__FILE__)), "lib", "**", "*.rb")].each {|file| require file }
|
2
|
+
|
3
|
+
module KineticSdk
|
4
|
+
|
5
|
+
# Filehub is a Ruby class that acts as a wrapper for the Kinetic FileHub REST API
|
6
|
+
# without having to make explicit HTTP requests.
|
7
|
+
#
|
8
|
+
class Filehub
|
9
|
+
|
10
|
+
# Include the KineticHttpUtils module
|
11
|
+
include KineticSdk::Utils::KineticHttpUtils
|
12
|
+
|
13
|
+
attr_reader :api_url, :username, :options, :password, :server, :version
|
14
|
+
|
15
|
+
# Initalize the FileHub SDK with the web server URL and configuration user
|
16
|
+
# credentials, along with any custom option values.
|
17
|
+
#
|
18
|
+
# @param opts [Hash] Kinetic FileHub properties
|
19
|
+
# @option opts [String] :config_file optional - path to the YAML configuration file
|
20
|
+
#
|
21
|
+
# * Ex: /opt/config/filehub-configuration1.yaml
|
22
|
+
#
|
23
|
+
# @option opts [String] :app_server_url the URL to the Kinetic Filehub web application.
|
24
|
+
#
|
25
|
+
# * Ex: <http://192.168.0.1:8080/kinetic-filehub>
|
26
|
+
#
|
27
|
+
# @option opts [String] :username the username for the user
|
28
|
+
# @option opts [String] :password the password for the user
|
29
|
+
# @option opts [Hash<Symbol, Object>] :options ({}) optional settings
|
30
|
+
#
|
31
|
+
# * :log_level (String) (_defaults to: off_) level of logging - off | info | debug | trace
|
32
|
+
# * :max_redirects (Fixnum) (_defaults to: 10_) maximum number of redirects to follow
|
33
|
+
# * :ssl_ca_file (String) full path to PEM certificate used to verify the server
|
34
|
+
# * :ssl_verify_mode (String) (_defaults to: none_) - none | peer
|
35
|
+
#
|
36
|
+
# Example: using a configuration file
|
37
|
+
#
|
38
|
+
# KineticSdk::Filehub.new({
|
39
|
+
# config_file: "/opt/config1.yaml"
|
40
|
+
# })
|
41
|
+
#
|
42
|
+
# Example: using a properties hash
|
43
|
+
#
|
44
|
+
# KineticSdk::Filehub.new({
|
45
|
+
# app_server_url: "http://localhost:8080/kinetic-filehub",
|
46
|
+
# username: "admin",
|
47
|
+
# password: "admin",
|
48
|
+
# options: {
|
49
|
+
# log_level: "debug",
|
50
|
+
# ssl_verify_mode: "peer",
|
51
|
+
# ssl_ca_file: "/usr/local/self_signing_ca.pem"
|
52
|
+
# }
|
53
|
+
# })
|
54
|
+
#
|
55
|
+
# If the +config_file+ option is present, it will be loaded first, and any additional
|
56
|
+
# options will overwrite any values in the config file
|
57
|
+
#
|
58
|
+
def initialize(opts={})
|
59
|
+
# initialize any variables
|
60
|
+
options = {}
|
61
|
+
|
62
|
+
# process the configuration file if it was provided
|
63
|
+
unless opts[:config_file].nil?
|
64
|
+
options.merge!(YAML::load_file opts[:config_file])
|
65
|
+
end
|
66
|
+
|
67
|
+
# process the configuration hash if it was provided
|
68
|
+
options.merge!(opts)
|
69
|
+
|
70
|
+
# process any individual options
|
71
|
+
@options = options.delete(:options) || {}
|
72
|
+
@username = options[:username]
|
73
|
+
@password = options[:password]
|
74
|
+
@server = options[:app_server_url].chomp('/')
|
75
|
+
@api_url = "#{@server}/app/api/v1"
|
76
|
+
@version = 1
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Filehub
|
3
|
+
|
4
|
+
# Add an Access Key for a Filestore
|
5
|
+
#
|
6
|
+
# @param slug [String] slug of the filestore
|
7
|
+
# @param payload [Hash] properties for the access key
|
8
|
+
# - +description+
|
9
|
+
# - +id+
|
10
|
+
# - +secret+
|
11
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
12
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
13
|
+
def add_access_key(slug, payload, headers=default_headers)
|
14
|
+
info("Adding Access Key for Filestore \"#{slug}\"")
|
15
|
+
post("#{@api_url}/filestores/#{slug}/access-keys", payload, headers)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Delete an Access Key for a Filestore
|
19
|
+
#
|
20
|
+
# @param slug [String] slug of the filestore
|
21
|
+
# @param id [String] id (key) of the access key
|
22
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
23
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
|
+
def delete_access_key(slug, id, headers=default_headers)
|
25
|
+
info("Deleting Access Key #{id} for Filestore \"#{slug}\"")
|
26
|
+
delete("#{@api_url}/filestores/#{slug}/access-keys/#{id}", headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Find Access Keys for a Filestore
|
30
|
+
#
|
31
|
+
# @param slug [String] slug of the filestore
|
32
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
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
|
+
def find_access_keys(slug, params={}, headers=default_headers)
|
36
|
+
info("Finding Access Keys for Filestore \"#{slug}\"")
|
37
|
+
get("#{@api_url}/filestores/#{slug}/access-keys", params, headers)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Find an Access Key for a Filestore
|
41
|
+
#
|
42
|
+
# @param slug [String] slug of the filestore
|
43
|
+
# @param id [String] id (key) of the access key
|
44
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
45
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
46
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
47
|
+
def find_access_key(slug, id, params={}, headers=default_headers)
|
48
|
+
info("Finding Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
49
|
+
get("#{@api_url}/filestores/#{slug}/access-keys/#{id}", params, headers)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Update a Filestore Access Key
|
53
|
+
#
|
54
|
+
# @param slug [String] slug of the filestore
|
55
|
+
# @param id [String] id (key) of the access key
|
56
|
+
# @param payload [Hash] properties for the access key
|
57
|
+
# - +description+
|
58
|
+
# - +secret+
|
59
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
60
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
61
|
+
def update_access_key(slug, id, payload, headers=default_headers)
|
62
|
+
info("Updating Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
63
|
+
put("#{@api_url}/filestores/#{slug}/access-keys/#{id}", payload, headers)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Filehub
|
3
|
+
|
4
|
+
# Add a Filestore
|
5
|
+
#
|
6
|
+
# @param payload [Hash] properties for the bridge
|
7
|
+
# - +accessKeys+
|
8
|
+
# - +adapterClass+
|
9
|
+
# - +name+
|
10
|
+
# - +properties+
|
11
|
+
# - +slug+
|
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_filestore(payload, headers=default_headers)
|
15
|
+
info("Adding Filestore \"#{payload['name']}\" with slug \"#{payload['slug']}\"")
|
16
|
+
post("#{@api_url}/filestores", payload, headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Delete a Filestore
|
20
|
+
#
|
21
|
+
# @param slug [String] slug of the filestore
|
22
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
23
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
|
+
def delete_filestore(slug, headers=default_headers)
|
25
|
+
info("Deleting Filestore \"#{slug}\"")
|
26
|
+
delete("#{@api_url}/filestores/#{slug}", headers)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Find Filestore
|
30
|
+
#
|
31
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
32
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
33
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
34
|
+
def find_filestores(params={}, headers=default_headers)
|
35
|
+
info("Find Filestores")
|
36
|
+
get("#{@api_url}/filestores", params, headers)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Find a Filestore
|
40
|
+
#
|
41
|
+
# @param slug [String] slug of the filestore
|
42
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
43
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
44
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
45
|
+
def find_filestore(slug, params={}, headers=default_headers)
|
46
|
+
info("Finding Filestore \"#{slug}\"")
|
47
|
+
get("#{@api_url}/filestores/#{slug}", params, headers)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Update a Filestore
|
51
|
+
#
|
52
|
+
# @param slug [String] slug of the filestore
|
53
|
+
# @param payload [Hash] properties for the bridge
|
54
|
+
# - +accessKeys+
|
55
|
+
# - +adapterClass+
|
56
|
+
# - +name+
|
57
|
+
# - +properties+
|
58
|
+
# - +slug+
|
59
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
60
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
61
|
+
def update_filestore(slug, payload, headers=default_headers)
|
62
|
+
info("Updating Filestore \"#{slug}\"")
|
63
|
+
put("#{@api_url}/filestores/#{slug}", payload, headers)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|