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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 565b25455d31d878a49e800e34b6b3b096322762300a7042ae677ed650ff21a5
4
- data.tar.gz: 8c9f6acc0a76f4ac7da4b3190a3e1d4e5e349ccc9678d487f23fa3ee237e3d65
3
+ metadata.gz: 0cddd625cce276c478e27e4c996690f8a8edcab5115981f84af0fb916cf5e81d
4
+ data.tar.gz: 9e81af88e194dfb37e55f75b94a24d3ecb33cccdac6571c09cc931e0ebccf171
5
5
  SHA512:
6
- metadata.gz: 94e719800898ca73d2028dd144a184e7ca98b5958b421846a8380bd176b7f5eef64e921e0cc3f973ed62b7607e29e801dfa64fc771d19d995cb7d00dec01f84a
7
- data.tar.gz: 337a076d2a17c2eb7201fc7f038f53018582f26c22fdbbfd61caf05268e382e8911e6aafaa8f20aaa9c64aafcf3681fc84ce0efbb2dc31174b89c9c5ad10ec23
6
+ metadata.gz: d010eed7fdfc3cae2d84c87686a52333822ecb204d772f44c30ecff51d0522b59ec09334ab3a2aaddc434cc2fda9d61beabd8a82aa4e5fb9a20455c4854b7822
7
+ data.tar.gz: 2781234795ae013152b0cfd5c13d95757db81e4468f45fddb703fd801c17a7b765cf7348a35b34368aa8f2294c49e4b51745b144248647ff6c98fab89bc51443
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (15.13.0)
4
+ dor-services-client (15.15.0)
5
5
  activesupport (>= 7.0.0)
6
6
  cocina-models (~> 0.104.1)
7
7
  deprecation
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
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '15.13.0'
6
+ VERSION = '15.15.0'
7
7
  end
8
8
  end
9
9
  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.13.0
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-26 00:00:00.000000000 Z
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