sdr-client 0.57.0 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8805b2135701957c156dab3904d0b7c127261fabe43e20ff0e17f7ca8efde9f
4
- data.tar.gz: f05557249334415399fc0ed05246077783d604157d9264cc8b587e56ae578ced
3
+ metadata.gz: 101554d535c7a2e1fd71fb0d2f9abbd956e871c688b09461c8330e4e3526864b
4
+ data.tar.gz: d65b128417c52e9df5aac2b399fc036cc77f3d93b62dac27b2aba24a2b8de24d
5
5
  SHA512:
6
- metadata.gz: 4de4a945bf87c88a3b01a56d09733c653f40f80c8145b12d3f693545437420493b56fdfcc1b7dea4eca75f22113467fffaf0fd9199f527636b667e41b9b4c896
7
- data.tar.gz: a46817a5a0c3fdd8d2b7394e4c68a8f08c68de482f092e33da30b9ab954c7dad6cdb070afba1321d8716bb6e6617e5e657a15c4d384b44cdde2a9180eb290cc4
6
+ metadata.gz: f732927aab94e1c2bf36f52976b5ec815788513111b8cbebf8cb3cf339c44976f70c574fa18267a81192f9f267ef1402e6c77baf3a23a23094bcad02f72313a7
7
+ data.tar.gz: d0ab06ae6318729d62adfab59483f4363e8b5d3fdcb1a97397fb0690d60d30e1fdbdd3976b8d7057e129d816eab40e4bad17a6c82321c1935b9ab9faaba55bf7
@@ -5,13 +5,15 @@ 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|
16
+ @connection ||= Faraday.new(url: url, request: request_options) do |conn|
15
17
  conn.authorization :Bearer, token
16
18
  conn.adapter :net_http
17
19
  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.57.0'
4
+ VERSION = '0.61.0'
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.60.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.57.0
4
+ version: 0.61.0
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-06-07 00:00:00.000000000 Z
11
+ date: 2021-08-26 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.60.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.60.0
40
+ version: 0.62.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-monads
43
43
  requirement: !ruby/object:Gem::Requirement