dor-workflow-client 3.10.0 → 3.11.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/README.md +11 -3
- data/lib/dor/workflow/client/version.rb +1 -1
- data/lib/dor/workflow/client/workflow_routes.rb +42 -11
- data/spec/workflow/client_spec.rb +105 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f99d2c878711b586b19b4493e6bfdfb97ccaa2d4633937aadf12527c275129be
|
4
|
+
data.tar.gz: 69101e12eb0cef2ee37e46983a7ca762e4d598f2794fcbc00923b0c4c07b30a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 332dc12278f377747eaabeeacb2c728420c268e6664e6760b314353d38fb6e1443cfa515caee3c8c1df49209d514d526253345fd9bbd1a44d4f449c601c7782d
|
7
|
+
data.tar.gz: b6c26f3c28452ab4b566ec1ee0d60531a6776a215a71d1859695fe615c9b45dc9e5640edf2d158f010cb42c8d4ddcaa48edee0e826663a7e3cfe8768577660a7
|
data/README.md
CHANGED
@@ -19,27 +19,35 @@ client = Dor::Workflow::Client.new(url: 'https://test-server.edu/workflow/')
|
|
19
19
|
Consumers of recent versions of the [dor-services](https://github.com/sul-dlss/dor-services) gem can access the configured `Dor::Workflow::Client` object via `Dor::Config`.
|
20
20
|
|
21
21
|
## API
|
22
|
+
[Rubydoc](https://www.rubydoc.info/github/sul-dlss/dor-workflow-client/master)
|
22
23
|
|
24
|
+
### Example usage
|
23
25
|
Create a workflow
|
24
26
|
```
|
25
27
|
client.create_workflow_by_name('druid:bc123df4567', 'etdSubmitWF')
|
26
28
|
```
|
27
29
|
|
28
30
|
Update a workflow step's status
|
29
|
-
```
|
31
|
+
```ruby
|
30
32
|
client.update_status(druid: 'druid:bc123df4567',
|
31
33
|
workflow: 'etdSubmitWF',
|
32
34
|
process: 'registrar-approval',
|
33
35
|
status: 'completed')
|
34
36
|
```
|
35
37
|
|
36
|
-
|
38
|
+
Show "milestones" for an object
|
39
|
+
```ruby
|
40
|
+
client.milestones('dor', 'druid:gv054hp4128')
|
41
|
+
#=> [{version: '1', milestone: 'published'}]
|
37
42
|
```
|
43
|
+
|
44
|
+
List workflow templates
|
45
|
+
```ruby
|
38
46
|
client.workflow_templates
|
39
47
|
```
|
40
48
|
|
41
49
|
Show a workflow template
|
42
|
-
```
|
50
|
+
```ruby
|
43
51
|
client.workflow_template('etdSubmitWF')
|
44
52
|
```
|
45
53
|
|
@@ -4,6 +4,7 @@ module Dor
|
|
4
4
|
module Workflow
|
5
5
|
class Client
|
6
6
|
# Makes requests relating to a workflow
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
7
8
|
class WorkflowRoutes
|
8
9
|
extend Deprecation
|
9
10
|
|
@@ -62,7 +63,7 @@ module Dor
|
|
62
63
|
# @return [Boolean] always true
|
63
64
|
# Http Call
|
64
65
|
# ==
|
65
|
-
# The method does an HTTP PUT to the URL
|
66
|
+
# The method does an HTTP PUT to the base URL. As an example:
|
66
67
|
#
|
67
68
|
# PUT "/objects/pid:123/workflows/GoogleScannedWF/convert"
|
68
69
|
# <process name=\"convert\" status=\"completed\" />"
|
@@ -95,7 +96,7 @@ module Dor
|
|
95
96
|
# @return [Boolean] always true
|
96
97
|
# Http Call
|
97
98
|
# ==
|
98
|
-
# The method does an HTTP PUT to the URL
|
99
|
+
# The method does an HTTP PUT to the base URL. As an example:
|
99
100
|
#
|
100
101
|
# PUT "/dor/objects/pid:123/workflows/GoogleScannedWF/convert"
|
101
102
|
# <process name=\"convert\" status=\"completed\" />"
|
@@ -120,8 +121,22 @@ module Dor
|
|
120
121
|
# @param [String] workflow The name of the workflow
|
121
122
|
# @param [String] process The name of the process step
|
122
123
|
# @return [String] status for repo-workflow-process-druid
|
123
|
-
|
124
|
-
|
124
|
+
# rubocop:disable Metrics/MethodLength
|
125
|
+
# rubocop:disable Metrics/AbcSize
|
126
|
+
def workflow_status(*args)
|
127
|
+
case args.length
|
128
|
+
when 4
|
129
|
+
Deprecation.warn(self, 'Calling workflow_status with positional args is deprecated, use kwargs instead')
|
130
|
+
(_repo, druid, workflow, process) = *args
|
131
|
+
when 1
|
132
|
+
opts = args.first
|
133
|
+
repo = opts[:repo]
|
134
|
+
Deprecation.warn(self, 'Passing `:repo` to workflow_status is deprecated and can be omitted') if repo
|
135
|
+
druid = opts[:druid]
|
136
|
+
workflow = opts[:workflow]
|
137
|
+
process = opts[:process]
|
138
|
+
end
|
139
|
+
workflow_md = workflow_xml(druid: druid, workflow: workflow)
|
125
140
|
doc = Nokogiri::XML(workflow_md)
|
126
141
|
raise Dor::WorkflowException, "Unable to parse response:\n#{workflow_md}" if doc.root.nil?
|
127
142
|
|
@@ -129,6 +144,8 @@ module Dor
|
|
129
144
|
process = processes.max { |a, b| a.attr('version').to_i <=> b.attr('version').to_i }
|
130
145
|
process&.attr('status')
|
131
146
|
end
|
147
|
+
# rubocop:enable Metrics/AbcSize
|
148
|
+
# rubocop:enable Metrics/MethodLength
|
132
149
|
|
133
150
|
#
|
134
151
|
# Retrieves the raw XML for the given workflow
|
@@ -136,7 +153,18 @@ module Dor
|
|
136
153
|
# @param [String] druid The id of the object
|
137
154
|
# @param [String] workflow The name of the workflow
|
138
155
|
# @return [String] XML of the workflow
|
139
|
-
def workflow_xml(
|
156
|
+
def workflow_xml(*args)
|
157
|
+
case args.length
|
158
|
+
when 3
|
159
|
+
Deprecation.warn(self, 'Calling workflow_xml with positional args is deprecated, use kwargs instead')
|
160
|
+
(repo, druid, workflow) = *args
|
161
|
+
when 1
|
162
|
+
opts = args.first
|
163
|
+
repo = opts[:repo]
|
164
|
+
Deprecation.warn(self, 'Passing `:repo` to workflow_xml is deprecated and can be omitted') if repo
|
165
|
+
druid = opts[:druid]
|
166
|
+
workflow = opts[:workflow]
|
167
|
+
end
|
140
168
|
raise ArgumentError, 'missing workflow' unless workflow
|
141
169
|
|
142
170
|
requestor.request "#{repo}/objects/#{druid}/workflows/#{workflow}"
|
@@ -156,7 +184,7 @@ module Dor
|
|
156
184
|
#
|
157
185
|
# Http Call
|
158
186
|
# ==
|
159
|
-
# The method does an HTTP PUT to the URL
|
187
|
+
# The method does an HTTP PUT to the base URL.
|
160
188
|
#
|
161
189
|
# PUT "/objects/pid:123/workflows/GoogleScannedWF/convert"
|
162
190
|
# <process name=\"convert\" status=\"error\" />"
|
@@ -178,7 +206,7 @@ module Dor
|
|
178
206
|
#
|
179
207
|
# Http Call
|
180
208
|
# ==
|
181
|
-
# The method does an HTTP PUT to the URL
|
209
|
+
# The method does an HTTP PUT to the base URL.
|
182
210
|
#
|
183
211
|
# PUT "/objects/pid:123/workflows/GoogleScannedWF/convert"
|
184
212
|
# <process name=\"convert\" status=\"error\" />"
|
@@ -213,8 +241,9 @@ module Dor
|
|
213
241
|
# @example
|
214
242
|
# client.workflows('druid:sr100hp0609')
|
215
243
|
# => ["accessionWF", "assemblyWF", "disseminationWF"]
|
216
|
-
def workflows(pid, repo =
|
217
|
-
|
244
|
+
def workflows(pid, repo = nil)
|
245
|
+
Deprecation.warn(self, 'Passing the second argument (repo) to workflows is deprecated and can be omitted') if repo
|
246
|
+
xml_doc = Nokogiri::XML(workflow_xml(druid: pid, workflow: ''))
|
218
247
|
xml_doc.xpath('//workflow').collect { |workflow| workflow['id'] }
|
219
248
|
end
|
220
249
|
|
@@ -222,8 +251,9 @@ module Dor
|
|
222
251
|
# @param [String] pid id of object
|
223
252
|
# @param [String] workflow_name The name of the workflow
|
224
253
|
# @return [Workflow::Response::Workflow]
|
225
|
-
def workflow(repo:
|
226
|
-
|
254
|
+
def workflow(repo: nil, pid:, workflow_name:)
|
255
|
+
Deprecation.warn(self, 'passing the repo parameter is deprecated and will be removed in the next major versions') if repo
|
256
|
+
xml = workflow_xml(druid: pid, workflow: workflow_name)
|
227
257
|
Workflow::Response::Workflow.new(xml: xml)
|
228
258
|
end
|
229
259
|
|
@@ -260,6 +290,7 @@ module Dor
|
|
260
290
|
builder.to_xml
|
261
291
|
end
|
262
292
|
end
|
293
|
+
# rubocop:enable Metrics/ClassLength
|
263
294
|
end
|
264
295
|
end
|
265
296
|
end
|
@@ -235,13 +235,13 @@ RSpec.describe Dor::Workflow::Client do
|
|
235
235
|
let(:druid) { @druid }
|
236
236
|
let(:stubs) do
|
237
237
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
238
|
-
stub.get("
|
238
|
+
stub.get("/objects/#{druid}/workflows/#{workflow_name}") do |_env|
|
239
239
|
response
|
240
240
|
end
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
-
subject { client.workflow_status(
|
244
|
+
subject { client.workflow_status(druid: druid, workflow: workflow_name, process: step_name) }
|
245
245
|
let(:step_name) { 'registrar-approval' }
|
246
246
|
let(:workflow_name) { 'etdSubmitWF' }
|
247
247
|
let(:status) { 200 }
|
@@ -250,6 +250,40 @@ RSpec.describe Dor::Workflow::Client do
|
|
250
250
|
end
|
251
251
|
let(:xml) { '' }
|
252
252
|
|
253
|
+
context 'when repo is provided' do
|
254
|
+
before do
|
255
|
+
allow(Deprecation).to receive(:warn)
|
256
|
+
end
|
257
|
+
subject { client.workflow_status(repo: repo, druid: druid, workflow: workflow_name, process: step_name) }
|
258
|
+
|
259
|
+
context 'when a single result is returned' do
|
260
|
+
let(:xml) do
|
261
|
+
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'returns status as a string' do
|
265
|
+
expect(subject).to eq('completed')
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
context 'with positional arguments' do
|
271
|
+
before do
|
272
|
+
allow(Deprecation).to receive(:warn)
|
273
|
+
end
|
274
|
+
subject { client.workflow_status(repo, druid, workflow_name, step_name) }
|
275
|
+
|
276
|
+
context 'when a single result is returned' do
|
277
|
+
let(:xml) do
|
278
|
+
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
279
|
+
end
|
280
|
+
|
281
|
+
it 'returns status as a string' do
|
282
|
+
expect(subject).to eq('completed')
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
253
287
|
context 'when a single result is returned' do
|
254
288
|
let(:xml) do
|
255
289
|
'<workflow><process name="registrar-approval" status="completed" /></workflow>'
|
@@ -302,29 +336,82 @@ RSpec.describe Dor::Workflow::Client do
|
|
302
336
|
end
|
303
337
|
|
304
338
|
describe '#workflow_xml' do
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
339
|
+
context 'with positional args' do
|
340
|
+
before do
|
341
|
+
allow(Deprecation).to receive(:warn)
|
342
|
+
end
|
343
|
+
subject(:workflow_xml) { client.workflow_xml('dor', 'druid:123', workflow) }
|
344
|
+
|
345
|
+
context 'when a workflow name is provided' do
|
346
|
+
let(:workflow) { 'etdSubmitWF' }
|
347
|
+
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
348
|
+
let(:stubs) do
|
349
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
350
|
+
stub.get('dor/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
351
|
+
[200, {}, xml]
|
352
|
+
end
|
314
353
|
end
|
315
354
|
end
|
355
|
+
|
356
|
+
it 'returns the xml for a given repository, druid, and workflow' do
|
357
|
+
expect(workflow_xml).to eq(xml)
|
358
|
+
end
|
316
359
|
end
|
317
360
|
|
318
|
-
|
319
|
-
|
361
|
+
context 'when no workflow name is provided' do
|
362
|
+
let(:workflow) { nil }
|
363
|
+
|
364
|
+
it 'raises an error' do
|
365
|
+
expect { workflow_xml }.to raise_error ArgumentError
|
366
|
+
end
|
320
367
|
end
|
321
368
|
end
|
369
|
+
context 'with keyword args' do
|
370
|
+
subject(:workflow_xml) { client.workflow_xml(druid: 'druid:123', workflow: workflow) }
|
322
371
|
|
323
|
-
|
324
|
-
|
372
|
+
context 'when a repo is provided' do
|
373
|
+
subject(:workflow_xml) { client.workflow_xml(repo: 'dor', druid: 'druid:123', workflow: workflow) }
|
374
|
+
before do
|
375
|
+
allow(Deprecation).to receive(:warn)
|
376
|
+
end
|
377
|
+
|
378
|
+
let(:workflow) { 'etdSubmitWF' }
|
379
|
+
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
380
|
+
let(:stubs) do
|
381
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
382
|
+
stub.get('dor/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
383
|
+
[200, {}, xml]
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'returns the xml for a given repository, druid, and workflow' do
|
389
|
+
expect(workflow_xml).to eq(xml)
|
390
|
+
end
|
391
|
+
end
|
325
392
|
|
326
|
-
|
327
|
-
|
393
|
+
context 'when a workflow name is provided' do
|
394
|
+
let(:workflow) { 'etdSubmitWF' }
|
395
|
+
let(:xml) { '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>' }
|
396
|
+
let(:stubs) do
|
397
|
+
Faraday::Adapter::Test::Stubs.new do |stub|
|
398
|
+
stub.get('/objects/druid:123/workflows/etdSubmitWF') do |_env|
|
399
|
+
[200, {}, xml]
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'returns the xml for a given repository, druid, and workflow' do
|
405
|
+
expect(workflow_xml).to eq(xml)
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
context 'when no workflow name is provided' do
|
410
|
+
let(:workflow) { nil }
|
411
|
+
|
412
|
+
it 'raises an error' do
|
413
|
+
expect { workflow_xml }.to raise_error ArgumentError
|
414
|
+
end
|
328
415
|
end
|
329
416
|
end
|
330
417
|
end
|
@@ -358,7 +445,7 @@ RSpec.describe Dor::Workflow::Client do
|
|
358
445
|
let(:xml) { '<workflow id="accessionWF"><process name="publish" status="completed" /></workflow>' }
|
359
446
|
let(:stubs) do
|
360
447
|
Faraday::Adapter::Test::Stubs.new do |stub|
|
361
|
-
stub.get("
|
448
|
+
stub.get("/objects/#{@druid}/workflows/") do |_env|
|
362
449
|
[200, {}, xml]
|
363
450
|
end
|
364
451
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willy Mene
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|