kinetic_sdk 5.0.21 → 5.0.23

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/Contributing.md +15 -14
  4. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/History.md +89 -23
  5. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/Manifest.txt +1 -0
  6. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/README.rdoc +1 -1
  7. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/Rakefile +12 -53
  8. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/type.rb +28 -2
  9. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/cache.rb +3 -7
  10. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/deprecations.rb +12 -12
  11. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/logger.rb +1 -1
  12. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/registry.rb +1 -1
  13. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types.rb +9 -9
  14. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/minitest_helper.rb +0 -1
  15. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_type.rb +47 -11
  16. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_types.rb +4 -0
  17. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_types_cache.rb +1 -1
  18. data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_types_class.rb +5 -0
  19. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/Contributing.md +3 -0
  20. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/History.md +94 -34
  21. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/Manifest.txt +0 -1
  22. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/Rakefile +34 -19
  23. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/content_type_mime.db +3 -0
  24. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/ext_mime.db +6 -2
  25. data/gems/mime-types-data-3.2023.1205/data/mime-types.json +1 -0
  26. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.content_type.column +149 -4
  27. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.docs.column +145 -0
  28. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.encoding.column +145 -0
  29. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.flags.column +152 -7
  30. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.friendly.column +145 -0
  31. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.pext.column +145 -0
  32. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.use_instead.column +148 -3
  33. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/data/mime.xrefs.column +230 -85
  34. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/lib/mime/types/data.rb +1 -1
  35. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/application.yaml +1291 -85
  36. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/audio.yaml +14 -5
  37. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/image.yaml +81 -20
  38. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/message.yaml +38 -2
  39. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/model.yaml +66 -6
  40. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/multipart.yaml +2 -2
  41. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/text.yaml +99 -8
  42. data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/video.yaml +28 -1
  43. data/lib/kinetic_sdk/core/lib/form_types.rb +7 -7
  44. data/lib/kinetic_sdk/core/lib/space.rb +148 -2
  45. data/lib/kinetic_sdk/core/lib/submissions.rb +10 -0
  46. data/lib/kinetic_sdk/task/lib/export.rb +4 -2
  47. data/lib/kinetic_sdk/task/lib/trees.rb +46 -50
  48. data/lib/kinetic_sdk/version.rb +1 -1
  49. metadata +66 -67
  50. data/gems/mime-types-data-3.2022.0105/data/mime-types.json +0 -1
  51. data/gems/mime-types-data-3.2022.0105/types/provisional-standard-types.yaml +0 -145
  52. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/Code-of-Conduct.md +0 -0
  53. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/Licence.md +0 -0
  54. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/type/columnar.rb +0 -0
  55. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/_columnar.rb +0 -0
  56. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/columnar.rb +0 -0
  57. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/container.rb +0 -0
  58. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/full.rb +0 -0
  59. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime/types/loader.rb +0 -0
  60. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/lib/mime-types.rb +0 -0
  61. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/bad-fixtures/malformed +0 -0
  62. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/fixture/json.json +0 -0
  63. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/fixture/old-data +0 -0
  64. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/fixture/yaml.yaml +0 -0
  65. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_types_lazy.rb +0 -0
  66. /data/gems/{mime-types-3.4.1 → mime-types-3.5.2}/test/test_mime_types_loader.rb +0 -0
  67. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/Code-of-Conduct.md +0 -0
  68. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/Licence.md +0 -0
  69. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/README.md +0 -0
  70. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/lib/mime-types-data.rb +0 -0
  71. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/chemical.yaml +0 -0
  72. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/conference.yaml +0 -0
  73. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/drawing.yaml +0 -0
  74. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/font.yaml +0 -0
  75. /data/gems/{mime-types-data-3.2022.0105 → mime-types-data-3.2023.1205}/types/world.yaml +0 -0
@@ -230,13 +230,22 @@
230
230
  template:
231
231
  - video/H265
232
232
  registered: true
233
+ - !ruby/object:MIME::Type
234
+ content-type: video/H266
235
+ encoding: base64
236
+ xrefs:
237
+ rfc:
238
+ - rfc9328
239
+ template:
240
+ - video/H266
241
+ registered: true
233
242
  - !ruby/object:MIME::Type
234
243
  content-type: video/iso.segment
235
244
  encoding: base64
236
245
  xrefs:
237
246
  person:
238
247
  - David_Singer
239
- - ISO-IEC_JTC1
248
+ - ISO-IEC_JTC_1
240
249
  template:
241
250
  - video/iso.segment
242
251
  registered: true
@@ -281,6 +290,24 @@
281
290
  template:
282
291
  - video/jxsv
283
292
  registered: true
293
+ - !ruby/object:MIME::Type
294
+ content-type: video/matroska
295
+ encoding: base64
296
+ xrefs:
297
+ draft:
298
+ - RFC-ietf-cellar-matroska-21
299
+ template:
300
+ - video/matroska
301
+ registered: true
302
+ - !ruby/object:MIME::Type
303
+ content-type: video/matroska-3d
304
+ encoding: base64
305
+ xrefs:
306
+ draft:
307
+ - RFC-ietf-cellar-matroska-21
308
+ template:
309
+ - video/matroska-3d
310
+ registered: true
284
311
  - !ruby/object:MIME::Type
285
312
  content-type: video/MJ2
286
313
  friendly:
@@ -18,7 +18,7 @@ module KineticSdk
18
18
  alias :add_formtype :add_form_type_on_kapp
19
19
 
20
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"
21
+ @logger.info "Deprecation Warning: add_form_type_on_kapp method will be removed in a future version. Please use #add_formtype"
22
22
  add_formtype(kapp_slug, body, headers=default_headers)
23
23
  end
24
24
 
@@ -35,7 +35,7 @@ module KineticSdk
35
35
  raise StandardError.new "Form Type properties is not valid, must be a Hash." unless body.is_a? Hash
36
36
  @logger.info("Updating Form Type \"#{body['name']}\" for \"#{kapp_slug}\" kapp")
37
37
  put("#{@api_url}/kapps/#{kapp_slug}/formTypes/#{encode(name)}", body, headers)
38
- end
38
+ end
39
39
 
40
40
  # Delete a form type on a Kapp
41
41
  # The method is being depreciated and replaced with delete_formtype
@@ -52,7 +52,7 @@ module KineticSdk
52
52
  alias :delete_formtype :delete_form_type
53
53
 
54
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"
55
+ @logger.info "Deprecation Warning: delete_form_type method will be removed in a future version. Please use #delete_formtype"
56
56
  delete_formtype(kapp_slug, name, headers=default_headers)
57
57
  end
58
58
 
@@ -71,9 +71,9 @@ module KineticSdk
71
71
  alias :delete_formtypes :delete_form_types_on_kapp
72
72
 
73
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"
74
+ @logger.info "Deprecation Warning: delete_form_types_on_kapp method will be removed in a future version. Please use #delete_formtypes"
75
75
  delete_formtypes(kapp_slug, headers=default_headers)
76
- end
76
+ end
77
77
 
78
78
  # Retrieve a single form types for a Kapp
79
79
  #
@@ -101,8 +101,8 @@ module KineticSdk
101
101
  alias :find_formtypes :find_form_types_on_kapp
102
102
 
103
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"
104
+ @logger.info "Deprecation Warning: find_form_types_on_kapp method will be removed in a future version. Please use #find_formtypes"
105
105
  find_formtypes(kapp_slug, params={}, headers=default_headers)
106
- end
106
+ end
107
107
  end
108
108
  end
@@ -85,11 +85,65 @@ module KineticSdk
85
85
  "space.webApis.{slug}",
86
86
  "space.webhooks.{name}",
87
87
  )
88
- core_data = get("#{@api_url}/space", { 'export' => true}, headers).content
88
+ core_data = find_space({ 'export' => true }, headers).content
89
89
  process_export(@options[:export_directory], export_shape, core_data)
90
+ export_workflows(headers)
90
91
  @logger.info("Finished exporting space definition to #{@options[:export_directory]}.")
91
92
  end
92
93
 
