Skip to content

Commit 79b1d9d

Browse files
committed
Update attachments with functional code
Signed-off-by: steve lasker <stevenlasker@hotmail.com>
1 parent 2554fca commit 79b1d9d

2 files changed

Lines changed: 39 additions & 79 deletions

File tree

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

Lines changed: 38 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Assets support attachments by creating an [Asset-Event](/developers/api-referenc
3838
- `"arc_file_name": "conformance.pdf"`
3939
- `"arc_display_name": "Conformance Report"`
4040

41-
Example of an Asset-event with two attachments:
41+
An example of an Asset-event with two attachments:
4242

4343
```json
4444
{
@@ -68,15 +68,15 @@ Example of an Asset-event with two attachments:
6868
}
6969
```
7070

71-
The name of the parent attribute (`"conformance_report"`) can be any value, providing a means to name multiple attachments within a single event, such as the additional `"security_report"` attachment.
71+
In the above example, the name of the parent attribute (`"conformance_report"`) can be any value, providing a means to name multiple attachments within a single event, such as the additional `"security_report"` attachment.
7272

7373
The DataTrails platform evaluates `"arc_attribute_type": "arc_attachment"` to reference a DataTrails [Blob](/developers/api-reference/blobs-api/) based attachment.
7474

75-
## Asset-Event Attachment API Examples
75+
## Create an Asset-Event Based Attachment
7676

77-
- Create the [bearer_token](/developers/developer-patterns/getting-access-tokens-using-app-registrations) and store in a file in a secure local directory with 0600 permissions.
78-
79-
- Upload the content of the Attachment using the [Blobs API](/developers/api-reference/blobs-api/).
77+
- [Create a bearer_token](/developers/developer-patterns/getting-access-tokens-using-app-registrations) and store in a file in a secure local directory with 0600 permissions.
78+
- [Create an Asset](/developers/api-reference/assets-api/) to associate the attachment.
79+
- Upload the content of an Attachment using the [Blobs API](/developers/api-reference/blobs-api/).
8080

8181
### Asset-Event Attachment Variables
8282

@@ -101,7 +101,7 @@ The DataTrails platform evaluates `"arc_attribute_type": "arc_attachment"` to re
101101
ASSET_ID=assets/a1234567-890a
102102
BLOB_ID=blobs/b1234567-890b
103103
BLOB_HASH=h1234567h
104-
BLOB_FILE=conformance.pdf
104+
BLOB_FILE=cat.jpg
105105

106106
### Create an Asset-Event Attachment
107107

@@ -113,15 +113,15 @@ The DataTrails platform evaluates `"arc_attribute_type": "arc_attachment"` to re
113113
"operation": "Record",
114114
"behaviour": "RecordEvidence",
115115
"event_attributes": {
116-
"arc_display_type": "Safety Conformance",
117-
"arc_description": "Safety conformance approved for version 1.6.",
118-
"conformance_report": {
116+
"arc_display_type": "Cat-ID",
117+
"arc_description": "Fydor, the cat on the scene",
118+
"cat-id": {
119119
"arc_attribute_type": "arc_attachment",
120120
"arc_blob_hash_value": "$BLOB_HASH",
121121
"arc_blob_identity": "$BLOB_ID",
122122
"arc_blob_hash_alg": "SHA256",
123123
"arc_file_name": "$BLOB_FILE",
124-
"arc_display_name": "Conformance Report"
124+
"arc_display_name": "Fydor"
125125
}
126126
}
127127
}
@@ -147,49 +147,52 @@ The DataTrails platform evaluates `"arc_attribute_type": "arc_attachment"` to re
147147
"asset_identity": "assets/a1234567-890a",
148148
"event_attributes": {
149149
"arc_description": "Safety conformance approved for version 1.6.",
150-
"conformance_report": {
150+
"cat-id": {
151151
"arc_attribute_type": "arc_attachment",
152152
"arc_blob_hash_value": "h1234567h",
153153
"arc_blob_identity": "blobs/b1234567-890b",
154154
"arc_blob_hash_alg": "SHA256",
155155
"arc_file_name": "cat.jpg",
156-
"arc_display_name": "Conformance Report"
156+
"arc_display_name": "Fydor"
157157
},
158-
"arc_display_type": "Safety Conformance"
158+
"arc_display_type": "Cat-ID"
159159
},
160160
"..."
161161
}
162162
```
163163
164-
### Retrieve a Specific Attachment on an Asset
164+
### Retrieve an Asset-Event Attachment
165165
166-
```bash
167-
curl -H "@$HOME/.datatrails/bearer-token.txt" \
168-
--output $BLOB_FILE
169-
https://app.datatrails.ai/archivist/v2/attachments/$ASSET_ID/$BLOB_ID
170-
```
166+
- When creating an attachment, an Asset-Event is created.
167+
In addition to the Asset_ID captured above, capture the Event_ID
168+
169+
```bash
170+
EVENT_ID=events/e1234567-890e
171+
```
171172
172-
### Retrieve a Specific Attachment on an Event
173+
- The `attachments/assets` Resource does not support `/blobs/` as part of the resource identifier.
174+
The `ATTACHMENT_ID` variable will parse the ID from the `$BLOB_ID`
173175
174-
```bash
175-
ASSET_ID=<asset-id>
176-
curl -H "@$HOME/.datatrails/bearer-token.txt" \
177-
https://app.datatrails.ai/archivist/v2/attachments/assets/$ASSET_ID/events/$EVENT_ID/$ATTACHMENT_ID
178-
```
176+
```bash
177+
ATTACHMENT_ID=$(echo ${BLOB_ID} | cut -d '/' -f 2)
179178
180-
### Retrieve Information About a Specific Attachment
179+
curl -H "@$HOME/.datatrails/bearer-token.txt" \
180+
--output $BLOB_FILE \
181+
https://app.datatrails.ai/archivist/v2/attachments/$ASSET_ID/$EVENT_ID/$ATTACHMENT_ID
182+
```
181183
182-
It’s also possible to retrieve information about specific attachment using the Attachments API.
184+
### Retrieve Metadata About an Asset-Event Attachment
183185
184-
This information includes the `scanned_status` of the attachment.
185-
Attachment scanning happens in batch, daily.
186+
Metadata information includes the `scanned_status` of the attachment.
187+
Attachment scanning happens daily batches.
186188
187-
To do so, simply issue a request as above with the suffix `/info`.
189+
- Issue a request as above with the suffix `/info`.
188190
189-
```bash
190-
curl -H "@$HOME/.datatrails/bearer-token.txt" \
191-
https://app.datatrails.ai/archivist/v2/attachments/assets/$ASSET_ID/$ATTACHMENT_ID/info
192-
```
191+
```bash
192+
curl -H "@$HOME/.datatrails/bearer-token.txt" \
193+
https://app.datatrails.ai/archivist/v2/attachments/$ASSET_ID/$EVENT_ID/$ATTACHMENT_ID/info \
194+
| jq
195+
```
193196
194197
The response will include basic information about the attachment:
195198
@@ -211,49 +214,6 @@ The response will include basic information about the attachment:
211214
}
212215
```
213216
214-
### Integrity Protecting External Content
215-
216-
To integrity protect content located external to the DataTrails platform, exclude the `"arc_attribute_type": "arc_attachment"`, `"arc_blob_identity"` and `"arc_display_name"` as not being relevant to external content.
217-
218-
```json
219-
cat > /tmp/event.json <<EOF
220-
{
221-
"operation": "Record",
222-
"behaviour": "RecordEvidence",
223-
"event_attributes": {
224-
"arc_blob_hash_value": "$BLOB_HASH",
225-
"arc_blob_hash_alg": "SHA256",
226-
"arc_file_name": "$BLOB_FILE"
227-
}
228-
}
229-
EOF
230-
```
231-
232-
- Post to the Integrity protected content as an Event:
233-
234-
```bash
235-
curl -X POST \
236-
-H "@$HOME/.datatrails/bearer-token.txt" \
237-
-H "Content-type: application/json" \
238-
-d "@/tmp/event.json" \
239-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events \
240-
| jq
241-
```
242-
243-
- Capture the new Event ID from above:
244-
245-
```bash
246-
EVENT_ID=<event-id>
247-
```
248-
249-
- Query the newly created Event, with integrity protection:
250-
251-
```bash
252-
curl -H "@$HOME/.datatrails/bearer-token.txt" \
253-
https://app.datatrails.ai/archivist/v2/assets/$ASSET_ID/events/$EVENT_ID \
254-
| jq
255-
```
256-
257217
## Attachment OpenAPI Docs
258218
259219
{{< openapi url="https://raw.githubusercontent.com/datatrails/datatrails-openapi/main/doc/attachmentsv2.swagger.json" >}}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The Blobs API enables uploading Binary Large OBjects (BLOBs) such as documents,
1818

1919
{{< note >}}
2020
**Note:** Blobs cannot be searched or listed as a collection using the blobs resource.
21-
BLobs must be associated with an Asset or Event through an Attachment Attribute and can only be downloaded by users with appropriate access rights to that Attachment.
21+
Blobs must be associated with an Asset or Event through an Attachment Attribute and can only be downloaded by users with appropriate access rights to that Attachment.
2222
Take note of the Blob ID returned in the API response, it will be needed for use with Assets and Events.<br>
2323
For information on Attachments and how to implement them, please refer to [the Events API Reference](../events-api/#adding-attachments).
2424
{{< /note >}}

0 commit comments

Comments
 (0)