pyPreservica 3.2.3__tar.gz → 3.2.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.
Potentially problematic release.
This version of pyPreservica might be problematic. Click here for more details.
- {pypreservica-3.2.3 → pypreservica-3.2.4}/PKG-INFO +1 -1
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/__init__.py +1 -1
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/common.py +0 -2
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/entityAPI.py +1 -1
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/uploadAPI.py +46 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica.egg-info/PKG-INFO +1 -1
- {pypreservica-3.2.3 → pypreservica-3.2.4}/setup.py +1 -1
- {pypreservica-3.2.3 → pypreservica-3.2.4}/LICENSE.txt +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/README.md +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/adminAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/authorityAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/contentAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/mdformsAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/monitorAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/opex.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/parAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/retentionAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/settingsAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/webHooksAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica/workflowAPI.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica.egg-info/SOURCES.txt +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica.egg-info/dependency_links.txt +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica.egg-info/requires.txt +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/pyPreservica.egg-info/top_level.txt +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/setup.cfg +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_authority_records.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_bitstream.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_children.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_content_api.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_crawl_fs.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_delete.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_download.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_entity.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_export_opex.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_groups.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_identifier.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_ingest.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_integrity_check.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_metadata.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_par.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_replace.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_retention.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_schema.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_security.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_settings.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_thumbnail.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_upload.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_users.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_workflow.py +0 -0
- {pypreservica-3.2.3 → pypreservica-3.2.4}/tests/test_xml_metadata.py +0 -0
|
@@ -822,8 +822,6 @@ class AuthenticatedAPI:
|
|
|
822
822
|
self.minor_version = int(version_numbers[1])
|
|
823
823
|
self.patch_version = int(version_numbers[2])
|
|
824
824
|
|
|
825
|
-
if self.server == "preview.preservica.com":
|
|
826
|
-
self.minor_version = 1
|
|
827
825
|
|
|
828
826
|
return version
|
|
829
827
|
elif request.status_code == requests.codes.unauthorized:
|
|
@@ -1044,7 +1044,6 @@ class EntityAPI(AuthenticatedAPI):
|
|
|
1044
1044
|
xml_request = xml.etree.ElementTree.tostring(xml_object, encoding='utf-8')
|
|
1045
1045
|
end_point = f"/{entity.path}/{entity.reference}/metadata"
|
|
1046
1046
|
logger.debug(xml_request)
|
|
1047
|
-
print(xml_request)
|
|
1048
1047
|
request = self.session.post(f'{self.protocol}://{self.server}/api/entity{end_point}', data=xml_request,
|
|
1049
1048
|
headers=headers)
|
|
1050
1049
|
if request.status_code == requests.codes.ok:
|
|
@@ -2648,3 +2647,4 @@ class EntityAPI(AuthenticatedAPI):
|
|
|
2648
2647
|
"_delete_entity", request.content.decode('utf-8'))
|
|
2649
2648
|
logger.error(exception)
|
|
2650
2649
|
raise exception
|
|
2650
|
+
|
|
@@ -1633,6 +1633,52 @@ class UploadAPI(AuthenticatedAPI):
|
|
|
1633
1633
|
logger.error(exception)
|
|
1634
1634
|
raise exception
|
|
1635
1635
|
|
|
1636
|
+
def clean_upload_bucket(self, bucket_name: str, older_than_days: int = 90):
|
|
1637
|
+
"""
|
|
1638
|
+
Clean up objects in an upload bucket which are older than older_than_days.
|
|
1639
|
+
|
|
1640
|
+
"""
|
|
1641
|
+
from azure.storage.blob import ContainerClient
|
|
1642
|
+
|
|
1643
|
+
for location in self.upload_locations():
|
|
1644
|
+
if location['containerName'] == bucket_name:
|
|
1645
|
+
|
|
1646
|
+
if location['type'] != 'AWS':
|
|
1647
|
+
credentials = self.upload_credentials(location['apiId'])
|
|
1648
|
+
account_key = credentials['key']
|
|
1649
|
+
session_token = credentials['sessionToken']
|
|
1650
|
+
sas_url = f"https://{account_key}.blob.core.windows.net/{bucket_name}"
|
|
1651
|
+
container = ContainerClient.from_container_url(container_url=sas_url, credential=session_token)
|
|
1652
|
+
now = datetime.now(timezone.utc)
|
|
1653
|
+
for blob in container.list_blobs():
|
|
1654
|
+
if abs((blob.last_modified - now).days) > older_than_days:
|
|
1655
|
+
logger.debug(f"Deleting expired object {blob.name}")
|
|
1656
|
+
container.delete_blob(blob.name)
|
|
1657
|
+
|
|
1658
|
+
if location['type'] == 'AWS':
|
|
1659
|
+
credentials = self.upload_credentials(location['apiId'])
|
|
1660
|
+
access_key = credentials['key']
|
|
1661
|
+
secret_key = credentials['secret']
|
|
1662
|
+
session_token = credentials['sessionToken']
|
|
1663
|
+
session = boto3.Session(aws_access_key_id=access_key, aws_secret_access_key=secret_key,
|
|
1664
|
+
aws_session_token=session_token)
|
|
1665
|
+
s3_client = session.client("s3")
|
|
1666
|
+
paginator = s3_client.get_paginator('list_objects_v2')
|
|
1667
|
+
now = datetime.now(timezone.utc)
|
|
1668
|
+
for page in paginator.paginate(Bucket=bucket_name):
|
|
1669
|
+
if 'Contents' in page:
|
|
1670
|
+
for key in page['Contents']:
|
|
1671
|
+
last_modified = key["LastModified"]
|
|
1672
|
+
if abs((last_modified - now).days) > older_than_days:
|
|
1673
|
+
logger.debug(f"Deleting expired object {key["Key"]}")
|
|
1674
|
+
s3_client.delete_object(Bucket=bucket_name, Key=key["Key"])
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
|
|
1636
1682
|
def upload_locations(self):
|
|
1637
1683
|
"""
|
|
1638
1684
|
Upload locations are configured on the Sources page as 'SIP Upload'.
|
|
@@ -21,7 +21,7 @@ if sys.argv[-1] == 'publish':
|
|
|
21
21
|
# This call to setup() does all the work
|
|
22
22
|
setup(
|
|
23
23
|
name=PKG,
|
|
24
|
-
version="3.2.
|
|
24
|
+
version="3.2.4",
|
|
25
25
|
description="Python library for the Preservica API",
|
|
26
26
|
long_description=README,
|
|
27
27
|
long_description_content_type="text/markdown",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|