94
+ # Exports linked workflows for the space, kapps, and forms. This method is automatically called from `KineticSdk.Core.export_space()`.
95
+ #
96
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
97
+ # @return nil
98
+ def export_workflows(headers=default_headers)
99
+ # Workflows were introduced in core v6
100
+ version = app_version(headers).content["version"]
101
+ if version && version["version"] < "6"
102
+ @logger.info("Skip exporting workflows because the Core server version doesn't support workflows.")
103
+ return
104
+ end
105
+
106
+ raise StandardError.new "An export directory must be defined to export workflows." if @options[:export_directory].nil?
107
+ @logger.info("Exporting workflows to #{@options[:export_directory]}.")
108
+
109
+ # space workflows
110
+ space_workflows = find_space_workflows({ "include" => "details" }, headers).content["workflows"] || []
111
+ space_workflows.select { |wf| !wf["event"].nil? }.each do |workflow|
112
+ @logger.info(workflow) unless workflow["name"]
113
+ evt = workflow["event"].slugify
114
+ name = workflow["name"].slugify
115
+ filename = "#{File.join(@options[:export_directory], "space", "workflows", evt, name)}.json"
116
+ workflow_json = find_space_workflow(workflow["id"], {}, headers).content["treeJson"]
117
+ write_object_to_file(filename, workflow_json)
118
+ end
119
+
120
+ space_content = find_space({ 'include' => "kapps.details,kapps.forms.details" }).content["space"]
121
+
122
+ # kapp workflows
123
+ space_content["kapps"].each do |kapp|
124
+ kapp_workflows = find_kapp_workflows(kapp["slug"], {}, headers).content["workflows"] || []
125
+ kapp_workflows.select { |wf| !wf["event"].nil? }.each do |workflow|
126
+ evt = workflow["event"].slugify
127
+ name = workflow["name"].slugify
128
+ filename = "#{File.join(@options[:export_directory], "space", "kapps", kapp["slug"], "workflows", evt, name)}.json"
129
+ workflow_json = find_kapp_workflow(kapp["slug"], workflow["id"], {}, headers).content["treeJson"]
130
+ write_object_to_file(filename, workflow_json)
131
+ end
132
+
133
+ # form workflows
134
+ kapp["forms"].each do |form|
135
+ form_workflows = find_form_workflows(kapp["slug"], form["slug"], {}, headers).content["workflows"] || []
136
+ form_workflows.select { |wf| !wf["event"].nil? }.each do |workflow|
137
+ evt = workflow["event"].slugify
138
+ name = workflow["name"].slugify
139
+ filename = "#{File.join(@options[:export_directory], "space", "kapps", kapp["slug"], "forms", form["slug"], "workflows", evt, name)}.json"
140
+ workflow_json = find_form_workflow(kapp["slug"], form["slug"], workflow["id"], {}, headers).content["treeJson"]
141
+ write_object_to_file(filename, workflow_json)
142
+ end
143
+ end
144
+ end
145
+ end
146
+
93
147
  # Find the space
94
148
  #
95
149
  # @param params [Hash] Query parameters that are added to the URL, such as +include+
@@ -100,7 +154,8 @@ module KineticSdk
100
154
  get("#{@api_url}/space", params, headers)
101
155
  end
102
156
 
103
- # Imports a full space definition from the export_directory
157
+ # Imports a full space definition from the export_directory, except for workflows. Those must be imported separately after
158
+ # the Kinetic Platform source exists in task.
104
159
  #
105
160
  # @param slug [String] the slug of the space that is being imported
106
161
  # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
@@ -146,6 +201,97 @@ module KineticSdk
146
201
  @logger.info("Finished importing space definition to #{@options[:export_directory]}.")
147
202
  end
148
203
 
204
+ # Imports the workflows for the space. This method should be called after importing the Kinetic Platform source into task.
205
+ #
206
+ # @param slug [String] the slug of the space that is being imported
207
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
208
+ # @return nil
209
+ def import_workflows(slug, headers=default_headers)
210
+ # Workflows were introduced in core v6
211
+ version = app_version(headers).content["version"]
212
+ if version && version["version"] < "6"
213
+ @logger.info("Skip importing workflows because the Core server version doesn't support workflows.")
214
+ return
215
+ end
216
+
217
+ raise StandardError.new "An export directory must be defined to import space." if @options[:export_directory].nil?
218
+ @logger.info("Importing workflows from #{@options[:export_directory]}.")
219
+
220
+ # Map of existing workflows by space, kapp, form
221
+ existing_workflows_cache = {}
222
+ # Regular expressions to match workflow paths by space, kapp, or form
223
+ form_re = /^\/kapps\/(?<kapp_slug>[a-z0-9]+(?:-[a-z0-9]+)*)\/forms\/(?<form_slug>[a-z0-9]+(?:-[a-z0-9]+)*)\/workflows/
224
+ kapp_re = /^\/kapps\/(?<kapp_slug>[a-z0-9]+(?:-[a-z0-9]+)*)\/workflows/
225
+ space_re = /^\/workflows/
226
+
227
+ # Loop over all provided files sorting files before folders
228
+ Dir["#{@options[:export_directory]}/space/**/workflows/**/*.json"].map { |file| [file.count("/"), file] }.sort.map { |file| file[1] }.each do |file|
229
+ rel_path = file.sub("#{@options[:export_directory]}/", '')
230
+ path_parts = File.dirname(rel_path).split(File::SEPARATOR)
231
+ api_parts_path = path_parts[0..-1]
232
+ api_path = "/#{api_parts_path.join("/").sub(/^space\//,'').sub(/\/[^\/]+$/,'')}"
233
+
234
+ # populate the existing workflows for the workflowable object
235
+ matches = form_re.match(api_path)
236
+ # form workflows
237
+ if matches
238
+ form_slug = matches["form_slug"]
239
+ kapp_slug = matches["kapp_slug"]
240
+ map_key = self.space_slug + "|" + kapp_slug + "|" + form_slug
241
+ if !existing_workflows_cache.has_key?(map_key)
242
+ response = find_form_workflows(kapp_slug, form_slug, { "includes" => "details" }, headers)
243
+ existing_workflows_cache[map_key] = response.content["workflows"]
244
+ end
245
+ else
246
+ matches = kapp_re.match(api_path)
247
+ # kapp workflows
248
+ if matches
249
+ kapp_slug = matches["kapp_slug"]
250
+ map_key = self.space_slug + "|" + kapp_slug
251
+ if !existing_workflows_cache.has_key?(map_key)
252
+ response = find_kapp_workflows(kapp_slug, { "includes" => "details" }, headers)
253
+ existing_workflows_cache[map_key] = response.content["workflows"]
254
+ end
255
+ else
256
+ # space workflows
257
+ map_key = self.space_slug
258
+ if !existing_workflows_cache.has_key?(map_key)
259
+ response = find_space_workflows({ "includes" => "details" }, headers)
260
+ existing_workflows_cache[map_key] = response.content["workflows"]
261
+ end
262
+ end
263
+ end
264
+
265
+ tree_json = JSON.parse(File.read(file))
266
+ event = path_parts.last.split("-").map { |part| part.capitalize }.join(" ")
267
+ name = tree_json["name"]
268
+
269
+ body = {
270
+ "event" => event,
271
+ "name" => name,
272
+ "treeJson" => tree_json
273
+ }
274
+
275
+ # check if the workflow already exists
276
+ existing_workflow = (existing_workflows_cache[map_key] || []).select { |wf|
277
+ wf["event"] == event && wf["name"] == name
278
+ }.first
279
+
280
+ if existing_workflow
281
+ workflow_id = existing_workflow["id"]
282
+ url = "#{@api_url}#{api_path}/#{workflow_id}"
283
+ @logger.info("Updating #{event} workflow #{workflow_id} from #{rel_path} to #{url}")
284
+ resp = put(url, body, headers)
285
+ @logger.warn("Failed to update workflow (#{resp.code}): #{resp.content}") unless resp.code == "200"
286
+ else
287
+ url = "#{@api_url}#{api_path}"
288
+ @logger.info("Importing #{event} workflow from #{rel_path} to #{url}")
289
+ resp = post(url, body, headers)
290
+ @logger.warn("Failed to import workflow (#{resp.code}): #{resp.content}") unless resp.code == "200"
291
+ end
292
+ end
293
+ end
294
+
149
295
  # Checks if the space exists
150
296
  #
151
297
  # @param slug [String] slug of the space
@@ -63,6 +63,16 @@ module KineticSdk
63
63
  post(uri.to_s, payload, headers)
64
64
  end
65
65
 
66
+ # Delete a Submission
67
+ #
68
+ # @param submission_id [String] id of the Submission
69
+ # @param headers [Hash] hash of headers to send, default is basic authentication and accept JSON content type
70
+ # @return [KineticSdk::Utils::KineticHttpResponse] object, with +code+, +message+, +content_string+, and +content+ properties
71
+ def delete_submission(submission_id, headers=default_headers)
72
+ @logger.info("Deleting a submission with id #{submission_id}.")
73
+ delete("#{@api_url}/submissions/#{submission_id}", headers)
74
+ end
75
+
66
76
  # Patch a new Submission
67
77
  #
68
78
  # @param kapp_slug [String] slug of the Kapp
@@ -15,10 +15,12 @@ module KineticSdk
15
15
  # * access keys
16
16
  #
17
17
  # @param headers [Hash] hash of headers to send, default is basic authentication
18
+ # @param export_opts [Hash] hash of export options
19
+ # - :include_workflows => true|false (default: false)
18
20
  # @return nil
19
- def export(headers=header_basic_auth)
21
+ def export(headers=header_basic_auth, export_opts={})
20
22
  export_sources(headers)
21
- export_trees(nil,headers) # Includes routines when nil passed
23
+ export_trees(nil,headers,export_opts) # Includes routines when nil passed
22
24
  export_handlers(headers)
