dor-services-client 6.28.0 → 6.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7deb2e9cf11e029ea63aa7bad9b918c09ccb0e8e556eff7e4fda128f8c6ad02e
4
- data.tar.gz: 71e3ddd60c340352e76e1a2f97cca49238a900deaa15216507761abab2d3b51a
3
+ metadata.gz: e44b232de63ec88be66da8ef7f2334860a33e996632b7ecb79ee2e2928af33e1
4
+ data.tar.gz: 9e373dcc5e8ebeb39b154853898117a88397d3dc263f466a60fcf6c1010c3f31
5
5
  SHA512:
6
- metadata.gz: 130bb091aac14a28ed07bfcae47cf610ae301195252b15a8a69b26e073eb6258e29f25ea1971000a5189dfa10a4c313b786566c9b934c1dc87bd85b0bf3555bf
7
- data.tar.gz: c9c729fdbb5b8191e676467703a225f70678fc884d8e79abb01a940a7d3b55ff6f6850b7478af4c59d16e649e9a75ac751ca27272309994764e3a278138f1dbe
6
+ metadata.gz: 9f87acf4192e098774c638f061f519ccd6f8b555d8087eeb591517c6892345e079b5d180de532ecb04a3a7e902af4aa4a620dc485b6f7a21ed66cf106e59607c
7
+ data.tar.gz: ecd7f9b38217c6b8d73d8cc25156fd5ea6c8ded64de91f442e1980fbc800076a1847ebb28a67b1a8edf6a52e861bb8387eafc2e547f0c2dfd91b288c930036de
data/README.md CHANGED
@@ -117,6 +117,7 @@ object_client.apply_admin_policy_defaults
117
117
  object_client.notify_goobi
118
118
 
119
119
  # Manage versions
120
+ object_client.version.inventory
120
121
  object_client.version.current
121
122
  object_client.version.openable?(**params)
122
123
  object_client.version.open(**params)
@@ -75,6 +75,33 @@ module Dor
75
75
  raise_exception_based_on_response!(resp, object_identifier)
76
76
  end
77
77
 
78
+ # rubocop:disable Lint/StructNewOverride
79
+ Datastream = Struct.new(:label, :dsid, :pid, :size, :mimeType, keyword_init: true)
80
+ # rubocop:enable Lint/StructNewOverride
81
+
82
+ # @return [Array] the list of datastreams for the item
83
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
84
+ def datastreams
85
+ resp = connection.get do |req|
86
+ req.url "#{base_path}/datastreams"
87
+ end
88
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
89
+
90
+ JSON.parse(resp.body).map { |params| Datastream.new(**params) }
91
+ end
92
+
93
+ # @param [String] dsid the identifier for the datastream
94
+ # @return [String] the contents of the specified datastream
95
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
96
+ def datastream(dsid)
97
+ resp = connection.get do |req|
98
+ req.url "#{base_path}/datastreams/#{dsid}"
99
+ end
100
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
101
+
102
+ resp.body
103
+ end
104
+
78
105
  private
79
106
 
80
107
  attr_reader :object_identifier
@@ -5,6 +5,8 @@ module Dor
5
5
  class Client
6
6
  # API calls that are about versions
7
7
  class ObjectVersion < VersionedService
8
+ Version = Struct.new(:versionId, :tag, :message, keyword_init: true)
9
+
8
10
  # @param object_identifier [String] the pid for the object
9
11
  def initialize(connection:, version:, object_identifier:)
10
12
  super(connection: connection, version: version)
@@ -17,7 +19,7 @@ module Dor
17
19
  # @return [String] the version identifier
18
20
  def current
19
21
  resp = connection.get do |req|
20
- req.url "#{object_path}/versions/current"
22
+ req.url "#{base_path}/current"
21
23
  end
22
24
  return resp.body if resp.success?
23
25
 
@@ -32,7 +34,7 @@ module Dor
32
34
  # rubocop:disable Metrics/MethodLength
33
35
  def openable?(**params)
34
36
  resp = connection.get do |req|
35
- req.url "#{object_path}/versions/openable"
37
+ req.url "#{base_path}/openable"
36
38
  req.params = params
37
39
  end
38
40
 
@@ -78,6 +80,17 @@ module Dor
78
80
  raise_exception_based_on_response!(resp)
79
81
  end
80
82
 
83
+ # @return [Array] a list of the versions
84
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
85
+ def inventory
86
+ resp = connection.get do |req|
87
+ req.url base_path
88
+ end
89
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
90
+
91
+ JSON.parse(resp.body).fetch('versions').map { |params| Version.new(**params) }
92
+ end
93
+
81
94
  private
82
95
 
83
96
  attr_reader :object_identifier
@@ -102,12 +115,14 @@ module Dor
102
115
  raise_exception_based_on_response!(resp)
103
116
  end
104
117
 
105
- def open_new_version_path
118
+ def base_path
106
119
  "#{object_path}/versions"
107
120
  end
108
121
 
122
+ alias open_new_version_path base_path
123
+
109
124
  def close_version_path
110
- "#{object_path}/versions/current/close"
125
+ "#{base_path}/current/close"
111
126
  end
112
127
  end
113
128
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '6.28.0'
6
+ VERSION = '6.29.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.28.0
4
+ version: 6.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-17 00:00:00.000000000 Z
12
+ date: 2021-03-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport