Skip to content

Commit 9829fbb

Browse files
authored
Merge pull request #980 from datatrails/steve/attachments
Attachment Updates
2 parents 4a28846 + f5d9aee commit 9829fbb

File tree

7 files changed

+343
-317
lines changed

7 files changed

+343
-317
lines changed

content/developers/api-reference/asset-events-api/index.md

Lines changed: 92 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ In a future release, Events will be created independently from Assets.
8787
-H "@$HOME/.datatrails/bearer-token.txt" \
8888
-H "Content-type: application/json" \
8989
-d "@/tmp/event.json" \
90-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events \
90+
https://app.datatrails.ai/archivist/v2/$ASSET_ID/events \
9191
| jq
9292
```
9393
@@ -136,6 +136,73 @@ In a future release, Events will be created independently from Assets.
136136
137137
- To query the events jump to [Fetch Specific Events by Identity](#fetch-events-for-a-specific-asset)
138138
139+
### DataTrails Reserved Attributes
140+
141+
The DataTrails platform has reserved attributes starting with `arc_` to perform specific capabilities.
142+
See [Reserved Attributes](/glossary/reserved-attributes/) for more info.
143+
144+
### Asset-Event Primary Image
145+
146+
Asset-Events can use the [Blobs API](/developers/api-reference/blobs-api/) to associate a primary image in the DataTrails Application.
147+
148+
#### Primary Image Variables
149+
150+
- To associate an existing Blob, set the `BLOB_ID`, `BLOB_HASH` value and `BLOB_FILE` from the [Blobs API](/developers/api-reference/blobs-api/):
151+
152+
{{< note >}}
153+
NOTE: The `ASSET_ID` dependency will be removed with [Non-asset based Events (preview)](/developers/api-reference/events-api/)
154+
{{< /note >}}
155+
156+
```bash
157+
ASSET_ID=<asset-id>
158+
BLOB_ID=<blob-id>
159+
BLOB_FILE=<file.ext>
160+
BLOB_HASH=<hash-value>
161+
```
162+
163+
Example:
164+
165+
ASSET_ID=assets/a1234567-890a
166+
BLOB_ID=blobs/b1234567-890b
167+
BLOB_FILE=conformance.pdf
168+
BLOB_HASH=h1234567hh
169+
170+
- Associate a Blob as the Event Primary Image:
171+
172+
```json
173+
cat > /tmp/event.json <<EOF
174+
{
175+
"operation": "Record",
176+
"behaviour": "RecordEvidence",
177+
"event_attributes": {
178+
"arc_primary_image": {
179+
"arc_attribute_type": "arc_attachment",
180+
"arc_display_name": "arc_primary_image",
181+
"arc_blob_identity": "$BLOB_ID",
182+
"arc_blob_hash_alg": "SHA256",
183+
"arc_blob_hash_value": "$BLOB_HASH",
184+
"arc_file_name": "$BLOB_FILE"
185+
}
186+
}
187+
}
188+
EOF
189+
```
190+
191+
- POST the Event Primary Image:
192+
193+
```bash
194+
curl -X POST \
195+
-H "@$HOME/.datatrails/bearer-token.txt" \
196+
-H "Content-type: application/json" \
197+
-d "@/tmp/event.json" \
198+
https://app.datatrails.ai/archivist/v2/$ASSET_ID/events \
199+
| jq
200+
```
201+
202+
### Adding Attachments
203+
204+
To associate an Attachment with an Asset-Event, see the [Attachments API](/developers/api-reference/attachments-api/)
205+
139206
### Document Profile Event Creation
140207
141208
There are two [Document Profile Events](/developers/developer-patterns/document-profile/) that are available as part of the document lifecycle. These are to `publish` a new version and to `withdraw` the document from use.
@@ -184,7 +251,7 @@ There are two [Document Profile Events](/developers/developer-patterns/document-
184251
-H "@$HOME/.datatrails/bearer-token.txt" \
185252
-H "Content-type: application/json" \
186253
-d "@/tmp/event.json" \
187-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events \
254+
https://app.datatrails.ai/archivist/v2/$ASSET_ID/events \
188255
| jq
189256
```
190257
@@ -271,7 +338,7 @@ There are two [Document Profile Events](/developers/developer-patterns/document-
271338
-H "@$HOME/.datatrails/bearer-token.txt" \
272339
-H "Content-type: application/json" \
273340
-d "@/tmp/event.json" \
274-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events \
341+
https://app.datatrails.ai/archivist/v2/$ASSET_ID/events \
275342
| jq
276343
```
277344
@@ -314,128 +381,19 @@ There are two [Document Profile Events](/developers/developer-patterns/document-
314381
}
315382
```
316383
317-
### Adding Attachments
318-
319-
The following assumes that an attachment has already been uploaded to DataTrails using the [Blob API](../blobs-api).
320-
321-
This attachment uuid is generically referred to as:
322-
323-
```bash
324-
blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
325-
```
326-
327-
Each attachment has an associated hash value and the name of the hash algorithm used that you can also get from the Blob API response.
328-
329-
- After uploading the content, use the `"arc_attribute_type": "arc_attachment"` key-value pair within a dictionary of blob information to add the attachment to the Event.
330-
331-
```json
332-
cat > /tmp/event.json <<EOF
333-
{
334-
"operation": "Record",
335-
"behaviour": "RecordEvidence",
336-
"event_attributes": {
337-
"arc_display_type": "Safety Conformance",
338-
"arc_description": "Safety conformance approved for version 1.6. See attached conformance report",
339-
"arc_evidence": "DVA Conformance Report attached",
340-
"conformance_report": {
341-
"arc_attribute_type": "arc_attachment",
342-
"arc_blob_hash_value": "$BLOB_HASH",
343-
"arc_blob_identity": "blobs/$BLOB_ID",
344-
"arc_blob_hash_alg": "SHA256",
345-
"arc_file_name": "safety_conformance.pdf",
346-
"arc_display_name": "Conformance Report"
347-
},
348-
"arc_primary_image": {
349-
"arc_attribute_type": "arc_attachment",
350-
"arc_blob_hash_value": "$BLOB_HASH",
351-
"arc_blob_identity": "blobs/$BLOB_ID",
352-
"arc_blob_hash_alg": "SHA256",
353-
"arc_file_name": "photo.jpg",
354-
"arc_display_name": "arc_primary_image"
355-
}
356-
},
357-
"timestamp_declared": "2019-11-27T14:44:19Z",
358-
"principal_declared": {
359-
"issuer": "idp.synsation.io/1234",
360-
"subject": "phil.b",
361-
"email": "phil.b@synsation.io"
362-
}
363-
}
364-
EOF
365-
```
366-
367-
- Add the request to the Asset Record by POSTing it to the resource:
368-
369-
```bash
370-
curl -X POST \
371-
-H "@$HOME/.datatrails/bearer-token.txt" \
372-
-H "Content-type: application/json" \
373-
-d "@/tmp/event.json" \
374-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events \
375-
| jq
376-
```
377-
378-
The response:
379-
380-
```json
381-
{
382-
"identity": "assets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/events/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
383-
"asset_identity": "assets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
384-
"operation": "Record",
385-
"behaviour": "RecordEvidence",
386-
"event_attributes": {
387-
"arc_display_type": "Safety Conformance",
388-
"arc_description": "Safety conformance approved for version 1.6. See attached conformance report",
389-
"arc_evidence": "DVA Conformance Report attached",
390-
"conformance_report": {
391-
"arc_attribute_type": "arc_attachment",
392-
"arc_blob_hash_value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
393-
"arc_blob_identity": "blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
394-
"arc_blob_hash_alg": "SHA256",
395-
"arc_file_name": "safety_conformance.pdf",
396-
"arc_display_name": "Conformance Report",
397-
},
398-
"arc_primary_image": {
399-
"arc_attribute_type": "arc_attachment",
400-
"arc_blob_hash_value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
401-
"arc_blob_identity": "blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
402-
"arc_blob_hash_alg": "SHA256",
403-
"arc_file_name": "safety_conformance.pdf",
404-
"arc_display_name": "Conformance Report",
405-
},
406-
},
407-
"timestamp_accepted": "2019-11-27T15:13:21Z",
408-
"timestamp_declared": "2019-11-27T14:44:19Z",
409-
"timestamp_committed": "2019-11-27T15:15:02Z",
410-
"principal_declared": {
411-
"issuer": "idp.synsation.io/1234",
412-
"subject": "phil.b",
413-
"email": "phil.b@synsation.io"
414-
},
415-
"principal_accepted": {
416-
"issuer": "job.idp.server/1234",
417-
"subject": "bob@job"
418-
},
419-
"confirmation_status": "COMMITTED",
420-
"block_number": 12,
421-
"transaction_index": 5,
422-
"transaction_id": "0x07569"
423-
}
424-
```
425-
426-
### Event Record Retrieval
384+
## Asset Event Record Retrieval
427385
428-
Event records in DataTrails are tokenized at creation time and referred to in all future API calls by a permanent unique identity of the form:
386+
Asset Event records in DataTrails are tokenized at creation time and referred to in all future API calls by a permanent unique identity of the form:
429387
430388
```bash
431-
assets/$ASSET_ID/events/$EVENT_ID
389+
assets/a1234567-890a/events/$EVENT_ID
432390
```
433391
434392
If you do not know the Event’s identity you can fetch Event records using other information you do know.
435393
436-
#### Fetch All Events
394+
### Fetch All Asset Events
437395
438-
- To fetch all Event records, simply `GET` the Events resources:
396+
- To fetch all Asset Event records, simply `GET` the Events resources:
439397
440398
```bash
441399
curl -X GET \
@@ -444,31 +402,31 @@ If you do not know the Event’s identity you can fetch Event records using othe
444402
| jq
445403
```
446404
447-
#### Fetch Events for a Specific Asset
405+
### Fetch Asset Events for a Specific Asset
448406
449407
- If you know the unique identity of the Asset record simply `GET` the resource:
450408
451409
```bash
452410
curl -X GET \
453411
-H "@$HOME/.datatrails/bearer-token.txt" \
454-
"https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events?page_size=5" \
412+
"https://app.datatrails.ai/archivist/v2/$ASSET_ID/events?page_size=5" \
455413
| jq
456414
```
457415
458-
#### Fetch Specific Events by Identity
416+
### Fetch Specific Asset Events by Identity
459417
460418
- If you know the unique identity of the Asset and Event record simply `GET` the resource:
461419
462420
```bash
463421
curl -X GET \
464422
-H "@$HOME/.datatrails/bearer-token.txt" \
465-
"https://app.datatrails.ai/archivst/v2/assets/$ASSET_ID/events/$EVENT_ID" \
423+
"https://app.datatrails.ai/archivst/v2/$ASSET_ID/events/$EVENT_ID" \
466424
| jq
467425
```
468426
469-
#### Fetch Event by Type
427+
### Fetch Asset Event by Type
470428
471-
- To fetch all Events of a specific type, `GET` the Events resource and filter on `arc_display_type`:
429+
- To fetch all Asset Events of a specific type, `GET` the Events resource and filter on `arc_display_type`:
472430
473431
```bash
474432
curl -g -X GET \
@@ -477,9 +435,9 @@ If you do not know the Event’s identity you can fetch Event records using othe
477435
| jq
478436
```
479437
480-
#### Fetch Event by Asset Attribute
438+
### Fetch Asset Event by Asset Attribute
481439
482-
- To fetch all Events of a specific Asset attribute, `GET` the Events resource and filter on `asset_attributes` at the Asset level:
440+
- To fetch all Asset Events of a specific Asset attribute, `GET` the Events resource and filter on `asset_attributes` at the Asset level:
483441
484442
```bash
485443
curl -g -X GET \
@@ -488,9 +446,9 @@ If you do not know the Event’s identity you can fetch Event records using othe
488446
| jq
489447
```
490448
491-
#### Fetch Events by Filtering for Presence of a Field
449+
### Fetch Asset Events by Filtering for Presence of an Attribute
492450
493-
- To fetch all Events with a field set to any value, `GET` the Events resource and filter on most available fields. For example:
451+
- To fetch all Asset Events with an Attribute set to any value, `GET` the Asset-Events resource and filter on most available attributes.
494452
495453
```bash
496454
curl -g -X GET \
@@ -501,9 +459,9 @@ If you do not know the Event’s identity you can fetch Event records using othe
501459
502460
Returns all Events which have `arc_display_type` that is not empty.
503461
504-
#### Fetch Events Which are Missing a Field
462+
### Fetch Asset Events Which are Missing a Field
505463
506-
- To fetch all Events with a field which is not set to any value, `GET` the Events resource and filter on most available fields. For example:
464+
- To fetch all Asset Events with a field which is not set to any value, `GET` the Events resource and filter on most available fields.
507465
508466
```bash
509467
curl -g -X GET \
@@ -512,11 +470,11 @@ If you do not know the Event’s identity you can fetch Event records using othe
512470
| jq
513471
```
514472
515-
Returns all Events which do not have `arc_display_type` or in which `arc_display_type` is empty.
473+
Returns all Asset Events which do not have `arc_display_type` or in which `arc_display_type` is empty.
516474
517-
#### Fetch Events by Minimum Confirmation Status
475+
### Fetch Asset Events by Minimum Confirmation Status
518476
519-
- To fetch all Events with a specified confirmation status or higher, `GET` the Events resource and filter on `minimum_trust`.
477+
- To fetch all Asset Events with a specified confirmation status or higher, `GET` the Events resource and filter on `minimum_trust`.
520478
521479
```bash
522480
curl -g -X GET \
@@ -525,7 +483,7 @@ If you do not know the Event’s identity you can fetch Event records using othe
525483
| jq
526484
```
527485
528-
- To fetch all Events which have a `confirmation_status` level of COMMITTED, CONFIRMED or UNEQUIVOCAL.
486+
- To fetch all Asset Events which have a `confirmation_status` level of COMMITTED, CONFIRMED or UNEQUIVOCAL.
529487
530488
```bash
531489
curl -g -X GET \
@@ -534,7 +492,7 @@ If you do not know the Event’s identity you can fetch Event records using othe
534492
| jq
535493
```
536494
537-
Returns all Events which have a `confirmation_status` level of CONFIRMED or UNEQUIVOCAL.
495+
Returns all Asset Events which have a `confirmation_status` level of CONFIRMED or UNEQUIVOCAL.
538496
539497
## Events OpenAPI Docs
540498

content/developers/api-reference/assets-api/index.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Additional YAML examples can be found in the articles in the [Overview](/platfor
9393
}
9494
```
9595
96-
### Assets With a Primary Image
96+
### Primary Image
9797
9898
An Asset can have a primary image, displayed in the DataTrails Application.
9999
The image must first be uploaded with the [Blobs API](/developers/api-reference/blobs-api/), with the BLOB_ID, BLOB_HASH and BLOB_FILE captured for uploading the asset.
@@ -102,10 +102,17 @@ The image must first be uploaded with the [Blobs API](/developers/api-reference/
102102
103103
```bash
104104
BLOB_ID=<blob-id>
105-
BLOB_FILE=file.jpg
106-
BLOB_HASH=<hash>
105+
BLOB_FILE=cat.jpg
106+
BLOB_HASH=<hash-value>
107107
```
108108
109+
Example:
110+
111+
ASSET_ID=assets/a1234567-890a
112+
BLOB_ID=blobs/b1234567-890b
113+
BLOB_FILE=cat.jpg
114+
BLOB_HASH=h1234567h
115+
109116
```bash
110117
cat > /tmp/asset.json <<EOF
111118
{
@@ -116,7 +123,7 @@ The image must first be uploaded with the [Blobs API](/developers/api-reference/
116123
"weight": "3.6kg",
117124
"arc_primary_image": {
118125
"arc_attribute_type": "arc_attachment",
119-
"arc_blob_identity": "blobs/$BLOB_ID",
126+
"arc_blob_identity": "$BLOB_ID",
120127
"arc_blob_hash_alg": "SHA256",
121128
"arc_blob_hash_value": "$BLOB_HASH",
122129
"arc_display_name": "arc_primary_image",

0 commit comments

Comments
 (0)