dor-services-client 6.28.0 → 6.32.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: fc73f1e0055882f5c80701e0c49eae8a6079553478799b4415676f651219ef4c
4
+ data.tar.gz: ebe6b6a76f73179da7e1835ddf242b50d355f61dc5e94f1b755536d2369e3235
5
5
  SHA512:
6
- metadata.gz: 130bb091aac14a28ed07bfcae47cf610ae301195252b15a8a69b26e073eb6258e29f25ea1971000a5189dfa10a4c313b786566c9b934c1dc87bd85b0bf3555bf
7
- data.tar.gz: c9c729fdbb5b8191e676467703a225f70678fc884d8e79abb01a940a7d3b55ff6f6850b7478af4c59d16e649e9a75ac751ca27272309994764e3a278138f1dbe
6
+ metadata.gz: a4cfe626ccfb4709f5f9c43d04ec228d3715df46fc252164e0ff57426d02a62d7e8be2d4fa7ba3525e5220ac504de632ef1c98e2d747dd6b3d7bd85137ca13ba
7
+ data.tar.gz: 45d554dedc4dc1c7236b294f780414bf39136544c83f4443b088522942f17cc0f47c892cd04aaad3cff7393386577ca113ad95819d4a5abf7ced176de2679001
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)
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '~> 2.6'
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 4.2', '< 7'
28
- spec.add_dependency 'cocina-models', '~> 0.55.0' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.58.0' # leave pinned to patch level until cocina-models hits 1.0
29
29
  spec.add_dependency 'deprecation', '>= 0'
30
30
  spec.add_dependency 'faraday', '>= 0.15', '< 2'
31
31
  spec.add_dependency 'moab-versioning', '~> 4.0'
@@ -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, :versionId, 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.symbolize_keys!) }
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.symbolize_keys!) }
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.32.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.32.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-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -37,14 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.55.0
40
+ version: 0.58.0
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.55.0
47
+ version: 0.58.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement