sdr-client 0.58.0 → 0.61.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0aeb8a257ee16931c449f5255f927b242fa1c9893303ae3b76feefa433adb24
4
- data.tar.gz: b00a06552dcff58238a57e2f13b500f48960861daf4567490d567d5598b01415
3
+ metadata.gz: a05e0c0eaec02cd41abd26e460c2be48a5dd45890b2e4e3f42b5c6fcad143936
4
+ data.tar.gz: 49a61ac42d58a64438d35f3f503cd690e4f3b560fad878929045d7152bde8724
5
5
  SHA512:
6
- metadata.gz: 045fa4dd33fce4c171c27dea01e0cbb12de8d91408eff404b2121f68690018549d26d6a43cb9792a8cae56f4953353952e0301b8b3a802215bc23d9ad7d2d730
7
- data.tar.gz: c15e6aecf2652ce4eb42f1433d3baab4d2cf7605e3e1f60a9b1ed5c5c8a4d7069c8f76ca9aa594741535b6bb3177582375d28280617f7c1096820cb344e3bf9d
6
+ metadata.gz: 1a02843244adbe817cd84806a445a257cedad1e56e1be71f1c76bb72210bd2a76525dcabc22641fa4dad9da0352274fa46c8cf7957d24fd9422c801ac958c1e9
7
+ data.tar.gz: d173d54a545ed1846f2418b502240e0141ab9dbe1b1d47663f8736f92317a982aa65b5d9c7b868814d09f0ff1b9d0542f5f740530526fe09fbd3792fc7b92b65
@@ -5,14 +5,16 @@ module SdrClient
5
5
  class Connection
6
6
  include Dry::Monads[:result]
7
7
 
8
- def initialize(url:, token: Credentials.read)
8
+ # @param [Integer] read_timeout the value in seconds to set the read timeout
9
+ def initialize(url:, token: Credentials.read, read_timeout: 180)
9
10
  @url = url
10
11
  @token = token
12
+ @request_options = { read_timeout: read_timeout }
11
13
  end
12
14
 
13
15
  def connection
14
- @connection ||= Faraday.new(url: url) do |conn|
15
- conn.authorization :Bearer, token
16
+ @connection ||= Faraday.new(url: url, request: request_options) do |conn|
17
+ conn.request :authorization, :Bearer, token
16
18
  conn.adapter :net_http
17
19
  end
18
20
  end
@@ -36,6 +38,6 @@ module SdrClient
36
38
 
37
39
  private
38
40
 
39
- attr_reader :url, :token
41
+ attr_reader :url, :token, :request_options
40
42
  end
41
43
  end
@@ -6,15 +6,21 @@ module SdrClient
6
6
  class CreateResource
7
7
  DRO_PATH = '/v1/resources'
8
8
 
9
- def self.run(accession:, metadata:, logger:, connection:)
10
- new(accession: accession, metadata: metadata, logger: logger, connection: connection).run
9
+ def self.run(accession:, assign_doi: false, metadata:, logger:, connection:)
10
+ new(accession: accession,
11
+ assign_doi: assign_doi,
12
+ metadata: metadata,
13
+ logger: logger,
14
+ connection: connection).run
11
15
  end
12
16
 
13
17
  # @param [Boolean] accession should the accessionWF be started
18
+ # @param [Boolean] assign_doi should a DOI be assigned to this item
14
19
  # @param [Cocina::Models::RequestDRO, Cocina::Models::RequestCollection] metadata
15
20
  # @param [Hash<Symbol,String>] the result of the metadata call
16
- def initialize(accession:, metadata:, logger:, connection:)
21
+ def initialize(accession:, assign_doi:, metadata:, logger:, connection:)
17
22
  @accession = accession
23
+ @assign_doi = assign_doi
18
24
  @metadata = metadata
19
25
  @logger = logger
20
26
  @connection = connection
@@ -48,8 +54,14 @@ module SdrClient
48
54
  @accession
49
55
  end
50
56
 
