ayon-python-api 1.0.8__tar.gz → 1.0.9__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-1.0.8 → ayon-python-api-1.0.9}/PKG-INFO +1 -1
  2. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/_api.py +44 -11
  3. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/entity_hub.py +9 -6
  4. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/graphql_queries.py +6 -0
  5. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/server_api.py +202 -251
  6. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/utils.py +10 -9
  7. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/version.py +1 -1
  8. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_python_api.egg-info/PKG-INFO +1 -1
  9. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/pyproject.toml +2 -2
  10. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/LICENSE +0 -0
  11. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/README.md +0 -0
  12. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/__init__.py +0 -0
  13. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/constants.py +0 -0
  14. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/events.py +0 -0
  15. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/exceptions.py +0 -0
  16. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/graphql.py +0 -0
  17. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_api/operations.py +0 -0
  18. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  19. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  20. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_python_api.egg-info/requires.txt +0 -0
  21. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/ayon_python_api.egg-info/top_level.txt +0 -0
  22. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/setup.cfg +0 -0
  23. {ayon-python-api-1.0.8 → ayon-python-api-1.0.9}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -18,6 +18,9 @@ from .constants import (
18
18
  )
19
19
  from .server_api import ServerAPI
20
20
  from .exceptions import FailedServiceInit
21
+ from .utils import (
22
+ get_default_settings_variant as _get_default_settings_variant
23
+ )
21
24
 
22
25
 
23
26
  class GlobalServerAPI(ServerAPI):
@@ -502,6 +505,8 @@ def get_default_settings_variant():
502
505
  Union[str, None]: name of variant or None.
503
506
 
504
507
  """
508
+ if not GlobalContext.is_connection_created():
509
+ return _get_default_settings_variant()
505
510
  con = get_server_api_connection()
506
511
  return con.get_default_settings_variant()
507
512
 
@@ -722,6 +727,7 @@ def get_events(*args, **kwargs):
722
727
 
723
728
  Args:
724
729
  topics (Optional[Iterable[str]]): Name of topics.
730
+ event_ids (Optional[Iterable[str]]): Event ids.
725
731
  project_names (Optional[Iterable[str]]): Project on which
726
732
  event happened.
727
733
  states (Optional[Iterable[str]]): Filtering by states.
@@ -746,6 +752,22 @@ def get_events(*args, **kwargs):
746
752
 
747
753
 
748
754
  def update_event(*args, **kwargs):
755
+ """Update event data.
756
+
757
+ Args:
758
+ event_id (str): Event id.
759
+ sender (Optional[str]): New sender of event.
760
+ project_name (Optional[str]): New project name.
761
+ username (Optional[str]): New username.
762
+ status (Optional[str]): New event status. Enum: "pending",
763
+ "in_progress", "finished", "failed", "aborted", "restarted"
764
+ description (Optional[str]): New description.
765
+ summary (Optional[dict[str, Any]]): New summary.
766
+ payload (Optional[dict[str, Any]]): New payload.
767
+ progress (Optional[int]): New progress. Range [0-100].
768
+ retries (Optional[int]): New retries.
769
+
770
+ """
749
771
  con = get_server_api_connection()
750
772
  return con.update_event(*args, **kwargs)
751
773
 
@@ -759,7 +781,7 @@ def dispatch_event(*args, **kwargs):
759
781
  event_hash (Optional[str]): Event hash.
760
782
  project_name (Optional[str]): Project name.
761
783
  username (Optional[str]): Username which triggered event.
762
- dependencies (Optional[list[str]]): List of event id dependencies.
784
+ depends_on (Optional[str]): Add dependency to another event.
763
785
  description (Optional[str]): Description of event.
764
786
  summary (Optional[dict[str, Any]]): Summary of event that can be used
765
787
  for simple filtering on listeners.
@@ -769,6 +791,8 @@ def dispatch_event(*args, **kwargs):
769
791
  store (Optional[bool]): Store event in event queue for possible
770
792
  future processing otherwise is event send only
771
793
  to active listeners.
794
+ dependencies (Optional[list[str]]): Deprecated.
795
+ List of event id dependencies.
772
796
 
773
797
  Returns:
774
798
  RestApiResponse: Response from server.
@@ -2370,6 +2394,8 @@ def get_folders(*args, **kwargs):
2370
2394
  children. Ignored when None, default behavior.
2371
2395
  statuses (Optional[Iterable[str]]): Folder statuses used
2372
2396
  for filtering.
2397
+ assignees_all (Optional[Iterable[str]]): Filter by assigness
2398
+ on children tasks. Task must have all of passed assignees.
2373
2399
  tags (Optional[Iterable[str]]): Folder tags used
2374
2400
  for filtering.
2375
2401
  active (Optional[bool]): Filter active/inactive folders.
@@ -2992,10 +3018,12 @@ def get_versions(*args, **kwargs):
2992
3018
  version filtering.
2993
3019
  product_ids (Optional[Iterable[str]]): Product ids used for
2994
3020
  version filtering.
3021
+ task_ids (Optional[Iterable[str]]): Task ids used for
3022
+ version filtering.
2995
3023
  versions (Optional[Iterable[int]]): Versions we're interested in.
2996
- hero (Optional[bool]): Receive also hero versions when set to true.
2997
- standard (Optional[bool]): Receive versions which are not hero when
2998
- set to true.
3024
+ hero (Optional[bool]): Skip hero versions when set to False.
3025
+ standard (Optional[bool]): Skip standard (non-hero) when
3026
+ set to False.
2999
3027
  latest (Optional[bool]): Return only latest version of standard
3000
3028
  versions. This can be combined only with 'standard' attribute
3001
3029
  set to True.
@@ -3250,6 +3278,7 @@ def update_version(*args, **kwargs):
3250
3278
  version (Optional[int]): New version.
3251
3279
  product_id (Optional[str]): New product id.
3252
3280
  task_id (Optional[Union[str, None]]): New task id.
3281
+ author (Optional[str]): New author username.
3253
3282
  attrib (Optional[dict[str, Any]]): New attributes.
3254
3283
  data (Optional[dict[str, Any]]): New data.
3255
3284
  tags (Optional[Iterable[str]]): New tags.
@@ -3277,9 +3306,10 @@ def delete_version(*args, **kwargs):
3277
3306
  def get_representations(*args, **kwargs):
3278
3307
  """Get representation entities based on passed filters from server.
