purl_fetcher-client 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/purl_fetcher/client/publish.rb +2 -2
- data/lib/purl_fetcher/client/reader.rb +1 -1
- data/lib/purl_fetcher/client/release_tags.rb +1 -1
- data/lib/purl_fetcher/client/unpublish.rb +1 -1
- data/lib/purl_fetcher/client/version.rb +1 -1
- data/lib/purl_fetcher/client/withdraw.rb +57 -0
- data/lib/purl_fetcher/client.rb +4 -4
- metadata +4 -4
- data/lib/purl_fetcher/client/legacy_publish.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f527139551834c001a5c25e7ce1c84b07f6dcfd2adb5d58fb9597e89b160324
|
4
|
+
data.tar.gz: 051d4b0e7c6034e719fc936a202aa3146c4727a85084688d65e9fcf4c6c965fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804b3f082dea214e88918377130260412c11d3a89697d69013f4eb79ed35d5a0427568f584db8c611d82c442cdd1076939f85d70f54872f2cbd6b4f10e41c626
|
7
|
+
data.tar.gz: cc004f4461fb528491fe868f60e052ed064ff9d7ee40539b4d3df3df9f48fc7725a1e39a90b0e6a5fde3b34841b10b4bc25bc2e57cd961980dd287609a23bad1
|
@@ -23,7 +23,7 @@ module PurlFetcher
|
|
23
23
|
|
24
24
|
def publish
|
25
25
|
logger.debug("Starting a publish request for: #{druid}")
|
26
|
-
client.
|
26
|
+
client.put(path:, body:)
|
27
27
|
logger.debug("Publish request complete")
|
28
28
|
end
|
29
29
|
|
@@ -54,7 +54,7 @@ module PurlFetcher
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def path
|
57
|
-
"/v1/
|
57
|
+
"/v1/purls/#{druid}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -25,7 +25,7 @@ class PurlFetcher::Client::Reader
|
|
25
25
|
# @raise [PurlFetcher::Client::NotFoundResponseError] if item is not found
|
26
26
|
# @raise [PurlFetcher::Client::ResponseError] if the response is not successful
|
27
27
|
def files_by_digest(druid)
|
28
|
-
retrieve_json("/purls/druid:#{druid.delete_prefix('druid:')}", {})
|
28
|
+
retrieve_json("/v1/purls/druid:#{druid.delete_prefix('druid:')}", {})
|
29
29
|
.fetch("files_by_md5", [])
|
30
30
|
end
|
31
31
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PurlFetcher
|
4
|
+
class Client
|
5
|
+
# Withdraw / restore a version of an item from the purl-fetcher cache
|
6
|
+
class Withdraw
|
7
|
+
# @param [String] druid the identifier of the item
|
8
|
+
# @param [String] version the version of the item
|
9
|
+
def self.withdraw(druid:, version:)
|
10
|
+
new(druid:, version:).withdraw
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [String] druid the identifier of the item
|
14
|
+
# @param [String] version the version of the item
|
15
|
+
def self.restore(druid:, version:)
|
16
|
+
new(druid:, version:).restore
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [String] druid the identifier of the item
|
20
|
+
# @param [String] version the version of the item
|
21
|
+
def initialize(druid:, version:)
|
22
|
+
@druid = druid
|
23
|
+
@version = version
|
24
|
+
end
|
25
|
+
|
26
|
+
def withdraw
|
27
|
+
logger.debug("Starting a withdraw request for: #{druid} (#{version})")
|
28
|
+
response = client.put(path: path(:withdraw))
|
29
|
+
logger.debug("Withdraw request complete")
|
30
|
+
response
|
31
|
+
end
|
32
|
+
|
33
|
+
def restore
|
34
|
+
logger.debug("Starting a restore request for: #{druid} (#{version})")
|
35
|
+
response = client.put(path: path(:restore))
|
36
|
+
logger.debug("Withdraw request complete")
|
37
|
+
response
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
attr_reader :druid, :version
|
43
|
+
|
44
|
+
def logger
|
45
|
+
Client.config.logger
|
46
|
+
end
|
47
|
+
|
48
|
+
def client
|
49
|
+
Client.instance
|
50
|
+
end
|
51
|
+
|
52
|
+
def path(action)
|
53
|
+
"/v1/purls/#{druid}/versions/#{version}/#{action}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/purl_fetcher/client.rb
CHANGED
@@ -7,10 +7,10 @@ require "logger"
|
|
7
7
|
require "purl_fetcher/client/version"
|
8
8
|
require "purl_fetcher/client/reader"
|
9
9
|
require "purl_fetcher/client/mods"
|
10
|
-
require "purl_fetcher/client/legacy_publish"
|
11
10
|
require "purl_fetcher/client/publish"
|
12
11
|
require "purl_fetcher/client/release_tags"
|
13
12
|
require "purl_fetcher/client/unpublish"
|
13
|
+
require "purl_fetcher/client/withdraw"
|
14
14
|
|
15
15
|
module PurlFetcher
|
16
16
|
class Client
|
@@ -76,9 +76,9 @@ module PurlFetcher
|
|
76
76
|
# @param path [String] the path for the API request
|
77
77
|
# @param body [String] the body of the POST request
|
78
78
|
# @param headers [Hash] extra headers to add to the SDR API request
|
79
|
-
def put(path:, body
|
79
|
+
def put(path:, body: nil, headers: {})
|
80
80
|
response = connection.put(path) do |request|
|
81
|
-
request.body = body
|
81
|
+
request.body = body if body
|
82
82
|
request.headers = default_headers.merge(headers)
|
83
83
|
end
|
84
84
|
|
@@ -112,7 +112,7 @@ module PurlFetcher
|
|
112
112
|
def default_request_options
|
113
113
|
# To allow transfer of large files.
|
114
114
|
{
|
115
|
-
read_timeout:
|
115
|
+
read_timeout: 1800, # 30 minutes for first response byte to be received
|
116
116
|
timeout: 36000
|
117
117
|
}
|
118
118
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purl_fetcher-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -126,13 +126,13 @@ files:
|
|
126
126
|
- bin/console
|
127
127
|
- bin/setup
|
128
128
|
- lib/purl_fetcher/client.rb
|
129
|
-
- lib/purl_fetcher/client/legacy_publish.rb
|
130
129
|
- lib/purl_fetcher/client/mods.rb
|
131
130
|
- lib/purl_fetcher/client/publish.rb
|
132
131
|
- lib/purl_fetcher/client/reader.rb
|
133
132
|
- lib/purl_fetcher/client/release_tags.rb
|
134
133
|
- lib/purl_fetcher/client/unpublish.rb
|
135
134
|
- lib/purl_fetcher/client/version.rb
|
135
|
+
- lib/purl_fetcher/client/withdraw.rb
|
136
136
|
- purl_fetcher-client.gemspec
|
137
137
|
homepage:
|
138
138
|
licenses: []
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
155
|
+
rubygems_version: 3.5.9
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Traject-compatible reader implementation for streaming data from purl-fetcher
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PurlFetcher
|
4
|
-
class Client
|
5
|
-
# Publish (metadata-only). This will be replaced with a single publish operation
|
6
|
-
class LegacyPublish
|
7
|
-
# @param [Cocina::Models::DRO,Cocina::Models::Collection] cocina the Cocina data object
|
8
|
-
def self.publish(cocina:)
|
9
|
-
new(cocina:).publish
|
10
|
-
end
|
11
|
-
|
12
|
-
# @param [Cocina::Models::DRO,Cocina::Models::Collection] cocina the Cocina data object
|
13
|
-
def initialize(cocina:)
|
14
|
-
@cocina = cocina
|
15
|
-
end
|
16
|
-
|
17
|
-
def publish
|
18
|
-
logger.debug("Starting a legacy publish request for: #{druid}")
|
19
|
-
response = client.post(path:, body:)
|
20
|
-
logger.debug("Legacy publish request complete")
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :cocina
|
26
|
-
|
27
|
-
def druid
|
28
|
-
cocina.externalIdentifier
|
29
|
-
end
|
30
|
-
|
31
|
-
def body
|
32
|
-
cocina.to_json
|
33
|
-
end
|
34
|
-
|
35
|
-
def logger
|
36
|
-
Client.config.logger
|
37
|
-
end
|
38
|
-
|
39
|
-
def client
|
40
|
-
Client.instance
|
41
|
-
end
|
42
|
-
|
43
|
-
def path
|
44
|
-
"/purls/#{druid}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|