Ayon-Python-Api 0.4.0__tar.gz → 0.4.2__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.
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/PKG-INFO +1 -1
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/_api.py +2 -2
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/graphql_queries.py +4 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/server_api.py +42 -24
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/utils.py +28 -6
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/version.py +1 -1
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/PKG-INFO +1 -1
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/pyproject.toml +1 -1
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/LICENSE +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/README.md +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/__init__.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/constants.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/entity_hub.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/events.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/exceptions.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/graphql.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_api/operations.py +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/SOURCES.txt +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/dependency_links.txt +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/requires.txt +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/top_level.txt +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/setup.cfg +0 -0
- {ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/setup.py +0 -0
|
@@ -753,12 +753,12 @@ def get_secrets(*args, **kwargs):
|
|
|
753
753
|
|
|
754
754
|
def get_secret(*args, **kwargs):
|
|
755
755
|
con = get_server_api_connection()
|
|
756
|
-
return con.
|
|
756
|
+
return con.get_secret(*args, **kwargs)
|
|
757
757
|
|
|
758
758
|
|
|
759
759
|
def save_secret(*args, **kwargs):
|
|
760
760
|
con = get_server_api_connection()
|
|
761
|
-
return con.
|
|
761
|
+
return con.save_secret(*args, **kwargs)
|
|
762
762
|
|
|
763
763
|
|
|
764
764
|
def delete_secret(*args, **kwargs):
|
|
@@ -175,6 +175,8 @@ def folders_graphql_query(fields):
|
|
|
175
175
|
parent_folder_ids_var = query.add_variable("parentFolderIds", "[String!]")
|
|
176
176
|
folder_paths_var = query.add_variable("folderPaths", "[String!]")
|
|
177
177
|
folder_names_var = query.add_variable("folderNames", "[String!]")
|
|
178
|
+
folder_types_var = query.add_variable("folderTypes", "[String!]")
|
|
179
|
+
statuses_var = query.add_variable("folderStatuses", "[String!]")
|
|
178
180
|
has_products_var = query.add_variable("folderHasProducts", "Boolean!")
|
|
179
181
|
|
|
180
182
|
project_field = query.add_field("project")
|
|
@@ -185,6 +187,8 @@ def folders_graphql_query(fields):
|
|
|
185
187
|
folders_field.set_filter("parentIds", parent_folder_ids_var)
|
|
186
188
|
folders_field.set_filter("names", folder_names_var)
|
|
187
189
|
folders_field.set_filter("paths", folder_paths_var)
|
|
190
|
+
folders_field.set_filter("folderTypes", folder_types_var)
|
|
191
|
+
folders_field.set_filter("statuses", statuses_var)
|
|
188
192
|
folders_field.set_filter("hasProducts", has_products_var)
|
|
189
193
|
|
|
190
194
|
nested_fields = fields_to_dict(fields)
|
|
@@ -75,6 +75,7 @@ from .utils import (
|
|
|
75
75
|
TransferProgress,
|
|
76
76
|
create_dependency_package_basename,
|
|
77
77
|
ThumbnailContent,
|
|
78
|
+
get_default_timeout,
|
|
78
79
|
)
|
|
79
80
|
|
|
80
81
|
PatternType = type(re.compile(""))
|
|
@@ -351,7 +352,6 @@ class ServerAPI(object):
|
|
|
351
352
|
timeout (Optional[float]): Timeout for requests.
|
|
352
353
|
max_retries (Optional[int]): Number of retries for requests.
|
|
353
354
|
"""
|
|
354
|
-
_default_timeout = 10.0
|
|
355
355
|
_default_max_retries = 3
|
|
356
356
|
|
|
357
357
|
def __init__(
|
|
@@ -385,8 +385,12 @@ class ServerAPI(object):
|
|
|
385
385
|
)
|
|
386
386
|
self._sender = sender
|
|
387
387
|
|
|
388
|
-
self._timeout =
|
|
389
|
-
self._max_retries =
|
|
388
|
+
self._timeout = None
|
|
389
|
+
self._max_retries = None
|
|
390
|
+
|
|
391
|
+
# Set timeout and max retries based on passed values
|
|
392
|
+
self.set_timeout(timeout)
|
|
393
|
+
self.set_max_retries(max_retries)
|
|
390
394
|
|
|
391
395
|
if ssl_verify is None:
|
|
392
396
|
# Custom AYON env variable for CA file or 'True'
|
|
@@ -496,20 +500,13 @@ class ServerAPI(object):
|
|
|
496
500
|
def get_default_timeout(cls):
|
|
497
501
|
"""Default value for requests timeout.
|
|
498
502
|
|
|
499
|
-
|
|
500
|
-
can affect timeout value. If not available then use class
|
|
501
|
-
attribute '_default_timeout'.
|
|
503
|
+
Utils function 'get_default_timeout' is used by default.
|
|
502
504
|
|
|
503
505
|
Returns:
|
|
504
506
|
float: Timeout value in seconds.
|
|
505
507
|
"""
|
|
506
508
|
|
|
507
|
-
|
|
508
|
-
return float(os.environ.get(SERVER_TIMEOUT_ENV_KEY))
|
|
509
|
-
except (ValueError, TypeError):
|
|
510
|
-
pass
|
|
511
|
-
|
|
512
|
-
return cls._default_timeout
|
|
509
|
+
return get_default_timeout()
|
|
513
510
|
|
|
514
511
|
@classmethod
|
|
515
512
|
def get_default_max_retries(cls):
|
|
@@ -3511,7 +3508,9 @@ class ServerAPI(object):
|
|
|
3511
3508
|
folder_ids=None,
|
|
3512
3509
|
folder_paths=None,
|
|
3513
3510
|
folder_names=None,
|
|
3511
|
+
folder_types=None,
|
|
3514
3512
|
parent_ids=None,
|
|
3513
|
+
statuses=None,
|
|
3515
3514
|
active=True,
|
|
3516
3515
|
fields=None,
|
|
3517
3516
|
own_attributes=False
|
|
@@ -3532,8 +3531,12 @@ class ServerAPI(object):
|
|
|
3532
3531
|
for filtering.
|
|
3533
3532
|
folder_names (Optional[Iterable[str]]): Folder names used
|
|
3534
3533
|
for filtering.
|
|
3534
|
+
folder_types (Optional[Iterable[str]]): Folder types used
|
|
3535
|
+
for filtering.
|
|
3535
3536
|
parent_ids (Optional[Iterable[str]]): Ids of folder parents.
|
|
3536
3537
|
Use 'None' if folder is direct child of project.
|
|
3538
|
+
statuses (Optional[Iterable[str]]): Folder statuses used
|
|
3539
|
+
for filtering.
|
|
3537
3540
|
active (Optional[bool]): Filter active/inactive folders.
|
|
3538
3541
|
Both are returned if is set to None.
|
|
3539
3542
|
fields (Optional[Iterable[str]]): Fields to be queried for
|
|
@@ -3570,6 +3573,18 @@ class ServerAPI(object):
|
|
|
3570
3573
|
return
|
|
3571
3574
|
filters["folderNames"] = list(folder_names)
|
|
3572
3575
|
|
|
3576
|
+
if folder_types is not None:
|
|
3577
|
+
folder_types = set(folder_types)
|
|
3578
|
+
if not folder_types:
|
|
3579
|
+
return
|
|
3580
|
+
filters["folderTypes"] = list(folder_types)
|
|
3581
|
+
|
|
3582
|
+
if statuses is not None:
|
|
3583
|
+
statuses = set(statuses)
|
|
3584
|
+
if not statuses:
|
|
3585
|
+
return
|
|
3586
|
+
filters["folderStatuses"] = list(statuses)
|
|
3587
|
+
|
|
3573
3588
|
if parent_ids is not None:
|
|
3574
3589
|
parent_ids = set(parent_ids)
|
|
3575
3590
|
if not parent_ids:
|
|
@@ -5841,19 +5856,22 @@ class ServerAPI(object):
|
|
|
5841
5856
|
"""Helper method to get links from server for entity types.
|
|
5842
5857
|
|
|
5843
5858
|
Example output:
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5859
|
+
{
|
|
5860
|
+
"59a212c0d2e211eda0e20242ac120001": [
|
|
5861
|
+
{
|
|
5862
|
+
"id": "59a212c0d2e211eda0e20242ac120002",
|
|
5863
|
+
"linkType": "reference",
|
|
5864
|
+
"description": "reference link between folders",
|
|
5865
|
+
"projectName": "my_project",
|
|
5866
|
+
"author": "frantadmin",
|
|
5867
|
+
"entityId": "b1df109676db11ed8e8c6c9466b19aa8",
|
|
5868
|
+
"entityType": "folder",
|
|
5869
|
+
"direction": "out"
|
|
5870
|
+
},
|
|
5871
|
+
...
|
|
5872
|
+
],
|
|
5855
5873
|
...
|
|
5856
|
-
|
|
5874
|
+
}
|
|
5857
5875
|
|
|
5858
5876
|
Args:
|
|
5859
5877
|
project_name (str): Project where links are.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import os
|
|
1
2
|
import re
|
|
2
3
|
import datetime
|
|
3
4
|
import uuid
|
|
@@ -15,6 +16,7 @@ except ImportError:
|
|
|
15
16
|
import requests
|
|
16
17
|
import unidecode
|
|
17
18
|
|
|
19
|
+
from .constants import SERVER_TIMEOUT_ENV_KEY
|
|
18
20
|
from .exceptions import UrlError
|
|
19
21
|
|
|
20
22
|
REMOVED_VALUE = object()
|
|
@@ -27,6 +29,23 @@ RepresentationParents = collections.namedtuple(
|
|
|
27
29
|
)
|
|
28
30
|
|
|
29
31
|
|
|
32
|
+
def get_default_timeout():
|
|
33
|
+
"""Default value for requests timeout.
|
|
34
|
+
|
|
35
|
+
First looks for environment variable SERVER_TIMEOUT_ENV_KEY which
|
|
36
|
+
can affect timeout value. If not available then use 10.0 s.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
float: Timeout value in seconds.
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
return float(os.environ.get(SERVER_TIMEOUT_ENV_KEY))
|
|
44
|
+
except (ValueError, TypeError):
|
|
45
|
+
pass
|
|
46
|
+
return 10.0
|
|
47
|
+
|
|
48
|
+
|
|
30
49
|
class ThumbnailContent:
|
|
31
50
|
"""Wrapper for thumbnail content.
|
|
32
51
|
|
|
@@ -231,11 +250,13 @@ def _try_parse_url(url):
|
|
|
231
250
|
return None
|
|
232
251
|
|
|
233
252
|
|
|
234
|
-
def _try_connect_to_server(url):
|
|
253
|
+
def _try_connect_to_server(url, timeout=None):
|
|
254
|
+
if timeout is None:
|
|
255
|
+
timeout = get_default_timeout()
|
|
235
256
|
try:
|
|
236
257
|
# TODO add validation if the url lead to Ayon server
|
|
237
|
-
# -
|
|
238
|
-
requests.get(url)
|
|
258
|
+
# - this won't validate if the url lead to 'google.com'
|
|
259
|
+
requests.get(url, timeout=timeout)
|
|
239
260
|
|
|
240
261
|
except BaseException:
|
|
241
262
|
return False
|
|
@@ -313,7 +334,7 @@ def is_token_valid(url, token):
|
|
|
313
334
|
return response.status_code == 200
|
|
314
335
|
|
|
315
336
|
|
|
316
|
-
def validate_url(url):
|
|
337
|
+
def validate_url(url, timeout=None):
|
|
317
338
|
"""Validate url if is valid and server is available.
|
|
318
339
|
|
|
319
340
|
Validation checks if can be parsed as url and contains scheme.
|
|
@@ -334,6 +355,7 @@ def validate_url(url):
|
|
|
334
355
|
|
|
335
356
|
Args:
|
|
336
357
|
url (str): Server url.
|
|
358
|
+
timeout (Optional[int]): Timeout in seconds for connection to server.
|
|
337
359
|
|
|
338
360
|
Returns:
|
|
339
361
|
Url which was used to connect to server.
|
|
@@ -369,10 +391,10 @@ def validate_url(url):
|
|
|
369
391
|
# - this will trigger UrlError if both will crash
|
|
370
392
|
if not parsed_url.scheme:
|
|
371
393
|
new_url = "https://" + modified_url
|
|
372
|
-
if _try_connect_to_server(new_url):
|
|
394
|
+
if _try_connect_to_server(new_url, timeout=timeout):
|
|
373
395
|
return new_url
|
|
374
396
|
|
|
375
|
-
if _try_connect_to_server(modified_url):
|
|
397
|
+
if _try_connect_to_server(modified_url, timeout=timeout):
|
|
376
398
|
return modified_url
|
|
377
399
|
|
|
378
400
|
hints = []
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Package declaring Python API for Ayon server."""
|
|
2
|
-
__version__ = "0.4.
|
|
2
|
+
__version__ = "0.4.2"
|
|
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
|
{ayon-python-api-0.4.0 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|