3279
3308
 
3280
- Todos:
3309
+ .. todo::
3310
+
3281
3311
  Add separated function for 'names_by_version_ids' filtering.
3282
- Because can't be combined with others.
3312
+ Because can't be combined with others.
3283
3313
 
3284
3314
  Args:
3285
3315
  project_name (str): Name of project where to look for versions.
@@ -3289,7 +3319,7 @@ def get_representations(*args, **kwargs):
3289
3319
  names used for representation filtering.
3290
3320
  version_ids (Optional[Iterable[str]]): Version ids used for
3291
3321
  representation filtering. Versions are parents of
3292
- representations.
3322
+ representations.
3293
3323
  names_by_version_ids (Optional[bool]): Find representations
3294
3324
  by names and version ids. This filter discard all
3295
3325
  other filters.
@@ -4028,7 +4058,10 @@ def delete_link(*args, **kwargs):
4028
4058
  def get_entities_links(*args, **kwargs):
4029
4059
  """Helper method to get links from server for entity types.
4030
4060
 
4031
- Example output::
4061
+ .. highlight:: text
4062
+ .. code-block:: text
4063
+
4064
+ Example output:
4032
4065
  {
4033
4066
  "59a212c0d2e211eda0e20242ac120001": [
4034
4067
  {
@@ -4049,12 +4082,12 @@ def get_entities_links(*args, **kwargs):
4049
4082
  Args:
4050
4083
  project_name (str): Project where links are.
4051
4084
  entity_type (Literal["folder", "task", "product",
4052
- "version", "representations"]): Entity type.
4085
+ | "version", "representations"]): Entity type.
4053
4086
  entity_ids (Optional[Iterable[str]]): Ids of entities for which
4054
- links should be received.
4087
+ | links should be received.
4055
4088
  link_types (Optional[Iterable[str]]): Link type filters.
4056
4089
  link_direction (Optional[Literal["in", "out"]]): Link direction
4057
- filter.
4090
+ | filter.
4058
4091
  link_names (Optional[Iterable[str]]): Link name filters.
4059
4092
  link_name_regex (Optional[str]): Regex filter for link name.
4060
4093
 
@@ -1029,14 +1029,17 @@ class EntityData(dict):
1029
1029
 
1030
1030
  It is not possible to store 'None' to root key. In that case the key is
1031
1031
  not stored, and removed if existed on entity.
1032
-
1033
1032
  To be able to store 'None' value use nested data structure:
1034
- {
1035
- "sceneInfo": {
1036
- "description": None,
1037
- "camera": "camera1"
1033
+
1034
+ .. highlight:: text
1035
+ .. code-block:: text
1036
+
1037
+ {
1038
+ "sceneInfo": {
1039
+ "description": None,
1040
+ "camera": "camera1"
1041
+ }
1038
1042
  }
1039
- }
1040
1043
 
1041
1044
  """
1042
1045
  def __init__(self, *args, **kwargs):
@@ -157,6 +157,9 @@ def folders_graphql_query(fields):
157
157
  has_links_var = query.add_variable("folderHasLinks", "HasLinksFilter")
158
158
  has_children_var = query.add_variable("folderHasChildren", "Boolean!")
159
159
  statuses_var = query.add_variable("folderStatuses", "[String!]")
160
+ folder_assignees_all_var = query.add_variable(
161
+ "folderAssigneesAll", "[String!]"
162
+ )
160
163
  tags_var = query.add_variable("folderTags", "[String!]")
161
164
 
162
165
  project_field = query.add_field("project")
@@ -170,6 +173,7 @@ def folders_graphql_query(fields):
170
173
  folders_field.set_filter("pathEx", folder_path_regex_var)
171
174
  folders_field.set_filter("folderTypes", folder_types_var)
172
175
  folders_field.set_filter("statuses", statuses_var)
