|
1 | | -# Jitsuin Archivist Client |
2 | | - |
3 | | -The standard Jitsuin Archivist python client. |
4 | | - |
5 | | -Please note that the canonical API for Jitsuin Archivist is always the REST API |
6 | | -documented at https://docs.jitsuin.com |
7 | | - |
8 | | -# Installation |
9 | | - |
10 | | -Use standard python pip utility: |
11 | | - |
12 | | -```bash |
13 | | -python3 -m pip install jitsuin-archivist |
14 | | -``` |
15 | | - |
16 | | -One can then use the examples code to create assets (see examples directory): |
17 | | - |
18 | | -```python |
19 | | -from archivist.archivist import Archivist |
20 | | -from archivist.errors import ArchivistError |
21 | | - |
22 | | -# Oauth2 token that grants access |
23 | | -with open(".auth_token", mode='r') as tokenfile: |
24 | | - authtoken = tokenfile.read().strip() |
25 | | - |
26 | | -# Initialize connection to Archivist - the URL for production will be different to this URL |
27 | | -arch = Archivist( |
28 | | - "https://rkvst.poc.jitsuin.io", |
29 | | - auth=authtoken, |
30 | | -) |
31 | | - |
32 | | -# Create a new asset |
33 | | -attrs = { |
34 | | - "arc_display_name": "display_name", # Asset's display name in the user interface |
35 | | - "arc_description": "display_description", # Asset's description in the user interface |
36 | | - "arc_display_type": "desplay_type", # Arc_display_type is a free text field |
37 | | - # allowing the creator of |
38 | | - # an asset to specify the asset |
39 | | - # type or class. Be careful when setting this: |
40 | | - # assets are grouped by type and |
41 | | - # sharing policies can be |
42 | | - # configured to share assets based on |
43 | | - # their arc_display_type. |
44 | | - # So a mistake here can result in asset data being |
45 | | - # under- or over-shared. |
46 | | - "some_custom_attribute": "value" # You can add any custom value as long as |
47 | | - # it does not start with arc_ |
48 | | -} |
49 | | -behaviours = ["Attachments", "RecordEvidence"] |
50 | | - |
51 | | -# The first argument is the behaviours of the asset |
52 | | -# The second argument is the attributes of the asset |
53 | | -# The third argument is wait for confirmation: |
54 | | -# If @confirm@ is True then this function will not |
55 | | -# return until the asset is confirmed on the blockchain and ready |
56 | | -# to accept events (or an error occurs) |
57 | | -# After an asset is submitted to the blockchain (submitted), |
58 | | -# it will be in the "Pending" status. |
59 | | -# Once it is added to the blockchain, the status will be changed to "Confirmed" |
60 | | -try: |
61 | | - asset = arch.assets.create(behaviours, attrs=attrs, confirm=True) |
62 | | -except Archivisterror as ex: |
63 | | - print("error", ex) |
64 | | -else: |
65 | | - print("asset", asset) |
66 | | - |
67 | | -``` |
68 | | - |
69 | | -## Logging |
70 | | - |
71 | | -Follows the Django model as described here: https://docs.djangoproject.com/en/3.2/topics/logging/ |
72 | | - |
73 | | -The base logger for this pacakage is rooted at "archivist" with subloggers for each endpoint: |
74 | | - |
75 | | -- "archivist.archivist" |
76 | | -- "archivist.assets" |
77 | | -- ... |
78 | | - |
79 | | -etc. etc. |
80 | | - |
81 | | -Logging is configured by either defining a root logger with suitable handlers, formatters etc. or |
82 | | -by using dictionary configuration as described here: https://docs.python.org/3/library/logging.config.html#logging-config-dictschema |
83 | | - |
84 | | -A recommended minimum configuration would be: |
85 | | - |
86 | | -```python |
87 | | -import logging |
88 | | - |
89 | | -logging.dictConfig({ |
90 | | - "version": 1, |
91 | | - "disable_existing_loggers": False, |
92 | | - "handlers": { |
93 | | - "console": { |
94 | | - "class": "logging.StreamHandler", |
95 | | - }, |
96 | | - }, |
97 | | - "root": { |
98 | | - "handlers": ["console"], |
99 | | - "level": "INFO", |
100 | | - }, |
101 | | -}) |
102 | | -``` |
103 | | - |
104 | 1 | # Development |
105 | 2 |
|
106 | 3 | ## Pre-requisites |
@@ -221,7 +118,7 @@ they be run in a production environment. |
221 | 118 | Set 2 environment variables and execute: |
222 | 119 |
|
223 | 120 | ```bash |
224 | | -export TEST_ARCHIVIST="https://rkvst.poc.jitsuin.io" |
| 121 | +export TEST_ARCHIVIST="https://app.rkvst.io" |
225 | 122 | export TEST_AUTHTOKEN_FILENAME=credentials/authtoken |
226 | 123 | task functests |
227 | 124 | ``` |
|
0 commit comments