accsyn-python-api 3.2.3__tar.gz → 3.3.1__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.
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/PKG-INFO +2 -2
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/README.md +1 -1
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/pyproject.toml +1 -1
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/source/accsyn_api/_version.py +1 -1
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/source/accsyn_api/session.py +117 -33
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/source/accsyn_api/__init__.py +0 -0
- {accsyn_python_api-3.2.3 → accsyn_python_api-3.3.1}/source/accsyn_api/_devtools.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: accsyn-python-api
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.1
|
|
4
4
|
Summary: A Python API for accsyn programmable fast and secure data delivery software
|
|
5
5
|
Home-page: https://accsyn.com
|
|
6
6
|
License: Apache-2.0
|
|
@@ -31,7 +31,7 @@ Description-Content-Type: text/markdown
|
|
|
31
31
|
# accsyn-python-api
|
|
32
32
|
Official accsyn fast and secure file delivery Python API
|
|
33
33
|
|
|
34
|
-
Python API support can be found [here](https://support.accsyn.com/
|
|
34
|
+
Python API support can be found [here](https://support.accsyn.com/developer/python-api).
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
Changelog:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# accsyn-python-api
|
|
2
2
|
Official accsyn fast and secure file delivery Python API
|
|
3
3
|
|
|
4
|
-
Python API support can be found [here](https://support.accsyn.com/
|
|
4
|
+
Python API support can be found [here](https://support.accsyn.com/developer/python-api).
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Changelog:
|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "accsyn-python-api"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.3.1"
|
|
8
8
|
description = "A Python API for accsyn programmable fast and secure data delivery software"
|
|
9
9
|
authors = ["Henrik Norin <support@accsyn.com>"]
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -86,7 +86,7 @@ UNIQUE_ENTITY_TYPES = [
|
|
|
86
86
|
"engine",
|
|
87
87
|
"queue",
|
|
88
88
|
]
|
|
89
|
-
# Entity types were code is unique and can be used to find the entity by code
|
|
89
|
+
# Entity types were code is unique and can be used to find the entity by its API identifier (code)
|
|
90
90
|
|
|
91
91
|
|
|
92
92
|
class JSONEncoder(json.JSONEncoder):
|
|
@@ -124,26 +124,27 @@ class JSONDecoder(json.JSONDecoder):
|
|
|
124
124
|
newlist.append(recursive_decode(i))
|
|
125
125
|
d[key] = newlist
|
|
126
126
|
elif Session._is_str(d[key]):
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
dt = None
|
|
128
|
+
if d[key].startswith("ObjectId:"):
|
|
129
|
+
d[key] = d[key].replace("ObjectId:", "") # Just treat as string
|
|
130
|
+
elif re.match(
|
|
131
|
+
"^[0-9]{2,4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$",
|
|
129
132
|
str(Session._safely_printable(d[key])),
|
|
130
133
|
):
|
|
131
134
|
if len(d[key].split("-")[0]) == 4:
|
|
132
135
|
dt = datetime.datetime.strptime(d[key], "%Y-%m-%dT%H:%M:%S")
|
|
133
136
|
else:
|
|
134
137
|
dt = datetime.datetime.strptime(d[key], "%y-%m-%dT%H:%M:%S")
|
|
135
|
-
# Backend sends UTC, convert to local timezone
|
|
136
|
-
dt = dt.replace(tzinfo=datetime.timezone.utc)
|
|
137
|
-
d[key] = dt.astimezone()
|
|
138
138
|
# With millis
|
|
139
139
|
elif re.match(
|
|
140
|
-
"^[0-9]{2,4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:
|
|
140
|
+
"^[0-9]{2,4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}$",
|
|
141
141
|
str(Session._safely_printable(d[key])),
|
|
142
142
|
):
|
|
143
143
|
if len(d[key].split("-")[0]) == 4:
|
|
144
144
|
dt = datetime.datetime.strptime(d[key], "%Y-%m-%dT%H:%M:%S.%f")
|
|
145
145
|
else:
|
|
146
146
|
dt = datetime.datetime.strptime(d[key], "%y-%m-%dT%H:%M:%S.%f")
|
|
147
|
+
if dt is not None:
|
|
147
148
|
# Backend sends UTC, convert to local timezone
|
|
148
149
|
dt = dt.replace(tzinfo=datetime.timezone.utc)
|
|
149
150
|
d[key] = dt.astimezone()
|
|
@@ -394,6 +395,7 @@ class Session(object):
|
|
|
394
395
|
data: Union[str, Dict[str, Any], List[Dict[str, Any]]],
|
|
395
396
|
entityid: Optional[str] = None,
|
|
396
397
|
allow_duplicates: Optional[bool] = None,
|
|
398
|
+
replace_duplicates: Optional[bool] = None,
|
|
397
399
|
) -> Union[Dict[str, Any], List[Dict[str, Any]]]:
|
|
398
400
|
"""
|
|
399
401
|
Create a new accsyn entity.
|
|
@@ -401,7 +403,8 @@ class Session(object):
|
|
|
401
403
|
:param entitytype: The type of entity to create (job, share, acl)
|
|
402
404
|
:param data: The entity data as a dictionary.
|
|
403
405
|
:param entityid: For creating sub entities (tasks), this is the parent (job) id.
|
|
404
|
-
:param allow_duplicates: (jobs and tasks) Allow
|
|
406
|
+
:param allow_duplicates: (jobs and tasks) Allow duplicate tasks (same uri), will ignore the provided task and retry the existing task instead.
|
|
407
|
+
:param replace_duplicates: (jobs and tasks) Do not retry the existing task, replace duplicate tasks (same uri) with the new one instead.
|
|
405
408
|
:return: The created entity data, as dictionary.
|
|
406
409
|
"""
|
|
407
410
|
entitytype = (entitytype or "").lower().strip()
|
|
@@ -428,7 +431,7 @@ class Session(object):
|
|
|
428
431
|
data = dict(tasks=data)
|
|
429
432
|
if entitytype == "file":
|
|
430
433
|
uri = "add"
|
|
431
|
-
if
|
|
434
|
+
if entitytype in [
|
|
432
435
|
"transfer",
|
|
433
436
|
"compute",
|
|
434
437
|
"delivery",
|
|
@@ -437,7 +440,10 @@ class Session(object):
|
|
|
437
440
|
"job",
|
|
438
441
|
"task",
|
|
439
442
|
]:
|
|
440
|
-
|
|
443
|
+
if allow_duplicates is not None:
|
|
444
|
+
data["allow_duplicates"] = allow_duplicates
|
|
445
|
+
if replace_duplicates is not None:
|
|
446
|
+
data["replace_duplicates"] = replace_duplicates
|
|
441
447
|
d = self._event(
|
|
442
448
|
"POST",
|
|
443
449
|
f"{entitytype}/{uri}",
|
|
@@ -574,6 +580,7 @@ class Session(object):
|
|
|
574
580
|
def find_one(
|
|
575
581
|
self,
|
|
576
582
|
query: str,
|
|
583
|
+
entityid: Optional[str] = None,
|
|
577
584
|
attributes: Optional[List[str]] = None,
|
|
578
585
|
finished: Optional[bool] = None,
|
|
579
586
|
inactive: Optional[bool] = None,
|
|
@@ -584,6 +591,7 @@ class Session(object):
|
|
|
584
591
|
Return a single entity.
|
|
585
592
|
|
|
586
593
|
:param query: The query, a string on accsyn query format.
|
|
594
|
+
:param entityid: The parent entity ID, required for sub entities "task" and "file".
|
|
587
595
|
:param attributes: The attributes to return, default is to return all attributes with access.
|
|
588
596
|
:param finished: (job) Search among finished/aborted jobs.
|
|
589
597
|
:param inactive: (user,share) Search among inactive entities.
|
|
@@ -596,6 +604,7 @@ class Session(object):
|
|
|
596
604
|
), "Invalid query type supplied, must be of string type!"
|
|
597
605
|
return self.find(
|
|
598
606
|
query,
|
|
607
|
+
entityid=entityid,
|
|
599
608
|
attributes=attributes,
|
|
600
609
|
finished=finished,
|
|
601
610
|
inactive=inactive or offline,
|
|
@@ -1530,41 +1539,116 @@ class Session(object):
|
|
|
1530
1539
|
def get_setting(
|
|
1531
1540
|
self,
|
|
1532
1541
|
name: Optional[str] = None,
|
|
1533
|
-
|
|
1534
|
-
|
|
1542
|
+
entitytype: str = 'workspace',
|
|
1543
|
+
entityid: Optional[str] = None,
|
|
1535
1544
|
integration: Optional[str] = None,
|
|
1536
1545
|
data: Optional[Dict[str, Any]] = None,
|
|
1537
1546
|
) -> Optional[Any]:
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1547
|
+
"""
|
|
1548
|
+
Retrive *name* setting value for the given *entitytype* (workspace, job, volume, user, queue, ...) and
|
|
1549
|
+
*entityid* or *integration* (ftrack,..).
|
|
1550
|
+
|
|
1551
|
+
:param name: Setting name.
|
|
1552
|
+
:param entitytype: Entity type (workspace, job, volume, user, queue, ...).
|
|
1553
|
+
:param entityid: Entity ID (None for workspace entity type).
|
|
1554
|
+
:param integration: Integration name (ftrack, ..).
|
|
1555
|
+
:param data: Additional data to include in the request.
|
|
1556
|
+
:return: Setting value.
|
|
1557
|
+
"""
|
|
1558
|
+
evt_data = dict(entitytype=entitytype, name=name)
|
|
1542
1559
|
if integration:
|
|
1543
1560
|
evt_data['integration'] = integration
|
|
1544
1561
|
if evt_data:
|
|
1545
1562
|
evt_data['data'] = data
|
|
1546
|
-
response = self._event("GET", "setting", evt_data)
|
|
1563
|
+
response = self._event("GET", "setting", evt_data, entityid=entityid)
|
|
1547
1564
|
return response.get("result")
|
|
1548
1565
|
|
|
1566
|
+
def get_settings(
|
|
1567
|
+
self,
|
|
1568
|
+
entitytype: Optional[str] = None,
|
|
1569
|
+
entityid: Optional[str] = None,
|
|
1570
|
+
recursive: bool = False,
|
|
1571
|
+
upstream: bool = False,
|
|
1572
|
+
omit_defaults: bool = True,
|
|
1573
|
+
share: Optional[str] = None,
|
|
1574
|
+
) -> Dict[str, Any]:
|
|
1575
|
+
"""
|
|
1576
|
+
Return settings JSON for an entity.
|
|
1577
|
+
|
|
1578
|
+
:param entitytype: Optional entity type (workspace, job, volume, user, queue, ...), defaults to 'workspace'.
|
|
1579
|
+
:param entityid: Optional entity ID, defaults to None.
|
|
1580
|
+
:param recursive: Include recursive settings lookup (for share trees, etc).
|
|
1581
|
+
:param upstream: Include inherited/upstream/default settings.
|
|
1582
|
+
:param omit_defaults: Omit unchanged defaults from response.
|
|
1583
|
+
:param share: Optional share ID/code used by some settings lookups.
|
|
1584
|
+
:return: Settings as a JSON-compatible dictionary.
|
|
1585
|
+
"""
|
|
1586
|
+
if entitytype:
|
|
1587
|
+
entitytype = entitytype.lower().strip()
|
|
1588
|
+
payload: Dict[str, Any] = dict(
|
|
1589
|
+
entitytype=entitytype,
|
|
1590
|
+
recursive=recursive,
|
|
1591
|
+
upstream=upstream,
|
|
1592
|
+
omit_defaults=omit_defaults,
|
|
1593
|
+
)
|
|
1594
|
+
if share:
|
|
1595
|
+
payload["share"] = share
|
|
1596
|
+
response = self._event("GET", "setting", payload, entityid=entityid)
|
|
1597
|
+
return cast(Dict[str, Any], response.get("result") or {})
|
|
1598
|
+
|
|
1549
1599
|
def set_setting(
|
|
1550
1600
|
self,
|
|
1601
|
+
entitytype: str,
|
|
1551
1602
|
name: str,
|
|
1552
|
-
value:
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1603
|
+
value: any,
|
|
1604
|
+
entityid: Optional[str] = None,
|
|
1605
|
+
) -> bool:
|
|
1606
|
+
"""
|
|
1607
|
+
Set a setting for an entity.
|
|
1608
|
+
|
|
1609
|
+
.. versionchanged:: 3.2
|
|
1610
|
+
Simplified to a single signature: ``set_setting(entitytype, entityid, name, value)``.
|
|
1611
|
+
Legacy compatibility argument patterns were removed.
|
|
1612
|
+
|
|
1613
|
+
:param entitytype: Entity type (workspace, job, volume, user, queue, ...)
|
|
1614
|
+
:param name: Setting name.
|
|
1615
|
+
:param value: Setting value, must be of string type. Dictionaries are supported, but must be converted to JSON string first. Serialise dates to ISO 8601 strings.
|
|
1616
|
+
:param entityid: Optional entity ID (None for workspace entity type, otherwise required).
|
|
1617
|
+
:return: True if setting was updated.
|
|
1618
|
+
"""
|
|
1619
|
+
assert 0 < len(entitytype or "") and Session._is_str(
|
|
1620
|
+
entitytype
|
|
1621
|
+
), "Invalid entity type supplied, must be of string type!"
|
|
1622
|
+
assert 0 < len(name or "") and Session._is_str(name), "Invalid name supplied, must be of string type!"
|
|
1623
|
+
assert value is not None and isinstance(value, str), "Invalid value supplied, must be of string type!"
|
|
1624
|
+
entitytype = entitytype.lower().strip()
|
|
1625
|
+
payload: Dict[str, Any] = dict(entitytype=entitytype, name=name, value=value)
|
|
1626
|
+
response = self._event("PUT", "setting", payload, entityid=entityid)
|
|
1627
|
+
return bool(response.get("result"))
|
|
1628
|
+
|
|
1629
|
+
def delete_setting(
|
|
1630
|
+
self,
|
|
1631
|
+
entitytype: str,
|
|
1632
|
+
name: str,
|
|
1633
|
+
entityid: Optional[str] = None,
|
|
1634
|
+
) -> bool:
|
|
1635
|
+
"""
|
|
1636
|
+
Delete a setting for an entity.
|
|
1637
|
+
|
|
1638
|
+
:param entitytype: Entity type (workspace, job, volume, user, queue, ...)
|
|
1639
|
+
:param name: Setting name.
|
|
1640
|
+
:param entityid: Optional entity ID (None for workspace entity type, otherwise required).
|
|
1641
|
+
:return: True if setting was deleted.
|
|
1642
|
+
"""
|
|
1643
|
+
assert 0 < len(entitytype or "") and Session._is_str(
|
|
1644
|
+
entitytype
|
|
1645
|
+
), "Invalid entity type supplied, must be of string type!"
|
|
1646
|
+
assert 0 < len(name or "") and Session._is_str(name), "Invalid name supplied, must be of string type!"
|
|
1647
|
+
entitytype = entitytype.lower().strip()
|
|
1648
|
+
payload: Dict[str, Any] = dict(entitytype=entitytype, name=name)
|
|
1649
|
+
response = self._event("DELETE", "setting", payload, entityid=entityid)
|
|
1650
|
+
return bool(response.get("result"))
|
|
1651
|
+
|
|
1568
1652
|
|
|
1569
1653
|
# Misc
|
|
1570
1654
|
def get_api_key(self) -> str:
|
|
File without changes
|
|
File without changes
|