ayon-python-api 1.2.12__tar.gz → 1.2.13__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 (49) hide show
  1. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/PKG-INFO +1 -1
  2. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/__init__.py +2 -0
  3. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api.py +7 -0
  4. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/base.py +6 -0
  5. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/folders.py +2 -0
  6. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/links.py +1 -0
  7. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/products.py +2 -0
  8. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/representations.py +2 -0
  9. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/tasks.py +4 -0
  10. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/versions.py +2 -1
  11. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/workfiles.py +2 -0
  12. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/graphql_queries.py +25 -10
  13. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/operations.py +2 -2
  14. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/server_api.py +22 -0
  15. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/version.py +1 -1
  16. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_python_api.egg-info/PKG-INFO +1 -1
  17. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/pyproject.toml +2 -2
  18. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/LICENSE +0 -0
  19. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/README.md +0 -0
  20. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/__init__.py +0 -0
  21. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/actions.py +0 -0
  22. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/activities.py +0 -0
  23. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/attributes.py +0 -0
  24. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/bundles_addons.py +0 -0
  25. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/dependency_packages.py +0 -0
  26. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/events.py +0 -0
  27. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/installers.py +0 -0
  28. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/lists.py +0 -0
  29. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/projects.py +0 -0
  30. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/secrets.py +0 -0
  31. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/_api_helpers/thumbnails.py +0 -0
  32. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/constants.py +0 -0
  33. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/entity_hub.py +0 -0
  34. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/events.py +0 -0
  35. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/exceptions.py +0 -0
  36. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/graphql.py +0 -0
  37. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/typing.py +0 -0
  38. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_api/utils.py +0 -0
  39. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  40. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  41. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_python_api.egg-info/requires.txt +0 -0
  42. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/ayon_python_api.egg-info/top_level.txt +0 -0
  43. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/setup.cfg +0 -0
  44. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/setup.py +0 -0
  45. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/tests/test_entity_hub.py +0 -0
  46. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/tests/test_folder_hierarchy.py +0 -0
  47. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/tests/test_get_events.py +0 -0
  48. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/tests/test_graphql_queries.py +0 -0
  49. {ayon_python_api-1.2.12 → ayon_python_api-1.2.13}/tests/test_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ayon_python_api
