kinetic_sdk 0.1.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.yardoc-includes/yard-helpers.rb +14 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +41 -0
- data/GettingStarted.md +6 -12
- data/README.md +85 -37
- data/Rakefile +13 -0
- data/kinetic_sdk.gemspec +33 -0
- data/lib/kinetic_sdk/agent/agent-sdk.rb +90 -0
- data/lib/kinetic_sdk/agent/lib/bridges.rb +92 -0
- data/lib/kinetic_sdk/agent/lib/filestores.rb +91 -0
- data/lib/kinetic_sdk/agent/lib/handler.rb +91 -0
- data/lib/kinetic_sdk/bridgehub/bridgehub-sdk.rb +11 -3
- data/lib/kinetic_sdk/bridgehub/lib/access_keys.rb +5 -5
- data/lib/kinetic_sdk/bridgehub/lib/bridge.rb +5 -5
- data/lib/kinetic_sdk/{request_ce/request-ce-sdk.rb → core/core-sdk.rb} +30 -16
- data/lib/kinetic_sdk/core/lib/attribute_definitions.rb +500 -0
- data/lib/kinetic_sdk/core/lib/bridges.rb +141 -0
- data/lib/kinetic_sdk/{request_ce → core}/lib/categories.rb +3 -3
- data/lib/kinetic_sdk/{request_ce → core}/lib/datastore_form.rb +8 -8
- data/lib/kinetic_sdk/{request_ce → core}/lib/datastore_submissions.rb +20 -9
- data/lib/kinetic_sdk/{request_ce → core}/lib/form.rb +7 -7
- data/lib/kinetic_sdk/{request_ce → core}/lib/form_types.rb +4 -4
- data/lib/kinetic_sdk/{request_ce → core}/lib/jwt.rb +4 -4
- data/lib/kinetic_sdk/{request_ce → core}/lib/kapp.rb +7 -7
- data/lib/kinetic_sdk/{request_ce → core}/lib/meta.rb +3 -3
- data/lib/kinetic_sdk/{request_ce → core}/lib/oauth.rb +4 -4
- data/lib/kinetic_sdk/{request_ce → core}/lib/security_policy_definitions.rb +11 -11
- data/lib/kinetic_sdk/core/lib/space.rb +156 -0
- data/lib/kinetic_sdk/{request_ce → core}/lib/submissions.rb +11 -11
- data/lib/kinetic_sdk/{request_ce → core}/lib/system_api.rb +19 -7
- data/lib/kinetic_sdk/{request_ce → core}/lib/teams.rb +9 -9
- data/lib/kinetic_sdk/{request_ce → core}/lib/users.rb +15 -15
- data/lib/kinetic_sdk/{request_ce → core}/lib/webhook_jobs.rb +5 -5
- data/lib/kinetic_sdk/{request_ce → core}/lib/webhooks.rb +9 -9
- data/lib/kinetic_sdk/discussions/discussions-sdk.rb +12 -4
- data/lib/kinetic_sdk/discussions/lib/discussions.rb +8 -8
- data/lib/kinetic_sdk/discussions/lib/invitations.rb +9 -9
- data/lib/kinetic_sdk/discussions/lib/messages.rb +8 -8
- data/lib/kinetic_sdk/discussions/lib/meta.rb +1 -1
- data/lib/kinetic_sdk/discussions/lib/participants.rb +5 -5
- data/lib/kinetic_sdk/discussions/lib/related_items.rb +4 -4
- data/lib/kinetic_sdk/discussions/lib/websockets.rb +9 -9
- data/lib/kinetic_sdk/filehub/filehub-sdk.rb +11 -3
- data/lib/kinetic_sdk/filehub/lib/access_keys.rb +5 -5
- data/lib/kinetic_sdk/filehub/lib/filestores.rb +5 -5
- data/lib/kinetic_sdk/task/lib/access_keys.rb +35 -7
- data/lib/kinetic_sdk/task/lib/categories.rb +30 -17
- data/lib/kinetic_sdk/task/lib/config.rb +14 -14
- data/lib/kinetic_sdk/task/lib/engine.rb +1 -1
- data/lib/kinetic_sdk/task/lib/errors.rb +10 -10
- data/lib/kinetic_sdk/task/lib/export.rb +32 -0
- data/lib/kinetic_sdk/task/lib/groups.rb +23 -10
- data/lib/kinetic_sdk/task/lib/handlers.rb +27 -11
- data/lib/kinetic_sdk/task/lib/health.rb +11 -3
- data/lib/kinetic_sdk/task/lib/license.rb +4 -4
- data/lib/kinetic_sdk/task/lib/policy_rules.rb +25 -12
- data/lib/kinetic_sdk/task/lib/runs.rb +43 -0
- data/lib/kinetic_sdk/task/lib/setup.rb +2 -2
- data/lib/kinetic_sdk/task/lib/sources.rb +39 -8
- data/lib/kinetic_sdk/task/lib/tasks.rb +1 -1
- data/lib/kinetic_sdk/task/lib/trees.rb +84 -28
- data/lib/kinetic_sdk/task/lib/users.rb +6 -6
- data/lib/kinetic_sdk/task/task-sdk.rb +16 -4
- data/lib/kinetic_sdk/utils/kinetic-export-utils.rb +157 -0
- data/lib/kinetic_sdk/utils/kinetic-http.rb +388 -98
- data/lib/kinetic_sdk/utils/logger.rb +82 -46
- data/lib/kinetic_sdk/utils/prettier-xml-formatter.rb +60 -0
- data/lib/kinetic_sdk/version.rb +1 -1
- data/lib/kinetic_sdk.rb +5 -2
- metadata +41 -27
- data/lib/kinetic_sdk/request_ce/lib/attribute_definitions.rb +0 -153
- data/lib/kinetic_sdk/request_ce/lib/bridges.rb +0 -66
- data/lib/kinetic_sdk/request_ce/lib/space.rb +0 -89
@@ -20,7 +20,7 @@ module KineticSdk
|
|
20
20
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
21
21
|
def add_message(discussion_id, message, headers=default_jwt_headers)
|
22
22
|
payload = message_content(message)
|
23
|
-
info("Adding a message to the #{discussion_id} Discussion")
|
23
|
+
@logger.info("Adding a message to the #{discussion_id} Discussion")
|
24
24
|
post("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers)
|
25
25
|
end
|
26
26
|
|
@@ -46,7 +46,7 @@ module KineticSdk
|
|
46
46
|
def add_message_with_attachments(discussion_id, properties={}, headers=default_jwt_headers)
|
47
47
|
payload = message_content(properties['message'])
|
48
48
|
payload["attachments"] = properties['attachments']
|
49
|
-
info("Adding a message to the #{discussion_id} Discussion")
|
49
|
+
@logger.info("Adding a message to the #{discussion_id} Discussion")
|
50
50
|
post_multipart("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers)
|
51
51
|
end
|
52
52
|
|
@@ -57,7 +57,7 @@ module KineticSdk
|
|
57
57
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
58
58
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
59
59
|
def find_messages(discussion_id, params={}, headers=default_jwt_headers)
|
60
|
-
info("Finding messages in the #{discussion_id} Discussion")
|
60
|
+
@logger.info("Finding messages in the #{discussion_id} Discussion")
|
61
61
|
get("#{@api_url}/discussions/#{discussion_id}/messages", params, headers)
|
62
62
|
end
|
63
63
|
|
@@ -69,7 +69,7 @@ module KineticSdk
|
|
69
69
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
70
70
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
71
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")
|
72
|
+
@logger.info("Finding the #{message_id} message in the #{discussion_id} Discussion")
|
73
73
|
get("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", params, headers)
|
74
74
|
end
|
75
75
|
|
@@ -93,7 +93,7 @@ module KineticSdk
|
|
93
93
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
94
94
|
def update_message(discussion_id, message_id, message, headers=default_jwt_headers)
|
95
95
|
payload = message_content(message)
|
96
|
-
info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
96
|
+
@logger.info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
97
97
|
put("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", payload, headers)
|
98
98
|
end
|
99
99
|
|
@@ -118,7 +118,7 @@ module KineticSdk
|
|
118
118
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
119
119
|
def update_message_with_attachments(discussion_id, message_id, message, attachments=[], headers=header_bearer_auth)
|
120
120
|
payload = { "message" => message_content(message).to_json, "attachments" => attachments }
|
121
|
-
info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
121
|
+
@logger.info("Updating the #{message_id} message in the #{discussion_id} Discussion")
|
122
122
|
post_multipart("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}", payload, headers)
|
123
123
|
end
|
124
124
|
|
@@ -137,7 +137,7 @@ module KineticSdk
|
|
137
137
|
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
138
138
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
139
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")
|
140
|
+
@logger.info("Downloading the #{filename} file attachment in the #{discussion_id} Discussion")
|
141
141
|
get("#{@api_url}/discussions/#{discussion_id}/messages/#{message_id}/files/#{document_id}/#{filename}", params, headers)
|
142
142
|
end
|
143
143
|
|
@@ -164,7 +164,7 @@ module KineticSdk
|
|
164
164
|
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
165
165
|
def export_message_attachment(discussion_id, message_id, document_id, filename, params={}, headers=header_bearer_auth)
|
166
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")
|
167
|
+
@logger.info("Exporting the #{filename} file attachment in the #{discussion_id} Discussion")
|
168
168
|
# Create the export directory if it doesn't yet exist
|
169
169
|
export_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], discussion_id, "files", message_id))
|
170
170
|
export_file = File.join(export_dir, filename)
|
@@ -6,7 +6,7 @@ module KineticSdk
|
|
6
6
|
# @param headers [Hash] hash of headers to send, default is accept JSON content type
|
7
7
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
8
8
|
def app_version(headers=header_accept_json)
|
9
|
-
info("Retrieving Discussions application version.")
|
9
|
+
@logger.info("Retrieving Discussions application version.")
|
10
10
|
get("#{@api_url}/version", {}, headers)
|
11
11
|
end
|
12
12
|
|
@@ -9,7 +9,7 @@ module KineticSdk
|
|
9
9
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
10
10
|
def add_participant(discussion_id, username, headers=default_jwt_headers)
|
11
11
|
payload = { "username" => username }
|
12
|
-
info("Participant #{username} joining the #{discussion_id} Discussion")
|
12
|
+
@logger.info("Participant #{username} joining the #{discussion_id} Discussion")
|
13
13
|
post("#{@api_url}/discussions/#{discussion_id}/participants", payload, headers)
|
14
14
|
end
|
15
15
|
|
@@ -20,7 +20,7 @@ module KineticSdk
|
|
20
20
|
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
21
21
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
22
22
|
def delete_participant(discussion_id, username, headers=header_bearer_auth)
|
23
|
-
info("Participant #{username} is leaving the #{discussion_id} Discussion")
|
23
|
+
@logger.info("Participant #{username} is leaving the #{discussion_id} Discussion")
|
24
24
|
delete("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", headers)
|
25
25
|
end
|
26
26
|
|
@@ -31,7 +31,7 @@ module KineticSdk
|
|
31
31
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
32
32
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
33
33
|
def find_participants(discussion_id, params={}, headers=default_jwt_headers)
|
34
|
-
info("Finding Participants in the #{discussion_id} Discussion")
|
34
|
+
@logger.info("Finding Participants in the #{discussion_id} Discussion")
|
35
35
|
get("#{@api_url}/discussions/#{discussion_id}/participants", params, headers)
|
36
36
|
end
|
37
37
|
|
@@ -43,7 +43,7 @@ module KineticSdk
|
|
43
43
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
44
44
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
45
45
|
def find_participant(discussion_id, username, params={}, headers=default_jwt_headers)
|
46
|
-
info("Finding the #{username} Participant in the #{discussion_id} Discussion")
|
46
|
+
@logger.info("Finding the #{username} Participant in the #{discussion_id} Discussion")
|
47
47
|
get("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", params, headers)
|
48
48
|
end
|
49
49
|
|
@@ -56,7 +56,7 @@ module KineticSdk
|
|
56
56
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
57
57
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
58
58
|
def update_participant(discussion_id, username, properties={}, headers=default_jwt_headers)
|
59
|
-
info("Updating the #{username} Participant in the #{discussion_id} Discussion")
|
59
|
+
@logger.info("Updating the #{username} Participant in the #{discussion_id} Discussion")
|
60
60
|
put("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", properties, headers)
|
61
61
|
end
|
62
62
|
|
@@ -10,7 +10,7 @@ module KineticSdk
|
|
10
10
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
11
11
|
def add_related_item(discussion_id, type, key, headers=default_jwt_headers)
|
12
12
|
payload = {"type": type, "key": key}
|
13
|
-
info("Adding a related item of type #{type} and key #{key} to the #{discussion_id} Discussion")
|
13
|
+
@logger.info("Adding a related item of type #{type} and key #{key} to the #{discussion_id} Discussion")
|
14
14
|
post("#{@api_url}/discussions/#{discussion_id}/relatedItems", payload, headers)
|
15
15
|
end
|
16
16
|
|
@@ -22,7 +22,7 @@ module KineticSdk
|
|
22
22
|
# @param headers [Hash] hash of headers to send, default is bearer authentication
|
23
23
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
24
|
def delete_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")
|
25
|
+
@logger.info("Deleting related item of type #{type} and key #{key} from the #{discussion_id} Discussion")
|
26
26
|
delete("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", payload, headers)
|
27
27
|
end
|
28
28
|
|
@@ -33,7 +33,7 @@ module KineticSdk
|
|
33
33
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
34
34
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
35
35
|
def find_related_items(discussion_id, params={}, headers=default_jwt_headers)
|
36
|
-
info("Finding related items in the #{discussion_id} Discussion")
|
36
|
+
@logger.info("Finding related items in the #{discussion_id} Discussion")
|
37
37
|
get("#{@api_url}/discussions/#{discussion_id}/relatedItems", params, headers)
|
38
38
|
end
|
39
39
|
|
@@ -46,7 +46,7 @@ module KineticSdk
|
|
46
46
|
# @param headers [Hash] hash of headers to send, default is bearer authentication and accept JSON content type
|
47
47
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
48
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")
|
49
|
+
@logger.info("Finding the related item of type #{type} and key #{key} in the #{discussion_id} Discussion")
|
50
50
|
get("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", params, headers)
|
51
51
|
end
|
52
52
|
|
@@ -47,18 +47,18 @@ module KineticSdk
|
|
47
47
|
|
48
48
|
|
49
49
|
def ws_writer(ws, msg)
|
50
|
-
info("Websocket send message: #{msg}")
|
50
|
+
@logger.info("Websocket send message: #{msg}")
|
51
51
|
ws.send(msg)
|
52
52
|
end
|
53
53
|
|
54
54
|
def ws_reader(ws, send_msg=nil)
|
55
55
|
ws.read do |msg|
|
56
|
-
info("Websocket read: #{msg}")
|
56
|
+
@logger.info("Websocket read: #{msg}")
|
57
57
|
o = JSON.parse(msg)
|
58
58
|
if ("error$".match(o['event']))
|
59
|
-
info("Websocket failure: #{o['payload']}")
|
59
|
+
@logger.info("Websocket failure: #{o['payload']}")
|
60
60
|
elsif (o['event'] == "participant:updated")
|
61
|
-
info("Websocket close: EOF")
|
61
|
+
@logger.info("Websocket close: EOF")
|
62
62
|
ws.close(1000, "EOF")
|
63
63
|
break
|
64
64
|
else
|
@@ -72,19 +72,19 @@ module KineticSdk
|
|
72
72
|
|
73
73
|
def ws_client(message)
|
74
74
|
write_thread = nil
|
75
|
-
info("Websocket connecting to #{@topics_ws_server}")
|
75
|
+
@logger.info("Websocket connecting to #{@topics_ws_server}")
|
76
76
|
Kontena::Websocket::Client.connect(@topics_ws_server) do |ws|
|
77
|
-
info("Websocket connected to #{ws.url}")
|
77
|
+
@logger.info("Websocket connected to #{ws.url}")
|
78
78
|
write_thread = Thread.new {
|
79
79
|
ws_writer(ws, identify_msg())
|
80
80
|
}
|
81
81
|
ws_reader(ws, message)
|
82
|
-
info("Websocket client closed connection with code #{ws.close_code}: #{ws.close_reason}")
|
82
|
+
@logger.info("Websocket client closed connection with code #{ws.close_code}: #{ws.close_reason}")
|
83
83
|
end
|
84
84
|
rescue Kontena::Websocket::CloseError => e
|
85
|
-
info(e)
|
85
|
+
@logger.info(e)
|
86
86
|
rescue Kontena::Websocket::Error => e
|
87
|
-
info(e)
|
87
|
+
@logger.info(e)
|
88
88
|
ensure
|
89
89
|
if write_thread
|
90
90
|
write_thread.kill
|
@@ -10,7 +10,7 @@ module KineticSdk
|
|
10
10
|
# Include the KineticHttpUtils module
|
11
11
|
include KineticSdk::Utils::KineticHttpUtils
|
12
12
|
|
13
|
-
attr_reader :api_url, :username, :options, :password, :server, :version
|
13
|
+
attr_reader :api_url, :username, :options, :password, :server, :version, :logger
|
14
14
|
|
15
15
|
# Initalize the FileHub SDK with the web server URL and configuration user
|
16
16
|
# credentials, along with any custom option values.
|
@@ -28,8 +28,11 @@ module KineticSdk
|
|
28
28
|
# @option opts [String] :password the password for the user
|
29
29
|
# @option opts [Hash<Symbol, Object>] :options ({}) optional settings
|
30
30
|
#
|
31
|
-
# * :
|
32
|
-
# * :
|
31
|
+
# * :gateway_retry_limit (FixNum) (_defaults to: 5_) max number of times to retry a bad gateway
|
32
|
+
# * :gateway_retry_delay (Float) (_defaults to: 1.0_) number of seconds to delay before retrying a bad gateway
|
33
|
+
# * :log_level (String) (_defaults to: off_) level of logging - off | error | warn | info | debug
|
34
|
+
# * :log_output (String) (_defaults to: STDOUT_) where to send output - STDOUT | STDERR
|
35
|
+
# * :max_redirects (Fixnum) (_defaults to: 5_) maximum number of redirects to follow
|
33
36
|
# * :ssl_ca_file (String) full path to PEM certificate used to verify the server
|
34
37
|
# * :ssl_verify_mode (String) (_defaults to: none_) - none | peer
|
35
38
|
#
|
@@ -69,6 +72,11 @@ module KineticSdk
|
|
69
72
|
|
70
73
|
# process any individual options
|
71
74
|
@options = options.delete(:options) || {}
|
75
|
+
# setup logging
|
76
|
+
log_level = @options[:log_level] || @options["log_level"]
|
77
|
+
log_output = @options[:log_output] || @options["log_output"]
|
78
|
+
@logger = KineticSdk::Utils::KLogger.new(log_level, log_output)
|
79
|
+
|
72
80
|
@username = options[:username]
|
73
81
|
@password = options[:password]
|
74
82
|
@server = options[:app_server_url].chomp('/')
|
@@ -11,7 +11,7 @@ module KineticSdk
|
|
11
11
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
12
12
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
13
13
|
def add_access_key(slug, payload, headers=default_headers)
|
14
|
-
info("Adding Access Key for Filestore \"#{slug}\"")
|
14
|
+
@logger.info("Adding Access Key for Filestore \"#{slug}\"")
|
15
15
|
post("#{@api_url}/filestores/#{slug}/access-keys", payload, headers)
|
16
16
|
end
|
17
17
|
|
@@ -22,7 +22,7 @@ module KineticSdk
|
|
22
22
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
23
23
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
24
|
def delete_access_key(slug, id, headers=default_headers)
|
25
|
-
info("Deleting Access Key #{id} for Filestore \"#{slug}\"")
|
25
|
+
@logger.info("Deleting Access Key #{id} for Filestore \"#{slug}\"")
|
26
26
|
delete("#{@api_url}/filestores/#{slug}/access-keys/#{id}", headers)
|
27
27
|
end
|
28
28
|
|
@@ -33,7 +33,7 @@ module KineticSdk
|
|
33
33
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
34
34
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
35
35
|
def find_access_keys(slug, params={}, headers=default_headers)
|
36
|
-
info("Finding Access Keys for Filestore \"#{slug}\"")
|
36
|
+
@logger.info("Finding Access Keys for Filestore \"#{slug}\"")
|
37
37
|
get("#{@api_url}/filestores/#{slug}/access-keys", params, headers)
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ module KineticSdk
|
|
45
45
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
46
46
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
47
47
|
def find_access_key(slug, id, params={}, headers=default_headers)
|
48
|
-
info("Finding Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
48
|
+
@logger.info("Finding Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
49
49
|
get("#{@api_url}/filestores/#{slug}/access-keys/#{id}", params, headers)
|
50
50
|
end
|
51
51
|
|
@@ -59,7 +59,7 @@ module KineticSdk
|
|
59
59
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
60
60
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
61
61
|
def update_access_key(slug, id, payload, headers=default_headers)
|
62
|
-
info("Updating Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
62
|
+
@logger.info("Updating Access Key \"#{id}\" for Filestore \"#{slug}\"")
|
63
63
|
put("#{@api_url}/filestores/#{slug}/access-keys/#{id}", payload, headers)
|
64
64
|
end
|
65
65
|
|
@@ -12,7 +12,7 @@ module KineticSdk
|
|
12
12
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
13
13
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
14
14
|
def add_filestore(payload, headers=default_headers)
|
15
|
-
info("Adding Filestore \"#{payload['name']}\" with slug \"#{payload['slug']}\"")
|
15
|
+
@logger.info("Adding Filestore \"#{payload['name']}\" with slug \"#{payload['slug']}\"")
|
16
16
|
post("#{@api_url}/filestores", payload, headers)
|
17
17
|
end
|
18
18
|
|
@@ -22,7 +22,7 @@ module KineticSdk
|
|
22
22
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
23
23
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
24
24
|
def delete_filestore(slug, headers=default_headers)
|
25
|
-
info("Deleting Filestore \"#{slug}\"")
|
25
|
+
@logger.info("Deleting Filestore \"#{slug}\"")
|
26
26
|
delete("#{@api_url}/filestores/#{slug}", headers)
|
27
27
|
end
|
28
28
|
|
@@ -32,7 +32,7 @@ module KineticSdk
|
|
32
32
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
33
33
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
34
34
|
def find_filestores(params={}, headers=default_headers)
|
35
|
-
info("Find Filestores")
|
35
|
+
@logger.info("Find Filestores")
|
36
36
|
get("#{@api_url}/filestores", params, headers)
|
37
37
|
end
|
38
38
|
|
@@ -43,7 +43,7 @@ module KineticSdk
|
|
43
43
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
44
44
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
45
45
|
def find_filestore(slug, params={}, headers=default_headers)
|
46
|
-
info("Finding Filestore \"#{slug}\"")
|
46
|
+
@logger.info("Finding Filestore \"#{slug}\"")
|
47
47
|
get("#{@api_url}/filestores/#{slug}", params, headers)
|
48
48
|
end
|
49
49
|
|
@@ -59,7 +59,7 @@ module KineticSdk
|
|
59
59
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
60
60
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
61
61
|
def update_filestore(slug, payload, headers=default_headers)
|
62
|
-
info("Updating Filestore \"#{slug}\"")
|
62
|
+
@logger.info("Updating Filestore \"#{slug}\"")
|
63
63
|
put("#{@api_url}/filestores/#{slug}", payload, headers)
|
64
64
|
end
|
65
65
|
|
@@ -26,7 +26,8 @@ module KineticSdk
|
|
26
26
|
# add_access_key()
|
27
27
|
#
|
28
28
|
def add_access_key(access_key={}, headers=default_headers)
|
29
|
-
info("Adding access key " + (access_key.has_key?('identifier') ? access_key['identifier'] : ""))
|
29
|
+
@logger.info("Adding access key " + (access_key.has_key?('identifier') ? access_key['identifier'] : ""))
|
30
|
+
access_key["secret"] = "SETME" if access_key["secret"].nil?
|
30
31
|
post("#{@api_url}/access-keys", access_key, headers)
|
31
32
|
end
|
32
33
|
|
@@ -36,7 +37,7 @@ module KineticSdk
|
|
36
37
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
37
38
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
38
39
|
def delete_access_key(identifier, headers=header_basic_auth)
|
39
|
-
info("Deleting access key \"#{identifier}\"")
|
40
|
+
@logger.info("Deleting access key \"#{identifier}\"")
|
40
41
|
delete("#{@api_url}/access-keys/#{encode(identifier)}", headers)
|
41
42
|
end
|
42
43
|
|
@@ -45,19 +46,46 @@ module KineticSdk
|
|
45
46
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
46
47
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
47
48
|
def delete_access_keys(headers=header_basic_auth)
|
48
|
-
info("Deleting all access keys")
|
49
|
+
@logger.info("Deleting all access keys")
|
49
50
|
(find_access_keys(headers).content["accessKeys"] || []).each do |access_key|
|
50
51
|
delete("#{@api_url}/access_keys/#{encode(access_key['identifier'])}", headers)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
# Export all access keys to :identifier.json file in export_directory/access-keys
|
56
|
+
#
|
57
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication
|
58
|
+
# @return nil
|
59
|
+
def export_access_keys(headers=header_basic_auth)
|
60
|
+
raise StandardError.new "An export directory must be defined to export access keys." if @options[:export_directory].nil?
|
61
|
+
response = find_access_keys
|
62
|
+
access_keys_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "access-keys"))
|
63
|
+
(response.content["accessKeys"] || []).each do |access_key|
|
64
|
+
access_key_file = File.join(access_keys_dir, "#{access_key['identifier'].slugify}.json")
|
65
|
+
write_object_to_file(access_key_file, access_key)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Import all access keys from :identifier.json file in export_directory/access-keys
|
70
|
+
#
|
71
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication
|
72
|
+
# @return nil
|
73
|
+
def import_access_keys(headers=default_headers)
|
74
|
+
raise StandardError.new "An export directory must be defined to import access keys from." if @options[:export_directory].nil?
|
75
|
+
@logger.info("Importing all Access Keys in Export Directory")
|
76
|
+
Dir["#{@options[:export_directory]}/access-keys/*.json"].sort.each do |file|
|
77
|
+
access_key = JSON.parse(File.read(file))
|
78
|
+
add_access_key(access_key, headers)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
54
82
|
# Find all access keys
|
55
83
|
#
|
56
84
|
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
57
85
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
58
86
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
59
87
|
def find_access_keys(params={}, headers=header_basic_auth)
|
60
|
-
info("Finding all access keys")
|
88
|
+
@logger.info("Finding all access keys")
|
61
89
|
get("#{@api_url}/access-keys", params, headers)
|
62
90
|
end
|
63
91
|
|
@@ -68,7 +96,7 @@ module KineticSdk
|
|
68
96
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
69
97
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
70
98
|
def find_access_key(identifier, params={}, headers=default_headers)
|
71
|
-
info("Finding access key \"#{identifier}\"")
|
99
|
+
@logger.info("Finding access key \"#{identifier}\"")
|
72
100
|
get("#{@api_url}/access-keys/#{encode(identifier)}", params, headers)
|
73
101
|
end
|
74
102
|
|
@@ -79,14 +107,14 @@ module KineticSdk
|
|
79
107
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
80
108
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
81
109
|
#
|
82
|
-
#
|
110
|
+
# Example
|
83
111
|
#
|
84
112
|
# update_identifier("X54DLNU", {
|
85
113
|
# "description": "Updated access key"
|
86
114
|
# })
|
87
115
|
#
|
88
116
|
def update_access_key(identifier, body={}, headers=default_headers)
|
89
|
-
info("Updating the \"#{identifier}\" access key")
|
117
|
+
@logger.info("Updating the \"#{identifier}\" access key")
|
90
118
|
put("#{@api_url}/access-keys/#{encode(identifier)}", body, headers)
|
91
119
|
end
|
92
120
|
|
@@ -11,7 +11,7 @@ module KineticSdk
|
|
11
11
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
12
12
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
13
13
|
def add_category(category, headers=default_headers)
|
14
|
-
info("Add category \"#{category['name']}\"")
|
14
|
+
@logger.info("Add category \"#{category['name']}\"")
|
15
15
|
post("#{@api_url}/categories", category, headers)
|
16
16
|
end
|
17
17
|
|
@@ -21,7 +21,7 @@ module KineticSdk
|
|
21
21
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
22
22
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
23
23
|
def delete_category(name, headers=header_basic_auth)
|
24
|
-
info("Deleting Category \"#{name}\"")
|
24
|
+
@logger.info("Deleting Category \"#{name}\"")
|
25
25
|
delete("#{@api_url}/categories/#{encode(name)}", headers)
|
26
26
|
end
|
27
27
|
|
@@ -30,7 +30,7 @@ module KineticSdk
|
|
30
30
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
31
31
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
32
32
|
def delete_categories(headers=header_basic_auth)
|
33
|
-
info("Deleting all categories")
|
33
|
+
@logger.info("Deleting all categories")
|
34
34
|
(find_categories(headers).content["categories"] || []).each do |category|
|
35
35
|
delete_category(category['name'], headers)
|
36
36
|
end
|
@@ -44,14 +44,14 @@ module KineticSdk
|
|
44
44
|
# - +policyRules+ - array of policy rule names associated to the category
|
45
45
|
# - +trees+ - array of tree (routine) definitionIds associated to the category
|
46
46
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
47
|
-
# @return
|
47
|
+
# @return nil
|
48
48
|
def export_category(category, headers=header_basic_auth)
|
49
49
|
raise StandardError.new "An export directory must be defined to export a category." if @options[:export_directory].nil?
|
50
50
|
if category.is_a? String
|
51
51
|
response = find_category(category, { "include" => "handlers,trees,policyRules" }, headers)
|
52
52
|
category = response.content
|
53
53
|
end
|
54
|
-
info("Exporting category \"#{category['name']}\" to #{@options[:export_directory]}.")
|
54
|
+
@logger.info("Exporting category \"#{category['name']}\" to #{@options[:export_directory]}.")
|
55
55
|
# Create the category directory if it doesn't yet exist
|
56
56
|
category_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "categories"))
|
57
57
|
category_file = File.join(category_dir, "#{category['name'].slugify}.json")
|
@@ -63,13 +63,13 @@ module KineticSdk
|
|
63
63
|
|
64
64
|
# write the file
|
65
65
|
File.write(category_file, JSON.pretty_generate(category))
|
66
|
-
info("Exported category: #{category['name']} to #{category_file}")
|
66
|
+
@logger.info("Exported category: #{category['name']} to #{category_file}")
|
67
67
|
end
|
68
68
|
|
69
69
|
# Export Categories
|
70
70
|
#
|
71
71
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
72
|
-
# @return
|
72
|
+
# @return nil
|
73
73
|
def export_categories(headers=header_basic_auth)
|
74
74
|
raise StandardError.new "An export directory must be defined to export categories." if @options[:export_directory].nil?
|
75
75
|
(find_categories({ "include" => "handlers,trees,policyRules" }).content["categories"] || []).each do |category|
|
@@ -77,13 +77,26 @@ module KineticSdk
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
# Import Categories
|
81
|
+
#
|
82
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication
|
83
|
+
# @return nil
|
84
|
+
def import_categories(headers=default_headers)
|
85
|
+
raise StandardError.new "An export directory must be defined to import categories from." if @options[:export_directory].nil?
|
86
|
+
@logger.info("Importing all Categories in Export Directory")
|
87
|
+
Dir["#{@options[:export_directory]}/categories/*.json"].sort.each do |file|
|
88
|
+
category = JSON.parse(File.read(file))
|
89
|
+
add_category(category, headers)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
80
93
|
# Find all categories
|
81
94
|
#
|
82
95
|
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
83
96
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
84
97
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
85
98
|
def find_categories(params={}, headers=header_basic_auth)
|
86
|
-
info("Finding all categories")
|
99
|
+
@logger.info("Finding all categories")
|
87
100
|
get("#{@api_url}/categories", params, headers)
|
88
101
|
end
|
89
102
|
|
@@ -94,7 +107,7 @@ module KineticSdk
|
|
94
107
|
# @param headers [Hash] hash of headers to send, default is basic authentication
|
95
108
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
96
109
|
def find_category(name, params={}, headers=header_basic_auth)
|
97
|
-
info("Finding Category \"#{name}\"")
|
110
|
+
@logger.info("Finding Category \"#{name}\"")
|
98
111
|
get("#{@api_url}/categories/#{encode(name)}", params, headers)
|
99
112
|
end
|
100
113
|
|
@@ -104,13 +117,13 @@ module KineticSdk
|
|
104
117
|
# @param body [Hash] the updated property values
|
105
118
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
106
119
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
107
|
-
#
|
120
|
+
#
|
108
121
|
# Example
|
109
122
|
#
|
110
123
|
# update_category("Foo", { "name" => "Bar" })
|
111
124
|
#
|
112
125
|
def update_category(original_name, body={}, headers=default_headers)
|
113
|
-
info("Updating Category \"#{original_name}\"")
|
126
|
+
@logger.info("Updating Category \"#{original_name}\"")
|
114
127
|
put("#{@api_url}/categories/#{encode(original_name)}", body, headers)
|
115
128
|
end
|
116
129
|
|
@@ -123,7 +136,7 @@ module KineticSdk
|
|
123
136
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
124
137
|
def add_handler_to_category(handler_id, category_name, headers=default_headers)
|
125
138
|
body = { "definitionId" => handler_id }
|
126
|
-
info("Adding handler \"#{handler_id}\" to category \"#{category_name}\"")
|
139
|
+
@logger.info("Adding handler \"#{handler_id}\" to category \"#{category_name}\"")
|
127
140
|
post("#{@api_url}/categories/#{encode(category_name)}/handlers", body, headers)
|
128
141
|
end
|
129
142
|
|
@@ -134,7 +147,7 @@ module KineticSdk
|
|
134
147
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
135
148
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
136
149
|
def remove_handler_from_category(handler_id, category_name, headers=default_headers)
|
137
|
-
info("Removing handler \"#{handler_id}\" from category \"#{category_name}\"")
|
150
|
+
@logger.info("Removing handler \"#{handler_id}\" from category \"#{category_name}\"")
|
138
151
|
delete("#{@api_url}/categories/#{encode(category_name)}/handlers/#{encode(handler_id)}", headers)
|
139
152
|
end
|
140
153
|
|
@@ -146,7 +159,7 @@ module KineticSdk
|
|
146
159
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
147
160
|
def add_routine_to_category(routine_id, category_name, headers=default_headers)
|
148
161
|
body = { "definitionId" => routine_id }
|
149
|
-
info("Adding routine \"#{routine_id}\" to category \"#{category_name}\"")
|
162
|
+
@logger.info("Adding routine \"#{routine_id}\" to category \"#{category_name}\"")
|
150
163
|
post("#{@api_url}/categories/#{encode(category_name)}/routines", body, headers)
|
151
164
|
end
|
152
165
|
|
@@ -157,7 +170,7 @@ module KineticSdk
|
|
157
170
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
158
171
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
159
172
|
def remove_routine_from_category(routine_id, category_name, headers=default_headers)
|
160
|
-
info("Removing routine \"#{routine_id}\" from category \"#{category_name}\"")
|
173
|
+
@logger.info("Removing routine \"#{routine_id}\" from category \"#{category_name}\"")
|
161
174
|
delete("#{@api_url}/categories/#{encode(category_name)}/routines/#{encode(routine_id)}", headers)
|
162
175
|
end
|
163
176
|
|
@@ -170,7 +183,7 @@ module KineticSdk
|
|
170
183
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
171
184
|
def add_policy_rule_to_category(policy_rule_type, policy_rule_name, category_name, headers=default_headers)
|
172
185
|
body = { "type" => policy_rule_type, "name" => policy_rule_name }
|
173
|
-
info("Adding policy rule \"#{policy_rule_type} - #{policy_rule_name}\" to category \"#{category_name}\"")
|
186
|
+
@logger.info("Adding policy rule \"#{policy_rule_type} - #{policy_rule_name}\" to category \"#{category_name}\"")
|
174
187
|
post("#{@api_url}/categories/#{encode(category_name)}/policyRules", body, headers)
|
175
188
|
end
|
176
189
|
|
@@ -182,7 +195,7 @@ module KineticSdk
|
|
182
195
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
183
196
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
184
197
|
def remove_policy_rule_from_category(policy_rule_type, policy_rule_name, category_name, headers=default_headers)
|
185
|
-
info("Removing policy rule \"#{policy_rule_type} - #{policy_rule_name}\" from category \"#{category_name}\"")
|
198
|
+
@logger.info("Removing policy rule \"#{policy_rule_type} - #{policy_rule_name}\" from category \"#{category_name}\"")
|
186
199
|
delete("#{@api_url}/categories/#{encode(category_name)}/policyRules/#{encode(policy_rule_type)}/#{encode(policy_rule_name)}", headers)
|
187
200
|
end
|
188
201
|
|