dor-services-client 15.13.0 → 15.15.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 +9 -0
- data/lib/dor/services/client/object_workflow.rb +19 -0
- data/lib/dor/services/client/process.rb +63 -0
- data/lib/dor/services/client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cddd625cce276c478e27e4c996690f8a8edcab5115981f84af0fb916cf5e81d
|
4
|
+
data.tar.gz: 9e81af88e194dfb37e55f75b94a24d3ecb33cccdac6571c09cc931e0ebccf171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d010eed7fdfc3cae2d84c87686a52333822ecb204d772f44c30ecff51d0522b59ec09334ab3a2aaddc434cc2fda9d61beabd8a82aa4e5fb9a20455c4854b7822
|
7
|
+
data.tar.gz: 2781234795ae013152b0cfd5c13d95757db81e4468f45fddb703fd801c17a7b765cf7348a35b34368aa8f2294c49e4b51745b144248647ff6c98fab89bc51443
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -158,6 +158,15 @@ 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
|
+
# Get the status of a workflow process
|
165
|
+
object_client.workflow('accessionWF').process('shelve').status
|
166
|
+
=> 'completed'
|
167
|
+
# Update workflow processes
|
168
|
+
object_client.workflow('accessionWF').process('shelve').update(status: 'completed')
|
169
|
+
object_client.workflow('accessionWF').process('shelve').update_error(error_msg: 'Something went wrong', error_text: 'Detailed error message')
|
161
170
|
|
162
171
|
# List milestones
|
163
172
|
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, object_workflow_client: self)
|
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,63 @@
|
|
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:, object_workflow_client:) # rubocop:disable Metrics/ParameterLists
|
12
|
+
super(connection: connection, version: version)
|
13
|
+
@object_identifier = object_identifier
|
14
|
+
@workflow_name = workflow_name
|
15
|
+
@process = process
|
16
|
+
@object_workflow_client = object_workflow_client
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieves the process status of the given workflow for the given object identifier
|
20
|
+
# @return [String,nil] status
|
21
|
+
def status
|
22
|
+
doc = object_workflow_client.find.xml
|
23
|
+
|
24
|
+
processes = doc.root.xpath("//process[@name='#{process}']")
|
25
|
+
process = processes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
|
26
|
+
process&.attr('status')
|
27
|
+
end
|
28
|
+
|
29
|
+
# Updates the status of one step in a workflow.
|
30
|
+
# @param [String] status The status of the process.
|
31
|
+
# @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.
|
32
|
+
# @param [String] lifecycle Bookeeping label for this particular workflow step. Examples are: 'registered', 'shelved'
|
33
|
+
# @param [String] note Any kind of string annotation that you want to attach to the workflow
|
34
|
+
# @param [String] current_status Setting this string tells the workflow service to compare the current status to this value.
|
35
|
+
# @raise [Dor::Services::Client::ConflictResponse] if the current status does not match the value passed in current_status.
|
36
|
+
def update(status:, elapsed: 0, lifecycle: nil, note: nil, current_status: nil)
|
37
|
+
perform_update(status: status, elapsed: elapsed, lifecycle: lifecycle, note: note, current_status: current_status)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Updates the status of one step in a workflow to error.
|
41
|
+
# @param [String] error_msg The error message. Ideally, this is a brief message describing the error
|
42
|
+
# @param [String] error_text A slot to hold more information about the error, like a full stacktrace
|
43
|
+
def update_error(error_msg:, error_text: nil)
|
44
|
+
perform_update(status: 'error', error_msg: error_msg, error_text: error_text)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :object_identifier, :workflow_name, :process, :object_workflow_client
|
50
|
+
|
51
|
+
def perform_update(**payload)
|
52
|
+
resp = connection.put do |req|
|
53
|
+
req.url "#{api_version}/objects/#{object_identifier}/workflows/#{workflow_name}/processes/#{process}"
|
54
|
+
req.headers['Content-Type'] = 'application/json'
|
55
|
+
req.body = payload.compact.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
- Michael Giarlo
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -258,6 +258,7 @@ files:
|
|
258
258
|
- lib/dor/services/client/object_workflow.rb
|
259
259
|
- lib/dor/services/client/object_workflows.rb
|
260
260
|
- lib/dor/services/client/objects.rb
|
261
|
+
- lib/dor/services/client/process.rb
|
261
262
|
- lib/dor/services/client/release_tag.rb
|
262
263
|
- lib/dor/services/client/release_tags.rb
|
263
264
|
- lib/dor/services/client/response_error_formatter.rb
|