3
- Version: 1.2.12
3
+ Version: 1.2.13
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -55,6 +55,7 @@ from ._api import (
55
55
  get_server_version,
56
56
  get_server_version_tuple,
57
57
  is_product_base_type_supported,
58
+ links_graphql_support_data,
58
59
  get_users,
59
60
  get_user_by_name,
60
61
  get_user,
@@ -339,6 +340,7 @@ __all__ = (
339
340
  "get_server_version",
340
341
  "get_server_version_tuple",
341
342
  "is_product_base_type_supported",
343
+ "links_graphql_support_data",
342
344
  "get_users",
343
345
  "get_user_by_name",
344
346
  "get_user",
@@ -729,6 +729,13 @@ def is_product_base_type_supported() -> bool:
729
729
  return con.is_product_base_type_supported()
730
730
 
731
731
 
732
+ def links_graphql_support_data() -> bool:
733
+ """Links data can be received by GraphQl.
734
+ """
735
+ con = get_server_api_connection()
736
+ return con.links_graphql_support_data()
737
+
738
+
732
739
  def get_users(
733
740
  project_name: Optional[str] = None,
734
741
  usernames: Optional[Iterable[str]] = None,
@@ -28,6 +28,9 @@ class BaseServerAPI:
28
28
  def is_product_base_type_supported(self) -> bool:
29
29
  raise NotImplementedError()
30
30
 
31
+ def links_graphql_support_data(self) -> bool:
32
+ raise NotImplementedError()
33
+
31
34
  def get_server_version(self) -> str:
32
35
  raise NotImplementedError()
33
36
 
@@ -142,6 +145,9 @@ class BaseServerAPI:
142
145
  ):
143
146
  raise NotImplementedError()
144
147
 
148
+ def _prepare_link_fields(self, fields: set[str]) -> None:
149
+ raise NotImplementedError()
150
+
145
151
  def _prepare_advanced_filters(
146
152
  self, filters: Union[str, dict[str, Any], None]
147
153
  ) -> Optional[str]:
@@ -331,6 +331,8 @@ class FoldersAPI(BaseServerAPI):
331
331
  if own_attributes:
332
332
  fields.add("ownAttrib")
333
333
 
334
+ self._prepare_link_fields(fields)
335
+
334
336
  query = folders_graphql_query(fields)
335
337
  for attr, filter_value in graphql_filters.items():
336
338
  query.set_variable_value(attr, filter_value)
@@ -362,6 +362,7 @@ class LinksAPI(BaseServerAPI):
362
362
  return output
363
363
 
364
364
  link_fields = {"id", "links"}
365
+ self._prepare_link_fields(link_fields)
365
366
  query = query_func(link_fields)
366
367
  for attr, filter_value in filters.items():
367
368
  query.set_variable_value(attr, filter_value)
@@ -179,6 +179,8 @@ class ProductsAPI(BaseServerAPI):
179
179
  if filter_value:
180
180
  graphql_filters[filter_key] = filter_value
181
181
 
182
+ self._prepare_link_fields(fields)
183
+
182
184
  query = products_graphql_query(fields)
183
185
  for attr, filter_value in graphql_filters.items():
184
186
  query.set_variable_value(attr, filter_value)
@@ -108,6 +108,8 @@ class RepresentationsAPI(BaseServerAPI):
108
108
  fields.discard("files")
109
109
  fields |= REPRESENTATION_FILES_FIELDS
110
110
 
111
+ self._prepare_link_fields(fields)
112
+
111
113
  graphql_filters = {
112
114
  "projectName": project_name
113
115
  }
@@ -106,6 +106,8 @@ class TasksAPI(BaseServerAPI):
106
106
  if active is not None:
107
107
  fields.add("active")
108
108
 
109
+ self._prepare_link_fields(fields)
110
+
109
111
  query = tasks_graphql_query(fields)
110
112
  for attr, filter_value in graphql_filters.items():
111
113
  query.set_variable_value(attr, filter_value)
@@ -267,6 +269,8 @@ class TasksAPI(BaseServerAPI):
267
269
  if active is not None:
268
270
  fields.add("active")
269
271
 
272
+ self._prepare_link_fields(fields)
273
+
270
274
  query = tasks_by_folder_paths_graphql_query(fields)
271
275
  for attr, filter_value in graphql_filters.items():
272
276
  query.set_variable_value(attr, filter_value)
@@ -87,6 +87,8 @@ class VersionsAPI(BaseServerAPI):
87
87
  if active is not None:
88
88
  fields.add("active")
89
89
 
90
+ self._prepare_link_fields(fields)
91
+
90
92
  if own_attributes is not _PLACEHOLDER:
91
93
  warnings.warn(
92
94
  (
@@ -116,7 +118,6 @@ class VersionsAPI(BaseServerAPI):
116
118
  ):
117
119
  return
118
120
 
119
-
120
121
  filters = self._prepare_advanced_filters(filters)
121
122
  if filters:
122
123
  graphql_filters["filter"] = filters
@@ -93,6 +93,8 @@ class WorkfilesAPI(BaseServerAPI):
93
93
  fields = set(fields)
94
94
  self._prepare_fields("workfile", fields)
95
95
 
96
+ self._prepare_link_fields(fields)
97
+
96
98
  query = workfiles_info_graphql_query(fields)
97
99
 
98
100
  for attr, filter_value in filters.items():
@@ -1,18 +1,31 @@
1
+ from __future__ import annotations
2
+
1
3
  import collections
4
+ import typing
2
5
 
3
6
  from .constants import DEFAULT_LINK_FIELDS
4
7
  from .graphql import FIELD_VALUE, GraphQlQuery, fields_to_dict
5
8
 
9
+ if typing.TYPE_CHECKING:
10
+ from .graphql import (
11
+ GraphQlQueryEdgeField,
12
+ )
13
+
6
14
 
7
- def add_links_fields(entity_field, nested_fields):
15
+ def add_links_fields(
16
+ entity_field: GraphQlQueryEdgeField,
17
+ nested_fields: dict | None,
18
+ ) -> None:
8
19
  if "links" not in nested_fields:
9
20
  return
10
21
  links_fields = nested_fields.pop("links")
11
-
12
22
  link_edge_fields = set(DEFAULT_LINK_FIELDS)
23
+
13
24
  if isinstance(links_fields, dict):
14
25
  simple_fields = set(links_fields)
15
- simple_variant = len(simple_fields - link_edge_fields) == 0
26
+ diff = simple_fields - link_edge_fields
27
+ diff.discard("data")
28
+ simple_variant = len(diff) == 0
16
29
  else:
17
30
  simple_variant = True
18
31
  simple_fields = link_edge_fields
@@ -121,7 +134,7 @@ def product_types_query(fields):
121
134
  return query
122
135
 
123
136
 
124
- def folders_graphql_query(fields):
137
+ def folders_graphql_query(fields: set[str]) -> GraphQlQuery:
125
138
  query = GraphQlQuery("FoldersQuery")
126
139
  project_name_var = query.add_variable("projectName", "String!")
127
140
  folder_ids_var = query.add_variable("folderIds", "[String!]")
@@ -161,6 +174,7 @@ def folders_graphql_query(fields):
161
174
  folders_field.set_filter("filter", filter_var)
162
175
 
163
176
  nested_fields = fields_to_dict(fields)
177
+
164
178
  add_links_fields(folders_field, nested_fields)
165
179
 
166
180
  query_queue = collections.deque()
@@ -179,7 +193,7 @@ def folders_graphql_query(fields):
179
193
  return query
180
194
 
181
195
 
182
- def tasks_graphql_query(fields):
196
+ def tasks_graphql_query(fields: set[str]) -> GraphQlQuery:
183
197
  query = GraphQlQuery("TasksQuery")
184
198
  project_name_var = query.add_variable("projectName", "String!")
185
199
  task_ids_var = query.add_variable("taskIds", "[String!]")
@@ -227,7 +241,7 @@ def tasks_graphql_query(fields):
227
241
  return query
228
242
 
229
243
 
230
- def tasks_by_folder_paths_graphql_query(fields):
244
+ def tasks_by_folder_paths_graphql_query(fields: set[str]) -> GraphQlQuery:
231
245
  query = GraphQlQuery("TasksByFolderPathQuery")
232
246
  project_name_var = query.add_variable("projectName", "String!")
233
247
  task_names_var = query.add_variable("taskNames", "[String!]")
@@ -258,6 +272,7 @@ def tasks_by_folder_paths_graphql_query(fields):
258
272
  tasks_field.set_filter("filter", filter_var)
259
273
 
260
274
  nested_fields = fields_to_dict(fields)
275
+
261
276
  add_links_fields(tasks_field, nested_fields)
262
277
 
263
278
  query_queue = collections.deque()
@@ -276,7 +291,7 @@ def tasks_by_folder_paths_graphql_query(fields):
276
291
  return query
277
292
 
278
293
 
279
- def products_graphql_query(fields):
294
+ def products_graphql_query(fields: set[str]) -> GraphQlQuery:
280
295
  query = GraphQlQuery("ProductsQuery")
281
296
 
282
297
  project_name_var = query.add_variable("projectName", "String!")
@@ -326,7 +341,7 @@ def products_graphql_query(fields):
326
341
  return query
327
342
 
328
343
 
329
- def versions_graphql_query(fields):
344
+ def versions_graphql_query(fields: set[str]) -> GraphQlQuery:
330
345
  query = GraphQlQuery("VersionsQuery")
331
346
 
332
347
  project_name_var = query.add_variable("projectName", "String!")
@@ -377,7 +392,7 @@ def versions_graphql_query(fields):
377
392
  return query
378
393
 
379
394
 
380
- def representations_graphql_query(fields):
395
+ def representations_graphql_query(fields: set[str]) -> GraphQlQuery:
381
396
  query = GraphQlQuery("RepresentationsQuery")
382
397
 
383
398
  project_name_var = query.add_variable("projectName", "String!")
@@ -525,7 +540,7 @@ def representations_hierarchy_qraphql_query(
525
540
  return query
526
541
 
527
542
 
528
- def workfiles_info_graphql_query(fields):
543
+ def workfiles_info_graphql_query(fields: set[str]) -> GraphQlQuery:
529
544
  query = GraphQlQuery("WorkfilesInfo")
530
545
  project_name_var = query.add_variable("projectName", "String!")
531
546
  workfiles_info_ids = query.add_variable("workfileIds", "[String!]")
@@ -834,8 +834,8 @@ class OperationsSession(object):
834
834
  if body is not None:
835
835
  operations_body.append(body)
836
836
 
837
- self._con.send_batch_operations(
838
- project_name, operations_body, can_fail=False
837
+ self._con.send_background_batch_operations(
838
+ project_name, operations_body, wait=True, can_fail=False
839
839
  )
840
840
 
841
841
  def create_entity(
@@ -38,6 +38,7 @@ from .constants import (
38
38
  DEFAULT_ACTIVITY_FIELDS,
39
39
  DEFAULT_USER_FIELDS,
40
40
  DEFAULT_ENTITY_LIST_FIELDS,
41
+ DEFAULT_LINK_FIELDS,
41
42
  )
42
43
  from .graphql import INTROSPECTION_QUERY
43
44
  from .graphql_queries import users_graphql_query
@@ -329,6 +330,7 @@ class ServerAPI(
329
330
 
330
331
  self._graphql_allows_traits_in_representations: Optional[bool] = None
331
332
  self._product_base_type_supported = None
333
+ self._links_graphql_support_data = None
332
334
 
333
335
  self._session = None
334
336
 
@@ -922,6 +924,15 @@ class ServerAPI(
922
924
  )
923
925
  return self._product_base_type_supported
924
926
 
927
+ def links_graphql_support_data(self) -> bool:
928
+ """Links data can be received by GraphQl."""
929
+ if self._links_graphql_support_data is None:
930
+ major, minor, patch, _, _ = self.server_version_tuple
931
+ self._links_graphql_support_data = (
932
+ (major, minor, patch) >= (1, 14, 2)
933
+ )
934
+ return self._links_graphql_support_data
935
+
925
936
  def _get_user_info(self) -> Optional[dict[str, Any]]:
926
937
  if self._access_token is None:
927
938
  return None
@@ -2445,6 +2456,17 @@ class ServerAPI(
2445
2456
  )
2446
2457
  }
2447
2458
 
2459
+ def _prepare_link_fields(self, fields: set[str]) -> None:
2460
+ if "links" not in fields:
2461
+ return
2462
+
2463
+ fields.discard("links")
2464
+ for field in DEFAULT_LINK_FIELDS:
2465
+ fields.add(f"links.{field}")
2466
+
2467
+ if self.links_graphql_support_data():
2468
+ fields.add("links.data")
2469
+
2448
2470
  def _prepare_advanced_filters(
2449
2471
  self, filters: Union[str, dict[str, Any], None]
2450
2472
  ) -> Optional[str]:
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for AYON server."""
2
- __version__ = "1.2.12"
2
+ __version__ = "1.2.13"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ayon_python_api
3
- Version: 1.2.12
3
+ Version: 1.2.13
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.2.12"
3
+ version = "1.2.13"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}
@@ -28,7 +28,7 @@ build-backend = "poetry.core.masonry.api"
28
28
 
29
29
  [tool.poetry]
30
30
  name = "ayon_python_api"
31
- version = "1.2.12"
31
+ version = "1.2.13"
32
32
  description = "AYON Python API"
33
33
  authors = [
34
34
  "ynput.io <info@ynput.io>"