dor-services-client 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +1 -1
- data/lib/dor/services/client/object.rb +50 -0
- data/lib/dor/services/client/objects.rb +4 -3
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client.rb +19 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eed92163307c689ed61735f07b910d9dd37821a8f77b744ffc5c1ff37956284
|
4
|
+
data.tar.gz: 7f7be3de30b2c121f0fd8fbdf7103d8aadff50d89a2c3cf30f0e741c98d2d6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47b70505a9c21255bdfcfb4ac6c523e33ef39cbec3838f794242b1704c607f209e3b572586bb790cf07f4a6f22dc729f8adfb4265fdaac0c9ccd872a7d76ef74
|
7
|
+
data.tar.gz: c3fcb06b5fba157bee9a5e7692b377f64d289fb3a5d4f476342783aec5e84f66bd583a5c2d78d9d8ecf7fe6a2b5d387abc8204d83329fcb3882d874ce28aab2c
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -50,6 +50,33 @@ module Dor
|
|
50
50
|
resp.body
|
51
51
|
end
|
52
52
|
|
53
|
+
# Open new version for an object
|
54
|
+
# @param params [Hash] optional params (see dor-services-app)
|
55
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
56
|
+
# @raise [MalformedResponse] when the response is not parseable.
|
57
|
+
# @return [String] the current version
|
58
|
+
def open_new_version(**params)
|
59
|
+
version = open_new_version_response(**params)
|
60
|
+
raise MalformedResponse, "Version of #{object} is empty" if version.empty?
|
61
|
+
|
62
|
+
version
|
63
|
+
end
|
64
|
+
|
65
|
+
# Close current version for an object
|
66
|
+
# @param params [Hash] optional params (see dor-services-app)
|
67
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
68
|
+
# @return [String] a message confirming successful closing
|
69
|
+
def close_version(**params)
|
70
|
+
resp = connection.post do |req|
|
71
|
+
req.url close_version_path
|
72
|
+
req.headers['Content-Type'] = 'application/json'
|
73
|
+
req.body = params.to_json if params.any?
|
74
|
+
end
|
75
|
+
return resp.body if resp.success?
|
76
|
+
|
77
|
+
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object}"
|
78
|
+
end
|
79
|
+
|
53
80
|
private
|
54
81
|
|
55
82
|
attr_reader :object
|
@@ -57,6 +84,29 @@ module Dor
|
|
57
84
|
def object_path
|
58
85
|
"#{api_version}/objects/#{object}"
|
59
86
|
end
|
87
|
+
|
88
|
+
# Make request to server to open a new version
|
89
|
+
# @param params [Hash] optional params (see dor-services-app)
|
90
|
+
# @raises [UnexpectedResponse] on an unsuccessful response from the server
|
91
|
+
# @returns [String] the plain text from the server
|
92
|
+
def open_new_version_response(**params)
|
93
|
+
resp = connection.post do |req|
|
94
|
+
req.url open_new_version_path
|
95
|
+
req.headers['Content-Type'] = 'application/json'
|
96
|
+
req.body = params.to_json if params.any?
|
97
|
+
end
|
98
|
+
return resp.body if resp.success?
|
99
|
+
|
100
|
+
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def open_new_version_path
|
104
|
+
"#{object_path}/versions"
|
105
|
+
end
|
106
|
+
|
107
|
+
def close_version_path
|
108
|
+
"#{object_path}/versions/current/close"
|
109
|
+
end
|
60
110
|
end
|
61
111
|
end
|
62
112
|
end
|
@@ -23,7 +23,7 @@ module Dor
|
|
23
23
|
def publish(object:)
|
24
24
|
Object.new(connection: connection, version: api_version, object: object).publish
|
25
25
|
end
|
26
|
-
deprecation_deprecate publish: 'Use Dor::Client.object(obj).publish instead'
|
26
|
+
deprecation_deprecate publish: 'Use Dor::Services::Client.object(obj).publish instead'
|
27
27
|
|
28
28
|
# Notify the external Goobi system for a new object that was registered in DOR
|
29
29
|
# @param object [String] the pid for the object
|
@@ -32,7 +32,7 @@ module Dor
|
|
32
32
|
def notify_goobi(object:)
|
33
33
|
Object.new(connection: connection, version: api_version, object: object).notify_goobi
|
34
34
|
end
|
35
|
-
deprecation_deprecate notify_goobi: 'Use Dor::Client.object(obj).notify_goobi instead'
|
35
|
+
deprecation_deprecate notify_goobi: 'Use Dor::Services::Client.object(obj).notify_goobi instead'
|
36
36
|
|
37
37
|
# Gets the current version number for the object
|
38
38
|
# @param object [String] the pid for the object
|
@@ -42,11 +42,12 @@ module Dor
|
|
42
42
|
def current_version(object:)
|
43
43
|
SDR.new(connection: connection, version: api_version).current_version(object: object)
|
44
44
|
end
|
45
|
-
deprecation_deprecate current_version: 'Use Dor::Client.sdr.current_version instead'
|
45
|
+
deprecation_deprecate current_version: 'Use Dor::Services::Client.sdr.current_version(object: obj) instead'
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
49
|
# make the registration request to the server
|
50
|
+
# @param params [Hash] optional params (see dor-services-app)
|
50
51
|
# @raises [UnexpectedResponse] on an unsuccessful response from the server
|
51
52
|
# @returns [String] the raw JSON from the server
|
52
53
|
def register_response(params:)
|
data/lib/dor/services/client.rb
CHANGED
@@ -127,6 +127,25 @@ module Dor
|
|
127
127
|
release_tags.create(object: object, release: release, what: what, to: to, who: who)
|
128
128
|
end
|
129
129
|
|
130
|
+
# Open new version for an object
|
131
|
+
# @param object [String] object identifier
|
132
|
+
# @param params [Hash] optional params (see dor-services-app)
|
133
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
134
|
+
# @raise [MalformedResponse] when the response is not parseable.
|
135
|
+
# @return [String] the current version
|
136
|
+
def open_new_version(object:, **params)
|
137
|
+
object(object).open_new_version(**params)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Close current version for an object
|
141
|
+
# @param object [String] object identifier
|
142
|
+
# @param params [Hash] optional params (see dor-services-app)
|
143
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
144
|
+
# @return [String] a message confirming successful closing
|
145
|
+
def close_version(object:, **params)
|
146
|
+
object(object).close_version(**params)
|
147
|
+
end
|
148
|
+
|
130
149
|
# Publish a new object
|
131
150
|
# @param object [String] the pid for the object
|
132
151
|
# @raise [UnexpectedResponse] when the response is not successful.
|
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: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -191,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
- !ruby/object:Gem::Version
|
192
192
|
version: '0'
|
193
193
|
requirements: []
|
194
|
-
|
195
|
-
rubygems_version: 2.7.6
|
194
|
+
rubygems_version: 3.0.2
|
196
195
|
signing_key:
|
197
196
|
specification_version: 4
|
198
197
|
summary: A client for dor-services-app
|