kinetic_sdk 5.0.9 → 5.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +109 -32
- data/lib/kinetic_sdk/agent/lib/bridges.rb +0 -1
- data/lib/kinetic_sdk/agent/lib/filestores.rb +0 -1
- data/lib/kinetic_sdk/agent/lib/handler.rb +0 -1
- data/lib/kinetic_sdk/core/lib/datastore_submissions.rb +55 -6
- data/lib/kinetic_sdk/core/lib/form_types.rb +59 -2
- data/lib/kinetic_sdk/core/lib/platform_components.rb +0 -1
- data/lib/kinetic_sdk/core/lib/submissions.rb +66 -8
- data/lib/kinetic_sdk/core/lib/teams.rb +0 -1
- data/lib/kinetic_sdk/core/lib/webapis.rb +144 -0
- data/lib/kinetic_sdk/core/lib/webhooks.rb +1 -1
- data/lib/kinetic_sdk/task/lib/handlers.rb +1 -1
- data/lib/kinetic_sdk/task/lib/sources.rb +1 -1
- data/lib/kinetic_sdk/utils/kinetic-export-utils.rb +6 -1
- data/lib/kinetic_sdk/utils/kinetic-http.rb +8 -5
- data/lib/kinetic_sdk/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67e6967468589fa6bfdf4a523663d1675053a618882337a2d3b001265a525c19
|
4
|
+
data.tar.gz: 32ffee19ba6489077e6102beea1c96a2bccbad93fcd1c5ee38291ecebc8aec9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d1a9fba8f13cb36dfe03848c6ffe81fe0c8be5b4298380ff8f18e39539dae0d9e17df66f17197b279a3f0022757e719d19c24827ad7d155f95db4b56e09239
|
7
|
+
data.tar.gz: 492ecbe9146c29d23e11f3a36fcb3a3cb52c712a5a902d8f7dbbb22c94cdac6890a85d7623265a7901a22999ade8d4c026a2fb8a6e2671ac2c10d9fb62e31393
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,116 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [5.0.14](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.14) (2021-01-15)
|
4
|
+
|
5
|
+
**Implemented enhancements:**
|
6
|
+
|
7
|
+
- Support for submitting attachments (datastore and form submissions)
|
8
|
+
- Bug Fixes
|
9
|
+
|
10
|
+
## [5.0.13](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.13) (2020-09-03)
|
11
|
+
|
12
|
+
**Implemented enhancements:**
|
13
|
+
|
14
|
+
- Added missing Form Type methods.
|
15
|
+
- Deprecated some Form Type methods and replaced with simpler names.
|
16
|
+
- Removed an unnecessary logging statement when adding a team attribute.
|
17
|
+
- Removed double URL encoding when deleting a webhook from a Kapp.
|
18
|
+
|
19
|
+
## [5.0.12](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.12) (2020-08-27)
|
20
|
+
|
21
|
+
**Implemented enhancements:**
|
22
|
+
|
23
|
+
- Implemented webapi APIs
|
24
|
+
|
25
|
+
## [5.0.11](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.11) (2020-08-24)
|
26
|
+
|
27
|
+
**Implemented enhancements:**
|
28
|
+
|
29
|
+
- Allow spaces in filenames when exporting items. Spaces were removed in 5.0.10, but they are valid in Windows so allowing them if they exist.
|
30
|
+
|
31
|
+
## [5.0.10](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.10) (2020-08-24)
|
32
|
+
|
33
|
+
**Implemented enhancements:**
|
34
|
+
|
35
|
+
- Changed how filenames are stored when items are exported to be compatible with Windows.
|
36
|
+
|
37
|
+
## [5.0.9](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.9) (2020-06-29)
|
38
|
+
|
39
|
+
**Implemented enhancements:**
|
40
|
+
|
41
|
+
- Bug fixes
|
42
|
+
|
43
|
+
## [5.0.8](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.8) (2020-06-11)
|
44
|
+
|
45
|
+
**Implemented enhancements:**
|
46
|
+
|
47
|
+
- Bug fixes
|
48
|
+
|
49
|
+
## [5.0.7](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.7) (2020-05-15)
|
50
|
+
|
51
|
+
**Implemented enhancements:**
|
52
|
+
|
53
|
+
- Bug fixes
|
54
|
+
|
55
|
+
## [5.0.6](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.6) (2020-04-24)
|
56
|
+
|
57
|
+
**Implemented enhancements:**
|
58
|
+
|
59
|
+
- Bug fixes
|
60
|
+
|
61
|
+
## [5.0.5](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.5) (2020-04-24)
|
62
|
+
|
63
|
+
**Implemented enhancements:**
|
64
|
+
|
65
|
+
- Bug fixes
|
66
|
+
|
67
|
+
## [5.0.4](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.4) (2020-02-12)
|
68
|
+
|
69
|
+
**Implemented enhancements:**
|
70
|
+
|
71
|
+
- Implemented platform components APIs
|
72
|
+
|
73
|
+
## [5.0.3](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.3) (2020-01-17)
|
74
|
+
|
75
|
+
**Implemented enhancements:**
|
76
|
+
|
77
|
+
- Implemented task engine configuration APIs
|
78
|
+
|
79
|
+
## [5.0.2](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.2) (2020-01-10)
|
80
|
+
|
81
|
+
**Implemented enhancements:**
|
82
|
+
|
83
|
+
- Fixed bug with jetching JWT regarding redirects
|
84
|
+
|
85
|
+
## [5.0.1](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.1) (2020-01-10)
|
86
|
+
|
87
|
+
**Implemented enhancements:**
|
88
|
+
|
89
|
+
- Implemented Task System error API
|
90
|
+
- Fixed typo in Discussions component
|
91
|
+
|
92
|
+
## [5.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.0) (2019-12-19)
|
93
|
+
|
94
|
+
### **1.x to 5.x Upgrade Warning**
|
95
|
+
|
96
|
+
All platform components (Core, Task, Agent, Discussions...etc) should be running a 5.x release or greater.
|
97
|
+
Unintended behavior is possible if running 5.x of the SDK against any platform component < 5.x.
|
98
|
+
|
99
|
+
## [1.0.2](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/1.0.2) (2019-12-18)
|
100
|
+
|
101
|
+
**Implemented enhancements:**
|
102
|
+
|
103
|
+
- Bug fixes
|
104
|
+
|
105
|
+
## [1.0.1](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/1.0.1) (2019-12-17)
|
106
|
+
|
107
|
+
**Implemented enhancements:**
|
108
|
+
|
109
|
+
- Bug fixes
|
110
|
+
|
3
111
|
## [1.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/1.0.0) (2019-06-13)
|
4
112
|
|
5
|
-
**
|
113
|
+
### **0.x to 1.x Upgrade Warning**
|
6
114
|
|
7
115
|
Export methods have been updated to reflect the folder structure
|
8
116
|
of their respective API routes.
|
@@ -39,34 +147,3 @@ sdk.logger.info("foo")
|
|
39
147
|
- Gateway errors (HTTP codes [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502), [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503), and [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504)) will automatically be retried, and may be controlled by the following options:
|
40
148
|
- :gateway_retry_limit (default 5), set to -1 to disable retrying gateway errors
|
41
149
|
- :gateway_retry_delay (default 1.0)
|
42
|
-
|
43
|
-
## [5.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.0) (2019-12-19)
|
44
|
-
|
45
|
-
** 1.x to 5.x Upgrade Warning **
|
46
|
-
All platform components (Core, Task, Agent, Discussions...etc) should be running a 5.x release or greater.
|
47
|
-
Unintended behavior is possible if running 5.x of the SDK against any platform component < 5.x.
|
48
|
-
|
49
|
-
## [5.0.1](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.1) (2020-01-10)
|
50
|
-
|
51
|
-
**Implemented enhancements:**
|
52
|
-
|
53
|
-
- Implemented Task System error API
|
54
|
-
- Fixed typo in Discussions component
|
55
|
-
|
56
|
-
## [5.0.2](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.2) (2020-01-10)
|
57
|
-
|
58
|
-
**Implemented enhancements:**
|
59
|
-
|
60
|
-
- Fixed bug with jetching JWT regarding redirects
|
61
|
-
|
62
|
-
## [5.0.3](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.3) (2020-01-17)
|
63
|
-
|
64
|
-
**Implemented enhancements:**
|
65
|
-
|
66
|
-
- Implmented task engine configuration APIs
|
67
|
-
|
68
|
-
## [5.0.4](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.4) (2020-02-12)
|
69
|
-
|
70
|
-
**Implemented enhancements:**
|
71
|
-
|
72
|
-
- Implmented platform components APIs
|
@@ -8,15 +8,16 @@ module KineticSdk
|
|
8
8
|
# - +origin+ - Origin ID of the submission to be added
|
9
9
|
# - +parent+ - Parent ID of the submission to be added
|
10
10
|
# - +values+ - hash of field values for the submission
|
11
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
11
12
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
12
13
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
13
14
|
def add_datastore_submission(form_slug, payload={}, headers=default_headers)
|
14
|
-
# initialize "values" if nil
|
15
|
-
payload["values"] = {} if payload["values"].nil?
|
16
15
|
# set origin hash if origin was passed as a string
|
17
16
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
18
17
|
# set parent hash if parent was passed as a string
|
19
18
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
19
|
+
# prepare any attachment values
|
20
|
+
payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
|
20
21
|
# Create the submission
|
21
22
|
@logger.info("Adding a submission in the \"#{form_slug}\" Datastore Form.")
|
22
23
|
post("#{@api_url}/datastore/forms/#{form_slug}/submissions", payload, headers)
|
@@ -30,15 +31,16 @@ module KineticSdk
|
|
30
31
|
# - +origin+ - Origin ID of the submission to be added
|
31
32
|
# - +parent+ - Parent ID of the submission to be added
|
32
33
|
# - +values+ - hash of field values for the submission
|
34
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
33
35
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
34
36
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
35
37
|
def add_datastore_submission_page(form_slug, page_name, payload={}, headers=default_headers)
|
36
|
-
# initialize "values" if nil
|
37
|
-
payload["values"] = {} if payload["values"].nil?
|
38
38
|
# set origin hash if origin was passed as a string
|
39
39
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
40
40
|
# set parent hash if parent was passed as a string
|
41
41
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
42
|
+
# prepare any attachment values
|
43
|
+
payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
|
42
44
|
# Create the submission
|
43
45
|
@logger.info("Adding a submission page in the \"#{form_slug}\" Datastore Form.")
|
44
46
|
post("#{@api_url}/datastore/forms/#{form_slug}/submissions?page=#{encode(page_name)}", payload, headers)
|
@@ -51,22 +53,47 @@ module KineticSdk
|
|
51
53
|
# - +origin+ - Origin ID of the submission to be patched
|
52
54
|
# - +parent+ - Parent ID of the submission to be patched
|
53
55
|
# - +values+ - hash of field values for the submission
|
56
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
54
57
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
55
58
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
56
59
|
def patch_datastore_submission(form_slug, payload={}, headers=default_headers)
|
57
60
|
# set the currentPage hash if currentPage was passed as a string
|
58
61
|
payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
|
59
|
-
# initialize "values" if nil
|
60
|
-
payload["values"] = {} if payload["values"].nil?
|
61
62
|
# set origin hash if origin was passed as a string
|
62
63
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
63
64
|
# set parent hash if parent was passed as a string
|
64
65
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
66
|
+
# prepare any attachment values
|
67
|
+
payload["values"] = prepare_new_datastore_submission_values(form_slug, payload["values"])
|
65
68
|
# Create the submission
|
66
69
|
@logger.info("Patching a submission in the \"#{form_slug}\" Form.")
|
67
70
|
patch("#{@api_url}/datastore/forms/#{form_slug}/submissions", payload, headers)
|
68
71
|
end
|
69
72
|
|
73
|
+
# Patch an existing Datastore Submission
|
74
|
+
#
|
75
|
+
# @param submission_id [String] id of the Submission
|
76
|
+
# @param payload [Hash] payload of the submission
|
77
|
+
# - +origin+ - Origin ID of the submission to be patched
|
78
|
+
# - +parent+ - Parent ID of the submission to be patched
|
79
|
+
# - +values+ - hash of field values for the submission
|
80
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
81
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
82
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
83
|
+
def patch_existing_datastore_submission(submission_id, payload={}, headers=default_headers)
|
84
|
+
# set the currentPage hash if currentPage was passed as a string
|
85
|
+
payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
|
86
|
+
# set origin hash if origin was passed as a string
|
87
|
+
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
88
|
+
# set parent hash if parent was passed as a string
|
89
|
+
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
90
|
+
# prepare any attachment values
|
91
|
+
payload["values"] = prepare_updated_datastore_submission_values(submission_id, payload["values"])
|
92
|
+
# Update the submission
|
93
|
+
@logger.info("Patching a submission with id \"#{submission_id}\"")
|
94
|
+
patch("#{@api_url}/datastore/submissions/#{submission_id}", payload, headers)
|
95
|
+
end
|
96
|
+
|
70
97
|
# Find all Submissions for a Datastore Form.
|
71
98
|
#
|
72
99
|
# This method will process pages of form submissions and internally
|
@@ -164,5 +191,27 @@ module KineticSdk
|
|
164
191
|
delete("#{@api_url}/datastore/submissions/#{encode(submission_id)}", headers)
|
165
192
|
end
|
166
193
|
|
194
|
+
private
|
195
|
+
|
196
|
+
# Prepares new datastore submission values for attachment fields
|
197
|
+
#
|
198
|
+
# @param form_slug [String] datastore form slug
|
199
|
+
# @param values [Hash] hash of values being submitted
|
200
|
+
# @return [Hash] hash of values with attachment paths replaced with uploaded file information
|
201
|
+
def prepare_new_datastore_submission_values(form_slug, values)
|
202
|
+
file_upload_url = "#{@api_url.gsub('/api/v1','')}/datastore/forms/#{form_slug}/files"
|
203
|
+
prepare_submission_values(values, file_upload_url)
|
204
|
+
end
|
205
|
+
|
206
|
+
# Prepares updated datastore submission values for attachment fields
|
207
|
+
#
|
208
|
+
# @param submission_id [String] id of the Submission
|
209
|
+
# @param values [Hash] hash of values being submitted
|
210
|
+
# @return [Hash] hash of values with attachment paths replaced with uploaded file information
|
211
|
+
def prepare_updated_datastore_submission_values(submission_id, values)
|
212
|
+
file_upload_url = "#{@api_url.gsub('/api/v1','')}/datastore/submissions/#{submission_id}/files"
|
213
|
+
prepare_submission_values(values, file_upload_url)
|
214
|
+
end
|
215
|
+
|
167
216
|
end
|
168
217
|
end
|
@@ -2,6 +2,7 @@ module KineticSdk
|
|
2
2
|
class Core
|
3
3
|
|
4
4
|
# Add a form type on a Kapp
|
5
|
+
# The method is being depreciated and replaced with add_formtype
|
5
6
|
#
|
6
7
|
# @param kapp_slug [String] slug of the Kapp the form type belongs to
|
7
8
|
# @param body [Hash] form type properties
|
@@ -14,7 +15,30 @@ module KineticSdk
|
|
14
15
|
post("#{@api_url}/kapps/#{kapp_slug}/formTypes", body, headers)
|
15
16
|
end
|
16
17
|
|
18
|
+
alias :add_formtype :add_form_type_on_kapp
|
19
|
+
|
20
|
+
def add_form_type_on_kapp(kapp_slug, body, headers=default_headers)
|
21
|
+
logger.info "Deprecation Warning: add_form_type_on_kapp method will be removed in a future version. Please use #add_formtype"
|
22
|
+
add_formtype(kapp_slug, body, headers=default_headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# Update a form type on a Kapp
|
27
|
+
#
|
28
|
+
# @param kapp_slug [String] slug of the Kapp the form type belongs to
|
29
|
+
# @param name [String] name of the form type
|
30
|
+
# @param body [Hash] form type properties
|
31
|
+
# - +name+ - A descriptive name for the form type
|
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 update_formtype(kapp_slug, name, body, headers=default_headers)
|
35
|
+
raise StandardError.new "Form Type properties is not valid, must be a Hash." unless body.is_a? Hash
|
36
|
+
@logger.info("Updating Form Type \"#{body['name']}\" for \"#{kapp_slug}\" kapp")
|
37
|
+
put("#{@api_url}/kapps/#{kapp_slug}/formTypes/#{encode(name)}", body, headers)
|
38
|
+
end
|
39
|
+
|
17
40
|
# Delete a form type on a Kapp
|
41
|
+
# The method is being depreciated and replaced with delete_formtype
|
18
42
|
#
|
19
43
|
# @param kapp_slug [String] slug of the Kapp the form type belongs to
|
20
44
|
# @param name [String] name of the form type
|
@@ -24,19 +48,46 @@ module KineticSdk
|
|
24
48
|
@logger.info("Deleting form type \"#{name}\" from \"#{kapp_slug}\" kapp")
|
25
49
|
delete("#{@api_url}/kapps/#{kapp_slug}/formTypes/#{encode(name)}", headers)
|
26
50
|
end
|
51
|
+
|
52
|
+
alias :delete_formtype :delete_form_type
|
53
|
+
|
54
|
+
def delete_form_type(kapp_slug, name, headers=default_headers)
|
55
|
+
logger.info "Deprecation Warning: delete_form_type method will be removed in a future version. Please use #delete_formtype"
|
56
|
+
delete_formtype(kapp_slug, name, headers=default_headers)
|
57
|
+
end
|
27
58
|
|
28
59
|
# Delete all form types on a Kapp
|
60
|
+
# The method is being depreciated and replaced with delete_formtypes
|
29
61
|
#
|
30
62
|
# @param kapp_slug [String] slug of the Kapp the form types belongs to
|
31
63
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
32
64
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
33
65
|
def delete_form_types_on_kapp(kapp_slug, headers=default_headers)
|
34
|
-
(
|
35
|
-
|
66
|
+
(find_formtypes(kapp_slug, {}, headers).content["formTypes"] || []).each do |form_type|
|
67
|
+
delete_formtype(kapp_slug, form_type['name'], headers)
|
36
68
|
end
|
37
69
|
end
|
70
|
+
|
71
|
+
alias :delete_formtypes :delete_form_types_on_kapp
|
72
|
+
|
73
|
+
def delete_form_types_on_kapp(kapp_slug, headers=default_headers)
|
74
|
+
logger.info "Deprecation Warning: delete_form_types_on_kapp method will be removed in a future version. Please use #delete_formtypes"
|
75
|
+
delete_formtypes(kapp_slug, headers=default_headers)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Retrieve a single form types for a Kapp
|
79
|
+
#
|
80
|
+
# @param kapp_slug [String] slug of the Kapp the form types belongs to
|
81
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
82
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
83
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
84
|
+
def find_formtype(kapp_slug, name, params={}, headers=default_headers)
|
85
|
+
@logger.info("Finding the #{name}Form Type for \"#{kapp_slug}\" kapp")
|
86
|
+
get("#{@api_url}/kapps/#{kapp_slug}/formTypes/#{encode(name)}", params, headers)
|
87
|
+
end
|
38
88
|
|
39
89
|
# Retrieve a list of all form types for a Kapp
|
90
|
+
# The method is being depreciated and replaced with find_formtypes
|
40
91
|
#
|
41
92
|
# @param kapp_slug [String] slug of the Kapp the form types belongs to
|
42
93
|
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
@@ -46,6 +97,12 @@ module KineticSdk
|
|
46
97
|
@logger.info("Finding Form Types for \"#{kapp_slug}\" kapp")
|
47
98
|
get("#{@api_url}/kapps/#{kapp_slug}/formTypes", params, headers)
|
48
99
|
end
|
100
|
+
|
101
|
+
alias :find_formtypes :find_form_types_on_kapp
|
49
102
|
|
103
|
+
def find_form_types_on_kapp(kapp_slug, params={}, headers=default_headers)
|
104
|
+
logger.info "Deprecation Warning: find_form_types_on_kapp method will be removed in a future version. Please use #find_formtypes"
|
105
|
+
find_formtypes(kapp_slug, params={}, headers=default_headers)
|
106
|
+
end
|
50
107
|
end
|
51
108
|
end
|
@@ -79,7 +79,6 @@ module KineticSdk
|
|
79
79
|
# Delete Agent Component
|
80
80
|
#
|
81
81
|
# @param agent_slug [String] the slug of the agent to retrieve
|
82
|
-
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
83
82
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
84
83
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
85
84
|
def delete_agent_component(agent_slug, headers = default_headers)
|
@@ -9,18 +9,19 @@ module KineticSdk
|
|
9
9
|
# - +origin+ - Origin ID of the submission to be added
|
10
10
|
# - +parent+ - Parent ID of the submission to be added
|
11
11
|
# - +values+ - hash of field values for the submission
|
12
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
12
13
|
# @param parameters [Hash] hash of query parameters to append to the URL
|
13
14
|
# - +include+ - comma-separated list of properties to include in the response
|
14
15
|
# - +completed+ - signals that the submission should be completed, default is false
|
15
16
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
16
17
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
17
18
|
def add_submission(kapp_slug, form_slug, payload={}, parameters={}, headers=default_headers)
|
18
|
-
# initialize "values" if nil
|
19
|
-
payload["values"] = {} if payload["values"].nil?
|
20
19
|
# set origin hash if origin was passed as a string
|
21
20
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
22
21
|
# set parent hash if parent was passed as a string
|
23
22
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
23
|
+
# prepare any attachment values
|
24
|
+
payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
|
24
25
|
# build the uri with the encoded parameters
|
25
26
|
uri = URI.parse("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions")
|
26
27
|
uri.query = URI.encode_www_form(parameters) unless parameters.empty?
|
@@ -38,6 +39,7 @@ module KineticSdk
|
|
38
39
|
# - +origin+ - Origin ID of the submission to be added
|
39
40
|
# - +parent+ - Parent ID of the submission to be added
|
40
41
|
# - +values+ - hash of field values for the submission
|
42
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
41
43
|
# @param parameters [Hash] hash of query parameters to append to the URL
|
42
44
|
# - +include+ - comma-separated list of properties to include in the response
|
43
45
|
# - +staged+ - Indicates whether field validations and page advancement should occur, default is false
|
@@ -45,12 +47,12 @@ module KineticSdk
|
|
45
47
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
46
48
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
47
49
|
def add_submission_page(kapp_slug, form_slug, page_name, payload={}, parameters={}, headers=default_headers)
|
48
|
-
# initialize "values" if nil
|
49
|
-
payload["values"] = {} if payload["values"].nil?
|
50
50
|
# set origin hash if origin was passed as a string
|
51
51
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
52
52
|
# set parent hash if parent was passed as a string
|
53
53
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
54
|
+
# prepare any attachment values
|
55
|
+
payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
|
54
56
|
# add the page name to the parameters
|
55
57
|
parameters["page"] = page_name
|
56
58
|
# build the uri with the encoded parameters
|
@@ -69,17 +71,18 @@ module KineticSdk
|
|
69
71
|
# - +origin+ - Origin ID of the submission to be patched
|
70
72
|
# - +parent+ - Parent ID of the submission to be patched
|
71
73
|
# - +values+ - hash of field values for the submission
|
74
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
72
75
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
73
76
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
74
77
|
def patch_new_submission(kapp_slug, form_slug, payload={}, headers=default_headers)
|
75
78
|
# set the currentPage hash if currentPage was passed as a string
|
76
79
|
payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
|
77
|
-
# initialize "values" if nil
|
78
|
-
payload["values"] = {} if payload["values"].nil?
|
79
80
|
# set origin hash if origin was passed as a string
|
80
81
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
81
82
|
# set parent hash if parent was passed as a string
|
82
83
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
84
|
+
# prepare any attachment values
|
85
|
+
payload["values"] = prepare_new_submission_values(kapp_slug, form_slug, payload["values"])
|
83
86
|
# Create the submission
|
84
87
|
@logger.info("Patching a submission in the \"#{form_slug}\" Form.")
|
85
88
|
patch("#{@api_url}/kapps/#{kapp_slug}/forms/#{form_slug}/submissions", payload, headers)
|
@@ -92,17 +95,18 @@ module KineticSdk
|
|
92
95
|
# - +origin+ - Origin ID of the submission to be patched
|
93
96
|
# - +parent+ - Parent ID of the submission to be patched
|
94
97
|
# - +values+ - hash of field values for the submission
|
98
|
+
# - attachment fields contain an Array of Hashes. Each hash represents an attachment answer for the field. The hash must include a `path` property with a value to represent the local file location.)
|
95
99
|
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
96
100
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
97
101
|
def patch_existing_submission(submission_id, payload={}, headers=default_headers)
|
98
102
|
# set the currentPage hash if currentPage was passed as a string
|
99
103
|
payload["currentPage"] = { "name" => payload["currentPage"] } if payload["currentPage"].is_a? String
|
100
|
-
# initialize "values" if nil
|
101
|
-
payload["values"] = {} if payload["values"].nil?
|
102
104
|
# set origin hash if origin was passed as a string
|
103
105
|
payload["origin"] = { "id" => payload["origin"] } if payload["origin"].is_a? String
|
104
106
|
# set parent hash if parent was passed as a string
|
105
107
|
payload["parent"] = { "id" => payload["parent"] } if payload["parent"].is_a? String
|
108
|
+
# prepare any attachment values
|
109
|
+
payload["values"] = prepare_updated_submission_values(submission_id, payload["values"])
|
106
110
|
# Create the submission
|
107
111
|
@logger.info("Patching a submission with id \"#{submission_id}\"")
|
108
112
|
patch("#{@api_url}/submissions/#{submission_id}", payload, headers)
|
@@ -211,5 +215,59 @@ module KineticSdk
|
|
211
215
|
put("#{@api_url}/submissions/#{encode(submission_id)}", body, headers)
|
212
216
|
end
|
213
217
|
|
218
|
+
private
|
219
|
+
|
220
|
+
# Prepares new submission values for attachment fields
|
221
|
+
#
|
222
|
+
# @param kapp_slug [String] kapp slug
|
223
|
+
# @param form_slug [String] form slug
|
224
|
+
# @param values [Hash] hash of values being submitted
|
225
|
+
# @return [Hash] hash of values with attachment paths replaced with uploaded file information
|
226
|
+
def prepare_new_submission_values(kapp_slug, form_slug, values)
|
227
|
+
file_upload_url = "#{@api_url.gsub('/app/api/v1','')}/#{kapp_slug}/#{form_slug}/files"
|
228
|
+
prepare_submission_values(values, file_upload_url)
|
229
|
+
end
|
230
|
+
|
231
|
+
# Prepares updated submission values for attachment fields
|
232
|
+
#
|
233
|
+
# @param submission_id [String] id of the Submission
|
234
|
+
# @param values [Hash] hash of values being submitted
|
235
|
+
# @return [Hash] hash of values with attachment paths replaced with uploaded file information
|
236
|
+
def prepare_updated_submission_values(submission_id, values)
|
237
|
+
file_upload_url = "#{@api_url.gsub('/app/api/v1','')}/submissions/#{submission_id}/files"
|
238
|
+
prepare_submission_values(values, file_upload_url)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Prepares submission values for attachment fields
|
242
|
+
#
|
243
|
+
# @param values [Hash] hash of values being submitted
|
244
|
+
# @param file_upload_url [String] url to post attachments
|
245
|
+
# @return [Hash] hash of values with attachment paths replaced with uploaded file information
|
246
|
+
def prepare_submission_values(values, file_upload_url)
|
247
|
+
# initialize the values
|
248
|
+
values = {} if values.nil?
|
249
|
+
# handle attachment values
|
250
|
+
values.each do |field, value|
|
251
|
+
# if the value contains an array of files
|
252
|
+
if value.is_a?(Array) && !value.empty? && value.first.is_a?(Hash) && value.first.has_key?('path')
|
253
|
+
value.each_with_index do |file, index|
|
254
|
+
# upload the file to the server
|
255
|
+
file_upload_response = post_multipart(
|
256
|
+
file_upload_url,
|
257
|
+
{ "package" => File.new(file['path']) },
|
258
|
+
default_headers)
|
259
|
+
# update the value with the file upload response
|
260
|
+
if file_upload_response.status == 200
|
261
|
+
values[field][index] = file_upload_response.content.first
|
262
|
+
else
|
263
|
+
raise "Attachment file upload failed: (#{file_upload_response.status}) #{file_upload_response.content_string}"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
# return the values
|
269
|
+
values
|
270
|
+
end
|
271
|
+
|
214
272
|
end
|
215
273
|
end
|
@@ -18,7 +18,6 @@ module KineticSdk
|
|
18
18
|
# either add or update the attribute value
|
19
19
|
exists = false
|
20
20
|
attributes.each do |attribute|
|
21
|
-
@logger.info("Attribute: #{attribute.inspect}")
|
22
21
|
# if the attribute already exists, update it
|
23
22
|
if attribute["name"] == attribute_name
|
24
23
|
attribute["values"] = attribute_value.is_a?(Array) ? attribute_value : [ attribute_value ]
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module KineticSdk
|
2
|
+
class Core
|
3
|
+
|
4
|
+
# Add a Web API on the Space
|
5
|
+
#
|
6
|
+
# @param body [Hash] hash of Web API properties
|
7
|
+
# - +method+ - The method of the Web API - "GET", "POST", "PUT", or "DELETE"
|
8
|
+
# - +slug+ - The slug of the Web API
|
9
|
+
# - +securityPolicies+ - [Array] Array of hashes
|
10
|
+
# - - +endpoint+ - "Execution"
|
11
|
+
# - - +name+ - Name of an existing Space Security Definition
|
12
|
+
|
13
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
14
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
15
|
+
def add_space_webapi(body, headers=default_headers)
|
16
|
+
raise StandardError.new "Web API properties is not valid, must be a Hash." unless body.is_a? Hash
|
17
|
+
@logger.info("Adding the \"#{body['slug']}\" to the Space.")
|
18
|
+
post("#{@api_url}/webApis", body, headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add a Web API on a Kapp
|
22
|
+
#
|
23
|
+
# @param kapp_slug [String] the Kapp slug
|
24
|
+
# @param body [Hash] hash of Web API properties
|
25
|
+
# - +method+ - The method of the Web API - "GET", "POST", "PUT", or "DELETE"
|
26
|
+
# - +slug+ - The slug of the Web API
|
27
|
+
# - +securityPolicies+ - [Array] Array of hashes
|
28
|
+
# - - +endpoint+ - "Execution"
|
29
|
+
# - - +name+ - Name of an existing Space Security Definition
|
30
|
+
|
31
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
32
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
33
|
+
def add_kapp_webapi(kapp_slug, body, headers=default_headers)
|
34
|
+
raise StandardError.new "Web API properties is not valid, must be a Hash." unless body.is_a? Hash
|
35
|
+
@logger.info("Adding the \"#{body['slug']}\" to the \"#{kapp_slug}\" Kapp.")
|
36
|
+
post("#{@api_url}/kapps/#{kapp_slug}/webApis", body, headers)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Find all Web APIs for the Space
|
40
|
+
#
|
41
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
42
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
43
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
44
|
+
def find_space_webapis(params={}, headers=default_headers)
|
45
|
+
@logger.info("Finding all Web APIs on the Space")
|
46
|
+
get("#{@api_url}/webApis", params, headers)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Find a single Web API on the Space
|
50
|
+
#
|
51
|
+
# @param slug [String] slug of the Web API
|
52
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
53
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
54
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
55
|
+
def find_space_webapi(slug, params={}, headers=default_headers)
|
56
|
+
@logger.info("Finding the \"#{slug}\" Web API on the Space")
|
57
|
+
get("#{@api_url}/webApis/#{slug}", params, headers)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Find all Web APIs for a Kapp
|
61
|
+
#
|
62
|
+
# @param kapp_slug [String] the Kapp slug
|
63
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
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 find_kapp_webapis(kapp_slug, params={}, headers=default_headers)
|
67
|
+
@logger.info("Finding all Web APIs on the \"#{kapp_slug}\" Kapp.")
|
68
|
+
get("#{@api_url}/kapps/#{kapp_slug}/webApis", params, headers)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Find a single Web API on the Kapp
|
72
|
+
#
|
73
|
+
# @param kapp_slug [String] the Kapp slug
|
74
|
+
# @param slug [String] slug of the Web API
|
75
|
+
# @param params [Hash] Query parameters that are added to the URL, such as +include+
|
76
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
77
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
78
|
+
def find_kapp_webapi(kapp_slug, slug, params={}, headers=default_headers)
|
79
|
+
@logger.info("Finding the \"#{slug}\" Web API on the \"#{kapp_slug}\" Kapp.")
|
80
|
+
get("#{@api_url}/kapps/#{kapp_slug}/webApis/#{slug}", params, headers)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Update a Web API on the Space
|
84
|
+
#
|
85
|
+
# All of the Web API properties are optional. Only the properties provided
|
86
|
+
# in the Hash will be updated, the other properties will retain their
|
87
|
+
# current values.
|
88
|
+
#
|
89
|
+
# @param slug [String] the slug of the Web API
|
90
|
+
# @param body [Hash] hash of Web API properties
|
91
|
+
# - +method+ - The method of the Web API - "GET", "POST", "PUT", or "DELETE"
|
92
|
+
# - +slug+ - The slug of the Web API
|
93
|
+
# - +securityPolicies+ - [Array] Array of hashes
|
94
|
+
# - - +endpoint+ - "Execution"
|
95
|
+
# - - +name+ - Name of an existing Space Security Definition
|
96
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
97
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
98
|
+
def update_space_webapi(slug, body, headers=default_headers)
|
99
|
+
@logger.info("Updating the \"#{slug}\" Web API on the Space.")
|
100
|
+
put("#{@api_url}/webApis/#{slug}", body, headers)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Update a Web API on a Kapp
|
104
|
+
#
|
105
|
+
# All of the Web API properties are optional. Only the properties provided
|
106
|
+
# in the Hash will be updated, the other properties will retain their
|
107
|
+
# current values.
|
108
|
+
#
|
109
|
+
# @param kapp_slug [String] the Kapp slug
|
110
|
+
# @param slug [String] the slug of the Web API
|
111
|
+
# @param body [Hash] hash of Web API properties
|
112
|
+
# - +method+ - The method of the Web API - "GET", "POST", "PUT", or "DELETE"
|
113
|
+
# - +slug+ - The slug of the Web API
|
114
|
+
# - +securityPolicies+ - [Array] Array of hashes
|
115
|
+
# - - +endpoint+ - "Execution"
|
116
|
+
# - - +name+ - Name of an existing Space Security Definition
|
117
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
118
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
119
|
+
def update_kapp_webapi(kapp_slug, slug, body, headers=default_headers)
|
120
|
+
@logger.info("Updating the \"#{slug}\" Web API on the \"#{kapp_slug}\" Kapp.")
|
121
|
+
put("#{@api_url}/kapps/#{kapp_slug}/webApis/#{slug}", body, headers)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Delete a Web API on the Space
|
125
|
+
# @param slug [String] the slug of the Web API
|
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 delete_space_webapi(slug, headers=default_headers)
|
129
|
+
@logger.info("Deleting the \"#{slug}\" Web API on the Space.")
|
130
|
+
delete("#{@api_url}/webApis/#{slug}", headers)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Delete a Web API on a Kapp
|
134
|
+
# @param kapp_slug [String] the Kapp slug
|
135
|
+
# @param slug [String] the slug of the Web API
|
136
|
+
# @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
|
137
|
+
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
138
|
+
def delete_kapp_webapi(kapp_slug, slug, headers=default_headers)
|
139
|
+
@logger.info("Deleting the \"#{slug}\" Web API on the \"#{kapp_slug}\" Kapp.")
|
140
|
+
delete("#{@api_url}/kapps/#{kapp_slug}/webApis/#{slug}", headers)
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
@@ -196,7 +196,7 @@ module KineticSdk
|
|
196
196
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
197
197
|
def delete_webhook_on_kapp(kapp_slug, name, headers=default_headers)
|
198
198
|
@logger.info("Deleting the #{name} webhook on the #{kapp_slug}\ kapp.")
|
199
|
-
delete(
|
199
|
+
delete("#{@api_url}/kapps/#{kapp_slug}/webhooks/#{encode(name)}", headers)
|
200
200
|
end
|
201
201
|
|
202
202
|
# Delete a webhook on space
|
@@ -18,7 +18,7 @@ module KineticSdk
|
|
18
18
|
def delete_handlers(headers=header_basic_auth)
|
19
19
|
@logger.info("Deleting all handlers")
|
20
20
|
(find_handlers(headers).content['handlers'] || []).each do |handler|
|
21
|
-
delete("#{@api_url}/handlers/#{handler['
|
21
|
+
delete("#{@api_url}/handlers/#{handler['definitionId']}", headers)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -49,7 +49,7 @@ module KineticSdk
|
|
49
49
|
# @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
|
50
50
|
def delete_sources(headers=header_basic_auth)
|
51
51
|
@logger.info("Deleting all sources")
|
52
|
-
(find_sources(headers).content[
|
52
|
+
(find_sources(headers).content["sourceRoots"] || []).each do |source|
|
53
53
|
delete("#{@api_url}/sources/#{encode(source['name'])}", headers)
|
54
54
|
end
|
55
55
|
end
|
@@ -140,11 +140,16 @@ module KineticSdk
|
|
140
140
|
|
141
141
|
# If this is not the "root" object
|
142
142
|
if object_path != '' && !file_contents.empty?
|
143
|
+
# Remove all `/` and `\` characters with ``
|
144
|
+
# Replace all `.` with `/`
|
145
|
+
# Replace all `::` with `-` (this ensures nested Teams/Categories maintain a separator)
|
146
|
+
# Replace all non-slug characters with ``
|
147
|
+
filename = "#{core_path}/#{object_path.gsub('/\\', '').gsub('.', '/').gsub(/::/, '-').gsub(/[^ a-zA-Z0-9_\-\/]/, '')}.json"
|
143
148
|
# Write the file_contents based upon the
|
144
|
-
filename = "#{core_path}/#{object_path.gsub('.', '/')}.json"
|
145
149
|
write_object_to_file(filename, file_contents)
|
146
150
|
end
|
147
151
|
|
152
|
+
|
148
153
|
# For each of the child objects
|
149
154
|
child_objects.each do |key, child_object|
|
150
155
|
# Process the export for that object (recursively)
|
@@ -634,9 +634,9 @@ module KineticSdk
|
|
634
634
|
# @option http_options [Fixnum] :max_redirects optional - max number of times to redirect
|
635
635
|
# @option http_options [Fixnum] :gateway_retry_limit optional - max number of times to retry a bad gateway
|
636
636
|
# @option http_options [Float] :gateway_retry_delay optional - number of seconds to delay before retrying a bad gateway
|
637
|
-
def stream_download_to_file(file_path, url, params={}, headers={}, http_options=@
|
637
|
+
def stream_download_to_file(file_path, url, params={}, headers={}, http_options=@options)
|
638
638
|
# Determine if redirection is involved
|
639
|
-
url = redirect_url(url, params, headers,
|
639
|
+
url = redirect_url(url, params, headers, http_options)
|
640
640
|
# parse the URL
|
641
641
|
uri = URI.parse(url)
|
642
642
|
|
@@ -645,15 +645,17 @@ module KineticSdk
|
|
645
645
|
# build the http object
|
646
646
|
http = build_http(uri)
|
647
647
|
|
648
|
-
#
|
649
|
-
file =
|
648
|
+
# prepare the download
|
649
|
+
file = nil
|
650
650
|
file_name = File.basename(file_path)
|
651
651
|
response_code = nil
|
652
652
|
message = nil
|
653
653
|
begin
|
654
|
+
# stream the attachment
|
654
655
|
http.request_get(uri.request_uri, headers) do |response|
|
655
656
|
response_code = response.code
|
656
657
|
if response_code == "200"
|
658
|
+
file = File.open(file_path, "wb")
|
657
659
|
response.read_body { |chunk| file.write(chunk) }
|
658
660
|
else
|
659
661
|
message = response.body
|
@@ -668,8 +670,9 @@ module KineticSdk
|
|
668
670
|
rescue StandardError => e
|
669
671
|
@logger.error("Failed to export file attachment \"#{file_name}\": (#{e})")
|
670
672
|
ensure
|
671
|
-
file.close()
|
673
|
+
file.close() unless file.nil?
|
672
674
|
end
|
675
|
+
message
|
673
676
|
end
|
674
677
|
|
675
678
|
|
data/lib/kinetic_sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinetic_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kinetic Data
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -17,8 +17,8 @@ dependencies:
|
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: 1.0.7
|
19
19
|
name: slugify
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
@@ -31,8 +31,8 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.0.0
|
33
33
|
name: multipart-post
|
34
|
-
prerelease: false
|
35
34
|
type: :runtime
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
@@ -45,8 +45,8 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '3.1'
|
47
47
|
name: mime-types
|
48
|
-
prerelease: false
|
49
48
|
type: :runtime
|
49
|
+
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
@@ -59,8 +59,8 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.12.1
|
61
61
|
name: parallel
|
62
|
-
prerelease: false
|
63
62
|
type: :runtime
|
63
|
+
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
@@ -73,8 +73,8 @@ dependencies:
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 1.9.0
|
75
75
|
name: ruby-progressbar
|
76
|
-
prerelease: false
|
77
76
|
type: :runtime
|
77
|
+
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
@@ -87,8 +87,8 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 0.1.1
|
89
89
|
name: kontena-websocket-client
|
90
|
-
prerelease: false
|
91
90
|
type: :development
|
91
|
+
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
@@ -101,8 +101,8 @@ dependencies:
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.17'
|
103
103
|
name: bundler
|
104
|
-
prerelease: false
|
105
104
|
type: :development
|
105
|
+
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
@@ -115,8 +115,8 @@ dependencies:
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 13.0.1
|
117
117
|
name: rake
|
118
|
-
prerelease: false
|
119
118
|
type: :development
|
119
|
+
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
@@ -129,8 +129,8 @@ dependencies:
|
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: 0.9.25
|
131
131
|
name: yard
|
132
|
-
prerelease: false
|
133
132
|
type: :development
|
133
|
+
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
@@ -362,6 +362,7 @@ files:
|
|
362
362
|
- lib/kinetic_sdk/core/lib/system_api.rb
|
363
363
|
- lib/kinetic_sdk/core/lib/teams.rb
|
364
364
|
- lib/kinetic_sdk/core/lib/users.rb
|
365
|
+
- lib/kinetic_sdk/core/lib/webapis.rb
|
365
366
|
- lib/kinetic_sdk/core/lib/webhook_jobs.rb
|
366
367
|
- lib/kinetic_sdk/core/lib/webhooks.rb
|
367
368
|
- lib/kinetic_sdk/discussions/discussions-sdk.rb
|
@@ -422,8 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
422
423
|
- !ruby/object:Gem::Version
|
423
424
|
version: '0'
|
424
425
|
requirements: []
|
425
|
-
|
426
|
-
rubygems_version: 2.6.11
|
426
|
+
rubygems_version: 3.0.6
|
427
427
|
signing_key:
|
428
428
|
specification_version: 4
|
429
429
|
summary: Ruby SDK for Kinetic Data application APIs
|