pyPreservica 2.0.3__py3-none-any.whl → 3.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyPreservica might be problematic. Click here for more details.
- pyPreservica/__init__.py +19 -7
- pyPreservica/adminAPI.py +43 -33
- pyPreservica/authorityAPI.py +9 -9
- pyPreservica/common.py +198 -54
- pyPreservica/contentAPI.py +199 -18
- pyPreservica/entityAPI.py +944 -250
- pyPreservica/mdformsAPI.py +572 -0
- pyPreservica/monitorAPI.py +3 -3
- pyPreservica/parAPI.py +7 -40
- pyPreservica/retentionAPI.py +58 -26
- pyPreservica/settingsAPI.py +295 -0
- pyPreservica/uploadAPI.py +426 -609
- pyPreservica/webHooksAPI.py +3 -1
- pyPreservica/workflowAPI.py +21 -37
- {pyPreservica-2.0.3.dist-info → pypreservica-3.3.3.dist-info}/METADATA +93 -84
- pypreservica-3.3.3.dist-info/RECORD +20 -0
- {pyPreservica-2.0.3.dist-info → pypreservica-3.3.3.dist-info}/WHEEL +1 -1
- pyPreservica/vocabularyAPI.py +0 -141
- pyPreservica-2.0.3.dist-info/RECORD +0 -19
- {pyPreservica-2.0.3.dist-info → pypreservica-3.3.3.dist-info/licenses}/LICENSE.txt +0 -0
- {pyPreservica-2.0.3.dist-info → pypreservica-3.3.3.dist-info}/top_level.txt +0 -0
pyPreservica/webHooksAPI.py
CHANGED
|
@@ -8,7 +8,6 @@ author: James Carr
|
|
|
8
8
|
licence: Apache License 2.0
|
|
9
9
|
|
|
10
10
|
"""
|
|
11
|
-
import json
|
|
12
11
|
from http.server import BaseHTTPRequestHandler
|
|
13
12
|
from urllib.parse import urlparse, parse_qs
|
|
14
13
|
import hmac
|
|
@@ -73,6 +72,9 @@ class TriggerType(Enum):
|
|
|
73
72
|
"""
|
|
74
73
|
MOVED = "MOVED"
|
|
75
74
|
INDEXED = "FULL_TEXT_INDEXED"
|
|
75
|
+
SECURITY_CHANGED = "CHANGED_SECURITY_DESCRIPTOR"
|
|
76
|
+
INGEST_FAILED = "INGEST_FAILED"
|
|
77
|
+
CHANGE_ASSET_VISIBILITY = "CHANGE_ASSET_VISIBILITY"
|
|
76
78
|
|
|
77
79
|
|
|
78
80
|
class WebHooksAPI(AuthenticatedAPI):
|
pyPreservica/workflowAPI.py
CHANGED
|
@@ -11,7 +11,7 @@ licence: Apache License 2.0
|
|
|
11
11
|
|
|
12
12
|
import uuid
|
|
13
13
|
import datetime
|
|
14
|
-
from
|
|
14
|
+
from typing import Callable
|
|
15
15
|
from xml.etree import ElementTree
|
|
16
16
|
|
|
17
17
|
from pyPreservica.common import *
|
|
@@ -19,23 +19,10 @@ from pyPreservica.common import *
|
|
|
19
19
|
logger = logging.getLogger(__name__)
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def prettify(elem):
|
|
23
|
-
"""Return a pretty-printed XML string for the Element.
|
|
24
|
-
"""
|
|
25
|
-
rough_string = ElementTree.tostring(elem, 'utf-8')
|
|
26
|
-
re_parsed = minidom.parseString(rough_string)
|
|
27
|
-
return re_parsed.toprettyxml(indent=" ")
|
|
28
|
-
|
|
29
|
-
|
|
30
22
|
class WorkflowInstance:
|
|
31
23
|
"""
|
|
32
24
|
Defines a workflow Instance.
|
|
33
|
-
The workflow Instance is context which has been executed
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:param instance_id: The Workflow instance Id
|
|
37
|
-
:type instance_id: int
|
|
38
|
-
|
|
25
|
+
The workflow Instance is a context which has been executed
|
|
39
26
|
"""
|
|
40
27
|
|
|
41
28
|
def __init__(self, instance_id: int):
|
|
@@ -62,14 +49,6 @@ class WorkflowContext:
|
|
|
62
49
|
"""
|
|
63
50
|
Defines a workflow context.
|
|
64
51
|
The workflow context is the pre-defined workflow which is ready to run
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
:param workflow_name: The Workflow context name
|
|
68
|
-
:type workflow_name: str
|
|
69
|
-
|
|
70
|
-
:param workflow_id: The Workflow context id
|
|
71
|
-
:type workflow_id: str
|
|
72
|
-
|
|
73
52
|
"""
|
|
74
53
|
|
|
75
54
|
def __init__(self, workflow_id, workflow_name: str):
|
|
@@ -77,8 +56,10 @@ class WorkflowContext:
|
|
|
77
56
|
self.workflow_name = workflow_name
|
|
78
57
|
|
|
79
58
|
def __str__(self):
|
|
80
|
-
return f"
|
|
81
|
-
|
|
59
|
+
return f"""
|
|
60
|
+
Workflow ID: {self.workflow_id}
|
|
61
|
+
Workflow Name: {self.workflow_name}
|
|
62
|
+
"""
|
|
82
63
|
|
|
83
64
|
def __repr__(self):
|
|
84
65
|
return self.__str__()
|
|
@@ -99,8 +80,11 @@ class WorkflowAPI(AuthenticatedAPI):
|
|
|
99
80
|
workflow_types = ['Ingest', 'Access', 'Transformation', 'DataManagement']
|
|
100
81
|
|
|
101
82
|
def __init__(self, username: str = None, password: str = None, tenant: str = None, server: str = None,
|
|
102
|
-
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
103
|
-
|
|
83
|
+
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
84
|
+
protocol: str = "https", request_hook: Callable = None, credentials_path: str = 'credentials.properties'):
|
|
85
|
+
|
|
86
|
+
super().__init__(username, password, tenant, server, use_shared_secret, two_fa_secret_key,
|
|
87
|
+
protocol, request_hook, credentials_path)
|
|
104
88
|
self.base_url = "sdb/rest/workflow"
|
|
105
89
|
|
|
106
90
|
def get_workflow_contexts_by_type(self, workflow_type: str):
|
|
@@ -265,13 +249,13 @@ class WorkflowAPI(AuthenticatedAPI):
|
|
|
265
249
|
assert instance_id == w_id
|
|
266
250
|
workflow_instance = WorkflowInstance(int(instance_id))
|
|
267
251
|
started_element = entity_response.find(f".//{{{NS_WORKFLOW}}}Started")
|
|
268
|
-
if started_element:
|
|
252
|
+
if started_element is not None:
|
|
269
253
|
if hasattr(started_element, "text"):
|
|
270
254
|
workflow_instance.started = datetime.datetime.strptime(started_element.text,
|
|
271
255
|
'%Y-%m-%dT%H:%M:%S.%fZ')
|
|
272
256
|
|
|
273
257
|
finished_element = entity_response.find(f".//{{{NS_WORKFLOW}}}Finished")
|
|
274
|
-
if finished_element:
|
|
258
|
+
if finished_element is not None:
|
|
275
259
|
if hasattr(finished_element, "text"):
|
|
276
260
|
workflow_instance.finished = datetime.datetime.strptime(finished_element.text,
|
|
277
261
|
'%Y-%m-%dT%H:%M:%S.%fZ')
|
|
@@ -348,13 +332,13 @@ class WorkflowAPI(AuthenticatedAPI):
|
|
|
348
332
|
creator = kwargs.get("creator")
|
|
349
333
|
params["creator"] = creator
|
|
350
334
|
|
|
351
|
-
if "
|
|
352
|
-
from_date = kwargs.get("
|
|
353
|
-
params["from"] = from_date
|
|
335
|
+
if "from_date" in kwargs:
|
|
336
|
+
from_date = kwargs.get("from_date")
|
|
337
|
+
params["from"] = parse_date_to_iso(from_date)
|
|
354
338
|
|
|
355
|
-
if "
|
|
356
|
-
to_date = kwargs.get("
|
|
357
|
-
params["to"] = to_date
|
|
339
|
+
if "to_date" in kwargs:
|
|
340
|
+
to_date = kwargs.get("to_date")
|
|
341
|
+
params["to"] = parse_date_to_iso(to_date)
|
|
358
342
|
|
|
359
343
|
params["start"] = int(start_value)
|
|
360
344
|
params["max"] = int(maximum)
|
|
@@ -373,13 +357,13 @@ class WorkflowAPI(AuthenticatedAPI):
|
|
|
373
357
|
workflow_instance = WorkflowInstance(int(instance_id))
|
|
374
358
|
|
|
375
359
|
started_element = instance.find(f".//{{{NS_WORKFLOW}}}Started")
|
|
376
|
-
if started_element:
|
|
360
|
+
if started_element is not None:
|
|
377
361
|
if hasattr(started_element, "text"):
|
|
378
362
|
workflow_instance.started = datetime.datetime.strptime(started_element.text,
|
|
379
363
|
'%Y-%m-%dT%H:%M:%S.%fZ')
|
|
380
364
|
|
|
381
365
|
finished_element = instance.find(f".//{{{NS_WORKFLOW}}}Finished")
|
|
382
|
-
if finished_element:
|
|
366
|
+
if finished_element is not None:
|
|
383
367
|
if hasattr(finished_element, "text"):
|
|
384
368
|
workflow_instance.finished = datetime.datetime.strptime(finished_element.text,
|
|
385
369
|
'%Y-%m-%dT%H:%M:%S.%fZ')
|
|
@@ -1,84 +1,93 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: pyPreservica
|
|
3
|
-
Version:
|
|
4
|
-
Summary: Python library for the Preservica API
|
|
5
|
-
Home-page: https://pypreservica.readthedocs.io/
|
|
6
|
-
Author: James Carr
|
|
7
|
-
Author-email: drjamescarr@gmail.com
|
|
8
|
-
License: Apache License 2.0
|
|
9
|
-
Project-URL: Documentation, https://pypreservica.readthedocs.io
|
|
10
|
-
Project-URL: Source, https://github.com/carj/pyPreservica
|
|
11
|
-
Project-URL: Discussion Forum, https://groups.google.com/g/pypreservica
|
|
12
|
-
Keywords: Preservica API Preservation
|
|
13
|
-
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.
|
|
19
|
-
Classifier:
|
|
20
|
-
Classifier: Operating System :: OS Independent
|
|
21
|
-
Classifier: Topic :: System :: Archiving
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
License-File: LICENSE.txt
|
|
24
|
-
Requires-Dist: requests
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
https://
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyPreservica
|
|
3
|
+
Version: 3.3.3
|
|
4
|
+
Summary: Python library for the Preservica API
|
|
5
|
+
Home-page: https://pypreservica.readthedocs.io/
|
|
6
|
+
Author: James Carr
|
|
7
|
+
Author-email: drjamescarr@gmail.com
|
|
8
|
+
License: Apache License 2.0
|
|
9
|
+
Project-URL: Documentation, https://pypreservica.readthedocs.io
|
|
10
|
+
Project-URL: Source, https://github.com/carj/pyPreservica
|
|
11
|
+
Project-URL: Discussion Forum, https://groups.google.com/g/pypreservica
|
|
12
|
+
Keywords: Preservica API Preservation
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Operating System :: OS Independent
|
|
21
|
+
Classifier: Topic :: System :: Archiving
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.txt
|
|
24
|
+
Requires-Dist: requests
|
|
25
|
+
Requires-Dist: urllib3
|
|
26
|
+
Requires-Dist: certifi
|
|
27
|
+
Requires-Dist: boto3>=1.38.0
|
|
28
|
+
Requires-Dist: botocore>=1.38.0
|
|
29
|
+
Requires-Dist: s3transfer
|
|
30
|
+
Requires-Dist: azure-storage-blob
|
|
31
|
+
Requires-Dist: tqdm
|
|
32
|
+
Requires-Dist: pyotp
|
|
33
|
+
Requires-Dist: python-dateutil
|
|
34
|
+
Dynamic: author
|
|
35
|
+
Dynamic: author-email
|
|
36
|
+
Dynamic: classifier
|
|
37
|
+
Dynamic: description
|
|
38
|
+
Dynamic: description-content-type
|
|
39
|
+
Dynamic: home-page
|
|
40
|
+
Dynamic: keywords
|
|
41
|
+
Dynamic: license
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
Dynamic: project-url
|
|
44
|
+
Dynamic: requires-dist
|
|
45
|
+
Dynamic: summary
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# pyPreservica
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
[](https://pypi.org/project/pyPreservica)
|
|
52
|
+
[](https://github.com/carj/pyPreservica/actions/workflows/codeql-analysis.yml)
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
Python language binding for the Preservica API
|
|
56
|
+
|
|
57
|
+
https://preservica.com/
|
|
58
|
+
|
|
59
|
+
This library provides a Python class for working with the Preservica Rest API
|
|
60
|
+
|
|
61
|
+
https://developers.preservica.com/api-reference
|
|
62
|
+
|
|
63
|
+
Wiki with example scripts https://github.com/carj/pyPreservica/wiki
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
The full documentation is available at: https://pypreservica.readthedocs.io/
|
|
68
|
+
|
|
69
|
+
[](https://pypreservica.readthedocs.io/en/latest/?badge=latest)
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/carj/pyPreservica
|
|
74
|
+
|
|
75
|
+
For announcements about new versions and discussion of pyPreservica please subscribe to the google groups
|
|
76
|
+
forum https://groups.google.com/g/pypreservica
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
The package is available as open source under the terms of the Apache License 2.0
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Installation
|
|
84
|
+
|
|
85
|
+
pyPreservica is available from the Python Package Index (PyPI)
|
|
86
|
+
|
|
87
|
+
https://pypi.org/project/pyPreservica/
|
|
88
|
+
|
|
89
|
+
To install pyPreservica, simply run this simple command in your terminal of choice:
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
$ pip install pyPreservica
|
|
93
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
pyPreservica/__init__.py,sha256=KIbmVi2I4p8xCxvtnzU-liKWrg0zJG-qOhw9YLFZORU,1250
|
|
2
|
+
pyPreservica/adminAPI.py,sha256=_ZTb8T708loYn8UdFgZ4G5RTef9Hd2HHtjKnnrzBAtY,38041
|
|
3
|
+
pyPreservica/authorityAPI.py,sha256=A52sFiAK4E4mlend_dknNIOW2BEwKXcLFI02anZBt3U,9211
|
|
4
|
+
pyPreservica/common.py,sha256=TV4VgO4QI5YDdPYvm9ue1lxqSIf2E2j0_tQbFmwMf0U,39922
|
|
5
|
+
pyPreservica/contentAPI.py,sha256=nnWImPoS7yt47yfohbtG1wWi1dNS_XdellWaPCE9iUk,25041
|
|
6
|
+
pyPreservica/entityAPI.py,sha256=kyw03RnxKEveViQvdDy6MdscXOcAZxs9LC7hpKe3B3g,140235
|
|
7
|
+
pyPreservica/mdformsAPI.py,sha256=A2YTT5uh6j1k_kg_33492cplwZc_jYv6zmiIt5Rvx6c,23259
|
|
8
|
+
pyPreservica/monitorAPI.py,sha256=LJOUrynBOWKlNiYpZ1iH8qB1oIIuKX1Ms1SRBcuXohA,6274
|
|
9
|
+
pyPreservica/opex.py,sha256=ccra1S4ojUXS3PlbU8WfxajOkJrwG4OykBnNrYP_jus,4875
|
|
10
|
+
pyPreservica/parAPI.py,sha256=f0ZUxLd0U-BW6kBx5K7W2Pv7NjG3MkTNydmxQ3U1ZVE,9296
|
|
11
|
+
pyPreservica/retentionAPI.py,sha256=QUTCbN4P3IpqmrebU_wd3n5ZVcyxVLTFAli8Y_GxOW4,24843
|
|
12
|
+
pyPreservica/settingsAPI.py,sha256=jXnMOCq3mimta6E-Os3J1I1if2pYsjLpOazAx8L-ZQI,10721
|
|
13
|
+
pyPreservica/uploadAPI.py,sha256=UVRFcLDH4s0Tik0vWmkQ6WkJX2h5Yk1MnJZX83HtcpQ,82084
|
|
14
|
+
pyPreservica/webHooksAPI.py,sha256=KMObsdHp_0K0HjJUl5oaFh-vs21GCAQZo2ZTKkY38R8,6872
|
|
15
|
+
pyPreservica/workflowAPI.py,sha256=bIoXNlr8uBQJ9Nkd1EdpN0uVt_UwtELa_YXpX1PEJh4,17619
|
|
16
|
+
pypreservica-3.3.3.dist-info/licenses/LICENSE.txt,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
17
|
+
pypreservica-3.3.3.dist-info/METADATA,sha256=IwjGyIEvGOgcN3yzo9LIFd9jZirLt0r4lJtTIyhjaHA,3077
|
|
18
|
+
pypreservica-3.3.3.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
19
|
+
pypreservica-3.3.3.dist-info/top_level.txt,sha256=iIBh6NAznYQHOV8mv_y_kGKSDITek9rANyFDwJsbU-c,13
|
|
20
|
+
pypreservica-3.3.3.dist-info/RECORD,,
|
pyPreservica/vocabularyAPI.py
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
pyPreservica ControlledVocabularyAPI module definition
|
|
3
|
-
|
|
4
|
-
A client library for the Preservica Repository web services Webhook API
|
|
5
|
-
https://us.preservica.com/api/reference-metadata/documentation.html
|
|
6
|
-
|
|
7
|
-
author: James Carr
|
|
8
|
-
licence: Apache License 2.0
|
|
9
|
-
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
from pyPreservica.common import *
|
|
13
|
-
|
|
14
|
-
logger = logging.getLogger(__name__)
|
|
15
|
-
|
|
16
|
-
BASE_ENDPOINT = '/api/reference-metadata'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class Table:
|
|
20
|
-
def __init__(self, reference: str, name: str, security_tag: str, displayField: str, metadataConnections: list):
|
|
21
|
-
self.reference = reference
|
|
22
|
-
self.name = name
|
|
23
|
-
self.security_tag = security_tag
|
|
24
|
-
self.displayField = displayField
|
|
25
|
-
self.metadataConnections = metadataConnections
|
|
26
|
-
self.fields = None
|
|
27
|
-
|
|
28
|
-
def __str__(self):
|
|
29
|
-
return f"Ref:\t\t\t{self.reference}\n" \
|
|
30
|
-
f"Name:\t\t\t{self.name}\n" \
|
|
31
|
-
f"Security Tag:\t{self.security_tag}\n" \
|
|
32
|
-
f"Display Field:\t\t\t{self.displayField}\n" \
|
|
33
|
-
f"Metadata Connections:\t\t\t{self.metadataConnections}\n" \
|
|
34
|
-
f"Fields:\t\t\t{self.fields}\n"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class ControlledVocabularyAPI(AuthenticatedAPI):
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def load_skos(self, uri):
|
|
41
|
-
"""
|
|
42
|
-
Load a SKOS controlled vocabulary in skos RDF format
|
|
43
|
-
|
|
44
|
-
Simple Knowledge Organization System (SKOS)
|
|
45
|
-
|
|
46
|
-
:param uri:
|
|
47
|
-
:return:
|
|
48
|
-
"""
|
|
49
|
-
pass
|
|
50
|
-
|
|
51
|
-
def record(self, reference: str):
|
|
52
|
-
"""
|
|
53
|
-
Get individual record by its ref.
|
|
54
|
-
:param reference:
|
|
55
|
-
:return:
|
|
56
|
-
"""
|
|
57
|
-
headers = {HEADER_TOKEN: self.token, 'accept': 'application/json;charset=UTF-8'}
|
|
58
|
-
response = self.session.get(f'{self.protocol}://{self.server}{BASE_ENDPOINT}/records/{reference}',
|
|
59
|
-
headers=headers)
|
|
60
|
-
if response.status_code == requests.codes.unauthorized:
|
|
61
|
-
self.token = self.__token__()
|
|
62
|
-
return self.record(reference)
|
|
63
|
-
if response.status_code == requests.codes.ok:
|
|
64
|
-
json_response = str(response.content.decode('utf-8'))
|
|
65
|
-
return json.loads(json_response)
|
|
66
|
-
else:
|
|
67
|
-
exception = HTTPException("", response.status_code, response.url, "record",
|
|
68
|
-
response.content.decode('utf-8'))
|
|
69
|
-
logger.error(exception)
|
|
70
|
-
raise exception
|
|
71
|
-
|
|
72
|
-
def records(self, table: Table):
|
|
73
|
-
"""
|
|
74
|
-
Get all records from a table.
|
|
75
|
-
:return:
|
|
76
|
-
"""
|
|
77
|
-
headers = {HEADER_TOKEN: self.token, 'accept': 'application/json;charset=UTF-8'}
|
|
78
|
-
response = self.session.get(f'{self.protocol}://{self.server}{BASE_ENDPOINT}/tables/{table.reference}/records',
|
|
79
|
-
headers=headers)
|
|
80
|
-
if response.status_code == requests.codes.unauthorized:
|
|
81
|
-
self.token = self.__token__()
|
|
82
|
-
return self.records(table)
|
|
83
|
-
if response.status_code == requests.codes.ok:
|
|
84
|
-
json_response = str(response.content.decode('utf-8'))
|
|
85
|
-
return json.loads(json_response)['records']
|
|
86
|
-
else:
|
|
87
|
-
exception = HTTPException("", response.status_code, response.url, "records",
|
|
88
|
-
response.content.decode('utf-8'))
|
|
89
|
-
logger.error(exception)
|
|
90
|
-
raise exception
|
|
91
|
-
|
|
92
|
-
def table(self, reference: str):
|
|
93
|
-
"""
|
|
94
|
-
fetch a metadata table by id
|
|
95
|
-
|
|
96
|
-
:param reference:
|
|
97
|
-
:return:
|
|
98
|
-
"""
|
|
99
|
-
headers = {HEADER_TOKEN: self.token, 'accept': 'application/json;charset=UTF-8'}
|
|
100
|
-
response = self.session.get(f'{self.protocol}://{self.server}{BASE_ENDPOINT}/tables/{reference}',
|
|
101
|
-
headers=headers)
|
|
102
|
-
if response.status_code == requests.codes.unauthorized:
|
|
103
|
-
self.token = self.__token__()
|
|
104
|
-
return self.table(reference)
|
|
105
|
-
if response.status_code == requests.codes.ok:
|
|
106
|
-
json_response = str(response.content.decode('utf-8'))
|
|
107
|
-
doc = json.loads(json_response)
|
|
108
|
-
table = Table(doc['ref'], doc['name'], doc['securityDescriptor'], doc['displayField'],
|
|
109
|
-
doc['metadataConnections'])
|
|
110
|
-
table.fields = doc['fields']
|
|
111
|
-
return table
|
|
112
|
-
else:
|
|
113
|
-
exception = HTTPException("", response.status_code, response.url, "table",
|
|
114
|
-
response.content.decode('utf-8'))
|
|
115
|
-
logger.error(exception)
|
|
116
|
-
raise exception
|
|
117
|
-
|
|
118
|
-
def tables(self):
|
|
119
|
-
"""
|
|
120
|
-
List reference metadata tables, optionally filtering by metadata connections.
|
|
121
|
-
:return:
|
|
122
|
-
"""
|
|
123
|
-
headers = {HEADER_TOKEN: self.token, 'accept': 'application/json;charset=UTF-8'}
|
|
124
|
-
response = self.session.get(f'{self.protocol}://{self.server}{BASE_ENDPOINT}/tables', headers=headers)
|
|
125
|
-
if response.status_code == requests.codes.unauthorized:
|
|
126
|
-
self.token = self.__token__()
|
|
127
|
-
return self.tables()
|
|
128
|
-
if response.status_code == requests.codes.ok:
|
|
129
|
-
json_response = str(response.content.decode('utf-8'))
|
|
130
|
-
doc = json.loads(json_response)
|
|
131
|
-
results = set()
|
|
132
|
-
for table in doc['tables']:
|
|
133
|
-
t = Table(table['ref'], table['name'], table['securityDescriptor'], table['displayField'],
|
|
134
|
-
table['metadataConnections'])
|
|
135
|
-
results.add(t)
|
|
136
|
-
return results
|
|
137
|
-
else:
|
|
138
|
-
exception = HTTPException("", response.status_code, response.url, "tables",
|
|
139
|
-
response.content.decode('utf-8'))
|
|
140
|
-
logger.error(exception)
|
|
141
|
-
raise exception
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
pyPreservica/__init__.py,sha256=wsWI-hy7FC_caKfcr3hzc95MwFXdCPZRYKnJ5sBKiUo,1084
|
|
2
|
-
pyPreservica/adminAPI.py,sha256=ILO8ADLbtVPjNQcmh4pUw17A7Zl9wAIT7Cyh7Z7UXKc,37685
|
|
3
|
-
pyPreservica/authorityAPI.py,sha256=XUuleBePg1-ji6SAGQi01etH8tbRX_tF4fuI-3sGzJQ,9142
|
|
4
|
-
pyPreservica/common.py,sha256=TbAmmTaeEh87mYvKoQI0g9ckie2NIT6WE-i-DFXQa4k,34848
|
|
5
|
-
pyPreservica/contentAPI.py,sha256=E-KkUStLpQREAlUMq_I-Bh3UgEWTpDv3Ki2pafu4vrY,16257
|
|
6
|
-
pyPreservica/entityAPI.py,sha256=g1ikcd7nImCwABRO5Izn3MaF7paf83habWndlYhFAHY,105700
|
|
7
|
-
pyPreservica/monitorAPI.py,sha256=Xto2uSiryfZlUMUCrH7it2B8xOPVSLgSVLodxZW45po,6258
|
|
8
|
-
pyPreservica/opex.py,sha256=ccra1S4ojUXS3PlbU8WfxajOkJrwG4OykBnNrYP_jus,4875
|
|
9
|
-
pyPreservica/parAPI.py,sha256=WdfDYKbrJFqDrRtRUu-f7sSh1R4t-3fcLsUO2APheks,10522
|
|
10
|
-
pyPreservica/retentionAPI.py,sha256=Cx1ofz9V31a8c8utEfKYLlfQaHSaaqg_D4R3LUFBEx0,23612
|
|
11
|
-
pyPreservica/uploadAPI.py,sha256=bPrM90Be0nDPMovz1U1cBLj0HUYj2OFvm1upOdUOhQw,92455
|
|
12
|
-
pyPreservica/vocabularyAPI.py,sha256=jPl6KDZoBGqlY0oEYjTpZ9kNEPzchDW-gyp-HH-MSKk,5729
|
|
13
|
-
pyPreservica/webHooksAPI.py,sha256=bhenk2nAlAZRauSET0AG9DZyKckJos2NENyl0LDN5Z4,6736
|
|
14
|
-
pyPreservica/workflowAPI.py,sha256=QOMd4Nw69Vf8tJ7Px4gSLpug7VakAtNi-90UTgWSed0,17862
|
|
15
|
-
pyPreservica-2.0.3.dist-info/LICENSE.txt,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
16
|
-
pyPreservica-2.0.3.dist-info/METADATA,sha256=YcCjCxt-wBC-6wSl9PD0qIVj0Ug25xVWS3WuFpgxOUE,2698
|
|
17
|
-
pyPreservica-2.0.3.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
18
|
-
pyPreservica-2.0.3.dist-info/top_level.txt,sha256=iIBh6NAznYQHOV8mv_y_kGKSDITek9rANyFDwJsbU-c,13
|
|
19
|
-
pyPreservica-2.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|