pyPreservica 2.9.1__tar.gz → 2.9.3__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.9.1 → pypreservica-2.9.3}/PKG-INFO +1 -1
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/__init__.py +1 -1
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/common.py +3 -3
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/contentAPI.py +4 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/entityAPI.py +3 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/mdformsAPI.py +127 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica.egg-info/PKG-INFO +1 -1
- {pypreservica-2.9.1 → pypreservica-2.9.3}/setup.py +1 -1
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_workflow.py +2 -2
- {pypreservica-2.9.1 → pypreservica-2.9.3}/LICENSE.txt +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/README.md +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/adminAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/authorityAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/monitorAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/opex.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/parAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/retentionAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/uploadAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/webHooksAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica/workflowAPI.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica.egg-info/SOURCES.txt +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica.egg-info/dependency_links.txt +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica.egg-info/requires.txt +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/pyPreservica.egg-info/top_level.txt +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/setup.cfg +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_authority_records.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_bitstream.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_children.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_content_api.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_crawl_fs.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_delete.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_download.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_entity.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_export_opex.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_groups.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_identifier.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_ingest.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_integrity_check.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_metadata.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_par.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_replace.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_retention.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_schema.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_security.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_thumbnail.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_upload.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_users.py +0 -0
- {pypreservica-2.9.1 → pypreservica-2.9.3}/tests/test_xml_metadata.py +0 -0
|
@@ -23,6 +23,6 @@ from .mdformsAPI import MetadataGroupsAPI, Group, GroupField, GroupFieldType
|
|
|
23
23
|
__author__ = "James Carr (drjamescarr@gmail.com)"
|
|
24
24
|
|
|
25
25
|
# Version of the pyPreservica package
|
|
26
|
-
__version__ = "2.9.
|
|
26
|
+
__version__ = "2.9.3"
|
|
27
27
|
|
|
28
28
|
__license__ = "Apache License Version 2.0"
|
|
@@ -79,9 +79,9 @@ class FileHash:
|
|
|
79
79
|
|
|
80
80
|
def identifiersToDict(identifiers: set) -> dict:
|
|
81
81
|
"""
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
Convert a set of tuples to a dict
|
|
83
|
+
:param identifiers:
|
|
84
|
+
:return:
|
|
85
85
|
"""
|
|
86
86
|
result = {}
|
|
87
87
|
for identifier_tuple in identifiers:
|
|
@@ -238,6 +238,10 @@ class ContentAPI(AuthenticatedAPI):
|
|
|
238
238
|
:param page_size: The default search page size
|
|
239
239
|
:return: search result
|
|
240
240
|
"""
|
|
241
|
+
|
|
242
|
+
if self.major_version < 7 and self.minor_version < 5:
|
|
243
|
+
raise RuntimeError("search_fields API call is not available when connected to a v7.5 System")
|
|
244
|
+
|
|
241
245
|
search_result = self._search_fields(query=query, fields=fields, start_index=0, page_size=page_size)
|
|
242
246
|
for e in search_result.results_list:
|
|
243
247
|
yield e
|
|
@@ -454,6 +454,7 @@ class EntityAPI(AuthenticatedAPI):
|
|
|
454
454
|
logger.error(request)
|
|
455
455
|
raise RuntimeError(request.status_code, "delete_identifier failed")
|
|
456
456
|
|
|
457
|
+
|
|
457
458
|
def identifiers_for_entity(self, entity: Entity) -> set[Tuple]:
|
|
458
459
|
"""
|
|
459
460
|
Get all external identifiers on an entity
|
|
@@ -491,6 +492,8 @@ class EntityAPI(AuthenticatedAPI):
|
|
|
491
492
|
logger.error(exception)
|
|
492
493
|
raise exception
|
|
493
494
|
|
|
495
|
+
|
|
496
|
+
|
|
494
497
|
def identifier(self, identifier_type: str, identifier_value: str) -> set[Entity]:
|
|
495
498
|
"""
|
|
496
499
|
Get all entities which have the external identifier
|
|
@@ -8,6 +8,7 @@ author: James Carr
|
|
|
8
8
|
licence: Apache License 2.0
|
|
9
9
|
|
|
10
10
|
"""
|
|
11
|
+
import json
|
|
11
12
|
import xml.etree.ElementTree
|
|
12
13
|
from typing import Callable, List, Union, Generator
|
|
13
14
|
|
|
@@ -247,6 +248,75 @@ class MetadataGroupsAPI(AuthenticatedAPI):
|
|
|
247
248
|
json_response: dict = self.add_group_json(json_document)
|
|
248
249
|
return json_response
|
|
249
250
|
|
|
251
|
+
def add_form(self, json_form: Union[dict, str]):
|
|
252
|
+
"""
|
|
253
|
+
Create a new Metadata fORM using a JSON dictionary object or document
|
|
254
|
+
|
|
255
|
+
:param json_form: JSON dictionary or string
|
|
256
|
+
:type json_form: dict
|
|
257
|
+
|
|
258
|
+
:return: JSON document
|
|
259
|
+
:rtype: dict
|
|
260
|
+
|
|
261
|
+
"""
|
|
262
|
+
headers = {HEADER_TOKEN: self.token, 'Content-Type': 'application/json;charset=UTF-8'}
|
|
263
|
+
url = f'{self.protocol}://{self.server}/api/metadata/forms/'
|
|
264
|
+
|
|
265
|
+
if isinstance(json_form, dict):
|
|
266
|
+
with self.session.post(url, headers=headers, json=json_form) as request:
|
|
267
|
+
if request.status_code == requests.codes.unauthorized:
|
|
268
|
+
self.token = self.__token__()
|
|
269
|
+
return self.add_form_json(json_form)
|
|
270
|
+
elif request.status_code == requests.codes.created:
|
|
271
|
+
return json.loads(str(request.content.decode('utf-8')))
|
|
272
|
+
else:
|
|
273
|
+
exception = HTTPException(None, request.status_code, request.url, "add_form_json",
|
|
274
|
+
request.content.decode('utf-8'))
|
|
275
|
+
logger.error(exception)
|
|
276
|
+
raise exception
|
|
277
|
+
|
|
278
|
+
elif isinstance(json_form, str):
|
|
279
|
+
with self.session.post(url, headers=headers, data=json_form) as request:
|
|
280
|
+
if request.status_code == requests.codes.unauthorized:
|
|
281
|
+
self.token = self.__token__()
|
|
282
|
+
return self.add_form_json(json_form)
|
|
283
|
+
elif request.status_code == requests.codes.created:
|
|
284
|
+
return json.loads(str(request.content.decode('utf-8')))
|
|
285
|
+
else:
|
|
286
|
+
exception = HTTPException(None, request.status_code, request.url, "add_form_json",
|
|
287
|
+
request.content.decode('utf-8'))
|
|
288
|
+
logger.error(exception)
|
|
289
|
+
raise exception
|
|
290
|
+
else:
|
|
291
|
+
raise RuntimeError("Argument must be a JSON dictionary or a JSON str")
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
# def set_default_form(self, form_id: str):
|
|
295
|
+
# """
|
|
296
|
+
# Set the default form
|
|
297
|
+
#
|
|
298
|
+
# """
|
|
299
|
+
#
|
|
300
|
+
# headers = {HEADER_TOKEN: self.token, 'Content-Type': 'application/json;charset=UTF-8'}
|
|
301
|
+
# url = f'{self.protocol}://{self.server}/api/metadata/forms/{form_id}/default'
|
|
302
|
+
#
|
|
303
|
+
# payload: dict = {"default": True, "useAsDefault": True}
|
|
304
|
+
#
|
|
305
|
+
# with self.session.get(url, headers=headers, json=json.dumps(payload)) as request:
|
|
306
|
+
# if request.status_code == requests.codes.unauthorized:
|
|
307
|
+
# self.token = self.__token__()
|
|
308
|
+
# return self.set_default_form(form_id)
|
|
309
|
+
# elif request.status_code == requests.codes.ok:
|
|
310
|
+
# return json.loads(str(request.content.decode('utf-8')))
|
|
311
|
+
# else:
|
|
312
|
+
# exception = HTTPException(None, request.status_code, request.url, "set_default_form",
|
|
313
|
+
# request.content.decode('utf-8'))
|
|
314
|
+
# logger.error(exception)
|
|
315
|
+
# raise exception
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
250
320
|
def add_group_json(self, json_object: Union[dict, str]) -> dict:
|
|
251
321
|
"""
|
|
252
322
|
Create a new Metadata Group using a JSON dictionary object or document
|
|
@@ -351,6 +421,63 @@ class MetadataGroupsAPI(AuthenticatedAPI):
|
|
|
351
421
|
logger.error(exception)
|
|
352
422
|
raise exception
|
|
353
423
|
|
|
424
|
+
def forms(self, schema_uri: Union[str, None] = None) -> dict:
|
|
425
|
+
"""
|
|
426
|
+
Return all the metadata Forms in the tenancy as a list of JSON dict objects
|
|
427
|
+
|
|
428
|
+
:param schema_uri: The Form schema Uri
|
|
429
|
+
:type schema_uri: str
|
|
430
|
+
|
|
431
|
+
:return: List of JSON dictionary object
|
|
432
|
+
:rtype: dict
|
|
433
|
+
|
|
434
|
+
"""
|
|
435
|
+
|
|
436
|
+
headers = {HEADER_TOKEN: self.token, 'Content-Type': 'application/json;charset=UTF-8'}
|
|
437
|
+
url = f'{self.protocol}://{self.server}/api/metadata/forms'
|
|
438
|
+
params = {}
|
|
439
|
+
if schema_uri is not None:
|
|
440
|
+
params = {'schemaUri': schema_uri}
|
|
441
|
+
with self.session.get(url, headers=headers, params=params) as request:
|
|
442
|
+
if request.status_code == requests.codes.unauthorized:
|
|
443
|
+
self.token = self.__token__()
|
|
444
|
+
return self.forms()
|
|
445
|
+
elif request.status_code == requests.codes.ok:
|
|
446
|
+
return json.loads(str(request.content.decode('utf-8')))['metadataForms']
|
|
447
|
+
else:
|
|
448
|
+
exception = HTTPException(None, request.status_code, request.url, "forms_json",
|
|
449
|
+
request.content.decode('utf-8'))
|
|
450
|
+
logger.error(exception)
|
|
451
|
+
raise exception
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
def form(self, form_id: str) -> dict:
|
|
455
|
+
"""
|
|
456
|
+
Return a Form as a JSON dict object
|
|
457
|
+
|
|
458
|
+
:param form_id: The Form id
|
|
459
|
+
:type form_id: str
|
|
460
|
+
|
|
461
|
+
:return: JSON document
|
|
462
|
+
:rtype: dict
|
|
463
|
+
|
|
464
|
+
"""
|
|
465
|
+
headers = {HEADER_TOKEN: self.token, 'Content-Type': 'application/json;charset=UTF-8'}
|
|
466
|
+
url = f'{self.protocol}://{self.server}/api/metadata/forms/{form_id}'
|
|
467
|
+
with self.session.get(url, headers=headers) as request:
|
|
468
|
+
if request.status_code == requests.codes.unauthorized:
|
|
469
|
+
self.token = self.__token__()
|
|
470
|
+
return self.form(form_id)
|
|
471
|
+
elif request.status_code == requests.codes.ok:
|
|
472
|
+
return json.loads(str(request.content.decode('utf-8')))
|
|
473
|
+
else:
|
|
474
|
+
exception = HTTPException(None, request.status_code, request.url, "form_json",
|
|
475
|
+
request.content.decode('utf-8'))
|
|
476
|
+
logger.error(exception)
|
|
477
|
+
raise exception
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
354
481
|
def groups(self) -> Generator[Group, None, None]:
|
|
355
482
|
"""
|
|
356
483
|
Return all the metadata Groups in the tenancy as Group Objects
|
|
@@ -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="2.9.
|
|
24
|
+
version="2.9.3",
|
|
25
25
|
description="Python library for the Preservica API",
|
|
26
26
|
long_description=README,
|
|
27
27
|
long_description_content_type="text/markdown",
|
|
@@ -11,7 +11,7 @@ def test_get_workflow_contexts():
|
|
|
11
11
|
def test_get_workflow_contexts2():
|
|
12
12
|
workflow = WorkflowAPI()
|
|
13
13
|
workflows = workflow.get_workflow_contexts("com.preservica.core.workflow.ingest")
|
|
14
|
-
assert len(workflows) ==
|
|
14
|
+
assert len(workflows) == 3
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
def test_get_workflow_contexts3():
|
|
@@ -24,7 +24,7 @@ def test_get_workflow_contexts_type():
|
|
|
24
24
|
workflow = WorkflowAPI()
|
|
25
25
|
|
|
26
26
|
workflows = workflow.get_workflow_contexts_by_type("Ingest")
|
|
27
|
-
assert len(workflows) ==
|
|
27
|
+
assert len(workflows) == 8
|
|
28
28
|
|
|
29
29
|
workflows = workflow.get_workflow_contexts_by_type("Access")
|
|
30
30
|
assert len(workflows) == 5
|
|
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
|