kinetic_sdk 5.0.12 → 5.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b48973a248ca9299a82e2f508af5fe67bea291f0b9a3b672c250fd963e96531b
4
- data.tar.gz: b2403cc106dee26a0a4f11f4bfe9be956d8ca3e7130a429285109569e4d406b0
3
+ metadata.gz: 22cb95924787cf5b0110e15bafdb1a6b4ca85f0175773618646d1b32f4912b50
4
+ data.tar.gz: ed52de6c6023256ad534e959d6e8282479cebc6282da90fef1c634387e962e4d
5
5
  SHA512:
6
- metadata.gz: 9b511e848a0eb5ba0c452b2407edb60382ae1a1fc03ca286e88245f8bd94330b0327b503dc1c592e2eaefd2769a86df09409c42c54b4a99ed1e8be8b6cf69680
7
- data.tar.gz: df63b8db823ae2d18b427534604ec14014f8e4263a303edb38bbfe62befe8cd0ed547c9cd8e0642e9d371fd2d3ad4140ad2c5bb31d9bde0f1821c922ac3fdda7
6
+ metadata.gz: a47c31339d5012c7f2c9f6416a32e461c52c2d8ec910bbde580b4c93b91e5a48463a507bfb769f87d27feccf47260b0c31bbb072b4f68748f0b0470e8eb6e4e2
7
+ data.tar.gz: '09def9dcb3e52be8816ab584529e0e3c94ff1d900c34be6c19af450fb372de2d176409699f716bbef3cf30c2155bd9ae1f66d452b42086fba55dcc85040e89a1'
data/CHANGELOG.md CHANGED
@@ -1,68 +1,135 @@
1
1
  # Change Log
2
2
 
3
+ ## [5.0.17](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.17) (2021-02-25)
4
+
5
+ **Implemented enhancements:**
6
+
7
+ - Bug fix related to removing user from a team
8
+
9
+
10
+ ## [5.0.16](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.16) (2021-02-25)
11
+
12
+ **Implemented enhancements:**
13
+
14
+ - Implmented ability to remove user from a team
15
+
16
+ ## [5.0.15](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.15) (2021-01-20)
17
+
18
+ **Implemented enhancements:**
19
+
20
+ - Bug Fixes
21
+
22
+ ## [5.0.14](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.14) (2021-01-15)
23
+
24
+ **Implemented enhancements:**
25
+
26
+ - Support for submitting attachments (datastore and form submissions)
27
+ - Bug Fixes
28
+
29
+ ## [5.0.13](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.13) (2020-09-03)
30
+
31
+ **Implemented enhancements:**
32
+
33
+ - Added missing Form Type methods.
34
+ - Deprecated some Form Type methods and replaced with simpler names.
35
+ - Removed an unnecessary logging statement when adding a team attribute.
36
+ - Removed double URL encoding when deleting a webhook from a Kapp.
37
+
3
38
  ## [5.0.12](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.12) (2020-08-27)
4
39
 
5
- Added routes for webapis.
40
+ **Implemented enhancements:**
41
+
42
+ - Implemented webapi APIs
6
43
 
7
44
  ## [5.0.11](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.11) (2020-08-24)
8
45
 
9
- Don't remove spaces in filenames when exporting items. Spaces are valid in Windows filenames.
46
+ **Implemented enhancements:**
47
+
48
+ - 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.
10
49
 
11
50
  ## [5.0.10](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.10) (2020-08-24)
12
51
 
13
- Changed how filenames are stored when items are exported to be compatible with Windows.
52
+ **Implemented enhancements:**
53
+
54
+ - Changed how filenames are stored when items are exported to be compatible with Windows.
14
55
 
15
56
  ## [5.0.9](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.9) (2020-06-29)
16
57
 
17
- Bug Fixes.
58
+ **Implemented enhancements:**
59
+
60
+ - Bug fixes
18
61
 
19
62
  ## [5.0.8](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.8) (2020-06-11)
20
63
 
21
- Bug Fixes.
64
+ **Implemented enhancements:**
65
+
66
+ - Bug fixes
22
67
 
23
68
  ## [5.0.7](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.7) (2020-05-15)
24
69
 
25
- Bug Fixes.
70
+ **Implemented enhancements:**
71
+
72
+ - Bug fixes
26
73
 
27
74
  ## [5.0.6](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.6) (2020-04-24)
28
75
 
29
- Bug Fixes.
76
+ **Implemented enhancements:**
77
+
78
+ - Bug fixes
30
79
 
31
80
  ## [5.0.5](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.5) (2020-04-24)
32
81
 
33
- Bug Fixes.
82
+ **Implemented enhancements:**
83
+
84
+ - Bug fixes
85
+
86
+ ## [5.0.4](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.4) (2020-02-12)
87
+
88
+ **Implemented enhancements:**
89
+
90
+ - Implemented platform components APIs
91
+
92
+ ## [5.0.3](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.3) (2020-01-17)
93
+
94
+ **Implemented enhancements:**
34
95
 
35
- ## [5.0.4](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.4) (2020-02-12)
96
+ - Implemented task engine configuration APIs
36
97
 
37
- Bug Fixes.
98
+ ## [5.0.2](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.2) (2020-01-10)
38
99
 
39
- ## [5.0.3](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.3) (2020-01-16)
100
+ **Implemented enhancements:**
40
101
 
41
- Bug Fixes.
102
+ - Fixed bug with jetching JWT regarding redirects
42
103
 
43
- ## [5.0.2](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.2) (2020-01-10)
104
+ ## [5.0.1](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.1) (2020-01-10)
44
105
 
45
- Bug Fixes.
106
+ **Implemented enhancements:**
46
107
 
47
- ## [5.0.1](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.1) (2020-01-10)
108
+ - Implemented Task System error API
109
+ - Fixed typo in Discussions component
48
110
 
49
- Bug Fixes.
111
+ ## [5.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.0) (2019-12-19)
50
112
 
51
- ## [5.0.0](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/5.0.0) (2019-12-19)
113
+ ### **1.x to 5.x Upgrade Warning**
52
114
 
53
- Bumped version to correspond with Kinetic Platform 5.0.0.
115
+ All platform components (Core, Task, Agent, Discussions...etc) should be running a 5.x release or greater.
116
+ Unintended behavior is possible if running 5.x of the SDK against any platform component < 5.x.
54
117
 
55
118
  ## [1.0.2](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/1.0.2) (2019-12-18)
56
119
 
57
- Bug Fixes.
120
+ **Implemented enhancements:**
121
+
122
+ - Bug fixes
58
123
 
59
124
  ## [1.0.1](https://github.com/kineticdata/kinetic-sdk-rb/releases/tag/1.0.1) (2019-12-17)
60
125
 
61
- Bug Fixes.
126
+ **Implemented enhancements:**
127
+
128
+ - Bug fixes
62
129
 
63
130
  ## [1.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/1.0.0) (2019-06-13)
64
131
 
65
- ** 0.x to 1.x Upgrade Warning **
132
+ ### **0.x to 1.x Upgrade Warning**
66
133
 
67
134
  Export methods have been updated to reflect the folder structure
68
135
  of their respective API routes.
@@ -99,34 +166,3 @@ sdk.logger.info("foo")
99
166
  - 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:
100
167
  - :gateway_retry_limit (default 5), set to -1 to disable retrying gateway errors
101
168
  - :gateway_retry_delay (default 1.0)
102
-
103
- ## [5.0.0](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.0) (2019-12-19)
104
-
105
- ** 1.x to 5.x Upgrade Warning **
106
- All platform components (Core, Task, Agent, Discussions...etc) should be running a 5.x release or greater.
107
- Unintended behavior is possible if running 5.x of the SDK against any platform component < 5.x.
108
-
109
- ## [5.0.1](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.1) (2020-01-10)
110
-
111
- **Implemented enhancements:**
112
-
113
- - Implemented Task System error API
114
- - Fixed typo in Discussions component
115
-
116
- ## [5.0.2](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.2) (2020-01-10)
117
-
118
- **Implemented enhancements:**
119
-
120
- - Fixed bug with jetching JWT regarding redirects
121
-
122
- ## [5.0.3](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.3) (2020-01-17)
123
-
124
- **Implemented enhancements:**
125
-
126
- - Implmented task engine configuration APIs
127
-
128
- ## [5.0.4](https://github.com/kineticdata/kinetic-sdk-rb/tree/5.0.4) (2020-02-12)
129
-
130
- **Implemented enhancements:**
131
-
132
- - Implmented platform components APIs
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Bridge to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Bridge
69
68
  # - +space+
