Skip to content

Commit 74c1ddb

Browse files
committedNov 13, 2023
examples: add some executable examples (hurl)
1 parent 4ac8a5c commit 74c1ddb

4 files changed

+104
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# create/register a pid record
2+
POST http://localhost:8090/api/v1/pit/pid/
3+
Content-Type: application/vnd.datamanager.pid.simple+json
4+
Accept: application/vnd.datamanager.pid.simple+json
5+
{
6+
"record": [
7+
{ "key": "21.T11148/076759916209e5d62bd5", "value": "21.T11148/301c6f04763a16f0f72a" },
8+
{ "key": "21.T11148/397d831aa3a9d18eb52c", "value": "2021-12-21T17:36:09.541+00:00" },
9+
{ "key": "21.T11148/8074aed799118ac263ad", "value": "21.T11148/37d0f4689c6ea3301787" },
10+
{ "key": "21.T11148/92e200311a56800b3e47", "value": "{ \"sha256sum\": \"sha256 c50624fd5ddd2b9652b72e2d2eabcb31a54b777718ab6fb7e44b582c20239a7c\" }" },
11+
{ "key": "21.T11148/aafd5fb4c7222e2d950a", "value": "2021-12-21T17:36:09.541+00:00" },
12+
{ "key": "21.T11148/b8457812905b83046284", "value": "https://test.repo/file001" },
13+
{ "key": "21.T11148/c692273deb2772da307f", "value": "1.0.0" },
14+
{ "key": "21.T11148/c83481d4bf467110e7c9", "value": "21.T11148/ManuscriptPage" }
15+
]
16+
}
17+
18+
# on success, we get a 201
19+
HTTP 201
20+
# in the response body, you'll get the record and the pid
21+
[Captures]
22+
pid: jsonpath "$.pid"
23+
24+
# if we resolve the pid...
25+
GET http://localhost:8090/api/v1/pit/pid/{{pid}}
26+
27+
# we get exactly the same body on success
28+
HTTP 200
29+
[Asserts]
30+
jsonpath "$.pid" == {{pid}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
POST http://localhost:8090/api/v1/search?page=0&size=20
2+
accept: application/hal+json
3+
Content-Type: application/json
4+
{
5+
"query": {
6+
"exists" : {
7+
"field" : "pid"
8+
}
9+
},
10+
"_source": ["pid"]
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Create/register a pid record.
2+
# As we use the Typed PID Maker, it must be valid, otherwise it will not work.
3+
POST http://localhost:8090/api/v1/pit/pid/
4+
Content-Type: application/vnd.datamanager.pid.simple+json
5+
Accept: application/vnd.datamanager.pid.simple+json
6+
{
7+
"record": [
8+
{ "key": "21.T11148/076759916209e5d62bd5", "value": "21.T11148/301c6f04763a16f0f72a" },
9+
{ "key": "21.T11148/397d831aa3a9d18eb52c", "value": "2021-12-21T17:36:09.541+00:00" },
10+
{ "key": "21.T11148/8074aed799118ac263ad", "value": "21.T11148/37d0f4689c6ea3301787" },
11+
{ "key": "21.T11148/92e200311a56800b3e47", "value": "{ \"sha256sum\": \"sha256 c50624fd5ddd2b9652b72e2d2eabcb31a54b777718ab6fb7e44b582c20239a7c\" }" },
12+
{ "key": "21.T11148/aafd5fb4c7222e2d950a", "value": "2021-12-21T17:36:09.541+00:00" },
13+
{ "key": "21.T11148/b8457812905b83046284", "value": "https://test.repo/file001" },
14+
{ "key": "21.T11148/c692273deb2772da307f", "value": "1.0.0" },
15+
{ "key": "21.T11148/c83481d4bf467110e7c9", "value": "21.T11148/ManuscriptPage" }
16+
]
17+
}
18+
19+
# on success, we get a 201
20+
HTTP 201
21+
# in the response body, you'll get the record and the pid
22+
[Captures]
23+
pid: jsonpath "$.pid"
24+
25+
# if we resolve the pid...
26+
GET http://localhost:8090/api/v1/pit/pid/{{pid}}?validation=true
27+
Accept: application/vnd.datamanager.pid.simple+json
28+
29+
# on validation fail, we get 400 instead of 200
30+
# unfortunately we can (by default) not create invalid PIDs using the Typed PID Maker,
31+
# so we can not properly demonstrate it here, as long as it is in sandboxed mode.
32+
# This limitation is being worked on (current version at the time of writing is 2.0.0):
33+
# In future we plan to allow resolving all kinds of real PIDs even in sandboxed mode.
34+
HTTP 200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Sending a pid record with dryrun parameter will skip registration,
2+
# but still include the validation!
3+
POST http://localhost:8090/api/v1/pit/pid/?dryrun=true
4+
Content-Type: application/vnd.datamanager.pid.simple+json
5+
Accept: application/vnd.datamanager.pid.simple+json
6+
{
7+
"record": [
8+
{ "key": "21.T11148/076759916209e5d62bd5", "value": "21.T11148/301c6f04763a16f0f72a" },
9+
{ "key": "21.T11148/397d831aa3a9d18eb52c", "value": "2021-12-21T17:36:09.541+00:00" },
10+
{ "key": "21.T11148/8074aed799118ac263ad", "value": "21.T11148/37d0f4689c6ea3301787" },
11+
{ "key": "21.T11148/92e200311a56800b3e47", "value": "{ \"sha256sum\": \"sha256 c50624fd5ddd2b9652b72e2d2eabcb31a54b777718ab6fb7e44b582c20239a7c\" }" },
12+
{ "key": "21.T11148/aafd5fb4c7222e2d950a", "value": "2021-12-21T17:36:09.541+00:00" },
13+
{ "key": "21.T11148/b8457812905b83046284", "value": "https://test.repo/noregistration321.zip" },
14+
{ "key": "21.T11148/c692273deb2772da307f", "value": "1.0.0" },
15+
{ "key": "21.T11148/c83481d4bf467110e7c9", "value": "21.T11148/ManuscriptPage" }
16+
]
17+
}
18+
19+
# On success, we get a 200 (success). Note it is _not_ 201 (created)!
20+
HTTP 200
21+
# In the response body, you'll get the record and the pid
22+
[Captures]
23+
pid: jsonpath "$.pid"
24+
25+
# If we resolve the pid...
26+
GET http://localhost:8090/api/v1/pit/pid/{{pid}}
27+
28+
# ...we will not be able to get it, because we did not registered it (dry run / validation only)!
29+
HTTP 404

0 commit comments

Comments
 (0)