176
+ folders_field.set_filter("assignees", folder_assignees_all_var)
173
177
  folders_field.set_filter("tags", tags_var)
174
178
  folders_field.set_filter("hasProducts", has_products_var)
175
179
  folders_field.set_filter("hasTasks", has_tasks_var)
@@ -567,6 +571,7 @@ def workfiles_info_graphql_query(fields):
567
571
  def events_graphql_query(fields):
568
572
  query = GraphQlQuery("Events")
569
573
  topics_var = query.add_variable("eventTopics", "[String!]")
574
+ ids_var = query.add_variable("eventIds", "[String!]")
570
575
  projects_var = query.add_variable("projectNames", "[String!]")
571
576
  states_var = query.add_variable("eventStates", "[String!]")
572
577
  users_var = query.add_variable("eventUsers", "[String!]")
@@ -576,6 +581,7 @@ def events_graphql_query(fields):
576
581
  older_than_var = query.add_variable("olderThanFilter", "String!")
577
582
 
578
583
  events_field = query.add_field_with_edges("events")
584
+ events_field.set_filter("ids", ids_var)
579
585
  events_field.set_filter("topics", topics_var)
580
586
  events_field.set_filter("projects", projects_var)
581
587
  events_field.set_filter("states", states_var)
@@ -14,6 +14,7 @@ import platform
14
14
  import copy
15
15
  import uuid
16
16
  import warnings
17
+ import itertools
17
18
  from contextlib import contextmanager
18
19
 
19
20
  try:
@@ -111,6 +112,29 @@ VERSION_REGEX = re.compile(
111
112
  )
112
113
 
113
114
 
115
+ def _convert_list_filter_value(value):
116
+ if value is None:
117
+ return None
118
+
119
+ if isinstance(value, PatternType):
120
+ return [value.pattern]
121
+
122
+ if isinstance(value, (int, float, str, bool)):
123
+ return [value]
124
+ return list(set(value))
125
+
126
+
127
+ def _prepare_list_filters(output, *args, **kwargs):
128
+ for key, value in itertools.chain(args, kwargs.items()):
129
+ value = _convert_list_filter_value(value)
130
+ if value is None:
131
+ continue
132
+ if not value:
133
+ return False
134
+ output[key] = value
135
+ return True
136
+
137
+
114
138
  def _get_description(response):
115
139
  if HTTPStatus is None:
116
140
  return str(response.orig_response)
@@ -1383,6 +1407,7 @@ class ServerAPI(object):
1383
1407
  def get_events(
1384
1408
  self,
1385
1409
  topics=None,
1410
+ event_ids=None,
1386
1411
  project_names=None,
1387
1412
  states=None,
1388
1413
  users=None,
@@ -1399,6 +1424,7 @@ class ServerAPI(object):
1399
1424
 
1400
1425
  Args:
1401
1426
  topics (Optional[Iterable[str]]): Name of topics.
1427
+ event_ids (Optional[Iterable[str]]): Event ids.
1402
1428
  project_names (Optional[Iterable[str]]): Project on which
1403
1429
  event happened.
1404
1430
  states (Optional[Iterable[str]]): Filtering by states.
@@ -1419,42 +1445,27 @@ class ServerAPI(object):
1419
1445
 
1420
1446
  """
1421
1447
  filters = {}
1422
- if topics is not None:
1423
- topics = set(topics)
1424
- if not topics:
1425
- return
1426
- filters["eventTopics"] = list(topics)
1427
-
1428
- if project_names is not None:
1429
- project_names = set(project_names)
1430
- if not project_names:
1431
- return
1432
- filters["projectNames"] = list(project_names)
1433
-
1434
- if states is not None:
1435
- states = set(states)
1436
- if not states:
1437
- return
1438
- filters["eventStates"] = list(states)
1439
-
1440
- if users is not None:
1441
- users = set(users)
1442
- if not users:
1443
- return
1444
- filters["eventUsers"] = list(users)
1448
+ if not _prepare_list_filters(
1449
+ filters,
1450
+ ("eventTopics", topics),
1451
+ ("eventIds", event_ids),
1452
+ ("projectNames", project_names),
1453
+ ("eventStates", states),
1454
+ ("eventUsers", users),
1455
+ ):
1456
+ return
1445
1457
 
1446
1458
  if include_logs is None:
1447
1459
  include_logs = False
1448
- filters["includeLogsFilter"] = include_logs
1449
-
1450
- if has_children is not None:
1451
- filters["hasChildrenFilter"] = has_children
1452
1460
 
1453
- if newer_than is not None:
1454
- filters["newerThanFilter"] = newer_than
1455
-
1456
- if older_than is not None:
1457
- filters["olderThanFilter"] = older_than
1461
+ for filter_key, filter_value in (
1462
+ ("includeLogsFilter", include_logs),
1463
+ ("hasChildrenFilter", has_children),
1464
+ ("newerThanFilter", newer_than),
1465
+ ("olderThanFilter", older_than),
1466
+ ):
1467
+ if filter_value is not None:
1468
+ filters[filter_key] = filter_value
1458
1469
 
1459
1470
  if not fields:
1460
1471
  fields = self.get_default_fields_for_type("event")
@@ -1472,6 +1483,7 @@ class ServerAPI(object):
1472
1483
  event_id,
1473
1484
  sender=None,
1474
1485
  project_name=None,
1486
+ username=None,
1475
1487
  status=None,
1476
1488
  description=None,
1477
1489
  summary=None,
@@ -1479,11 +1491,28 @@ class ServerAPI(object):
1479
1491
  progress=None,
1480
1492
  retries=None
1481
1493
  ):
1494
+ """Update event data.
1495
+
1496
+ Args:
1497
+ event_id (str): Event id.
1498
+ sender (Optional[str]): New sender of event.
1499
+ project_name (Optional[str]): New project name.
1500
+ username (Optional[str]): New username.
1501
+ status (Optional[str]): New event status. Enum: "pending",
1502
+ "in_progress", "finished", "failed", "aborted", "restarted"
1503
+ description (Optional[str]): New description.
1504
+ summary (Optional[dict[str, Any]]): New summary.
1505
+ payload (Optional[dict[str, Any]]): New payload.
1506
+ progress (Optional[int]): New progress. Range [0-100].
1507
+ retries (Optional[int]): New retries.
1508
+
1509
+ """
1482
1510
  kwargs = {
1483
1511
  key: value
1484
1512
  for key, value in (
1485
1513
  ("sender", sender),
1486
1514
  ("project", project_name),
1515
+ ("user", username),
1487
1516
  ("status", status),
1488
1517
  ("description", description),
1489
1518
  ("summary", summary),
@@ -1522,12 +1551,13 @@ class ServerAPI(object):
1522
1551
  event_hash=None,
1523
1552
  project_name=None,
1524
1553
  username=None,
1525
- dependencies=None,
1554
+ depends_on=None,
1526
1555
  description=None,
1527
1556
  summary=None,
1528
1557
  payload=None,
1529
1558
  finished=True,
1530
1559
  store=True,
1560
+ dependencies=None,
1531
1561
  ):
1532
1562
  """Dispatch event to server.
1533
1563
 
@@ -1536,8 +1566,8 @@ class ServerAPI(object):
1536
1566
  sender (Optional[str]): Sender of event.
1537
1567
  event_hash (Optional[str]): Event hash.
1538
1568
  project_name (Optional[str]): Project name.
1569
+ depends_on (Optional[str]): Add dependency to another event.
1539
1570
  username (Optional[str]): Username which triggered event.
1540
- dependencies (Optional[list[str]]): List of event id dependencies.
1541
1571
  description (Optional[str]): Description of event.
1542
1572
  summary (Optional[dict[str, Any]]): Summary of event that can be used
1543
1573
  for simple filtering on listeners.
@@ -1547,6 +1577,8 @@ class ServerAPI(object):
1547
1577
  store (Optional[bool]): Store event in event queue for possible
1548
1578
  future processing otherwise is event send only
1549
1579
  to active listeners.
1580
+ dependencies (Optional[list[str]]): Deprecated.
1581
+ List of event id dependencies.
1550
1582
 
1551
1583
  Returns:
1552
1584
  RestApiResponse: Response from server.
@@ -1562,13 +1594,23 @@ class ServerAPI(object):
1562
1594
  "hash": event_hash,
1563
1595
  "project": project_name,
1564
1596
  "user": username,
1565
- "dependencies": dependencies,
1566
1597
  "description": description,
1567
1598
  "summary": summary,
1568
1599
  "payload": payload,
1569
1600
  "finished": finished,
1570
1601
  "store": store,
1571
1602
  }
1603
+ if depends_on:
1604
+ event_data["dependsOn"] = depends_on
1605
+
1606
+ if dependencies:
1607
+ warnings.warn(
1608
+ (
1609
+ "Used deprecated argument 'dependencies' in"
1610
+ " 'dispatch_event'. Use 'depends_on' instead."
1611
+ ),
1612
+ DeprecationWarning
1613
+ )
1572
1614
 
1573
1615
  response = self.post("events", **event_data)
1574
1616
  response.raise_for_status()
@@ -1650,6 +1692,7 @@ class ServerAPI(object):
1650
1692
  kwargs["description"] = description
1651
1693
  if events_filter is not None:
1652
1694
  kwargs["filter"] = events_filter
1695
+
1653
1696
  response = self.post("enroll", **kwargs)
1654
1697
  if response.status_code == 204:
1655
1698
  return None
@@ -3038,7 +3081,7 @@ class ServerAPI(object):
3038
3081
 
3039
3082
  if site_id is None:
3040
3083
  return {}
3041
- roots = self.get_project_roots_by_site(project_name)
3084
+ roots = self.get_project_root_overrides(project_name)
3042
3085
  return roots.get(site_id, {})
3043
3086
 
3044
3087
  def get_project_roots_for_site(self, project_name, site_id=None):
@@ -4069,6 +4112,13 @@ class ServerAPI(object):
4069
4112
  list[dict[str, Any]]: List of folder entities.
4070
4113
 