70
69
  # - +adapterClass+
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Filestore to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Filestore
69
68
  # - +space+
70
69
  # - +adapterClass+
@@ -64,7 +64,6 @@ module KineticSdk
64
64
 
65
65
  # Add Handler to Space
66
66
  #
67
- # @param space [String] slug of the space
68
67
  # @param body [Hash] properties associated to the Handler
69
68
  # - +space+
70
69
  # - +definitionId+
@@ -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
- (find_form_types_on_kapp(kapp_slug, {}, headers).content["formTypes"] || []).each do |form_type|
35
- delete_form_type(kapp_slug, form_type['name'], headers)
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 ]
@@ -74,6 +73,18 @@ module KineticSdk
74
73
  post("#{@api_url}/memberships/", body, headers)
75
74
  end
76
75
 
76
+ # remove a team membership
77
+ #
78
+ # @param team_name [String] the team name
79
+ # @param username [String] the username to remove to the team
80
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
81
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
82
+ def remove_team_membership(team_name, username, headers=default_headers)
83
+ team_slug = Digest::MD5.hexdigest(team_name)
84
+ @logger.info("Removing user: \"#{username}\" from \"#{team_name}\" team")
85
+ delete("#{@api_url}/memberships/#{team_slug}_#{username}", headers)
86
+ end
87
+
77
88
  # Find teams
78
89
  #
79
90
  # @param params [Hash] Query parameters that are added to the URL, such as +include+
@@ -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(URI.encode("#{@api_url}/kapps/#{kapp_slug}/webhooks/#{encode(name)}"), headers)
199
+ delete("#{@api_url}/kapps/#{kapp_slug}/webhooks/#{encode(name)}", headers)
200
200
  end
201
201
 
202
202
  # Delete a webhook on space
@@ -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['sources'] || []).each do |source|
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
@@ -424,13 +424,11 @@ module KineticSdk
424
424
  # prepare the payload
425
425
  payload = data.inject({}) do |h,(k,v)|
426
426
  if v.class == File
427
- h[k] = UploadIO.new(v, mimetype(v), File.basename(v))
427
+ h[k] = UploadIO.new(v, mimetype(v).first, File.basename(v))
428
428
  elsif v.class == Array
429
- # f = v.first
430
- # h[k] = UploadIO.new(f, mimetype(f), File.basename(f)) unless f.nil?
431
429
  h[k] = v.inject([]) do |files, part|
432
430
  if part.class == File
433
- files << UploadIO.new(part, mimetype(part), File.basename(part))
431
+ files << UploadIO.new(part, mimetype(part).first, File.basename(part))
434
432
  end
435
433
  end
436
434
  else
@@ -634,9 +632,9 @@ module KineticSdk
634
632
  # @option http_options [Fixnum] :max_redirects optional - max number of times to redirect
635
633
  # @option http_options [Fixnum] :gateway_retry_limit optional - max number of times to retry a bad gateway
636
634
  # @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=@http_options)
635
+ def stream_download_to_file(file_path, url, params={}, headers={}, http_options=@options)
638
636
  # Determine if redirection is involved
639
- url = redirect_url(url, params, headers, max_redirects)
637
+ url = redirect_url(url, params, headers, http_options)
640
638
  # parse the URL
641
639
  uri = URI.parse(url)
642
640
 
@@ -645,15 +643,17 @@ module KineticSdk
645
643
  # build the http object
646
644
  http = build_http(uri)
647
645
 
648
- # stream the attachment
649
- file = File.open(file_path, "wb")
646
+ # prepare the download
647
+ file = nil
650
648
  file_name = File.basename(file_path)
