Package: datatrails-samples
# datatrails-samplesSample python code that uses the datatrails python SDK to manage particular types of assets
such as ‘doors’, ‘cards’, ‘containers’ etc.# Installing the samples codePython 3.8 and later versions are supported.Use the standard python pip utility:`bash python3-mpip install--userdatatrails-samples`and this will create 7 entry points:archivist_samples_documentarchivist_samples_door_entryarchivist_samples_estate_infoarchivist_samples_signed_recordsarchivist_samples_synsationarchivist_samples_software_bill_of_materialsarchivist_samples_wipp## Pre-requisitesAdd a token to the file credentials/.auth_token and set some environment vars to
specify the archivist endpoint:`bash exportTEST_ARCHIVIST="https://app.datatrails.ai"exportTEST_AUTHTOKEN_FILENAME=credentials/.auth_tokenexportTEST_NAMESPACE="uniquelabel" exportTEST_VERBOSE=-vexportTEST_PROOF_MECHANISM="--proof-mechanism=SIMPLE_HASH"`If TEST_VERBOSE is “-v” debugging output will appear when running the examples. Otherwise leave blank or undefined.TEST_PROOF_MECHANISM should be “KHIPU” or “SIMPLE_HASH”. If unspecified the default is “SIMPLE_HASH”Windows using Powershell - at the command prompt set values for environment variables:`bash$Env:TEST_ARCHIVIST="https://app.datatrails.ai"$Env:TEST_AUTHTOKEN_FILENAME = '<path of token location>' $Env:TEST_NAMESPACE =Get-Date-UFormat%s $Env:TEST_VERBOSE ='-v'$Env:TEST_PROOF_MECHANISM="--proof-mechanism=SIMPLE_HASH"`TEST_NAMESPACE is set to the date and time value in Unix format, thus providing a unique id upon execution.## TEST_NAMESPACEIf TEST_NAMESPACE is blank or unspecified, any assets events, locations will be visible to other users running the same examples
on the same URL.Each example creates assets,events,locations that are not visible to other examples.
For example the door_entry assets,events etc are not visible to the synsation example.*Note: Assets and locations are only created if they do not already exist according to namespace.  If one wants to execute a sample multiple
times, feel free to set TEST_NAMESPACE to a different unique id.*Due to restrictions attachments are always uploaded during every example execution.Events are created every execution of an example - currently no check is done if the event already exists.## EXAMPLESAll examples use a common set of arguments:`bash exportAUTH="-u$TEST_ARCHIVIST-t$TEST_AUTHTOKEN_FILENAME $TEST_VERBOSE $TEST_PROOF_MECHANISM" exportARGS="$AUTH--namespace$TEST_NAMESPACE" `### Door Entry ControlSome commands to simply create and manage doors and cards:`bash archivist_samples_door_entry $ARGS--createarchivist_samples_door_entry $ARGS--listall archivist_samples_door_entry $ARGS--listdoors archivist_samples_door_entry $ARGS--listcards archivist_samples_door_entry $ARGS--list'Courts of Justice front door' archivist_samples_door_entry $ARGS--list'access_card_1' `Execute opening doors with a card:`bash archivist_samples_door_entry $ARGS--open"Courts of Justice front door,access_card_1" archivist_samples_door_entry $ARGS--open"Courts of Justice front door,access_card_3" archivist_samples_door_entry $ARGS--open"Courts of Justice front door,access_card_4" archivist_samples_door_entry $ARGS--open"Courts of Justice front door,access_card_0" archivist_samples_door_entry $ARGS--open"Courts of Justice front door,access_card_2" archivist_samples_door_entry $ARGS--open"Bastille front door,access_card_2" archivist_samples_door_entry $ARGS--open"City Hall front door,access_card_2" archivist_samples_door_entry $ARGS--open"Gare du Nord apartments side door,access_card_2" `### Manage assets and events and check for any inconsistenciesNB no namespace required …`bash archivist_samples_estate_info $AUTH--quick-countarchivist_samples_estate_info $AUTH--double-check`### Signed Records`bash archivist_samples_signed_records $ARGS--create'samples' archivist_samples_signed_records $ARGS--sign-message'signature' 'samples' archivist_samples_signed_records $ARGS--bad-sign-message'signature' 'samples' archivist_samples_signed_records $ARGS--check'samples' `### Synsation`bash archivist_samples_synsation initialise  $ARGS--num-assets100--wait1--await-confirmationarchivist_samples_synsation charger     $ARGS--start-date20190909--stop-date20191009--fast-forward9876 archivist_samples_synsation simulator   $ARGS--asset-nametcl.ccj.001--wait1.0 archivist_samples_synsation wanderer    $ARGS archivist_samples_synsation analyze     $ARGS `### Software Bill of Materials`bash archivist_samples_software_bill_of_materials $ARGS `### WIPP`bash archivist_samples_wipp $ARGS `