4071
4114
  """
4115
+ warnings.warn(
4116
+ (
4117
+ "DEPRECATION: Used deprecated 'get_folders_rest',"
4118
+ " use 'get_rest_folders' instead."
4119
+ ),
4120
+ DeprecationWarning
4121
+ )
4072
4122
  return self.get_rest_folders(project_name, include_attrib)
4073
4123
 
4074
4124
  def get_folders(
@@ -4084,6 +4134,7 @@ class ServerAPI(object):
4084
4134
  has_tasks=None,
4085
4135
  has_children=None,
4086
4136
  statuses=None,
4137
+ assignees_all=None,
4087
4138
  tags=None,
4088
4139
  active=True,
4089
4140
  has_links=None,
@@ -4120,6 +4171,8 @@ class ServerAPI(object):
4120
4171
  children. Ignored when None, default behavior.
4121
4172
  statuses (Optional[Iterable[str]]): Folder statuses used
4122
4173
  for filtering.
4174
+ assignees_all (Optional[Iterable[str]]): Filter by assigness
4175
+ on children tasks. Task must have all of passed assignees.
4123
4176
  tags (Optional[Iterable[str]]): Folder tags used
4124
4177
  for filtering.
4125
4178
  active (Optional[bool]): Filter active/inactive folders.
@@ -4142,41 +4195,27 @@ class ServerAPI(object):
4142
4195
  filters = {
4143
4196
  "projectName": project_name
4144
4197
  }
4145
- if folder_ids is not None:
4146
- folder_ids = set(folder_ids)
4147
- if not folder_ids:
4148
- return
4149
- filters["folderIds"] = list(folder_ids)
4150
-
4151
- if folder_paths is not None:
4152
- folder_paths = set(folder_paths)
4153
- if not folder_paths:
4154
- return
4155
- filters["folderPaths"] = list(folder_paths)
4156
-
4157
- if folder_names is not None:
4158
- folder_names = set(folder_names)
4159
- if not folder_names:
4160
- return
4161
- filters["folderNames"] = list(folder_names)
4162
-
4163
- if folder_types is not None:
4164
- folder_types = set(folder_types)
4165
- if not folder_types:
4166
- return
4167
- filters["folderTypes"] = list(folder_types)
4168
-
4169
- if statuses is not None:
4170
- statuses = set(statuses)
4171
- if not statuses:
4172
- return
4173
- filters["folderStatuses"] = list(statuses)
4198
+ if not _prepare_list_filters(
4199
+ filters,
4200
+ ("folderIds", folder_ids),
4201
+ ("folderPaths", folder_paths),
4202
+ ("folderNames", folder_names),
4203
+ ("folderTypes", folder_types),
4204
+ ("folderStatuses", statuses),
4205
+ ("folderTags", tags),
4206
+ ("folderAssigneesAll", assignees_all),
4207
+ ):
4208
+ return
4174
4209
 
4175
- if tags is not None:
4176
- tags = set(tags)
4177
- if not tags:
4178
- return
4179
- filters["folderTags"] = list(tags)
4210
+ for filter_key, filter_value in (
4211
+ ("folderPathRegex", folder_path_regex),
4212
+ ("folderHasProducts", has_products),
4213
+ ("folderHasTasks", has_tasks),
4214
+ ("folderHasLinks", has_links),
4215
+ ("folderHasChildren", has_children),
4216
+ ):
4217
+ if filter_value is not None:
4218
+ filters[filter_key] = filter_value
4180
4219
 
4181
4220
  if parent_ids is not None:
4182
4221
  parent_ids = set(parent_ids)
@@ -4198,21 +4237,6 @@ class ServerAPI(object):
4198
4237
 
4199
4238
  filters["parentFolderIds"] = list(parent_ids)
4200
4239
 
4201
- if folder_path_regex is not None:
4202
- filters["folderPathRegex"] = folder_path_regex
4203
-
4204
- if has_products is not None:
4205
- filters["folderHasProducts"] = has_products
4206
-
4207
- if has_tasks is not None:
4208
- filters["folderHasTasks"] = has_tasks
4209
-
4210
- if has_links is not None:
4211
- filters["folderHasLinks"] = has_links.upper()
4212
-
4213
- if has_children is not None:
4214
- filters["folderHasChildren"] = has_children
4215
-
4216
4240
  if not fields:
4217
4241
  fields = self.get_default_fields_for_type("folder")
4218
4242
  else:
@@ -4590,54 +4614,18 @@ class ServerAPI(object):
4590
4614
  filters = {
4591
4615
  "projectName": project_name
4592
4616
  }
4593
-
4594
- if task_ids is not None:
4595
- task_ids = set(task_ids)
4596
- if not task_ids:
4597
- return
4598
- filters["taskIds"] = list(task_ids)
4599
-
4600
- if task_names is not None:
4601
- task_names = set(task_names)
4602
- if not task_names:
4603
- return
4604
- filters["taskNames"] = list(task_names)
4605
-
4606
- if task_types is not None:
4607
- task_types = set(task_types)
4608
- if not task_types:
4609
- return
4610
- filters["taskTypes"] = list(task_types)
4611
-
4612
- if folder_ids is not None:
4613
- folder_ids = set(folder_ids)
4614
- if not folder_ids:
4615
- return
4616
- filters["folderIds"] = list(folder_ids)
4617
-
4618
- if assignees is not None:
4619
- assignees = set(assignees)
4620
- if not assignees:
4621
- return
4622
- filters["taskAssigneesAny"] = list(assignees)
4623
-
4624
- if assignees_all is not None:
4625
- assignees_all = set(assignees_all)
4626
- if not assignees_all:
4627
- return
4628
- filters["taskAssigneesAll"] = list(assignees_all)
4629
-
4630
- if statuses is not None:
4631
- statuses = set(statuses)
4632
- if not statuses:
4633
- return
4634
- filters["taskStatuses"] = list(statuses)
4635
-
4636
- if tags is not None:
4637
- tags = set(tags)
4638
- if not tags:
4639
- return
4640
- filters["taskTags"] = list(tags)
4617
+ if not _prepare_list_filters(
4618
+ filters,
4619
+ ("taskIds", task_ids),
4620
+ ("taskNames", task_names),
4621
+ ("taskTypes", task_types),
4622
+ ("folderIds", folder_ids),
4623
+ ("taskAssigneesAny", assignees),
4624
+ ("taskAssigneesAll", assignees_all),
4625
+ ("taskStatuses", statuses),
4626
+ ("taskTags", tags),
4627
+ ):
4628
+ return
4641
4629
 
4642
4630
  if not fields:
4643
4631
  fields = self.get_default_fields_for_type("task")
@@ -4795,42 +4783,16 @@ class ServerAPI(object):
4795
4783
  "projectName": project_name,
4796
4784
  "folderPaths": list(folder_paths),
4797
4785
  }
4798
-
4799
- if task_names is not None:
4800
- task_names = set(task_names)
4801
- if not task_names:
4802
- return
4803
- filters["taskNames"] = list(task_names)
4804
-
4805
- if task_types is not None:
4806
- task_types = set(task_types)
4807
- if not task_types:
4808
- return
4809
- filters["taskTypes"] = list(task_types)
4810
-
4811
- if assignees is not None:
4812
- assignees = set(assignees)
4813
- if not assignees:
4814
- return
4815
- filters["taskAssigneesAny"] = list(assignees)
4816
-
4817
- if assignees_all is not None:
4818
- assignees_all = set(assignees_all)
4819
- if not assignees_all:
4820
- return
4821
- filters["taskAssigneesAll"] = list(assignees_all)
4822
-
4823
- if statuses is not None:
4824
- statuses = set(statuses)
4825
- if not statuses:
4826
- return
4827
- filters["taskStatuses"] = list(statuses)
4828
-
4829
- if tags is not None:
4830
- tags = set(tags)
4831
- if not tags:
4832
- return
4833
- filters["taskTags"] = list(tags)
4786
+ if not _prepare_list_filters(
4787
+ filters,
4788
+ ("taskNames", task_names),
4789
+ ("taskTypes", task_types),
4790
+ ("taskAssigneesAny", assignees),
4791
+ ("taskAssigneesAll", assignees_all),
4792
+ ("taskStatuses", statuses),
4793
+ ("taskTags", tags),
4794
+ ):
4795
+ return
4834
4796
 
4835
4797
  if not fields:
4836
4798
  fields = self.get_default_fields_for_type("task")
@@ -5229,9 +5191,12 @@ class ServerAPI(object):
5229
5191
 
5230
5192
  if own_attributes is not _PLACEHOLDER:
5231
5193
  warnings.warn(
5232
- "'own_attributes' is not supported for products. The argument"
5233
- " will be removed form function signature in future"
5234
- " (apx. version 1.0.10 or 1.1.0)."
5194
+ (
5195
+ "'own_attributes' is not supported for products. The"
5196
+ " argument will be removed form function signature in"
5197
+ " future (apx. version 1.0.10 or 1.1.0)."
5198
+ ),
5199
+ DeprecationWarning
5235
5200
  )
5236
5201
 
5237
5202
  # Add 'name' and 'folderId' if 'names_by_folder_ids' filter is entered
@@ -5250,35 +5215,21 @@ class ServerAPI(object):
5250
5215
  if filter_product_names:
5251
5216
  filters["productNames"] = list(filter_product_names)
5252
5217
 
5253
- if product_ids is not None:
5254
- product_ids = set(product_ids)
5255
- if not product_ids:
5256
- return
5257
- filters["productIds"] = list(product_ids)
5258
-
5259
- if product_types is not None:
5260
- product_types = set(product_types)
5261
- if not product_types:
5262
- return
5263
- filters["productTypes"] = list(product_types)
5264
-
5265
- if statuses is not None:
5266
- statuses = set(statuses)
5267
- if not statuses:
5268
- return
5269
- filters["productStatuses"] = list(statuses)
5270
-
5271
- if tags is not None:
5272
- tags = set(tags)
5273
- if not tags:
5274
- return
5275
- filters["productTags"] = list(tags)
5276
-
5277
- if product_name_regex:
5278
- filters["productNameRegex"] = product_name_regex
5218
+ if not _prepare_list_filters(
5219
+ filters,
5220
+ ("productIds", product_ids),
5221
+ ("productTypes", product_types),
5222
+ ("productStatuses", statuses),
5223
+ ("productTags", tags),
5224
+ ):
5225
+ return
5279
5226
 
5280
- if product_path_regex:
5281
- filters["productPathRegex"] = product_path_regex
5227
+ for filter_key, filter_value in (
5228
+ ("productNameRegex", product_name_regex),
5229
+ ("productPathRegex", product_path_regex),
5230
+ ):
5231
+ if filter_value:
5232
+ filters[filter_key] = filter_value
5282
5233
 
5283
5234
  query = products_graphql_query(fields)
5284
5235
  for attr, filter_value in filters.items():
@@ -5590,6 +5541,7 @@ class ServerAPI(object):
5590
5541
  project_name,
5591
5542
  version_ids=None,
5592
5543
  product_ids=None,
5544
+ task_ids=None,
5593
5545
  versions=None,
5594
5546
  hero=True,
5595
5547
  standard=True,
@@ -5608,10 +5560,12 @@ class ServerAPI(object):
5608
5560
  version filtering.
5609
5561
  product_ids (Optional[Iterable[str]]): Product ids used for
5610
5562
  version filtering.
5563
+ task_ids (Optional[Iterable[str]]): Task ids used for
5564
+ version filtering.
5611
5565
  versions (Optional[Iterable[int]]): Versions we're interested in.
5612
- hero (Optional[bool]): Receive also hero versions when set to true.
5613
- standard (Optional[bool]): Receive versions which are not hero when
5614
- set to true.
5566
+ hero (Optional[bool]): Skip hero versions when set to False.
5567
+ standard (Optional[bool]): Skip standard (non-hero) when
5568
+ set to False.
5615
5569
  latest (Optional[bool]): Return only latest version of standard
5616
5570
  versions. This can be combined only with 'standard' attribute
5617
5571
  set to True.
@@ -5652,46 +5606,30 @@ class ServerAPI(object):
5652
5606
 
5653
5607
  if own_attributes is not _PLACEHOLDER:
5654
5608
  warnings.warn(
5655
- "'own_attributes' is not supported for versions. The argument"
5656
- " will be removed form function signature in future"
5657
- " (apx. version 1.0.10 or 1.1.0)."
5609
+ (
5610
+ "'own_attributes' is not supported for versions. The"
5611
+ " argument will be removed form function signature in"
5612
+ " future (apx. version 1.0.10 or 1.1.0)."
5613
+ ),
5614
+ DeprecationWarning
5658
5615
  )
5659
5616
 
5617
+ if not hero and not standard:
5618
+ return
5619
+
5660
5620
  filters = {
5661
5621
  "projectName": project_name
5662
5622
  }
5663
- if version_ids is not None:
5664
- version_ids = set(version_ids)
5665
- if not version_ids:
5666
- return
5667
- filters["versionIds"] = list(version_ids)
5668
-
5669
- if product_ids is not None:
5670
- product_ids = set(product_ids)
5671
- if not product_ids:
5672
- return
5673
- filters["productIds"] = list(product_ids)
5674
-
5675
- # TODO versions can't be used as filter at this moment!
5676
- if versions is not None:
5677
- versions = set(versions)
5678
- if not versions:
5679
- return
5680
- filters["versions"] = list(versions)
5681
-
5682
- if statuses is not None:
5683
- statuses = set(statuses)
5684
- if not statuses:
5685
- return
5686
- filters["versionStatuses"] = list(statuses)
5687
-
5688
- if tags is not None:
5689
- tags = set(tags)
5690
- if not tags:
5691
- return
5692
- filters["versionTags"] = list(tags)
5693
-
5694
- if not hero and not standard:
5623
+ if not _prepare_list_filters(
5624
+ filters,
5625
+ ("taskIds", task_ids),
5626
+ ("versionIds", version_ids),
5627
+ ("productIds", product_ids),
5628
+ ("taskIds", task_ids),
5629
+ ("versions", versions),
5630
+ ("versionStatuses", statuses),
5631
+ ("versionTags", tags),
5632
+ ):
5695
5633
  return
5696
5634
 
5697
5635
  queries = []
@@ -6143,6 +6081,7 @@ class ServerAPI(object):
6143
6081
  version=None,
6144
6082
  product_id=None,
6145
6083
  task_id=NOT_SET,
6084
+ author=None,
6146
6085
  attrib=None,
6147
6086
  data=None,
6148
6087
  tags=None,
@@ -6167,6 +6106,7 @@ class ServerAPI(object):
6167
6106
  version (Optional[int]): New version.
6168
6107
  product_id (Optional[str]): New product id.
6169
6108
  task_id (Optional[Union[str, None]]): New task id.
6109
+ author (Optional[str]): New author username.
6170
6110
  attrib (Optional[dict[str, Any]]): New attributes.
6171
6111
  data (Optional[dict[str, Any]]): New data.
6172
6112
  tags (Optional[Iterable[str]]): New tags.
@@ -6185,6 +6125,7 @@ class ServerAPI(object):
6185
6125
  ("tags", tags),
6186
6126
  ("status", status),
6187
6127
  ("active", active),
6128
+ ("author", author),
6188
6129
  ):
6189
6130
  if value is not None:
6190
6131
  update_data[key] = value
@@ -6248,9 +6189,10 @@ class ServerAPI(object):
6248
6189
  ):
6249
6190
  """Get representation entities based on passed filters from server.
