Ayon-Python-Api 0.4.1__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.
Files changed (23) hide show
  1. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/PKG-INFO +1 -1
  2. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/_api.py +2 -2
  3. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/graphql_queries.py +4 -0
  4. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/server_api.py +36 -22
  5. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/utils.py +28 -6
  6. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/version.py +1 -1
  7. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/PKG-INFO +1 -1
  8. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/pyproject.toml +1 -1
  9. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/LICENSE +0 -0
  10. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/README.md +0 -0
  11. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/__init__.py +0 -0
  12. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/constants.py +0 -0
  13. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/entity_hub.py +0 -0
  14. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/events.py +0 -0
  15. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/exceptions.py +0 -0
  16. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/graphql.py +0 -0
  17. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_api/operations.py +0 -0
  18. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  19. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  20. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/requires.txt +0 -0
  21. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/ayon_python_api.egg-info/top_level.txt +0 -0
  22. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/setup.cfg +0 -0
  23. {ayon-python-api-0.4.1 → ayon-python-api-0.4.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -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.delete_secret(*args, **kwargs)
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.delete_secret(*args, **kwargs)
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__(
@@ -500,20 +500,13 @@ class ServerAPI(object):
500
500
  def get_default_timeout(cls):
501
501
  """Default value for requests timeout.
502
502
 
503
- First looks for environment variable SERVER_TIMEOUT_ENV_KEY which
504
- can affect timeout value. If not available then use class
505
- attribute '_default_timeout'.
503
+ Utils function 'get_default_timeout' is used by default.
506
504
 
507
505
  Returns:
508
506
  float: Timeout value in seconds.
509
507
  """
510
508
 
511
- try:
512
- return float(os.environ.get(SERVER_TIMEOUT_ENV_KEY))
513
- except (ValueError, TypeError):
514
- pass
515
-
516
- return cls._default_timeout
509
+ return get_default_timeout()
517
510
 
518
511
  @classmethod
519
512
  def get_default_max_retries(cls):
@@ -3515,7 +3508,9 @@ class ServerAPI(object):
3515
3508
  folder_ids=None,
3516
3509
  folder_paths=None,
3517
3510
  folder_names=None,
3511
+ folder_types=None,
3518
3512
  parent_ids=None,
3513
+ statuses=None,
3519
3514
  active=True,
3520
3515
  fields=None,
3521
3516
  own_attributes=False
@@ -3536,8 +3531,12 @@ class ServerAPI(object):
3536
3531
  for filtering.
3537
3532
  folder_names (Optional[Iterable[str]]): Folder names used
3538
3533
  for filtering.
3534
+ folder_types (Optional[Iterable[str]]): Folder types used
3535
+ for filtering.
3539
3536
  parent_ids (Optional[Iterable[str]]): Ids of folder parents.
3540
3537
  Use 'None' if folder is direct child of project.
3538
+ statuses (Optional[Iterable[str]]): Folder statuses used
3539
+ for filtering.
3541
3540
  active (Optional[bool]): Filter active/inactive folders.
3542
3541
  Both are returned if is set to None.
3543
3542
  fields (Optional[Iterable[str]]): Fields to be queried for
@@ -3574,6 +3573,18 @@ class ServerAPI(object):
3574
3573
  return
3575
3574
  filters["folderNames"] = list(folder_names)
3576
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
+
3577
3588
  if parent_ids is not None:
3578
3589
  parent_ids = set(parent_ids)
3579
3590
  if not parent_ids:
@@ -5845,19 +5856,22 @@ class ServerAPI(object):
5845
5856
  """Helper method to get links from server for entity types.
5846
5857
 
5847
5858
  Example output:
5848
- [
5849
- {
5850
- "id": "59a212c0d2e211eda0e20242ac120002",
5851
- "linkType": "reference",
5852
- "description": "reference link between folders",
5853
- "projectName": "my_project",
5854
- "author": "frantadmin",
5855
- "entityId": "b1df109676db11ed8e8c6c9466b19aa8",
5856
- "entityType": "folder",
5857
- "direction": "out"
5858
- },
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
+ ],
5859
5873
  ...
5860
- ]
5874
+ }
5861
5875
 
5862
5876
  Args:
5863
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
- # - thiw won't validate if the url lead to 'google.com'
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.1"
2
+ __version__ = "0.4.2"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ayon-python-api"
3
- version = "0.4.1"
3
+ version = "0.4.2"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}
File without changes