-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #964 from datatrails/dev/jag/10053-access-policy-e…
…xamples API example tidy-ups ahead of Event Centric move
- Loading branch information
Showing
6 changed files
with
28 additions
and
208 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
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 |
---|---|---|
|
@@ -122,81 +122,6 @@ ASSET_UUID=<ASSET_UUID> | |
- To query the events jump to [Fetch Specific Events by Identity](#fetch-events-for-a-specific-asset) | ||
### Updating an Asset Attribute | ||
To update an Asset attribute, record an Event and enter the new value. Here we will update the weight of the cat Asset created in the [Assets API reference](https://docs.datatrails.ai/developers/api-reference/assets-api/#asset-record-creation) example. | ||
```json | ||
cat > /tmp/event.json <<EOF | ||
{ | ||
"operation": "Record", | ||
"behaviour": "RecordEvidence", | ||
"event_attributes": { | ||
"arc_display_type": "groom", | ||
"additional_checks": "weigh the cat" | ||
}, | ||
"asset_attributes": { | ||
"weight": "3.5kg" | ||
}, | ||
"public": false | ||
} | ||
EOF | ||
``` | ||
POST the Event to update the Asset: | ||
```bash | ||
curl -X POST \ | ||
-H "@$HOME/.datatrails/bearer-token.txt" \ | ||
-H "Content-type: application/json" \ | ||
-d "@/tmp/event.json" \ | ||
https://app.datatrails.ai/archivist/v2/assets/$ASSET_UUID/events | ||
``` | ||
The response: | ||
```json | ||
{ | ||
"identity": "assets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/events/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"asset_identity": "assets/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"event_attributes": { | ||
"arc_display_type": "groom", | ||
"additional_checks": "weigh the cat" | ||
}, | ||
"asset_attributes": { | ||
"weight": "3.5kg" | ||
}, | ||
"operation": "Record", | ||
"behaviour": "RecordEvidence", | ||
"timestamp_declared": "2024-05-30T12:28:50Z", | ||
"timestamp_accepted": "2024-05-30T12:28:50Z", | ||
"timestamp_committed": "1970-01-01T00:00:00Z", | ||
"principal_declared": { | ||
"issuer": "https://app.datatrails.ai/appidpv1", | ||
"subject": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"display_name": "Custom Integration", | ||
"email": "" | ||
}, | ||
"principal_accepted": { | ||
"issuer": "https://app.datatrails.ai/appidpv1", | ||
"subject": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"display_name": "Custom Integration", | ||
"email": "" | ||
}, | ||
"confirmation_status": "PENDING", | ||
"transaction_id": "", | ||
"block_number": 0, | ||
"transaction_index": 0, | ||
"from": "", | ||
"tenant_identity": "", | ||
"merklelog_entry": { | ||
"commit": null, | ||
"confirm": null, | ||
"unequivocal": null | ||
} | ||
} | ||
``` | ||
### Document Profile Event Creation | ||
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. | ||
|
@@ -220,7 +145,7 @@ cat > /tmp/event.json <<EOF | |
"arc_description":"Publish version 2 of Test Document", | ||
"arc_display_type":"Publish", | ||
"document_version_authors": [ | ||
{ | ||
{ | ||
"display_name": "George", | ||
"email": "[email protected]" | ||
}, | ||
|
@@ -385,9 +310,9 @@ blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
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. | ||
Once you've uploaded your file, you can use the `"arc_attribute_type": "arc_attachment"` key-value pair within a dictionary of blob information to add the attachment to either your Asset or Event. | ||
Once you've uploaded your file, you can use the `"arc_attribute_type": "arc_attachment"` key-value pair within a dictionary of blob information to add the attachment to your Event. | ||
The following example shows you usage with both the `event_attributes` and the `asset_attributes`: | ||
For example: | ||
```json | ||
cat > /tmp/event.json <<EOF | ||
|
@@ -415,16 +340,6 @@ cat > /tmp/event.json <<EOF | |
"arc_display_name": "arc_primary_image", | ||
}, | ||
}, | ||
"asset_attributes": { | ||
"latest_conformance_report": { | ||
"arc_attribute_type": "arc_attachment", | ||
"arc_blob_hash_value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | ||
"arc_blob_identity": "blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"arc_blob_hash_alg": "SHA256", | ||
"arc_file_name": "safety_conformance.pdf", | ||
"arc_display_name": "Latest Conformance Report", | ||
}, | ||
}, | ||
"timestamp_declared": "2019-11-27T14:44:19Z", | ||
"principal_declared": { | ||
"issuer": "idp.synsation.io/1234", | ||
|
@@ -474,16 +389,6 @@ The response: | |
"arc_display_name": "Conformance Report", | ||
}, | ||
}, | ||
"asset_attributes": { | ||
"latest_conformance_report": { | ||
"arc_attribute_type": "arc_attachment", | ||
"arc_blob_hash_value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | ||
"arc_blob_identity": "blobs/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", | ||
"arc_blob_hash_alg": "SHA256", | ||
"arc_file_name": "safety_conformance.pdf", | ||
"arc_display_name": "Latest Conformance Report", | ||
}, | ||
}, | ||
"timestamp_accepted": "2019-11-27T15:13:21Z", | ||
"timestamp_declared": "2019-11-27T14:44:19Z", | ||
"timestamp_committed": "2019-11-27T15:15:02Z", | ||
|
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 |
---|---|---|
|
@@ -185,21 +185,21 @@ A simple Access Policy may look like this: | |
"display_name": "Sample Policy", | ||
"description": "An Access Policy created for DataTrails user docs" | ||
|
||
// Filters define which Assets this Policy applies to | ||
// Filters define which Assets (sets of Events) this Policy applies to | ||
"filters": [ | ||
{ | ||
// Any Crate, Box, or Bag ... | ||
// Any image, video, or whitepaper... | ||
"or": [ | ||
"attributes.arc_display_type=Crate", | ||
"attributes.arc_display_type=Box", | ||
"attributes.arc_display_type=Bag" | ||
"attributes.arc_display_type=Image", | ||
"attributes.arc_display_type=Video", | ||
"attributes.arc_display_type=Whitepaper" | ||
] | ||
}, | ||
{ | ||
// ... whose registered handler is either Fred or Margaret | ||
// ... which is marked either CONFIDENTIAL or SECRET | ||
"or": [ | ||
"attributes.handler=Fred", | ||
"attributes.handler=Margaret" | ||
"attributes.classification=CONFIDENTIAL", | ||
"attributes.classification=SECRET" | ||
] | ||
} | ||
], | ||
|
@@ -218,31 +218,27 @@ A simple Access Policy may look like this: | |
{ "or": [ "[email protected]" ] } | ||
], | ||
|
||
// Limit the APIs they can call | ||
"behaviours": [ "RecordEvidence" ], | ||
|
||
// Select which Asset attributes these users can see | ||
"asset_attributes_read": [ | ||
"Height", | ||
"arc_display_name", | ||
"arc_display_type" | ||
], | ||
|
||
// Select which Asset attributes these users can modify | ||
"asset_attributes_write": [ | ||
"Height" | ||
], | ||
// Note modifying Asset attributes in this way is deprecated | ||
// and not recommended | ||
"asset_attributes_write": [], | ||
|
||
// Select which Events from the Asset history these users can see | ||
// Select which types of Events these users can see | ||
"event_arc_display_type_read": [ | ||
"Measure", | ||
"Open", | ||
"Seal" | ||
"Pre-release", | ||
"Watermark", | ||
"Approve" | ||
], | ||
|
||
// Select which Events these users can contribute to the history | ||
// Select which types of Events these users can contribute to the Trail | ||
"event_arc_display_type_write": [ | ||
"Measure" | ||
"Approve" | ||
], | ||
|
||
// Note the include_attributes field is deprecated | ||
|
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