651
649
  response_code = nil
652
650
  message = nil
653
651
  begin
652
+ # stream the attachment
654
653
  http.request_get(uri.request_uri, headers) do |response|
655
654
  response_code = response.code
656
655
  if response_code == "200"
656
+ file = File.open(file_path, "wb")
657
657
  response.read_body { |chunk| file.write(chunk) }
658
658
  else
659
659
  message = response.body
@@ -668,8 +668,9 @@ module KineticSdk
668
668
  rescue StandardError => e
669
669
  @logger.error("Failed to export file attachment \"#{file_name}\": (#{e})")
670
670
  ensure
671
- file.close()
671
+ file.close() unless file.nil?
672
672
  end
673
+ message
673
674
  end
674
675
 
675
676
 
@@ -3,5 +3,5 @@ module KineticSdk
3
3
  # Version of Kinetic SDK
4
4
  #
5
5
  # @return [String] Version of the SDK
6
- VERSION = "5.0.12"
6
+ VERSION = "5.0.17"
7
7
  end
metadata CHANGED
@@ -1,142 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kinetic_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.12
4
+ version: 5.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinetic Data
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2021-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: slugify
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '='
17
18
  - !ruby/object:Gem::Version
18
19
  version: 1.0.7
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
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.0.7
27
27
  - !ruby/object:Gem::Dependency
28
+ name: multipart-post
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - '='
31
32
  - !ruby/object:Gem::Version
32
33
  version: 2.0.0
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
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
+ name: mime-types
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - '='
45
46
  - !ruby/object:Gem::Version
46
47
  version: '3.1'
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
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.1'
55
55
  - !ruby/object:Gem::Dependency
56
+ name: parallel
56
57
  requirement: !ruby/object:Gem::Requirement
57
58
  requirements:
58
59
  - - '='
59
60
  - !ruby/object:Gem::Version
60
61
  version: 1.12.1
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
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.12.1
69
69
  - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
70
71
  requirement: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - '='
73
74
  - !ruby/object:Gem::Version
74
75
  version: 1.9.0
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
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.9.0
83
83
  - !ruby/object:Gem::Dependency
84
+ name: kontena-websocket-client
84
85
  requirement: !ruby/object:Gem::Requirement
85
86
  requirements:
86
87
  - - '='
87
88
  - !ruby/object:Gem::Version
88
89
  version: 0.1.1
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
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.1.1
97
97
  - !ruby/object:Gem::Dependency
98
+ name: bundler
98
99
  requirement: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - "~>"
101
102
  - !ruby/object:Gem::Version
102
103
  version: '1.17'
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
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.17'
111
111
  - !ruby/object:Gem::Dependency
112
+ name: rake
112
113
  requirement: !ruby/object:Gem::Requirement
113
114
  requirements:
114
115
  - - "~>"
115
116
  - !ruby/object:Gem::Version
116
117
  version: 13.0.1
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
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 13.0.1
125
125
  - !ruby/object:Gem::Dependency
126
+ name: yard
126
127
  requirement: !ruby/object:Gem::Requirement
127
128
  requirements:
128
129
  - - "~>"
129
130
  - !ruby/object:Gem::Version
130
131
  version: 0.9.25
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
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.9.25
139
- description:
139
+ description:
140
140
  email:
141
141
  - support@kineticdata.com
142
142
  executables:
@@ -408,7 +408,7 @@ homepage: https://github.com/kineticdata/kinetic-sdk-rb
408
408
  licenses: []
409
409
  metadata:
410
410
  yard.run: yri
411
- post_install_message:
411
+ post_install_message:
412
412
  rdoc_options: []
413
413
  require_paths:
414
414
  - lib
@@ -423,9 +423,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
423
423
  - !ruby/object:Gem::Version
424
424
  version: '0'
425
425
  requirements: []
426
- rubyforge_project:
427
- rubygems_version: 2.6.11
428
- signing_key:
426
+ rubygems_version: 3.0.3
427
+ signing_key:
429
428
  specification_version: 4
430
429
  summary: Ruby SDK for Kinetic Data application APIs
431
430
  test_files: []