-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
167 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ Or install it yourself as: | |
|
||
``` | ||
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4") | ||
I, [2014-12-04T15:06:02.428445 #86655] INFO -- : EZID MINT ark:/99999/fk4 -- success: ark:/99999/fk4rx9d523 | ||
I, [2014-12-04T15:06:03.249793 #86655] INFO -- : EZID GET ark:/99999/fk4rx9d523 -- success: ark:/99999/fk4rx9d523 | ||
I, [2014-12-04T15:06:02.428445 #86655] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4rx9d523 | ||
I, [2014-12-04T15:06:03.249793 #86655] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4rx9d523 | ||
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523" created="2014-12-04 20:06:02 UTC"> | ||
>> identifier.id | ||
=> "ark:/99999/fk4rx9d523" | ||
|
@@ -60,25 +60,25 @@ New identifiers will then be minted on the default shoulder when a shoulder is n | |
|
||
``` | ||
>> identifier = Ezid::Identifier.create | ||
I, [2014-12-09T11:22:34.499860 #32279] INFO -- : EZID MINT ark:/99999/fk4 -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:22:35.317181 #32279] INFO -- : EZID GET ark:/99999/fk43f4wd4v -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:22:34.499860 #32279] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:22:35.317181 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v | ||
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk43f4wd4v" created="2014-12-09 16:22:35 UTC"> | ||
``` | ||
|
||
[Create a specific identifier](http://ezid.cdlib.org/doc/apidoc.html#operation-create-identifier) | ||
|
||
``` | ||
>> identifier = Ezid::Identifier.create(id: "ark:/99999/fk4rx9d523/12345") | ||
I, [2014-12-09T11:21:42.077297 #32279] INFO -- : EZID CREATE ark:/99999/fk4rx9d523/12345 -- success: ark:/99999/fk4rx9d523/12345 | ||
I, [2014-12-09T11:21:42.808534 #32279] INFO -- : EZID GET ark:/99999/fk4rx9d523/12345 -- success: ark:/99999/fk4rx9d523/12345 | ||
I, [2014-12-09T11:21:42.077297 #32279] INFO -- : EZID CreateIdentifier -- success: ark:/99999/fk4rx9d523/12345 | ||
I, [2014-12-09T11:21:42.808534 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4rx9d523/12345 | ||
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523/12345" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523/12345" created="2014-12-09 16:21:42 UTC"> | ||
``` | ||
|
||
**Retrieve** (Get Metadata) | ||
|
||
``` | ||
>> identifier = Ezid::Identifier.find("ark:/99999/fk4rx9d523") | ||
I, [2014-12-04T15:07:00.648676 #86655] INFO -- : EZID GET ark:/99999/fk4rx9d523 -- success: ark:/99999/fk4rx9d523 | ||
I, [2014-12-04T15:07:00.648676 #86655] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4rx9d523 | ||
=> #<Ezid::Identifier id="ark:/99999/fk4rx9d523" status="public" target="http://ezid.cdlib.org/id/ark:/99999/fk4rx9d523" created="2014-12-04 20:06:02 UTC"> | ||
``` | ||
|
||
|
@@ -90,8 +90,8 @@ I, [2014-12-04T15:07:00.648676 #86655] INFO -- : EZID GET ark:/99999/fk4rx9d523 | |
>> identifier.target = "http://example.com" | ||
=> "http://example.com" | ||
>> identifier.save | ||
I, [2014-12-09T11:24:26.321801 #32279] INFO -- : EZID MODIFY ark:/99999/fk43f4wd4v -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GET ark:/99999/fk43f4wd4v -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:24:26.321801 #32279] INFO -- : EZID ModifyIdentifier -- success: ark:/99999/fk43f4wd4v | ||
I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk43f4wd4v | ||
=> #<Ezid::Identifier id="ark:/99999/fk43f4wd4v" status="public" target="http://example.com" created="2014-12-09 16:22:35 UTC"> | ||
>> identifier.target | ||
=> "http://example.com" | ||
|
@@ -103,14 +103,32 @@ I, [2014-12-09T11:24:27.039288 #32279] INFO -- : EZID GET ark:/99999/fk43f4wd4v | |
|
||
``` | ||
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4", status: "reserved") | ||
I, [2014-12-04T15:12:39.976930 #86734] INFO -- : EZID MINT ark:/99999/fk4 -- success: ark:/99999/fk4n58pc0r | ||
I, [2014-12-04T15:12:40.693256 #86734] INFO -- : EZID GET ark:/99999/fk4n58pc0r -- success: ark:/99999/fk4n58pc0r | ||
I, [2014-12-04T15:12:39.976930 #86734] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4n58pc0r | ||
I, [2014-12-04T15:12:40.693256 #86734] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4n58pc0r | ||
=> #<Ezid::Identifier id="ark:/99999/fk4n58pc0r" status="reserved" target="http://ezid.cdlib.org/id/ark:/99999/fk4n58pc0r" created="2014-12-04 20:12:39 UTC"> | ||
>> identifier.delete | ||
I, [2014-12-04T15:12:48.853964 #86734] INFO -- : EZID DELETE ark:/99999/fk4n58pc0r -- success: ark:/99999/fk4n58pc0r | ||
I, [2014-12-04T15:12:48.853964 #86734] INFO -- : EZID DeleteIdentifier -- success: ark:/99999/fk4n58pc0r | ||
=> #<Ezid::Identifier id="ark:/99999/fk4n58pc0r" DELETED> | ||
``` | ||
|
||
## Batch Download | ||
|
||
Instantiate an `Ezid::Client` and call `batch_download` with hash options -- see http://ezid.cdlib.org/doc/apidoc.html#parameters. Repeated values should be given as an array value for the parameter key. | ||
|
||
Note that, due to the asynchronous nature of this request, the response only returns the URL at which the batch will be available to download (as described in the EZID documentation). Use the `notify` option to specify one or more email addresses to receive notification when the download file is actually available. | ||
|
||
**Example** | ||
|
||
``` | ||
>> c = Ezid::Client.new | ||
=> #<Ezid::Client connection=#<Net::HTTP ezid.cdlib.org:443 open=false> user="eziduser" session=CLOSED> | ||
>> response = c.batch_download(format: "csv", notify: "[email protected]", column: ["_id", "_target", "_status", "_profile", "_export", "_created", "_updated"], convertTimestamps: "yes", permanence: "real", owner: "eziduser") | ||
I, [2015-02-20T15:16:53.462660 #55850] INFO -- : EZID BatchDownload -- success: http://ezid.cdlib.org/download/473deecb96.csv.gz | ||
=> #<Net::HTTPOK 200 OK readbody=true> | ||
>> response.download_url | ||
=> "http://ezid.cdlib.org/download/da543b91a0.csv.gz" | ||
``` | ||
|
||
## Metadata handling | ||
|
||
Accessors are provided to ease the use of EZID [reserved metadata elements](http://ezid.cdlib.org/doc/apidoc.html#internal-metadata) and [metadata profiles](http://ezid.cdlib.org/doc/apidoc.html#metadata-profiles): | ||
|
@@ -169,8 +187,8 @@ Then new identifiers will receive the defaults: | |
|
||
``` | ||
>> identifier = Ezid::Identifier.create(shoulder: "ark:/99999/fk4") | ||
I, [2014-12-09T11:38:37.335136 #32279] INFO -- : EZID MINT ark:/99999/fk4 -- success: ark:/99999/fk4zs2w500 | ||
I, [2014-12-09T11:38:38.153546 #32279] INFO -- : EZID GET ark:/99999/fk4zs2w500 -- success: ark:/99999/fk4zs2w500 | ||
I, [2014-12-09T11:38:37.335136 #32279] INFO -- : EZID MintIdentifier -- success: ark:/99999/fk4zs2w500 | ||
I, [2014-12-09T11:38:38.153546 #32279] INFO -- : EZID GetIdentifierMetadata -- success: ark:/99999/fk4zs2w500 | ||
=> #<Ezid::Identifier id="ark:/99999/fk4zs2w500" status="reserved" target="http://ezid.cdlib.org/id/ark:/99999/fk4zs2w500" created="2014-12-09 16:38:38 UTC"> | ||
>> identifier.profile | ||
=> "dc" | ||
|
@@ -232,6 +250,30 @@ end | |
client = Ezid::Client.new(host: "localhost", port: 80) | ||
``` | ||
|
||
## HTTP Timeout | ||
|
||
The default HTTP timeout is set to 300 seconds (5 minutes). The setting can be customized: | ||
|
||
- By environment variable: | ||
|
||
```sh | ||
export EZID_TIMEOUT=600 | ||
``` | ||
|
||
- Client configuration: | ||
|
||
```ruby | ||
Ezid::Client.configure do |config| | ||
config.timeout = 600 | ||
end | ||
``` | ||
|
||
- At client initialization | ||
|
||
```ruby | ||
client = Ezid::Client.new(timeout: 600) | ||
``` | ||
|
||
## Test Helper | ||
|
||
If you have tests that (directly or indirectly) use `ezid-client` you may want to require the test helper module: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.12.0 | ||
0.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require_relative "request" | ||
|
||
module Ezid | ||
class BatchDownloadRequest < Request | ||
|
||
self.http_method = POST | ||
self.path = "/download_request" | ||
self.response_class = BatchDownloadResponse | ||
|
||
attr_reader :params | ||
|
||
def initialize(client, params={}) | ||
@params = params | ||
super | ||
end | ||
|
||
def customize_request | ||
set_form_data(params) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require_relative "response" | ||
|
||
module Ezid | ||
class BatchDownloadResponse < Response | ||
|
||
def download_url | ||
message | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Ezid | ||
RSpec.describe BatchDownloadRequest do | ||
|
||
let(:client) { Client.new } | ||
let(:params) do | ||
{ format: "xml", | ||
notify: "[email protected]", | ||
convertTimestamps: "yes", | ||
exported: "no", | ||
owner: ["you", "me"], | ||
status: ["reserved", "unavailable"], | ||
type: "ark" | ||
} | ||
end | ||
subject { described_class.new(client, params) } | ||
|
||
it "should add the request params to the request body" do | ||
expect(subject.body).to eq("format=xml¬ify=noreply%40example.com&convertTimestamps=yes&exported=no&owner=you&owner=me&status=reserved&status=unavailable&type=ark") | ||
end | ||
|
||
it "should have the correct content type" do | ||
expect(subject.content_type).to eq("application/x-www-form-urlencoded") | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters