pyPreservica 2.7.2__tar.gz → 2.7.4__tar.gz
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.
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/PKG-INFO +10 -1
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/__init__.py +1 -1
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/common.py +30 -4
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/contentAPI.py +9 -5
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/entityAPI.py +7 -3
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/mdformsAPI.py +7 -2
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/retentionAPI.py +5 -3
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/uploadAPI.py +151 -98
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/workflowAPI.py +11 -7
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica.egg-info/PKG-INFO +10 -1
- pypreservica-2.7.4/pyPreservica.egg-info/SOURCES.txt +45 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/setup.py +1 -1
- pypreservica-2.7.4/tests/test_authority_records.py +20 -0
- pypreservica-2.7.4/tests/test_bitstream.py +77 -0
- pypreservica-2.7.4/tests/test_children.py +75 -0
- pypreservica-2.7.4/tests/test_content_api.py +83 -0
- pypreservica-2.7.4/tests/test_crawl_fs.py +27 -0
- pypreservica-2.7.4/tests/test_delete.py +17 -0
- pypreservica-2.7.4/tests/test_download.py +102 -0
- pypreservica-2.7.4/tests/test_entity.py +323 -0
- pypreservica-2.7.4/tests/test_export_opex.py +36 -0
- pypreservica-2.7.4/tests/test_identifier.py +131 -0
- pypreservica-2.7.4/tests/test_ingest.py +102 -0
- pypreservica-2.7.4/tests/test_integrity_check.py +43 -0
- pypreservica-2.7.4/tests/test_metadata.py +141 -0
- pypreservica-2.7.4/tests/test_par.py +49 -0
- pypreservica-2.7.4/tests/test_replace.py +36 -0
- pypreservica-2.7.4/tests/test_retention.py +133 -0
- pypreservica-2.7.4/tests/test_schema.py +99 -0
- pypreservica-2.7.4/tests/test_security.py +67 -0
- pypreservica-2.7.4/tests/test_thumbnail.py +41 -0
- pypreservica-2.7.4/tests/test_upload.py +151 -0
- pypreservica-2.7.4/tests/test_users.py +43 -0
- pypreservica-2.7.4/tests/test_workflow.py +37 -0
- pypreservica-2.7.4/tests/test_xml_metadata.py +20 -0
- pyPreservica-2.7.2/pyPreservica.egg-info/SOURCES.txt +0 -22
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/LICENSE.txt +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/README.md +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/adminAPI.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/authorityAPI.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/monitorAPI.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/opex.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/parAPI.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica/webHooksAPI.py +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica.egg-info/dependency_links.txt +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica.egg-info/requires.txt +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/pyPreservica.egg-info/top_level.txt +0 -0
- {pyPreservica-2.7.2 → pypreservica-2.7.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyPreservica
|
|
3
|
-
Version: 2.7.
|
|
3
|
+
Version: 2.7.4
|
|
4
4
|
Summary: Python library for the Preservica API
|
|
5
5
|
Home-page: https://pypreservica.readthedocs.io/
|
|
6
6
|
Author: James Carr
|
|
@@ -20,6 +20,15 @@ Classifier: Operating System :: OS Independent
|
|
|
20
20
|
Classifier: Topic :: System :: Archiving
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE.txt
|
|
23
|
+
Requires-Dist: requests
|
|
24
|
+
Requires-Dist: urllib3
|
|
25
|
+
Requires-Dist: certifi
|
|
26
|
+
Requires-Dist: boto3
|
|
27
|
+
Requires-Dist: botocore
|
|
28
|
+
Requires-Dist: s3transfer
|
|
29
|
+
Requires-Dist: azure-storage-blob
|
|
30
|
+
Requires-Dist: tqdm
|
|
31
|
+
Requires-Dist: pyotp
|
|
23
32
|
|
|
24
33
|
|
|
25
34
|
# pyPreservica
|
|
@@ -477,10 +477,10 @@ class Entity:
|
|
|
477
477
|
def __repr__(self):
|
|
478
478
|
return self.__str__()
|
|
479
479
|
|
|
480
|
-
def has_metadata(self):
|
|
480
|
+
def has_metadata(self) -> bool:
|
|
481
481
|
return bool(self.metadata)
|
|
482
482
|
|
|
483
|
-
def metadata_namespaces(self):
|
|
483
|
+
def metadata_namespaces(self) -> list:
|
|
484
484
|
return list(self.metadata.values())
|
|
485
485
|
|
|
486
486
|
|
|
@@ -714,11 +714,33 @@ class AuthenticatedAPI:
|
|
|
714
714
|
|
|
715
715
|
return entity_dict
|
|
716
716
|
|
|
717
|
+
def edition(self) -> str:
|
|
718
|
+
"""
|
|
719
|
+
Return the edition of this tenancy
|
|
720
|
+
"""
|
|
721
|
+
if self.major_version < 8 and self.minor_version < 3:
|
|
722
|
+
raise RuntimeError("Entitlement API is only available when connected to a v7.3 System")
|
|
723
|
+
|
|
724
|
+
headers = {HEADER_TOKEN: self.token, 'Content-Type': 'application/json'}
|
|
725
|
+
|
|
726
|
+
response = self.session.get(f'{self.protocol}://{self.server}/api/entitlement/edition', headers=headers)
|
|
727
|
+
|
|
728
|
+
if response.status_code == requests.codes.ok:
|
|
729
|
+
return response.json()['edition']
|
|
730
|
+
elif response.status_code == requests.codes.unauthorized:
|
|
731
|
+
self.token = self.__token__()
|
|
732
|
+
return self.edition()
|
|
733
|
+
else:
|
|
734
|
+
exception = HTTPException("", response.status_code, response.url,
|
|
735
|
+
"edition", response.content.decode('utf-8'))
|
|
736
|
+
logger.error(exception)
|
|
737
|
+
raise exception
|
|
738
|
+
|
|
717
739
|
def __version_namespace__(self):
|
|
718
740
|
"""
|
|
719
741
|
Generate version specific namespaces from the server version
|
|
720
742
|
"""
|
|
721
|
-
if self.major_version
|
|
743
|
+
if self.major_version > 6:
|
|
722
744
|
self.xip_ns = f"{NS_XIP_ROOT}v{self.major_version}.{self.minor_version}"
|
|
723
745
|
self.entity_ns = f"{NS_ENTITY_ROOT}v{self.major_version}.{self.minor_version}"
|
|
724
746
|
self.rm_ns = f"{NS_RM_ROOT}v{6}.{2}"
|
|
@@ -857,12 +879,16 @@ class AuthenticatedAPI:
|
|
|
857
879
|
raise RuntimeError(response.status_code, msg)
|
|
858
880
|
|
|
859
881
|
def __init__(self, username: str = None, password: str = None, tenant: str = None, server: str = None,
|
|
860
|
-
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
882
|
+
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
883
|
+
protocol: str = "https", request_hook=None):
|
|
861
884
|
|
|
862
885
|
config = configparser.ConfigParser(interpolation=configparser.Interpolation())
|
|
863
886
|
config.read('credentials.properties', encoding='utf-8')
|
|
864
887
|
self.session: Session = requests.Session()
|
|
865
888
|
|
|
889
|
+
if request_hook is not None:
|
|
890
|
+
self.session.hooks['response'].append(request_hook)
|
|
891
|
+
|
|
866
892
|
retries = Retry(
|
|
867
893
|
total=3,
|
|
868
894
|
backoff_factor=0.1,
|
|
@@ -10,7 +10,7 @@ licence: Apache License 2.0
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
import csv
|
|
13
|
-
from typing import Generator
|
|
13
|
+
from typing import Generator, Callable
|
|
14
14
|
from pyPreservica.common import *
|
|
15
15
|
|
|
16
16
|
logger = logging.getLogger(__name__)
|
|
@@ -19,8 +19,10 @@ logger = logging.getLogger(__name__)
|
|
|
19
19
|
class ContentAPI(AuthenticatedAPI):
|
|
20
20
|
|
|
21
21
|
def __init__(self, username=None, password=None, tenant=None, server=None, use_shared_secret=False,
|
|
22
|
-
two_fa_secret_key: str = None, protocol: str = "https"):
|
|
23
|
-
|
|
22
|
+
two_fa_secret_key: str = None, protocol: str = "https", request_hook: Callable = None):
|
|
23
|
+
|
|
24
|
+
super().__init__(username, password, tenant, server, use_shared_secret, two_fa_secret_key,
|
|
25
|
+
protocol, request_hook)
|
|
24
26
|
self.callback = None
|
|
25
27
|
|
|
26
28
|
class SearchResult:
|
|
@@ -130,7 +132,8 @@ class ContentAPI(AuthenticatedAPI):
|
|
|
130
132
|
logger.error(f"indexed_fields failed with error code: {results.status_code}")
|
|
131
133
|
raise RuntimeError(results.status_code, f"indexed_fields failed with error code: {results.status_code}")
|
|
132
134
|
|
|
133
|
-
def simple_search_csv(self, query: str = "%", page_size: int = 50, csv_file="search.csv",
|
|
135
|
+
def simple_search_csv(self, query: str = "%", page_size: int = 50, csv_file="search.csv",
|
|
136
|
+
list_indexes: list = None):
|
|
134
137
|
if list_indexes is None or len(list_indexes) == 0:
|
|
135
138
|
metadata_fields = ["xip.reference", "xip.title", "xip.description", "xip.document_type",
|
|
136
139
|
"xip.parent_ref", "xip.security_descriptor"]
|
|
@@ -193,7 +196,8 @@ class ContentAPI(AuthenticatedAPI):
|
|
|
193
196
|
logger.error(f"search failed with error code: {results.status_code}")
|
|
194
197
|
raise RuntimeError(results.status_code, f"simple_search failed with error code: {results.status_code}")
|
|
195
198
|
|
|
196
|
-
def search_index_filter_csv(self, query: str = "%", csv_file="search.csv", page_size: int = 50,
|
|
199
|
+
def search_index_filter_csv(self, query: str = "%", csv_file="search.csv", page_size: int = 50,
|
|
200
|
+
filter_values: dict = None,
|
|
197
201
|
sort_values: dict = None):
|
|
198
202
|
if filter_values is None:
|
|
199
203
|
filter_values = {}
|
|
@@ -15,7 +15,7 @@ import xml.etree.ElementTree
|
|
|
15
15
|
from datetime import datetime, timedelta, timezone
|
|
16
16
|
from io import BytesIO
|
|
17
17
|
from time import sleep
|
|
18
|
-
from typing import Any, Generator, Tuple, Iterable, Union
|
|
18
|
+
from typing import Any, Generator, Tuple, Iterable, Union, Callable
|
|
19
19
|
|
|
20
20
|
from pyPreservica.common import *
|
|
21
21
|
|
|
@@ -34,8 +34,12 @@ class EntityAPI(AuthenticatedAPI):
|
|
|
34
34
|
"""
|
|
35
35
|
|
|
36
36
|
def __init__(self, username: str = None, password: str = None, tenant: str = None, server: str = None,
|
|
37
|
-
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
38
|
-
|
|
37
|
+
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
38
|
+
protocol: str = "https", request_hook: Callable = None):
|
|
39
|
+
|
|
40
|
+
super().__init__(username, password, tenant, server, use_shared_secret, two_fa_secret_key,
|
|
41
|
+
protocol, request_hook)
|
|
42
|
+
|
|
39
43
|
xml.etree.ElementTree.register_namespace("oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/")
|
|
40
44
|
xml.etree.ElementTree.register_namespace("ead", "urn:isbn:1-931666-22-9")
|
|
41
45
|
|
|
@@ -10,14 +10,19 @@ licence: Apache License 2.0
|
|
|
10
10
|
"""
|
|
11
11
|
import json
|
|
12
12
|
import xml.etree.ElementTree
|
|
13
|
+
from typing import Callable
|
|
13
14
|
|
|
14
15
|
from pyPreservica.common import *
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class MDFormsAPI(AuthenticatedAPI):
|
|
18
19
|
def __init__(self, username: str = None, password: str = None, tenant: str = None, server: str = None,
|
|
19
|
-
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
20
|
-
|
|
20
|
+
use_shared_secret: bool = False, two_fa_secret_key: str = None,
|
|
21
|
+
protocol: str = "https", request_hook: Callable = None):
|
|
22
|
+
|
|
23
|
+
super().__init__(username, password, tenant, server, use_shared_secret, two_fa_secret_key,
|
|
24
|
+
protocol, request_hook)
|
|
25
|
+
|
|
21
26
|
xml.etree.ElementTree.register_namespace("oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/")
|
|
22
27
|
xml.etree.ElementTree.register_namespace("ead", "urn:isbn:1-931666-22-9")
|
|
23
28
|
|
|
@@ -11,7 +11,7 @@ licence: Apache License 2.0
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
import xml.etree.ElementTree
|
|
14
|
-
from typing import Set
|
|
14
|
+
from typing import Set, Callable
|
|
15
15
|
|
|
16
16
|
from pyPreservica.common import *
|
|
17
17
|
|
|
@@ -59,8 +59,10 @@ class RetentionPolicy:
|
|
|
59
59
|
class RetentionAPI(AuthenticatedAPI):
|
|
60
60
|
|
|
61
61
|
def __init__(self, username=None, password=None, tenant=None, server=None, use_shared_secret=False,
|
|
62
|
-
two_fa_secret_key: str = None, protocol: str = "https"):
|
|
63
|
-
|
|
62
|
+
two_fa_secret_key: str = None, protocol: str = "https", request_hook: Callable = None):
|
|
63
|
+
|
|
64
|
+
super().__init__(username, password, tenant, server, use_shared_secret, two_fa_secret_key,
|
|
65
|
+
protocol, request_hook)
|
|
64
66
|
if self.major_version < 7 and self.minor_version < 2:
|
|
65
67
|
raise RuntimeError("Retention API is only available when connected to a v6.2 System")
|
|
66
68
|
|