6250
6191
 
6251
- Todos:
6192
+ .. todo::
6193
+
6252
6194
  Add separated function for 'names_by_version_ids' filtering.
6253
- Because can't be combined with others.
6195
+ Because can't be combined with others.
6254
6196
 
6255
6197
  Args:
6256
6198
  project_name (str): Name of project where to look for versions.
@@ -6260,7 +6202,7 @@ class ServerAPI(object):
6260
6202
  names used for representation filtering.
6261
6203
  version_ids (Optional[Iterable[str]]): Version ids used for
6262
6204
  representation filtering. Versions are parents of
6263
- representations.
6205
+ representations.
6264
6206
  names_by_version_ids (Optional[bool]): Find representations
6265
6207
  by names and version ids. This filter discard all
6266
6208
  other filters.
@@ -6302,9 +6244,12 @@ class ServerAPI(object):
6302
6244
 
6303
6245
  if own_attributes is not _PLACEHOLDER:
6304
6246
  warnings.warn(
6305
- "'own_attributes' is not supported for representations. "
6306
- "The argument will be removed form function signature in "
6307
- "future (apx. version 1.0.10 or 1.1.0)."
6247
+ (
6248
+ "'own_attributes' is not supported for representations. "
6249
+ "The argument will be removed form function signature in "
6250
+ "future (apx. version 1.0.10 or 1.1.0)."
6251
+ ),
6252
+ DeprecationWarning
6308
6253
  )
6309
6254
 
6310
6255
  if "files" in fields:
@@ -7003,9 +6948,12 @@ class ServerAPI(object):
7003
6948
 
7004
6949
  if own_attributes is not _PLACEHOLDER:
7005
6950
  warnings.warn(
7006
- "'own_attributes' is not supported for workfiles. The argument"
7007
- " will be removed form function signature in future"
7008
- " (apx. version 1.0.10 or 1.1.0)."
6951
+ (
6952
+ "'own_attributes' is not supported for workfiles. The"
6953
+ " argument will be removed form function signature in"
6954
+ " future (apx. version 1.0.10 or 1.1.0)."
6955
+ ),
6956
+ DeprecationWarning
7009
6957
  )
7010
6958
 
7011
6959
  query = workfiles_info_graphql_query(fields)
@@ -7765,7 +7713,10 @@ class ServerAPI(object):
7765
7713
  ):
7766
7714
  """Helper method to get links from server for entity types.
7767
7715
 
7768
- Example output::
7716
+ .. highlight:: text
7717
+ .. code-block:: text
7718
+
7719
+ Example output:
7769
7720
  {
7770
7721
  "59a212c0d2e211eda0e20242ac120001": [
7771
7722
  {
@@ -7786,12 +7737,12 @@ class ServerAPI(object):
7786
7737
  Args:
7787
7738
  project_name (str): Project where links are.
7788
7739
  entity_type (Literal["folder", "task", "product",
7789
- "version", "representations"]): Entity type.
7740
+ | "version", "representations"]): Entity type.
7790
7741
  entity_ids (Optional[Iterable[str]]): Ids of entities for which
7791
- links should be received.
7742
+ | links should be received.
7792
7743
  link_types (Optional[Iterable[str]]): Link type filters.
7793
7744
  link_direction (Optional[Literal["in", "out"]]): Link direction
7794
- filter.
7745
+ | filter.
7795
7746
  link_names (Optional[Iterable[str]]): Link name filters.
7796
7747
  link_name_regex (Optional[str]): Regex filter for link name.
7797
7748
 
@@ -412,16 +412,17 @@ def validate_url(url, timeout=None):
412
412
  Function will try to autofix url thus will return modified url when
413
413
  connection to server works.
414
414
 
415
- ```python
416
- my_url = "my.server.url"
417
- try:
418
- # Store new url
419
- validated_url = validate_url(my_url)
415
+ .. highlight:: python
416
+ .. code-block:: python
417
+
418
+ my_url = "my.server.url"
419
+ try:
420
+ # Store new url
421
+ validated_url = validate_url(my_url)
420
422
 
421
- except UrlError:
422
- # Handle invalid url
423
- ...
424
- ```
423
+ except UrlError:
424
+ # Handle invalid url
425
+ ...
425
426
 
426
427
  Args:
427
428
  url (str): Server url.
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for AYON server."""
2
- __version__ = "1.0.8"
2
+ __version__ = "1.0.9"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 1.0.8
3
+ Version: 1.0.9
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 = "1.0.8"
3
+ version = "1.0.9"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}
@@ -29,7 +29,7 @@ build-backend = "poetry.core.masonry.api"
29
29
 
30
30
  [tool.poetry]
31
31
  name = "ayon-python-api"
32
- version = "1.0.8"
32
+ version = "1.0.9"
33
33
  description = "AYON Python API"
34
34
  authors = [
35
35
  "ynput.io <info@ynput.io>"
File without changes