folio_client 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.autoupdate/postupdate +19 -0
- data/Gemfile.lock +2 -1
- data/lib/folio_client/data_import.rb +11 -0
- data/lib/folio_client/source_storage.rb +2 -1
- data/lib/folio_client/unexpected_response.rb +4 -2
- data/lib/folio_client/version.rb +1 -1
- data/lib/folio_client.rb +35 -9
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e7b3edaad66a7bca966c6316eb979f722fe0eb2336def7f45eda9952a2a5ee
|
4
|
+
data.tar.gz: 7d4d555e56d607acbb4649ef59e94e5ab417ee1f4f78fce2a999864f9e8486ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad63a3b363409b8561ca3ecf0f94b05f915ffe8ec621915e692f7d805d1f1c140b7626d2c95d613cc35974c08425a313e33ac72cc3249f68a1b3aece8d182688
|
7
|
+
data.tar.gz: 6e0bfb061e5fafda66cc4690726bb69a17e3ccdd474997bb433d3fa9f02d55f2e6c103edc263ab82e22d69c36960576a7acc5ab73f23b7e6364acee487efb99e
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/bin/bash --login
|
2
|
+
|
3
|
+
# This script is called by our weekly dependency update job in Jenkins after updating Ruby and other deps
|
4
|
+
|
5
|
+
# Switch to Ruby 3.1 for FolioClient (3.0 is default in Jenkinsfile)
|
6
|
+
rvm use 3.1.2@folio_client --create &&
|
7
|
+
gem install bundler &&
|
8
|
+
bundle install --gemfile Gemfile
|
9
|
+
|
10
|
+
standardrb --fix > folio_client_standard.txt
|
11
|
+
|
12
|
+
retVal=$?
|
13
|
+
|
14
|
+
git commit -am "Update to latest standard style guide"
|
15
|
+
|
16
|
+
if [ $retVal -ne 0 ]; then
|
17
|
+
echo "ERROR UPDATING RUBY TO STANDARD STYLE (folio_client)"
|
18
|
+
cat folio_client_standard.txt
|
19
|
+
fi
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
folio_client (0.
|
4
|
+
folio_client (0.11.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
dry-monads
|
7
7
|
faraday
|
@@ -116,6 +116,7 @@ PLATFORMS
|
|
116
116
|
x86_64-darwin-19
|
117
117
|
x86_64-darwin-20
|
118
118
|
x86_64-darwin-21
|
119
|
+
x86_64-darwin-22
|
119
120
|
x86_64-linux
|
120
121
|
|
121
122
|
DEPENDENCIES
|
@@ -7,6 +7,8 @@ require "stringio"
|
|
7
7
|
class FolioClient
|
8
8
|
# Imports MARC records into FOLIO
|
9
9
|
class DataImport
|
10
|
+
JOB_PROFILE_ATTRIBUTES = %w[id name description dataType].freeze
|
11
|
+
|
10
12
|
# @param client [FolioClient] the configured client
|
11
13
|
def initialize(client)
|
12
14
|
@client = client
|
@@ -15,6 +17,7 @@ class FolioClient
|
|
15
17
|
# @param record [MARC::Record] record to be imported
|
16
18
|
# @param job_profile_id [String] job profile id to use for import
|
17
19
|
# @param job_profile_name [String] job profile name to use for import
|
20
|
+
# @return [JobStatus] a job status instance to get information about the data import job
|
18
21
|
def import(marc:, job_profile_id:, job_profile_name:)
|
19
22
|
response_hash = client.post("/data-import/uploadDefinitions", {fileDefinitions: [{name: marc_filename}]})
|
20
23
|
upload_definition_id = response_hash.dig("fileDefinitions", 0, "uploadDefinitionId")
|
@@ -38,6 +41,14 @@ class FolioClient
|
|
38
41
|
JobStatus.new(client, job_execution_id: job_execution_id)
|
39
42
|
end
|
40
43
|
|
44
|
+
# @return [Array<Hash<String,String>>] a list of job profile hashes
|
45
|
+
def job_profiles
|
46
|
+
client
|
47
|
+
.get("/data-import-profiles/jobProfiles")
|
48
|
+
.fetch("jobProfiles", [])
|
49
|
+
.map { |profile| profile.slice(*JOB_PROFILE_ATTRIBUTES) }
|
50
|
+
end
|
51
|
+
|
41
52
|
private
|
42
53
|
|
43
54
|
attr_reader :client, :marc, :job_profile_id, :job_profile_name
|
@@ -13,7 +13,8 @@ class FolioClient
|
|
13
13
|
# get marc bib data from folio given an instance HRID
|
14
14
|
# @param instance_hrid [String] the key to use for MARC lookup
|
15
15
|
# @return [Hash] hash representation of the MARC. should be usable by MARC::Record.new_from_hash (from ruby-marc gem)
|
16
|
-
# @
|
16
|
+
# @raise [ResourceNotFound]
|
17
|
+
# @raise [MultipleResourcesFound]
|
17
18
|
def fetch_marc_hash(instance_hrid:)
|
18
19
|
response_hash = client.get("/source-storage/source-records", {instanceHrid: instance_hrid})
|
19
20
|
|
@@ -12,10 +12,12 @@ class FolioClient
|
|
12
12
|
raise ForbiddenError, "The operation requires privileges which the client does not have: #{response.body}"
|
13
13
|
when 404
|
14
14
|
raise ResourceNotFound, "Endpoint not found or resource does not exist: #{response.body}"
|
15
|
+
when 409
|
16
|
+
raise ConflictError, "Resource cannot be updated: #{response.body}"
|
15
17
|
when 422
|
16
|
-
raise ValidationError, "There was a validation problem with the request: #{response.body}
|
18
|
+
raise ValidationError, "There was a validation problem with the request: #{response.body}"
|
17
19
|
when 500
|
18
|
-
raise ServiceUnavailable, "The remote server returned an internal server error."
|
20
|
+
raise ServiceUnavailable, "The remote server returned an internal server error: #{response.body}"
|
19
21
|
else
|
20
22
|
raise StandardError, "Unexpected response: #{response.status} #{response.body}"
|
21
23
|
end
|
data/lib/folio_client/version.rb
CHANGED
data/lib/folio_client.rb
CHANGED
@@ -35,6 +35,9 @@ class FolioClient
|
|
35
35
|
# Error raised when the Folio API returns a 422 Unprocessable Entity
|
36
36
|
class ValidationError < Error; end
|
37
37
|
|
38
|
+
# Error raised when the Folio API returns a 409 Conflict
|
39
|
+
class ConflictError < Error; end
|
40
|
+
|
38
41
|
DEFAULT_HEADERS = {
|
39
42
|
accept: "application/json, text/plain",
|
40
43
|
content_type: "application/json"
|
@@ -44,24 +47,32 @@ class FolioClient
|
|
44
47
|
# @param url [String] the folio API URL
|
45
48
|
# @param login_params [Hash] the folio client login params (username:, password:)
|
46
49
|
# @param okapi_headers [Hash] the okapi specific headers to add (X-Okapi-Tenant:, User-Agent:)
|
47
|
-
def configure(url:, login_params:, okapi_headers:)
|
48
|
-
instance.config = OpenStruct.new(
|
49
|
-
|
50
|
+
def configure(url:, login_params:, okapi_headers:, timeout: default_timeout)
|
51
|
+
instance.config = OpenStruct.new(
|
52
|
+
url: url,
|
53
|
+
login_params: login_params,
|
54
|
+
okapi_headers: okapi_headers,
|
55
|
+
timeout: timeout
|
56
|
+
)
|
57
|
+
|
58
|
+
# NOTE: The token cannot be set above, since `#connection` relies on
|
59
|
+
# `instance.config` parameters having already been set.
|
50
60
|
instance.config.token = Authenticator.token(login_params, connection)
|
51
61
|
|
52
62
|
self
|
53
63
|
end
|
54
64
|
|
55
|
-
delegate :config, :connection, :
|
56
|
-
|
57
|
-
:
|
65
|
+
delegate :config, :connection, :data_import, :default_timeout, :edit_marc_json,
|
66
|
+
:fetch_external_id, :fetch_hrid, :fetch_instance_info, :fetch_marc_hash, :get,
|
67
|
+
:has_instance_status?, :interface_details, :job_profiles, :organization_interfaces,
|
68
|
+
:organizations, :post, :put, to: :instance
|
58
69
|
end
|
59
70
|
|
60
71
|
attr_accessor :config
|
61
72
|
|
62
73
|
# Send an authenticated get request
|
63
74
|
# @param path [String] the path to the Folio API request
|
64
|
-
# @param
|
75
|
+
# @param params [Hash] params to get to the API
|
65
76
|
def get(path, params = {})
|
66
77
|
response = TokenWrapper.refresh(config, connection) do
|
67
78
|
connection.get(path, params, {"x-okapi-token": config.token})
|
@@ -120,7 +131,8 @@ class FolioClient
|
|
120
131
|
def connection
|
121
132
|
@connection ||= Faraday.new(
|
122
133
|
url: config.url,
|
123
|
-
headers: DEFAULT_HEADERS.merge(config.okapi_headers || {})
|
134
|
+
headers: DEFAULT_HEADERS.merge(config.okapi_headers || {}),
|
135
|
+
request: {timeout: config.timeout}
|
124
136
|
)
|
125
137
|
end
|
126
138
|
|
@@ -168,28 +180,42 @@ class FolioClient
|
|
168
180
|
.import(...)
|
169
181
|
end
|
170
182
|
|
171
|
-
# @see
|
183
|
+
# @ see DataImport#job_profiles
|
184
|
+
def job_profiles(...)
|
185
|
+
DataImport
|
186
|
+
.new(self)
|
187
|
+
.job_profiles(...)
|
188
|
+
end
|
189
|
+
|
190
|
+
# @see RecordsEditor#edit_marc_json
|
172
191
|
def edit_marc_json(...)
|
173
192
|
RecordsEditor
|
174
193
|
.new(self)
|
175
194
|
.edit_marc_json(...)
|
176
195
|
end
|
177
196
|
|
197
|
+
# @see Organizations#fetch_list
|
178
198
|
def organizations(...)
|
179
199
|
Organizations
|
180
200
|
.new(self)
|
181
201
|
.fetch_list(...)
|
182
202
|
end
|
183
203
|
|
204
|
+
# @see Organizations#fetch_interface_list
|
184
205
|
def organization_interfaces(...)
|
185
206
|
Organizations
|
186
207
|
.new(self)
|
187
208
|
.fetch_interface_list(...)
|
188
209
|
end
|
189
210
|
|
211
|
+
# @see Organizations#fetch_interface_details
|
190
212
|
def interface_details(...)
|
191
213
|
Organizations
|
192
214
|
.new(self)
|
193
215
|
.fetch_interface_details(...)
|
194
216
|
end
|
217
|
+
|
218
|
+
def default_timeout
|
219
|
+
120
|
220
|
+
end
|
195
221
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: folio_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -177,6 +177,7 @@ executables: []
|
|
177
177
|
extensions: []
|
178
178
|
extra_rdoc_files: []
|
179
179
|
files:
|
180
|
+
- ".autoupdate/postupdate"
|
180
181
|
- ".rspec"
|
181
182
|
- ".rubocop.yml"
|
182
183
|
- ".rubocop/custom.yml"
|
@@ -205,7 +206,7 @@ metadata:
|
|
205
206
|
source_code_uri: https://github.com/sul-dlss/folio_client
|
206
207
|
changelog_uri: https://github.com/sul-dlss/folio_client/releases
|
207
208
|
rubygems_mfa_required: 'true'
|
208
|
-
post_install_message:
|
209
|
+
post_install_message:
|
209
210
|
rdoc_options: []
|
210
211
|
require_paths:
|
211
212
|
- lib
|
@@ -220,8 +221,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
- !ruby/object:Gem::Version
|
221
222
|
version: '0'
|
222
223
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
224
|
-
signing_key:
|
224
|
+
rubygems_version: 3.3.7
|
225
|
+
signing_key:
|
225
226
|
specification_version: 4
|
226
227
|
summary: Interface for interacting with the Folio ILS API.
|
227
228
|
test_files: []
|