dor-services-client 1.1.0 → 1.1.1
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/lib/dor/services/client/files.rb +7 -7
- data/lib/dor/services/client/object.rb +12 -12
- data/lib/dor/services/client/release_tags.rb +5 -5
- data/lib/dor/services/client/sdr.rb +6 -6
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client/workflow.rb +5 -5
- data/lib/dor/services/client/workspace.rb +5 -5
- data/lib/dor/services/client.rb +2 -2
- 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: 8647a5b059a14045feb35bb4fe72147cc44854dfb88e19c7af98132a719ba8aa
|
4
|
+
data.tar.gz: 715989551938b54347651a53e3221a46d68d7e7d455ac6ac65e7e0bb766f38d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce7568f2fbd9b2672eb5879a68bc07fc7b29f092f8ec2fa4c00c9683a199f6801a3c3386a8f81ff60d4de10ad861a07e7722c32146ab9d9c5e6d9091195366e
|
7
|
+
data.tar.gz: f1b77e539cde7590cc63270eb577dfa95131f9a4b893c5ff4efc87c53c3705557034516cf0b3ea7dd3ee07a58a6c1d4503c29d401de283fe8226c8c27a8f2305
|
@@ -5,10 +5,10 @@ module Dor
|
|
5
5
|
class Client
|
6
6
|
# API calls relating to files
|
7
7
|
class Files < VersionedService
|
8
|
-
# @param
|
9
|
-
def initialize(connection:, version:,
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
10
|
super(connection: connection, version: version)
|
11
|
-
@
|
11
|
+
@object_identifier = object_identifier
|
12
12
|
end
|
13
13
|
|
14
14
|
# Get the contents from the workspace
|
@@ -16,7 +16,7 @@ module Dor
|
|
16
16
|
# @return [String] the file contents from the workspace
|
17
17
|
def retrieve(filename:)
|
18
18
|
resp = connection.get do |req|
|
19
|
-
req.url "#{api_version}/objects/#{
|
19
|
+
req.url "#{api_version}/objects/#{object_identifier}/contents/#{filename}"
|
20
20
|
end
|
21
21
|
return unless resp.success?
|
22
22
|
|
@@ -29,7 +29,7 @@ module Dor
|
|
29
29
|
# @return [String] the file contents from the SDR
|
30
30
|
def preserved_content(filename:, version:)
|
31
31
|
resp = connection.get do |req|
|
32
|
-
req.url "#{api_version}/sdr/objects/#{
|
32
|
+
req.url "#{api_version}/sdr/objects/#{object_identifier}/content/#{CGI.escape(filename)}?version=#{version}"
|
33
33
|
end
|
34
34
|
return unless resp.success?
|
35
35
|
|
@@ -40,7 +40,7 @@ module Dor
|
|
40
40
|
# @return [Array<String>] the list of filenames in the workspace
|
41
41
|
def list
|
42
42
|
resp = connection.get do |req|
|
43
|
-
req.url "#{api_version}/objects/#{
|
43
|
+
req.url "#{api_version}/objects/#{object_identifier}/contents"
|
44
44
|
end
|
45
45
|
return [] unless resp.success?
|
46
46
|
|
@@ -50,7 +50,7 @@ module Dor
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
attr_reader :
|
53
|
+
attr_reader :object_identifier
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -11,34 +11,34 @@ module Dor
|
|
11
11
|
class Client
|
12
12
|
# API calls that are about a repository object
|
13
13
|
class Object < VersionedService
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :object_identifier
|
15
15
|
|
16
|
-
# @param
|
17
|
-
def initialize(connection:, version:,
|
18
|
-
raise ArgumentError, "The `
|
16
|
+
# @param object_identifier [String] the pid for the object
|
17
|
+
def initialize(connection:, version:, object_identifier:)
|
18
|
+
raise ArgumentError, "The `object_identifier` parameter must be an identifier string: #{object_identifier.inspect}" unless object_identifier.is_a?(String)
|
19
19
|
|
20
20
|
super(connection: connection, version: version)
|
21
|
-
@
|
21
|
+
@object_identifier = object_identifier
|
22
22
|
end
|
23
23
|
|
24
24
|
def sdr
|
25
|
-
@sdr ||= SDR.new(connection: connection, version: api_version,
|
25
|
+
@sdr ||= SDR.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
26
26
|
end
|
27
27
|
|
28
28
|
def files
|
29
|
-
@files ||= Files.new(connection: connection, version: api_version,
|
29
|
+
@files ||= Files.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
30
30
|
end
|
31
31
|
|
32
32
|
def workflow
|
33
|
-
@workflow ||= Workflow.new(connection: connection, version: api_version,
|
33
|
+
@workflow ||= Workflow.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
34
34
|
end
|
35
35
|
|
36
36
|
def workspace
|
37
|
-
@workspace ||= Workspace.new(connection: connection, version: api_version,
|
37
|
+
@workspace ||= Workspace.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
38
38
|
end
|
39
39
|
|
40
40
|
def release_tags
|
41
|
-
@release_tags ||= ReleaseTags.new(connection: connection, version: api_version,
|
41
|
+
@release_tags ||= ReleaseTags.new(connection: connection, version: api_version, object_identifier: object_identifier)
|
42
42
|
end
|
43
43
|
|
44
44
|
# Publish a new object
|
@@ -88,7 +88,7 @@ module Dor
|
|
88
88
|
# @return [String] the current version
|
89
89
|
def open_new_version(**params)
|
90
90
|
version = open_new_version_response(**params)
|
91
|
-
raise MalformedResponse, "Version of #{
|
91
|
+
raise MalformedResponse, "Version of #{object_identifier} is empty" if version.empty?
|
92
92
|
|
93
93
|
version
|
94
94
|
end
|
@@ -112,7 +112,7 @@ module Dor
|
|
112
112
|
private
|
113
113
|
|
114
114
|
def object_path
|
115
|
-
"#{api_version}/objects/#{
|
115
|
+
"#{api_version}/objects/#{object_identifier}"
|
116
116
|
end
|
117
117
|
|
118
118
|
def raise_exception_based_on_response!(response)
|
@@ -5,10 +5,10 @@ module Dor
|
|
5
5
|
class Client
|
6
6
|
# API calls that are about a repository object
|
7
7
|
class ReleaseTags < VersionedService
|
8
|
-
# @param
|
9
|
-
def initialize(connection:, version:,
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
10
|
super(connection: connection, version: version)
|
11
|
-
@
|
11
|
+
@object_identifier = object_identifier
|
12
12
|
end
|
13
13
|
|
14
14
|
# Creates a new release tag for the object
|
@@ -27,7 +27,7 @@ module Dor
|
|
27
27
|
release: release
|
28
28
|
}
|
29
29
|
resp = connection.post do |req|
|
30
|
-
req.url "#{api_version}/objects/#{
|
30
|
+
req.url "#{api_version}/objects/#{object_identifier}/release_tags"
|
31
31
|
req.headers['Content-Type'] = 'application/json'
|
32
32
|
req.body = params.to_json
|
33
33
|
end
|
@@ -39,7 +39,7 @@ module Dor
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
attr_reader :
|
42
|
+
attr_reader :object_identifier
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -7,10 +7,10 @@ module Dor
|
|
7
7
|
class Client
|
8
8
|
# API calls that are about preserved objects
|
9
9
|
class SDR < VersionedService
|
10
|
-
# @param
|
11
|
-
def initialize(connection:, version:,
|
10
|
+
# @param object_identifier [String] the pid for the object
|
11
|
+
def initialize(connection:, version:, object_identifier:)
|
12
12
|
super(connection: connection, version: version)
|
13
|
-
@
|
13
|
+
@object_identifier = object_identifier
|
14
14
|
end
|
15
15
|
|
16
16
|
# Gets the current version number for the object
|
@@ -31,7 +31,7 @@ module Dor
|
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
attr_reader :
|
34
|
+
attr_reader :object_identifier
|
35
35
|
|
36
36
|
# make the request to the server for the currentVersion xml
|
37
37
|
# @raises [UnexpectedResponse] on an unsuccessful response from the server
|
@@ -42,11 +42,11 @@ module Dor
|
|
42
42
|
end
|
43
43
|
return resp.body if resp.success?
|
44
44
|
|
45
|
-
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{
|
45
|
+
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}"
|
46
46
|
end
|
47
47
|
|
48
48
|
def current_version_path
|
49
|
-
"#{api_version}/sdr/objects/#{
|
49
|
+
"#{api_version}/sdr/objects/#{object_identifier}/current_version"
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -5,10 +5,10 @@ module Dor
|
|
5
5
|
class Client
|
6
6
|
# API calls that are about workflow
|
7
7
|
class Workflow < VersionedService
|
8
|
-
# @param
|
9
|
-
def initialize(connection:, version:,
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
10
|
super(connection: connection, version: version)
|
11
|
-
@
|
11
|
+
@object_identifier = object_identifier
|
12
12
|
end
|
13
13
|
|
14
14
|
# Begin a new workflow
|
@@ -17,14 +17,14 @@ module Dor
|
|
17
17
|
# @return nil
|
18
18
|
def create(wf_name:)
|
19
19
|
resp = connection.post do |req|
|
20
|
-
req.url "#{api_version}/objects/#{
|
20
|
+
req.url "#{api_version}/objects/#{object_identifier}/apo_workflows/#{wf_name}"
|
21
21
|
end
|
22
22
|
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
attr_reader :
|
27
|
+
attr_reader :object_identifier
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -5,10 +5,10 @@ module Dor
|
|
5
5
|
class Client
|
6
6
|
# API calls that are about the DOR workspace
|
7
7
|
class Workspace < VersionedService
|
8
|
-
# @param
|
9
|
-
def initialize(connection:, version:,
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
10
|
super(connection: connection, version: version)
|
11
|
-
@
|
11
|
+
@object_identifier = object_identifier
|
12
12
|
end
|
13
13
|
|
14
14
|
# Initializes a new workspace
|
@@ -17,7 +17,7 @@ module Dor
|
|
17
17
|
# @return nil
|
18
18
|
def create(source:)
|
19
19
|
resp = connection.post do |req|
|
20
|
-
req.url "#{api_version}/objects/#{
|
20
|
+
req.url "#{api_version}/objects/#{object_identifier}/initialize_workspace"
|
21
21
|
req.params['source'] = source
|
22
22
|
end
|
23
23
|
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?
|
@@ -25,7 +25,7 @@ module Dor
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
-
attr_reader :
|
28
|
+
attr_reader :object_identifier
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/dor/services/client.rb
CHANGED
@@ -37,9 +37,9 @@ module Dor
|
|
37
37
|
# Return memoized object instance if object identifier value is the same
|
38
38
|
# This allows us to test the client more easily in downstream codebases,
|
39
39
|
# opening up stubbing without requiring `any_instance_of`
|
40
|
-
return @object if @object&.
|
40
|
+
return @object if @object&.object_identifier == object_identifier
|
41
41
|
|
42
|
-
@object = Object.new(connection: connection, version: DEFAULT_VERSION,
|
42
|
+
@object = Object.new(connection: connection, version: DEFAULT_VERSION, object_identifier: object_identifier)
|
43
43
|
end
|
44
44
|
|
45
45
|
# @return [Dor::Services::Client::Objects] an instance of the `Client::Objects` class
|
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.1.
|
4
|
+
version: 1.1.1
|
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-01-
|
12
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|