57
+ def assign_doi?
58
+ @assign_doi
59
+ end
60
+
51
61
  def path
52
- "#{DRO_PATH}?accession=#{accession?}"
62
+ params = { accession: accession? }
63
+ params[:assign_doi] = true if assign_doi? # false is default
64
+ DRO_PATH + '?' + params.map { |k, v| "#{k}=#{v}" }.join('&')
53
65
  end
54
66
  end
55
67
  end
@@ -10,14 +10,19 @@ module SdrClient
10
10
  # @param [Connection] connection the connection to use
11
11
  # @param [Array<String>] files a list of file names to upload
12
12
  # @param [Boolean] accession should the accessionWF be started
13
+ # @param [Boolean] assign_doi should a DOI be assigned to this item
13
14
  # @param [Logger] logger the logger to use
14
- def initialize(request_dro:, connection:,
15
- files: [], accession:, logger: Logger.new(STDOUT))
15
+ def initialize(request_dro:, # rubocop:disable Metrics/ParameterLists
16
+ connection:,
17
+ files: [], accession:,
18
+ assign_doi: false,
19
+ logger: Logger.new(STDOUT))
16
20
  @files = files
17
21
  @connection = connection
18
22
  @request_dro = request_dro
19
23
  @logger = logger
20
24
  @accession = accession
25
+ @assign_doi = assign_doi
21
26
  end
22
27
 
23
28
  def run
@@ -30,6 +35,7 @@ module SdrClient
30
35
  connection: connection)
31
36
  new_request_dro = UpdateDroWithFileIdentifiers.update(request_dro: request_dro, upload_responses: upload_responses)
32
37
  CreateResource.run(accession: @accession,
38
+ assign_doi: @assign_doi,
33
39
  metadata: new_request_dro,
34
40
  logger: logger,
35
41
  connection: connection)
@@ -10,18 +10,21 @@ module SdrClient
10
10
  # @param [Class] grouping_strategy class whose run method groups an array of uploads
11
11
  # @param [String] connection the server connection to use
12
12
  # @param [Array<String>] files a list of file names to upload
13
+ # @param [Boolean] assign_doi should a DOI be assigned to this item
13
14
  # @param [Boolean] accession should the accessionWF be started
14
15
  # @param [Logger] logger the logger to use
15
16
  #
16
17
  # rubocop:disable Metrics/ParameterLists
17
18
  def initialize(metadata:, grouping_strategy: SingleFileGroupingStrategy,
18
- connection:, files: [], accession:, logger: Logger.new(STDOUT))
19
+ connection:, files: [], accession:, assign_doi: false,
20
+ logger: Logger.new(STDOUT))
19
21
  @files = files
20
22
  @connection = connection
21
23
  @metadata = metadata
22
24
  @logger = logger
23
25
  @grouping_strategy = grouping_strategy
24
26
  @accession = accession
27
+ @assign_doi = assign_doi
25
28
  end
26
29
  # rubocop:enable Metrics/ParameterLists
27
30
 
@@ -40,6 +43,7 @@ module SdrClient
40
43
  request = metadata_builder.with_uploads(upload_responses)
41
44
  model = Cocina::Models.build_request(request.as_json.with_indifferent_access)
42
45
  CreateResource.run(accession: @accession,
46
+ assign_doi: @assign_doi,
43
47
  metadata: model,
44
48
  logger: logger,
45
49
  connection: connection)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.58.0'
4
+ VERSION = '0.61.1'
5
5
  end
data/sdr-client.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ['lib']
29
29
 
30
30
  spec.add_dependency 'activesupport'
31
- spec.add_dependency 'cocina-models', '~> 0.61.0'
31
+ spec.add_dependency 'cocina-models', '~> 0.62.0'
32
32
  spec.add_dependency 'dry-monads'
33
33
  spec.add_dependency 'faraday', '>= 0.16'
34
34
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdr-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.58.0
4
+ version: 0.61.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-06 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.61.0
33
+ version: 0.62.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.61.0
40
+ version: 0.62.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement