sdr-client 0.39.0 → 0.40.0

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: aee57dd9e83aee0530538727e3005296c202386262d6f6da4cd0d3ed5dec1f36
4
- data.tar.gz: dcf68795553348151c29d96184d5bdd4974693cacf45ac9cdac070a0381c281e
3
+ metadata.gz: cf5c97821bfab525a4f0b272b9519f26dd5bf46b164ab475965a1273588a31d0
4
+ data.tar.gz: 7545a75643e71bcdbd8bddfa6afdff6303e4ce05251746ea49d831669a48fc85
5
5
  SHA512:
6
- metadata.gz: 8ab3ffa98954c69286a227769c976a9029a142721a1c8b127695b8184fb8ac310ca712d7de624a329641f4a756a66a48a071c4ac9d624f821518914bea020cac
7
- data.tar.gz: 6e85cafdfa689f00e0971a28d1eacc93f502b73f9a9b4ad8c812d5a2c5ca9f33f75a72da2bdfb76fa3b7cc1c13f631f6755529f9c070d4be67f1e0523933e86a
6
+ metadata.gz: da880356f2d5bcfac1bc39c765411538e52b9449e4eb8ce3ccdcc5a9fd1ec8044cd5784905b76be318dc705b404df283b3ea0102b63059e877cb1cf36d8458bc
7
+ data.tar.gz: 6a55918f74cd35898ad80d991ae61102ce7971170d5a29c94a9791cbb3e23d46ea4f38736e05d99c7610ecd95eb22f012ac11dd159efe100ff850889c6457955
data/README.md CHANGED
@@ -45,3 +45,9 @@ sdr --service-url https://sdr-api-server:3000 deposit --label 'hey there' \
45
45
  --collection 'druid:gh456kw9876' \
46
46
  --source-id 'googlebooks:stanford_12345' image42.jp2 ocr.html
47
47
  ```
48
+
49
+ View the object:
50
+ ```
51
+ sdr --service-url https://sdr-api-server:3000 get druid:bw581ng3176
52
+ {"type":"http://cocina.sul.stanford.edu/models/document.jsonld","externalIdentifier":"druid:bw581ng3176","label":"Something something better title","version":1,"access":{"access":"stanford","copyright":"This work is copyrighted by the creator.","download":"stanford","useAndReproductionStatement":"This document is available only to the Stanford faculty, staff and student community."},"administrative":{"hasAdminPolicy":"druid:zx485kb6348"},"description":{"title":[{"value":"Something something better title"}],"contributor":[{"name":[{"value":"Hodge, Amy"}],"type":"person","role":[{"value":"Author"},{"value":"author","uri":"http://id.loc.gov/vocabulary/relators/aut","source":{"code":"marcrelator","uri":"http://id.loc.gov/vocabulary/relators/"}},{"value":"Creator"}]}],"form":[{"structuredValue":[{"value":"Text","type":"type"},{"value":"Report","type":"subtype"}],"type":"resource type","source":{"value":"Stanford self-deposit resource types"}},{"value":"reports","type":"genre","uri":"http://vocab.getty.edu/aat/300027267","source":{"code":"aat"}},{"value":"text","type":"resource type","source":{"value":"MODS resource types"}}],"note":[{"value":";alkdfjlsadkjf;l","type":"summary"},{"value":"amyhodge@stanford.edu","type":"contact","displayLabel":"Contact"}],"subject":[{"value":"lkfj","type":"topic"},{"value":";kfj","type":"topic"},{"value":"fjwelkb","type":"topic"}]},"identification":{"sourceId":"hydrus:20"},"structural":{"contains":[{"type":"http://cocina.sul.stanford.edu/models/fileset.jsonld","externalIdentifier":"bw581ng3176_1","label":"Test file","version":1,"structural":{"contains":[{"type":"http://cocina.sul.stanford.edu/models/file.jsonld","externalIdentifier":"druid:bw581ng3176/test.txt","label":"test.txt","filename":"test.txt","size":11,"version":1,"hasMimeType":"text/plain","hasMessageDigests":[{"type":"sha1","digest":"5d39343e4bb48abd97f759828282f5ebbac56c5e"},{"type":"md5","digest":"63b8812b0c05722a9d6c51cbd2bfb54b"}],"access":{"access":"world","download":"world"},"administrative":{"sdrPreserve":true,"shelve":true}}]}}]}}
53
+ ```
data/exe/sdr CHANGED
@@ -19,6 +19,9 @@ end
19
19
  global.order!
20
20
  command = ARGV.shift
21
21
 
22
+ retrieve_options = OptionParser.new do |opts|
23
+ end
24
+
22
25
  deposit_options = OptionParser.new do |opts|
23
26
  opts.banner = "Usage: sdr #{command} [options]"
24
27
  opts.on('--label LABEL', 'The object label') do |label|
@@ -94,6 +97,7 @@ end
94
97
  SdrClient::CLI.help unless command
95
98
 
96
99
  subcommands = {
100
+ 'get' => retrieve_options,
97
101
  'deposit' => deposit_options,
98
102
  'register' => deposit_options,
99
103
  'login' => OptionParser.new
@@ -106,11 +110,10 @@ end
106
110
 
107
111
  subcommands[command].order!
108
112
 
109
- options[:files] = ARGV unless ARGV.empty?
110
113
  options[:url] ||= 'https://sdr-api-prod.stanford.edu'
111
114
 
112
115
  begin
113
- SdrClient::CLI.start(command, options)
116
+ SdrClient::CLI.start(command, options, ARGV)
114
117
  rescue StandardError => e
115
118
  warn "There was a problem making your request:\n\n"
116
119
  warn e.message
@@ -11,6 +11,7 @@ require 'cocina/models'
11
11
  require 'sdr_client/version'
12
12
  require 'sdr_client/deposit'
13
13
  require 'sdr_client/credentials'
14
+ require 'sdr_client/find'
14
15
  require 'sdr_client/login'
15
16
  require 'sdr_client/login_prompt'
16
17
  require 'sdr_client/cli'
@@ -23,6 +23,9 @@ module SdrClient
23
23
 
24
24
 
25
25
  COMMANDS:
26
+ get
27
+ Retrieve an object from the SDR
28
+
26
29
  deposit
27
30
  Accession an object into the SDR
28
31
 
@@ -34,12 +37,12 @@ module SdrClient
34
37
 
35
38
  HELP
36
39
 
37
- def self.start(command, options)
40
+ def self.start(command, options, arguments = [])
38
41
  case command
42
+ when 'get'
43
+ puts SdrClient::Find.run(arguments.first, **options)
39
44
  when 'deposit', 'register'
40
- display_errors(validate_deposit_options(options))
41
- job_id = SdrClient::Deposit.run(accession: command == 'deposit', **options)
42
- poll_for_job_complete(job_id: job_id, url: options[:url]) # TODO: add an option that skips this
45
+ deposit(command, options, arguments)
43
46
  when 'login'
44
47
  status = SdrClient::Login.run(options)
45
48
  puts status.failure if status.failure?
@@ -51,6 +54,13 @@ module SdrClient
51
54
  exit(1)
52
55
  end
53
56
 
57
+ def self.deposit(command, options, arguments)
58
+ options[:files] = arguments if arguments.present?
59
+ display_errors(validate_deposit_options(options))
60
+ job_id = SdrClient::Deposit.run(accession: command == 'deposit', **options)
61
+ poll_for_job_complete(job_id: job_id, url: options[:url]) # TODO: add an option that skips this
62
+ end
63
+
54
64
  def self.display_errors(errors)
55
65
  return if errors.empty?
56
66
 
@@ -32,7 +32,7 @@ module SdrClient
32
32
  end
33
33
  end
34
34
 
35
- delegate :put, :post, to: :connection
35
+ delegate :put, :post, :get, to: :connection
36
36
 
37
37
  private
38
38
 
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module SdrClient
6
+ # The namespace for the "get" command
7
+ module Find
8
+ DRO_PATH = '/v1/resources/%<id>s'
9
+ # @return [String] job id for the background job result
10
+ def self.run(druid, url:, logger: Logger.new(STDOUT))
11
+ connection = Connection.new(url: url)
12
+ path = format(DRO_PATH, id: druid)
13
+ logger.info("Retrieving metadata from: #{path}")
14
+ response = connection.get(path)
15
+ response.body
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SdrClient
4
- VERSION = '0.39.0'
4
+ VERSION = '0.40.0'
5
5
  end
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.39.0
4
+ version: 0.40.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: 2020-12-11 00:00:00.000000000 Z
11
+ date: 2020-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -213,6 +213,7 @@ files:
213
213
  - lib/sdr_client/deposit/update_resource.rb
214
214
  - lib/sdr_client/deposit/upload_files.rb
215
215
  - lib/sdr_client/deposit/upload_files_metadata_builder.rb
216
+ - lib/sdr_client/find.rb
216
217
  - lib/sdr_client/login.rb
217
218
  - lib/sdr_client/login_prompt.rb
218
219
  - lib/sdr_client/version.rb
@@ -238,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
239
  - !ruby/object:Gem::Version
239
240
  version: '0'
240
241
  requirements: []
241
- rubygems_version: 3.1.2
242
+ rubygems_version: 3.1.4
242
243
  signing_key:
243
244
  specification_version: 4
244
245
  summary: The CLI for https://github.com/sul-dlss/sdr-api