dor-services-client 1.7.0 → 1.8.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 +4 -0
- data/lib/dor/services/client.rb +14 -4
- data/lib/dor/services/client/metadata.rb +46 -0
- data/lib/dor/services/client/object.rb +18 -0
- data/lib/dor/services/client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ebc90d8d21ff990c42ec2836981cc9f9f58ecb0381a563b02beaa9f7f1c4192
|
4
|
+
data.tar.gz: a6c3e9486eb2b3bd734eec127721d8f17bbee913718e5038fa37b9910be0c2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e178424afe1d89adb1f2aa6f372eac45d3e5a04da66839494acb95780d370e50b09c26e43efe7d9093cb57940dab8c5306ee62b4a57763f9f4e558c88fc63a
|
7
|
+
data.tar.gz: 907c84790debd06e77586f9f636fcbdc9c2d621a266c54aeee920a2de7ef468c3de43b15eee0e9624a53e5c0f2b31bbac84de5612d1488c992a930e57c693493
|
data/README.md
CHANGED
@@ -59,10 +59,14 @@ objects_client.register(params: {})
|
|
59
59
|
# For performing operations on a known, registered object
|
60
60
|
object_client = Dor::Services::Client.object(object_identifier)
|
61
61
|
object_client.publish
|
62
|
+
# Copy metadata from Symphony into descMetadata
|
63
|
+
object_client.refresh_metadata
|
62
64
|
object_client.notify_goobi
|
63
65
|
object_client.current_version
|
64
66
|
object_client.open_new_version(**params)
|
65
67
|
object_client.close_version(**params)
|
68
|
+
# Return the Dublin Core XML representation
|
69
|
+
object_client.metadata.dublin_core
|
66
70
|
object_client.files.retrieve(filename: filename_string)
|
67
71
|
object_client.files.preserved_content(filename: filename_string, version: version_string)
|
68
72
|
object_client.files.list
|
data/lib/dor/services/client.rb
CHANGED
@@ -56,10 +56,19 @@ module Dor
|
|
56
56
|
end
|
57
57
|
|
58
58
|
class << self
|
59
|
-
|
59
|
+
# @param [String] url
|
60
|
+
# @param [String] username
|
61
|
+
# @param [String] password
|
62
|
+
# @param [String] token a bearer token for HTTP auth
|
63
|
+
# @param [String] token_header ('Authorization') set this to something if you are also using
|
64
|
+
# basic auth, or the headers will collide
|
65
|
+
def configure(url:, username: nil, password: nil, token: nil, token_header: 'Authorization')
|
60
66
|
instance.url = url
|
61
67
|
instance.username = username
|
62
68
|
instance.password = password
|
69
|
+
instance.token = token
|
70
|
+
instance.token_header = token_header
|
71
|
+
|
63
72
|
# Force connection to be re-established when `.configure` is called
|
64
73
|
instance.connection = nil
|
65
74
|
|
@@ -69,11 +78,11 @@ module Dor
|
|
69
78
|
delegate :objects, :object, :workflows, to: :instance
|
70
79
|
end
|
71
80
|
|
72
|
-
attr_writer :url, :username, :password, :connection
|
81
|
+
attr_writer :url, :username, :password, :token, :token_header, :connection
|
73
82
|
|
74
83
|
private
|
75
84
|
|
76
|
-
attr_reader :username, :password
|
85
|
+
attr_reader :username, :password, :token, :token_header
|
77
86
|
|
78
87
|
def url
|
79
88
|
@url || raise(Error, 'url has not yet been configured')
|
@@ -86,9 +95,10 @@ module Dor
|
|
86
95
|
# @note when username & password are nil, this line is required else
|
87
96
|
# the Faraday instance will be passed an empty block, which
|
88
97
|
# causes the adapter not to be set. Thus, everything breaks.
|
89
|
-
conn.adapter
|
98
|
+
conn.adapter Faraday.default_adapter
|
90
99
|
conn.basic_auth username, password if username && password
|
91
100
|
conn.headers[:user_agent] = user_agent
|
101
|
+
conn.headers[token_header] = "Bearer #{token}" if token
|
92
102
|
end
|
93
103
|
end
|
94
104
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: tru
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Services
|
5
|
+
class Client
|
6
|
+
# API calls that are about retrieving metadata
|
7
|
+
class Metadata < VersionedService
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
|
+
super(connection: connection, version: version)
|
11
|
+
@object_identifier = object_identifier
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String] The Dublin Core XML representation of the object
|
15
|
+
def dublin_core
|
16
|
+
resp = connection.get do |req|
|
17
|
+
req.url "#{base_path}/dublin_core"
|
18
|
+
end
|
19
|
+
return resp.body if resp.success?
|
20
|
+
return if resp.status == 404
|
21
|
+
|
22
|
+
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}"
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] The descriptive metadata XML representation of the object
|
26
|
+
def descriptive
|
27
|
+
resp = connection.get do |req|
|
28
|
+
req.url "#{base_path}/descriptive"
|
29
|
+
end
|
30
|
+
return resp.body if resp.success?
|
31
|
+
return if resp.status == 404
|
32
|
+
|
33
|
+
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}"
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :object_identifier
|
39
|
+
|
40
|
+
def base_path
|
41
|
+
"#{api_version}/objects/#{object_identifier}/metadata"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -5,6 +5,7 @@ require 'dor/services/client/release_tags'
|
|
5
5
|
require 'dor/services/client/sdr'
|
6
6
|
require 'dor/services/client/workflow'
|
7
7
|
require 'dor/services/client/workspace'
|
8
|
+
require 'dor/services/client/metadata'
|
8
9
|
|
9
10
|
module Dor
|
10
11
|
module Services
|
@@ -25,6 +26,10 @@ module Dor
|
|
25
26
|
@sdr ||= SDR.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
26
27
|
end
|
27
28
|
|
29
|
+
def metadata
|
30
|
+
@metadata ||= Metadata.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
31
|
+
end
|
32
|
+
|
28
33
|
def files
|
29
34
|
@files ||= Files.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
30
35
|
end
|
@@ -67,6 +72,19 @@ module Dor
|
|
67
72
|
raise_exception_based_on_response!(resp)
|
68
73
|
end
|
69
74
|
|
75
|
+
# Pull in metadata from Symphony and update descMetadata
|
76
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
77
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
78
|
+
# @return [boolean] true on success
|
79
|
+
def refresh_metadata
|
80
|
+
resp = connection.post do |req|
|
81
|
+
req.url "#{object_path}/refresh_metadata"
|
82
|
+
end
|
83
|
+
return true if resp.success?
|
84
|
+
|
85
|
+
raise_exception_based_on_response!(resp)
|
86
|
+
end
|
87
|
+
|
70
88
|
# Notify the external Goobi system for a new object that was registered in DOR
|
71
89
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
72
90
|
# @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: 1.
|
4
|
+
version: 1.8.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: 2019-
|
12
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/dor/services/client.rb
|
181
181
|
- lib/dor/services/client/error_faraday_middleware.rb
|
182
182
|
- lib/dor/services/client/files.rb
|
183
|
+
- lib/dor/services/client/metadata.rb
|
183
184
|
- lib/dor/services/client/object.rb
|
184
185
|
- lib/dor/services/client/objects.rb
|
185
186
|
- lib/dor/services/client/release_tags.rb
|