dor-services-client 15.13.0 → 15.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -0
- data/lib/dor/services/client/object_workflow.rb +19 -0
- data/lib/dor/services/client/process.rb +60 -0
- data/lib/dor/services/client/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd62911db328e4acec57538baa18003ff2525c02929f2f96adbd9df74ba43e30
|
4
|
+
data.tar.gz: 9591c4c8977d9a81cffbf46a300e04778a60330c0ce9d9743232cc72bcca56e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa6acadd9432a53789fd3d33ab07bafca9d1078544536c80e2bfa661490921201a781c84e1b0a1898264c62e5d5a7d19ac95316409f894b074f88de917d91ea
|
7
|
+
data.tar.gz: 359df5ae75ca8e63aa4cc5d3fd56e13ce716e3ec67d3e74c4535906f573f4419c041683b1008cd563d098d0fbcf8750b698fe497ad85d825efd9d56528a6a379
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -158,6 +158,13 @@ object_client.workflows
|
|
158
158
|
object_client.workflow('accessionWF').find
|
159
159
|
# Create workflow
|
160
160
|
object_client.workflow('etdSubmitWF').create(version: 2)
|
161
|
+
# Skip all workflow steps
|
162
|
+
object_client.workflow('accessionWF').skip_all(note: 'Cleaning up')
|
163
|
+
|
164
|
+
# Update workflow processes
|
165
|
+
object_client.workflow('accessionWF').process('shelve').update(status: 'completed')
|
166
|
+
object_client.workflow('accessionWF').process('shelve').update_error(error_msg: 'Something went wrong', error_text: 'Detailed error message')
|
167
|
+
|
161
168
|
|
162
169
|
# List milestones
|
163
170
|
object_client.milestones.list
|
@@ -13,12 +13,19 @@ module Dor
|
|
13
13
|
@workflow_name = workflow_name
|
14
14
|
end
|
15
15
|
|
16
|
+
# @return [Dor::Services::Client::Process]
|
17
|
+
def process(process)
|
18
|
+
@process ||= Process.new(connection: connection, version: api_version, object_identifier: object_identifier,
|
19
|
+
workflow_name: workflow_name, process: process)
|
20
|
+
end
|
21
|
+
|
16
22
|
# @return [Workflow::Response::Workflow]
|
17
23
|
def find
|
18
24
|
resp = connection.get do |req|
|
19
25
|
req.url "#{api_version}/objects/#{object_identifier}/workflows/#{workflow_name}"
|
20
26
|
req.headers['Accept'] = 'application/xml'
|
21
27
|
end
|
28
|
+
|
22
29
|
raise_exception_based_on_response!(resp) unless resp.success?
|
23
30
|
|
24
31
|
Dor::Services::Response::Workflow.new(xml: Nokogiri::XML(resp.body))
|
@@ -37,6 +44,18 @@ module Dor
|
|
37
44
|
req.headers['Content-Type'] = 'application/json'
|
38
45
|
req.body = { context: context }.to_json if context
|
39
46
|
end
|
47
|
+
|
48
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
49
|
+
end
|
50
|
+
|
51
|
+
# Skips all steps in a workflow.
|
52
|
+
# @param note [String] a note to be added to the skipped steps
|
53
|
+
def skip_all(note:)
|
54
|
+
resp = connection.post do |req|
|
55
|
+
req.url "#{api_version}/objects/#{object_identifier}/workflows/#{workflow_name}/skip_all"
|
56
|
+
req.params['note'] = note
|
57
|
+
end
|
58
|
+
|
40
59
|
raise_exception_based_on_response!(resp) unless resp.success?
|
41
60
|
end
|
42
61
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Services
|
5
|
+
class Client
|
6
|
+
# API calls around workflow process for an object.
|
7
|
+
class Process < VersionedService
|
8
|
+
# @param object_identifier [String] the druid for the object
|
9
|
+
# @param [String] workflow_name The name of the workflow
|
10
|
+
# @param [String] process The name of the workflow step
|
11
|
+
def initialize(connection:, version:, object_identifier:, workflow_name:, process:)
|
12
|
+
super(connection: connection, version: version)
|
13
|
+
@object_identifier = object_identifier
|
14
|
+
@workflow_name = workflow_name
|
15
|
+
@process = process
|
16
|
+
end
|
17
|
+
|
18
|
+
# Updates the status of one step in a workflow.
|
19
|
+
# @param [String] status The status of the process.
|
20
|
+
# @param [Float] elapsed The number of seconds it took to complete this step. Can have a decimal. Is set to 0 if not passed in.
|
21
|
+
# @param [String] lifecycle Bookeeping label for this particular workflow step. Examples are: 'registered', 'shelved'
|
22
|
+
# @param [String] note Any kind of string annotation that you want to attach to the workflow
|
23
|
+
# @param [String] current_status Setting this string tells the workflow service to compare the current status to this value.
|
24
|
+
# @raise [Dor::Services::Client::ConflictResponse] if the current status does not match the value passed in current_status.
|
25
|
+
def update(status:, elapsed: 0, lifecycle: nil, note: nil, current_status: nil)
|
26
|
+
perform_update(status: status, elapsed: elapsed, lifecycle: lifecycle, note: note, current_status: current_status)
|
27
|
+
# resp = connection.get do |req|
|
28
|
+
# req.url "#{api_version}/objects/#{object_identifier}/workflows/#{workflow_name}"
|
29
|
+
# req.headers['Accept'] = 'application/xml'
|
30
|
+
# end
|
31
|
+
|
32
|
+
# raise_exception_based_on_response!(resp) unless resp.success?
|
33
|
+
|
34
|
+
# Dor::Services::Response::Workflow.new(xml: Nokogiri::XML(resp.body))
|
35
|
+
end
|
36
|
+
|
37
|
+
# Updates the status of one step in a workflow to error.
|
38
|
+
# @param [String] error_msg The error message. Ideally, this is a brief message describing the error
|
39
|
+
# @param [String] error_text A slot to hold more information about the error, like a full stacktrace
|
40
|
+
def update_error(error_msg:, error_text: nil)
|
41
|
+
perform_update(status: 'error', error_msg: error_msg, error_text: error_text)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
attr_reader :object_identifier, :workflow_name, :process
|
47
|
+
|
48
|
+
def perform_update(**payload)
|
49
|
+
resp = connection.put do |req|
|
50
|
+
req.url "#{api_version}/objects/#{object_identifier}/workflows/#{workflow_name}/processes/#{process}"
|
51
|
+
req.headers['Content-Type'] = 'application/json'
|
52
|
+
req.body = payload.compact.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-services-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.
|
4
|
+
version: 15.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
- Michael Giarlo
|
9
|
+
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
12
|
date: 2025-06-26 00:00:00.000000000 Z
|
@@ -220,6 +221,7 @@ dependencies:
|
|
220
221
|
- - ">="
|
221
222
|
- !ruby/object:Gem::Version
|
222
223
|
version: '0'
|
224
|
+
description:
|
223
225
|
email:
|
224
226
|
- jcoyne@justincoyne.com
|
225
227
|
- leftwing@alumni.rutgers.edu
|
@@ -258,6 +260,7 @@ files:
|
|
258
260
|
- lib/dor/services/client/object_workflow.rb
|
259
261
|
- lib/dor/services/client/object_workflows.rb
|
260
262
|
- lib/dor/services/client/objects.rb
|
263
|
+
- lib/dor/services/client/process.rb
|
261
264
|
- lib/dor/services/client/release_tag.rb
|
262
265
|
- lib/dor/services/client/release_tags.rb
|
263
266
|
- lib/dor/services/client/response_error_formatter.rb
|
@@ -274,6 +277,7 @@ homepage: https://github.com/sul-dlss/dor-services-client
|
|
274
277
|
licenses: []
|
275
278
|
metadata:
|
276
279
|
rubygems_mfa_required: 'true'
|
280
|
+
post_install_message:
|
277
281
|
rdoc_options: []
|
278
282
|
require_paths:
|
279
283
|
- lib
|
@@ -291,7 +295,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
295
|
- !ruby/object:Gem::Version
|
292
296
|
version: '0'
|
293
297
|
requirements: []
|
294
|
-
rubygems_version: 3.
|
298
|
+
rubygems_version: 3.5.11
|
299
|
+
signing_key:
|
295
300
|
specification_version: 4
|
296
301
|
summary: A client for dor-services-app
|
297
302
|
test_files: []
|