23
25
  export_groups(headers)
24
26
  export_policy_rules(headers)
@@ -213,92 +213,88 @@ module KineticSdk
213
213
  get("#{@api_url}/trees/guid/#{tree_id}", params, headers)
214
214
  end
215
215
 
216
- # Export a single tree or routine
216
+ # Export a single tree or routine. This method will not export Kinetic Core
217
+ # workflows unless `export_opts[:include_workflows] => true` export option
218
+ # is provided.
217
219
  #
218
220
  # @param title [String] the title of the tree or routine
219
221
  # @param headers [Hash] hash of headers to send, default is basic authentication
222
+ # @param export_opts [Hash] hash of export options
223
+ # - :include_workflows => true|false (default: false)
220
224
  # @return nil
221
225
  #
222
- def export_tree(title, headers=header_basic_auth)
226
+ def export_tree(title, headers=header_basic_auth, export_opts={})
223
227
  raise StandardError.new "An export directory must be defined to export a tree." if @options[:export_directory].nil?
224
228
  @logger.info("Exporting tree \"#{title}\" to #{@options[:export_directory]}.")
225
229
  # Get the tree
226
- response = find_tree(title, { "include" => "export" })
230
+ response = find_tree(title, { "include" => "details,export" })
227
231
  # Parse the response and export the tree
228
232
  tree = response.content
233
+ if export_opts[:include_workflows] || (!tree.has_key?("event") || tree["event"].nil?)
234
+ # determine which directory to write the file to
235
+ if tree['sourceGroup'] == "-"
236
+ # Create the directory if it doesn't yet exist
237
+ routine_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "routines"))
238
+ tree_file = File.join(routine_dir, "#{tree['name'].slugify}.xml")
239
+ else
240
+ # Create the directory if it doesn't yet exist
241
+ tree_dir = FileUtils::mkdir_p(File.join(@options[:export_directory],"sources", tree['sourceName'].slugify , "trees"))
242
+ tree_file = File.join(tree_dir, "#{tree['sourceGroup'].slugify}.#{tree['name'].slugify}.xml")
243
+ end
229
244
 
230
- # determine which directory to write the file to
231
- if tree['sourceGroup'] == "-"
232
- # Create the directory if it doesn't yet exist
233
- routine_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "routines"))
234
- tree_file = File.join(routine_dir, "#{tree['name'].slugify}.xml")
235
- else
236
- # Create the directory if it doesn't yet exist
237
- tree_dir = FileUtils::mkdir_p(File.join(@options[:export_directory],"sources", tree['sourceName'].slugify , "trees"))
238
- tree_file = File.join(tree_dir, "#{tree['sourceGroup'].slugify}.#{tree['name'].slugify}.xml")
239
- end
240
-
241
- # write the file
242
- server_version = server_info(headers).content["version"]
243
- if server_version > "04.03.0z"
244
- File.write(tree_file, tree['export'])
245
+ # write the file
246
+ server_version = server_info(headers).content["version"]
247
+ if server_version > "04.03.0z"
248
+ File.write(tree_file, tree['export'])
249
+ else
250
+ xml_doc = REXML::Document.new(tree["export"])
251
+ xml_doc.context[:attribute_quote] = :quote
252
+ xml_formatter = Prettier.new
253
+ xml_formatter.write(xml_doc, File.open(tree_file, "w"))
254
+ end
255
+ @logger.info("Exported #{tree['type']}: #{tree['title']} to #{tree_file}")
245
256
  else
246
- xml_doc = REXML::Document.new(tree["export"])
247
- xml_doc.context[:attribute_quote] = :quote
248
- xml_formatter = Prettier.new
249
- xml_formatter.write(xml_doc, File.open(tree_file, "w"))
257
+ @logger.info("Did not export #{tree['type']}: #{tree['title']} because it is a Core linked workflow")
250
258
  end
251
- @logger.info("Exported #{tree['type']}: #{tree['title']} to #{tree_file}")
252
259
  end
253
260
 
254
- # Export all trees and local routines for a source, and global routines
261
+ # Export trees and local routines for a source, and global routines. This method will
262
+ # not export Kinetic Core workflows unless `export_opts[:include_workflows] => true`
263
+ # export option is provided.
255
264
  #
256
265
  # @param source_name [String] Name of the source to export trees and local routines
257
266
  # - Leave blank or pass nil to export all trees and global routines
258
267
  # - Pass "-" to export only global routines
259
268
  # @param headers [Hash] hash of headers to send, default is basic authentication
269
+ # @param export_opts [Hash] hash of export options
270
+ # - :include_workflows => true|false (default: false)
260
271
  # @return nil
261
- def export_trees(source_name=nil, headers=header_basic_auth)
272
+ def export_trees(source_name=nil, headers=header_basic_auth, export_opts={})
262
273
  raise StandardError.new "An export directory must be defined to export trees." if @options[:export_directory].nil?
263
274
  if source_name.nil?
264
- @logger.info("Exporting all trees and routines to #{@options[:export_directory]}.")
275
+ if export_opts[:include_workflows]
276
+ @logger.info("Exporting all trees, routines, and workflows to #{@options[:export_directory]}.")
277
+ else
278
+ @logger.info("Exporting all trees and routines to #{@options[:export_directory]}.")
279
+ end
265
280
  export_routines(headers)
266
281
  (find_sources({}, headers).content["sourceRoots"] || []).each do |sourceRoot|
267
- export_trees(sourceRoot['name'])
282
+ export_trees(sourceRoot['name'], headers, export_opts)
268
283
  end
269
284
  return
270
285
  elsif source_name == "-"
271
286
  @logger.info("Exporting global routines to #{@options[:export_directory]}.")
272
287
  else
273
- @logger.info("Exporting trees and routines for source \"#{source_name}\" to #{@options[:export_directory]}.")
288
+ @logger.info("Exporting trees and local routines for source \"#{source_name}\" to #{@options[:export_directory]}.")
274
289
  end
275
290
 
276
291
  # Get all the trees and routines for the source
277
- response = find_trees({ "source" => source_name, "include" => "export" })
292
+ response = find_trees({ "source" => source_name, "include" => "details" }, headers)
278
293
  # Parse the response and export each tree
279
294
  (response.content["trees"] || []).each do |tree|
280
- # determine which directory to write the file to
281
- if tree['sourceGroup'] == "-"
282
- # create the directory if it doesn't yet exist
283
- routine_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "routines"))
284
- tree_file = File.join(routine_dir, "#{tree['name'].slugify}.xml")
285
- else
286
- # create the directory if it doesn't yet exist
287
- tree_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], "sources", source_name.slugify ,"trees"))
288
- tree_file = File.join(tree_dir, "#{tree['sourceGroup'].slugify}.#{tree['name'].slugify}.xml")
295
+ if export_opts[:include_workflows] || (!tree.has_key?("event") || tree["event"].nil?)
296
+ export_tree(tree['title'], headers, export_opts)
289
297
  end
290
-
291
- # write the file
292
- server_version = server_info(headers).content["version"]
293
- if server_version > "04.03.0z"
294
- File.write(tree_file, tree['export'])
295
- else
296
- xml_doc = REXML::Document.new(tree["export"])
297
- xml_doc.context[:attribute_quote] = :quote
298
- xml_formatter = Prettier.new
299
- xml_formatter.write(xml_doc, File.open(tree_file, "w"))
300
- end
301
- @logger.info("Exported #{tree['type']}: #{tree['title']} to #{tree_file}")
302
298
  end
303
299
  end
304
300
 
@@ -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.21"
6
+ VERSION = "5.0.23"
7
7
  end
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.21
4
+ version: 5.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinetic Data
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2024-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slugify
@@ -111,71 +111,70 @@ files:
111
111
  - Rakefile
112
112
  - bin/console
113
113
  - bin/setup
114
- - gems/mime-types-3.4.1/Code-of-Conduct.md
115
- - gems/mime-types-3.4.1/Contributing.md
116
- - gems/mime-types-3.4.1/History.md
117
- - gems/mime-types-3.4.1/Licence.md
118
- - gems/mime-types-3.4.1/Manifest.txt
119
- - gems/mime-types-3.4.1/README.rdoc
120
- - gems/mime-types-3.4.1/Rakefile
121
- - gems/mime-types-3.4.1/lib/mime-types.rb
122
- - gems/mime-types-3.4.1/lib/mime/type.rb
123
- - gems/mime-types-3.4.1/lib/mime/type/columnar.rb
124
- - gems/mime-types-3.4.1/lib/mime/types.rb
125
- - gems/mime-types-3.4.1/lib/mime/types/_columnar.rb
126
- - gems/mime-types-3.4.1/lib/mime/types/cache.rb
127
- - gems/mime-types-3.4.1/lib/mime/types/columnar.rb
128
- - gems/mime-types-3.4.1/lib/mime/types/container.rb
129
- - gems/mime-types-3.4.1/lib/mime/types/deprecations.rb
130
- - gems/mime-types-3.4.1/lib/mime/types/full.rb
131
- - gems/mime-types-3.4.1/lib/mime/types/loader.rb
132
- - gems/mime-types-3.4.1/lib/mime/types/logger.rb
133
- - gems/mime-types-3.4.1/lib/mime/types/registry.rb
134
- - gems/mime-types-3.4.1/test/bad-fixtures/malformed
135
- - gems/mime-types-3.4.1/test/fixture/json.json
136
- - gems/mime-types-3.4.1/test/fixture/old-data
137
- - gems/mime-types-3.4.1/test/fixture/yaml.yaml
138
- - gems/mime-types-3.4.1/test/minitest_helper.rb
139
- - gems/mime-types-3.4.1/test/test_mime_type.rb
140
- - gems/mime-types-3.4.1/test/test_mime_types.rb
141
- - gems/mime-types-3.4.1/test/test_mime_types_cache.rb
142
- - gems/mime-types-3.4.1/test/test_mime_types_class.rb
143
- - gems/mime-types-3.4.1/test/test_mime_types_lazy.rb
144
- - gems/mime-types-3.4.1/test/test_mime_types_loader.rb
145
- - gems/mime-types-data-3.2022.0105/Code-of-Conduct.md
146
- - gems/mime-types-data-3.2022.0105/Contributing.md
147
- - gems/mime-types-data-3.2022.0105/History.md
148
- - gems/mime-types-data-3.2022.0105/Licence.md
149
- - gems/mime-types-data-3.2022.0105/Manifest.txt
150
- - gems/mime-types-data-3.2022.0105/README.md
151
- - gems/mime-types-data-3.2022.0105/Rakefile
152
- - gems/mime-types-data-3.2022.0105/data/content_type_mime.db
153
- - gems/mime-types-data-3.2022.0105/data/ext_mime.db
154
- - gems/mime-types-data-3.2022.0105/data/mime-types.json
155
- - gems/mime-types-data-3.2022.0105/data/mime.content_type.column
156
- - gems/mime-types-data-3.2022.0105/data/mime.docs.column
157
- - gems/mime-types-data-3.2022.0105/data/mime.encoding.column
158
- - gems/mime-types-data-3.2022.0105/data/mime.flags.column
159
- - gems/mime-types-data-3.2022.0105/data/mime.friendly.column
160
- - gems/mime-types-data-3.2022.0105/data/mime.pext.column
161
- - gems/mime-types-data-3.2022.0105/data/mime.use_instead.column
162
- - gems/mime-types-data-3.2022.0105/data/mime.xrefs.column
163
- - gems/mime-types-data-3.2022.0105/lib/mime-types-data.rb
164
- - gems/mime-types-data-3.2022.0105/lib/mime/types/data.rb
165
- - gems/mime-types-data-3.2022.0105/types/application.yaml
166
- - gems/mime-types-data-3.2022.0105/types/audio.yaml
167
- - gems/mime-types-data-3.2022.0105/types/chemical.yaml
168
- - gems/mime-types-data-3.2022.0105/types/conference.yaml
169
- - gems/mime-types-data-3.2022.0105/types/drawing.yaml
170
- - gems/mime-types-data-3.2022.0105/types/font.yaml
171
- - gems/mime-types-data-3.2022.0105/types/image.yaml
172
- - gems/mime-types-data-3.2022.0105/types/message.yaml
173
- - gems/mime-types-data-3.2022.0105/types/model.yaml
174
- - gems/mime-types-data-3.2022.0105/types/multipart.yaml
175
- - gems/mime-types-data-3.2022.0105/types/provisional-standard-types.yaml
176
- - gems/mime-types-data-3.2022.0105/types/text.yaml
177
- - gems/mime-types-data-3.2022.0105/types/video.yaml
178
- - gems/mime-types-data-3.2022.0105/types/world.yaml
114
+ - gems/mime-types-3.5.2/Code-of-Conduct.md
115
+ - gems/mime-types-3.5.2/Contributing.md
116
+ - gems/mime-types-3.5.2/History.md
117
+ - gems/mime-types-3.5.2/Licence.md
118
+ - gems/mime-types-3.5.2/Manifest.txt
119
+ - gems/mime-types-3.5.2/README.rdoc
120
+ - gems/mime-types-3.5.2/Rakefile
121
+ - gems/mime-types-3.5.2/lib/mime-types.rb
122
+ - gems/mime-types-3.5.2/lib/mime/type.rb
123
+ - gems/mime-types-3.5.2/lib/mime/type/columnar.rb
124
+ - gems/mime-types-3.5.2/lib/mime/types.rb
125
+ - gems/mime-types-3.5.2/lib/mime/types/_columnar.rb
126
+ - gems/mime-types-3.5.2/lib/mime/types/cache.rb
127
+ - gems/mime-types-3.5.2/lib/mime/types/columnar.rb
128
+ - gems/mime-types-3.5.2/lib/mime/types/container.rb
129
+ - gems/mime-types-3.5.2/lib/mime/types/deprecations.rb
130
+ - gems/mime-types-3.5.2/lib/mime/types/full.rb
131
+ - gems/mime-types-3.5.2/lib/mime/types/loader.rb
132
+ - gems/mime-types-3.5.2/lib/mime/types/logger.rb
133
+ - gems/mime-types-3.5.2/lib/mime/types/registry.rb
134
+ - gems/mime-types-3.5.2/test/bad-fixtures/malformed
135
+ - gems/mime-types-3.5.2/test/fixture/json.json
136
+ - gems/mime-types-3.5.2/test/fixture/old-data
137
+ - gems/mime-types-3.5.2/test/fixture/yaml.yaml
138
+ - gems/mime-types-3.5.2/test/minitest_helper.rb
139
+ - gems/mime-types-3.5.2/test/test_mime_type.rb
140
+ - gems/mime-types-3.5.2/test/test_mime_types.rb
141
+ - gems/mime-types-3.5.2/test/test_mime_types_cache.rb
142
+ - gems/mime-types-3.5.2/test/test_mime_types_class.rb
143
+ - gems/mime-types-3.5.2/test/test_mime_types_lazy.rb
144
+ - gems/mime-types-3.5.2/test/test_mime_types_loader.rb
145
+ - gems/mime-types-data-3.2023.1205/Code-of-Conduct.md
146
+ - gems/mime-types-data-3.2023.1205/Contributing.md
147
+ - gems/mime-types-data-3.2023.1205/History.md
148
+ - gems/mime-types-data-3.2023.1205/Licence.md
149
+ - gems/mime-types-data-3.2023.1205/Manifest.txt
150
+ - gems/mime-types-data-3.2023.1205/README.md
151
+ - gems/mime-types-data-3.2023.1205/Rakefile
152
+ - gems/mime-types-data-3.2023.1205/data/content_type_mime.db
153
+ - gems/mime-types-data-3.2023.1205/data/ext_mime.db
154
+ - gems/mime-types-data-3.2023.1205/data/mime-types.json
155
+ - gems/mime-types-data-3.2023.1205/data/mime.content_type.column
156
+ - gems/mime-types-data-3.2023.1205/data/mime.docs.column
157
+ - gems/mime-types-data-3.2023.1205/data/mime.encoding.column
158
+ - gems/mime-types-data-3.2023.1205/data/mime.flags.column
159
+ - gems/mime-types-data-3.2023.1205/data/mime.friendly.column
160
+ - gems/mime-types-data-3.2023.1205/data/mime.pext.column
161
+ - gems/mime-types-data-3.2023.1205/data/mime.use_instead.column
162
+ - gems/mime-types-data-3.2023.1205/data/mime.xrefs.column
163
+ - gems/mime-types-data-3.2023.1205/lib/mime-types-data.rb
164
+ - gems/mime-types-data-3.2023.1205/lib/mime/types/data.rb
165
+ - gems/mime-types-data-3.2023.1205/types/application.yaml
166
+ - gems/mime-types-data-3.2023.1205/types/audio.yaml
167
+ - gems/mime-types-data-3.2023.1205/types/chemical.yaml
168
+ - gems/mime-types-data-3.2023.1205/types/conference.yaml
169
+ - gems/mime-types-data-3.2023.1205/types/drawing.yaml
170
+ - gems/mime-types-data-3.2023.1205/types/font.yaml
171
+ - gems/mime-types-data-3.2023.1205/types/image.yaml
172
+ - gems/mime-types-data-3.2023.1205/types/message.yaml
173
+ - gems/mime-types-data-3.2023.1205/types/model.yaml
174
+ - gems/mime-types-data-3.2023.1205/types/multipart.yaml
175
+ - gems/mime-types-data-3.2023.1205/types/text.yaml
176
+ - gems/mime-types-data-3.2023.1205/types/video.yaml
177
+ - gems/mime-types-data-3.2023.1205/types/world.yaml
179
178
  - gems/multipart-post-2.0.0/Gemfile
180
179
  - gems/multipart-post-2.0.0/History.txt
181
180
  - gems/multipart-post-2.0.0/Manifest.txt