preservation-client 3.2.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -0
- data/README.md +5 -1
- data/lib/preservation/client/objects.rb +10 -0
- data/lib/preservation/client/version.rb +1 -1
- data/lib/preservation/client/versioned_api_service.rb +8 -6
- data/lib/preservation/client.rb +8 -3
- data/preservation-client.gemspec +1 -1
- metadata +6 -6
- data/.travis.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 859dd579bd9f390d624b4017952f76cd4f7ee652e24cd1a3e6a26ad997df921f
|
4
|
+
data.tar.gz: 210a26faa77c81accc7e694306e6b51f6ed61a6f2e4bf130a01f0e759b835792
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a69642114e5eae5c81bbbc5928e521b29fea8680005579ea7538ed9b9cbefc89c7ff6ce948cfcd4652e29d2f648f4643784ea2b0dbfb6dc3766a3f174db4c91
|
7
|
+
data.tar.gz: 5338f001b55fc8823164b9a11798cda7dc6910178a76b87dbdd529d86bf7e483e5ed1c3565b80d15c70533b645c4d72e6bcdfdf840f11a7ccef0c49694284979
|
@@ -0,0 +1,35 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
docker:
|
6
|
+
- image: circleci/ruby:2.7.1
|
7
|
+
environment:
|
8
|
+
CC_TEST_REPORTER_ID: 02e8afad8d0b699828dd69b6f45b598e7317b2d9828ea23380c3a97113068a0c
|
9
|
+
RAILS_ENV: test
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Install Bundler
|
14
|
+
command: gem install bundler
|
15
|
+
- run:
|
16
|
+
name: Which bundler?
|
17
|
+
command: bundle -v
|
18
|
+
- run:
|
19
|
+
name: Bundle Install
|
20
|
+
command: bundle check || bundle install
|
21
|
+
- run:
|
22
|
+
name: Lint using rubocop
|
23
|
+
command: bundle exec rubocop
|
24
|
+
- run:
|
25
|
+
name: Setup Code Climate test-reporter
|
26
|
+
command: |
|
27
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
28
|
+
chmod +x ./cc-test-reporter
|
29
|
+
./cc-test-reporter before-build
|
30
|
+
- run:
|
31
|
+
name: rspec
|
32
|
+
command: bundle exec rspec
|
33
|
+
- run:
|
34
|
+
name: upload test coverage report to Code Climate
|
35
|
+
command: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/preservation-client.svg)](https://badge.fury.io/rb/preservation-client)
|
2
|
-
[![
|
2
|
+
[![CircleCI](https://circleci.com/gh/sul-dlss/preservation-client.svg?style=svg)](https://circleci.com/gh/sul-dlss/preservation-client)
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/00d2d8957226777105b3/maintainability)](https://codeclimate.com/github/sul-dlss/preservation-client/maintainability)
|
4
4
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/00d2d8957226777105b3/test_coverage)](https://codeclimate.com/github/sul-dlss/preservation-client/test_coverage)
|
5
5
|
|
@@ -92,6 +92,10 @@ Note that the preservation service is behind a firewall.
|
|
92
92
|
|
93
93
|
- `client.objects.primary_moab_location(druid: 'ooo000oo0000')` - returns the path to the storage location for the primary moab
|
94
94
|
|
95
|
+
### Validate the Moab
|
96
|
+
|
97
|
+
- `client.objects.validate_moab(druid: 'ooo000oo0000')` - validates that the Moab object, used by preservationWF to ensure we have a valid Moab before replicating to various preservation endpoints
|
98
|
+
|
95
99
|
### Get difference information between passed contentMetadata.xml and files in the Moab
|
96
100
|
|
97
101
|
- `client.objects.content_inventory_diff(druid: 'oo000oo0000', content_metadata: '<contentMetadata>...</contentMetadata>')` - returns Moab::FileInventoryDifference containing differences between passed content metadata and latest version for subset 'all'
|
@@ -71,10 +71,20 @@ module Preservation
|
|
71
71
|
file(druid, 'metadata', filepath, version)
|
72
72
|
end
|
73
73
|
|
74
|
+
# calls the endpoint to queue a ValidateMoab job for a specific druid
|
75
|
+
# typically called by a preservationIngestWF robot
|
76
|
+
# @param [String] druid - with or without prefix: 'druid:ab123cd4567' or 'ab123cd4567'
|
77
|
+
# @return [String] "ok" when job queued
|
78
|
+
# @raise [Preservation::Client::NotFoundError] when druid is not found
|
79
|
+
def validate_moab(druid:)
|
80
|
+
get("objects/#{druid}/validate_moab", {}, on_data: nil)
|
81
|
+
end
|
82
|
+
|
74
83
|
# retrieve the storage location for the primary moab of the given druid
|
75
84
|
# @param [String] druid - with or without prefix: 'druid:ab123cd4567' or 'ab123cd4567'
|
76
85
|
# @return [String] the storage location of the primary moab for the given druid
|
77
86
|
# @raise [Preservation::Client::NotFoundError] when druid is not found
|
87
|
+
# @raise [Preservation::Client::LockedError] when druid is in locked state (not available for versioning)
|
78
88
|
def primary_moab_location(druid:)
|
79
89
|
get("objects/#{druid}/primary_moab_location", {}, on_data: nil)
|
80
90
|
end
|
@@ -25,14 +25,14 @@ module Preservation
|
|
25
25
|
|
26
26
|
errmsg = ResponseErrorFormatter
|
27
27
|
.format(response: resp, object_id: object_id, client_method_name: caller_locations.first.label)
|
28
|
-
raise
|
28
|
+
raise UnexpectedResponseError, errmsg
|
29
29
|
rescue Faraday::ResourceNotFound
|
30
30
|
errmsg = "#{object_id} not found in Preservation at #{connection.url_prefix}#{req_url}"
|
31
|
-
raise
|
31
|
+
raise NotFoundError, errmsg
|
32
32
|
rescue Faraday::Error => e
|
33
33
|
errmsg = "Preservation::Client.#{caller_locations.first.label} for #{object_id} " \
|
34
34
|
"got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
|
35
|
-
raise
|
35
|
+
raise UnexpectedResponseError, errmsg
|
36
36
|
end
|
37
37
|
|
38
38
|
# @param path [String] path to be appended to connection url (no leading slash)
|
@@ -83,18 +83,20 @@ module Preservation
|
|
83
83
|
request_json = params.to_json if params&.any?
|
84
84
|
connection.public_send(method, req_url, request_json, 'Content-Type' => 'application/json')
|
85
85
|
end
|
86
|
+
|
86
87
|
return resp.body if resp.success?
|
87
88
|
|
88
89
|
errmsg = ResponseErrorFormatter.format(response: resp, client_method_name: caller_locations.first.label)
|
89
|
-
raise
|
90
|
+
raise UnexpectedResponseError, errmsg
|
90
91
|
rescue Faraday::ResourceNotFound => e
|
91
92
|
errmsg = "Preservation::Client.#{caller_locations.first.label} " \
|
92
93
|
"got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
|
93
|
-
raise
|
94
|
+
raise NotFoundError, errmsg
|
94
95
|
rescue Faraday::Error => e
|
95
96
|
errmsg = "Preservation::Client.#{caller_locations.first.label} " \
|
96
97
|
"got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
|
97
|
-
|
98
|
+
exception_class = e.response[:status] == 423 ? LockedError : UnexpectedResponseError
|
99
|
+
raise exception_class, errmsg
|
98
100
|
end
|
99
101
|
end
|
100
102
|
end
|
data/lib/preservation/client.rb
CHANGED
@@ -17,13 +17,18 @@ module Preservation
|
|
17
17
|
class Client
|
18
18
|
class Error < StandardError; end
|
19
19
|
|
20
|
-
# Error
|
20
|
+
# Error raised when server returns 404 Not Found
|
21
21
|
class NotFoundError < Error; end
|
22
22
|
|
23
|
-
# Error
|
24
|
-
|
23
|
+
# Error raised when server returns 423 Locked
|
24
|
+
class LockedError < Error; end
|
25
|
+
|
26
|
+
# Error raised when server returns an unexpected response
|
27
|
+
# e.g., 4xx or 5xx status not otherwise handled
|
25
28
|
class UnexpectedResponseError < Error; end
|
26
29
|
|
30
|
+
# Error raised when Faraday gem fails to connect, e.g., on SSL errors or
|
31
|
+
# timeouts
|
27
32
|
class ConnectionFailedError < Error; end
|
28
33
|
|
29
34
|
DEFAULT_API_VERSION = 'v1'
|
data/preservation-client.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ['lib']
|
30
30
|
|
31
|
-
spec.add_dependency 'activesupport', '>= 4.2', '<
|
31
|
+
spec.add_dependency 'activesupport', '>= 4.2', '< 8'
|
32
32
|
spec.add_dependency 'faraday', '>= 0.15', '< 2.0'
|
33
33
|
spec.add_dependency 'moab-versioning', '~> 4.3'
|
34
34
|
spec.add_dependency 'zeitwerk', '~> 2.1'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: preservation-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '8'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '4.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '8'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: faraday
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,12 +184,12 @@ executables: []
|
|
184
184
|
extensions: []
|
185
185
|
extra_rdoc_files: []
|
186
186
|
files:
|
187
|
+
- ".circleci/config.yml"
|
187
188
|
- ".github/pull_request_template.md"
|
188
189
|
- ".gitignore"
|
189
190
|
- ".rspec"
|
190
191
|
- ".rubocop.yml"
|
191
192
|
- ".rubocop_todo.yml"
|
192
|
-
- ".travis.yml"
|
193
193
|
- Gemfile
|
194
194
|
- LICENSE
|
195
195
|
- README.md
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
|
-
rubygems_version: 3.1.
|
228
|
+
rubygems_version: 3.1.4
|
229
229
|
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: A thin client for getting info from SDR preservation.
|
data/.travis.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
rvm:
|
4
|
-
- 2.5.3
|
5
|
-
- 2.6.4
|
6
|
-
- 2.7.1
|
7
|
-
|
8
|
-
env:
|
9
|
-
jobs:
|
10
|
-
- RAILS_VERSION=5.2.3
|
11
|
-
- RAILS_VERSION=6.0.0
|
12
|
-
global:
|
13
|
-
- CC_TEST_REPORTER_ID=02e8afad8d0b699828dd69b6f45b598e7317b2d9828ea23380c3a97113068a0c
|
14
|
-
|
15
|
-
before_install: gem install bundler -v 2.1.2
|
16
|
-
|
17
|
-
before_script:
|
18
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
19
|
-
- chmod +x ./cc-test-reporter
|
20
|
-
- ./cc-test-reporter before-build
|
21
|
-
after_script:
|
22
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
23
|
-
|
24
|
-
notifications:
|
25
|
-
email: false
|