Ayon-Python-Api 0.3.4__tar.gz → 0.3.5__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 (24) hide show
  1. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/PKG-INFO +1 -1
  2. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/__init__.py +22 -0
  3. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/_api.py +62 -0
  4. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/constants.py +19 -0
  5. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/graphql_queries.py +25 -0
  6. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/operations.py +93 -24
  7. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/server_api.py +282 -88
  8. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/utils.py +39 -0
  9. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/version.py +1 -1
  10. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_python_api.egg-info/PKG-INFO +1 -1
  11. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_python_api.egg-info/SOURCES.txt +0 -1
  12. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/pyproject.toml +1 -1
  13. ayon-python-api-0.3.4/ayon_api/thumbnails.py +0 -219
  14. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/LICENSE +0 -0
  15. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/README.md +0 -0
  16. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/entity_hub.py +0 -0
  17. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/events.py +0 -0
  18. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/exceptions.py +0 -0
  19. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_api/graphql.py +0 -0
  20. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  21. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_python_api.egg-info/requires.txt +0 -0
  22. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/ayon_python_api.egg-info/top_level.txt +0 -0
  23. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/setup.cfg +0 -0
  24. {ayon-python-api-0.3.4 → ayon-python-api-0.3.5}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.3.4
3
+ Version: 0.3.5
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -30,6 +30,8 @@ from ._api import (
30
30
  set_client_version,
31
31
  get_default_settings_variant,
32
32
  set_default_settings_variant,
33
+ get_sender,
34
+ set_sender,
33
35
 
34
36
  get_base_url,
35
37
  get_rest_url,
@@ -92,6 +94,7 @@ from ._api import (
92
94
  get_users,
93
95
 
94
96
  get_attributes_for_type,
97
+ get_attributes_fields_for_type,
95
98
  get_default_fields_for_type,
96
99
 
97
100
  get_project_anatomy_preset,
@@ -110,6 +113,11 @@ from ._api import (
110
113
  get_addons_project_settings,
111
114
  get_addons_settings,
112
115
 
116
+ get_secrets,
117
+ get_secret,
118
+ save_secret,
119
+ delete_secret,
120
+
113
121
  get_project_names,
114
122
  get_projects,
115
123
  get_project,
@@ -124,6 +132,8 @@ from ._api import (
124
132
  get_folders_hierarchy,
125
133
 
126
134
  get_tasks,
135
+ get_task_by_id,
136
+ get_task_by_name,
127
137
 
128
138
  get_folder_ids_with_products,
129
139
  get_product_by_id,
@@ -154,6 +164,7 @@ from ._api import (
154
164
  get_workfile_info,
155
165
  get_workfile_info_by_id,
156
166
 
167
+ get_thumbnail_by_id,
157
168
  get_thumbnail,
158
169
  get_folder_thumbnail,
159
170
  get_version_thumbnail,
@@ -216,6 +227,8 @@ __all__ = (
216
227
  "set_client_version",
217
228
  "get_default_settings_variant",
218
229
  "set_default_settings_variant",
230
+ "get_sender",
231
+ "set_sender",
219
232
 
220
233
  "get_base_url",
221
234
  "get_rest_url",
@@ -278,6 +291,7 @@ __all__ = (
278
291
  "get_users",
279
292
 
280
293
  "get_attributes_for_type",
294
+ "get_attributes_fields_for_type",
281
295
  "get_default_fields_for_type",
282
296
 
283
297
  "get_project_anatomy_preset",
@@ -295,6 +309,11 @@ __all__ = (
295
309
  "get_addons_project_settings",
296
310
  "get_addons_settings",
297
311
 
312
+ "get_secrets",
313
+ "get_secret",
314
+ "save_secret",
315
+ "delete_secret",
316
+
298
317
  "get_project_names",
299
318
  "get_projects",
300
319
  "get_project",
@@ -308,6 +327,8 @@ __all__ = (
308
327
  "get_folders",
309
328
 
310
329
  "get_tasks",
330
+ "get_task_by_id",
331
+ "get_task_by_name",
311
332
 
312
333
  "get_folder_ids_with_products",
313
334
  "get_product_by_id",
@@ -338,6 +359,7 @@ __all__ = (
338
359
  "get_workfile_info",
339
360
  "get_workfile_info_by_id",
340
361
 
362
+ "get_thumbnail_by_id",
341
363
  "get_thumbnail",
342
364
  "get_folder_thumbnail",
343
365
  "get_version_thumbnail",
@@ -392,6 +392,28 @@ def set_default_settings_variant(variant):
392
392
  return con.set_default_settings_variant(variant)
393
393
 
394
394
 
395
+ def get_sender():
396
+ """Sender used to send requests.
397
+
398
+ Returns:
399
+ Union[str, None]: Sender name or None.
400
+ """
401
+
402
+ con = get_server_api_connection()
403
+ return con.get_sender()
404
+
405
+
406
+ def set_sender(sender):
407
+ """Change sender used for requests.
408
+
409
+ Args:
410
+ sender (Union[str, None]): Sender name or None.
411
+ """
412
+
413
+ con = get_server_api_connection()
414
+ return con.set_sender(sender)
415
+
416
+
395
417
  def get_base_url():
396
418
  con = get_server_api_connection()
397
419
  return con.get_base_url()
@@ -704,6 +726,26 @@ def get_addons_settings(*args, **kwargs):
704
726
  return con.get_addons_settings(*args, **kwargs)
705
727
 
706
728
 
729
+ def get_secrets(*args, **kwargs):
730
+ con = get_server_api_connection()
731
+ return con.get_secrets(*args, **kwargs)
732
+
733
+
734
+ def get_secret(*args, **kwargs):
735
+ con = get_server_api_connection()
736
+ return con.delete_secret(*args, **kwargs)
737
+
738
+
739
+ def save_secret(*args, **kwargs):
740
+ con = get_server_api_connection()
741
+ return con.delete_secret(*args, **kwargs)
742
+
743
+
744
+ def delete_secret(*args, **kwargs):
745
+ con = get_server_api_connection()
746
+ return con.delete_secret(*args, **kwargs)
747
+
748
+
707
749
  def get_project_names(*args, **kwargs):
708
750
  con = get_server_api_connection()
709
751
  return con.get_project_names(*args, **kwargs)
@@ -734,6 +776,16 @@ def get_tasks(*args, **kwargs):
734
776
  return con.get_tasks(*args, **kwargs)
735
777
 
736
778
 
779
+ def get_task_by_id(*args, **kwargs):
780
+ con = get_server_api_connection()
781
+ return con.get_task_by_id(*args, **kwargs)
782
+
783
+
784
+ def get_task_by_name(*args, **kwargs):
785
+ con = get_server_api_connection()
786
+ return con.get_task_by_name(*args, **kwargs)
787
+
788
+
737
789
  def get_folder_by_id(*args, **kwargs):
738
790
  con = get_server_api_connection()
739
791
  return con.get_folder_by_id(*args, **kwargs)
@@ -904,6 +956,11 @@ def delete_project(project_name):
904
956
  return con.delete_project(project_name)
905
957
 
906
958
 
959
+ def get_thumbnail_by_id(project_name, thumbnail_id):
960
+ con = get_server_api_connection()
961
+ con.get_thumbnail_by_id(project_name, thumbnail_id)
962
+
963
+
907
964
  def get_thumbnail(project_name, entity_type, entity_id, thumbnail_id=None):
908
965
  con = get_server_api_connection()
909
966
  con.get_thumbnail(project_name, entity_type, entity_id, thumbnail_id)
@@ -934,6 +991,11 @@ def update_thumbnail(project_name, thumbnail_id, src_filepath):
934
991
  return con.update_thumbnail(project_name, thumbnail_id, src_filepath)
935
992
 
936
993
 
994
+ def get_attributes_fields_for_type(entity_type):
995
+ con = get_server_api_connection()
996
+ return con.get_attributes_fields_for_type(entity_type)
997
+
998
+
937
999
  def get_default_fields_for_type(entity_type):
938
1000
  con = get_server_api_connection()
939
1001
  return con.get_default_fields_for_type(entity_type)
@@ -4,6 +4,25 @@ SERVER_API_ENV_KEY = "AYON_API_KEY"
4
4
  # Backwards compatibility
5
5
  SERVER_TOKEN_ENV_KEY = SERVER_API_ENV_KEY
6
6
 
7
+ # --- User ---
8
+ DEFAULT_USER_FIELDS = {
9
+ "roles",
10
+ "name",
11
+ "isService",
12
+ "isManager",
13
+ "isGuest",
14
+ "isAdmin",
15
+ "defaultRoles",
16
+ "createdAt",
17
+ "active",
18
+ "hasPassword",
19
+ "updatedAt",
20
+ "apiKeyPreview",
21
+ "attrib.avatarUrl",
22
+ "attrib.email",
23
+ "attrib.fullName",
24
+ }
25
+
7
26
  # --- Product types ---
8
27
  DEFAULT_PRODUCT_TYPE_FIELDS = {
9
28
  "name",
@@ -462,3 +462,28 @@ def events_graphql_query(fields):
462
462
  for k, v in value.items():
463
463
  query_queue.append((k, v, field))
464
464
  return query
465
+
466
+
467
+ def users_graphql_query(fields):
468
+ query = GraphQlQuery("Users")
469
+ names_var = query.add_variable("userNames", "[String!]")
470
+
471
+ users_field = query.add_field_with_edges("users")
472
+ users_field.set_filter("names", names_var)
473
+
474
+ nested_fields = fields_to_dict(set(fields))
475
+
476
+ query_queue = collections.deque()
477
+ for key, value in nested_fields.items():
478
+ query_queue.append((key, value, users_field))
479
+
480
+ while query_queue:
481
+ item = query_queue.popleft()
482
+ key, value, parent = item
483
+ field = parent.add_field(key)
484
+ if value is FIELD_VALUE:
485
+ continue
486
+
487
+ for k, v in value.items():
488
+ query_queue.append((k, v, field))
489
+ return query
@@ -1,3 +1,4 @@
1
+ import os
1
2
  import copy
2
3
  import collections
3
4
  import uuid
@@ -22,6 +23,8 @@ def new_folder_entity(
22
23
  name,
23
24
  folder_type,
24
25
  parent_id=None,
26
+ status=None,
27
+ tags=None,
25
28
  attribs=None,
26
29
  data=None,
27
30
  thumbnail_id=None,
@@ -32,12 +35,14 @@ def new_folder_entity(
32
35
  Args:
33
36
  name (str): Is considered as unique identifier of folder in project.
34
37
  folder_type (str): Type of folder.
35
- parent_id (Optional[str]]): Id of parent folder.
38
+ parent_id (Optional[str]): Parent folder id.
39
+ status (Optional[str]): Product status.
40
+ tags (Optional[List[str]]): List of tags.
36
41
  attribs (Optional[Dict[str, Any]]): Explicitly set attributes
37
42
  of folder.
38
43
  data (Optional[Dict[str, Any]]): Custom folder data. Empty dictionary
39
44
  is used if not passed.
40
- thumbnail_id (Optional[str]): Id of thumbnail related to folder.
45
+ thumbnail_id (Optional[str]): Thumbnail id related to folder.
41
46
  entity_id (Optional[str]): Predefined id of entity. New id is
42
47
  created if not passed.
43
48
 
@@ -54,7 +59,7 @@ def new_folder_entity(
54
59
  if parent_id is not None:
55
60
  parent_id = _create_or_convert_to_id(parent_id)
56
61
 
57
- return {
62
+ output = {
58
63
  "id": _create_or_convert_to_id(entity_id),
59
64
  "name": name,
60
65
  # This will be ignored
@@ -64,6 +69,11 @@ def new_folder_entity(
64
69
  "attrib": attribs,
65
70
  "thumbnailId": thumbnail_id
66
71
  }
72
+ if status:
73
+ output["status"] = status
74
+ if tags:
75
+ output["tags"] = tags
76
+ return output
67
77
 
68
78
 
69
79
  def new_product_entity(
@@ -71,6 +81,7 @@ def new_product_entity(
71
81
  product_type,
72
82
  folder_id,
73
83
  status=None,
84
+ tags=None,
74
85
  attribs=None,
75
86
  data=None,
76
87
  entity_id=None
@@ -81,8 +92,9 @@ def new_product_entity(
81
92
  name (str): Is considered as unique identifier of
82
93
  product under folder.
83
94
  product_type (str): Product type.
84
- folder_id (str): Id of parent folder.
95
+ folder_id (str): Parent folder id.
85
96
  status (Optional[str]): Product status.
97
+ tags (Optional[List[str]]): List of tags.
86
98
  attribs (Optional[Dict[str, Any]]): Explicitly set attributes
87
99
  of product.
88
100
  data (Optional[Dict[str, Any]]): product entity data. Empty dictionary
@@ -110,6 +122,8 @@ def new_product_entity(
110
122
  }
111
123
  if status:
112
124
  output["status"] = status
125
+ if tags:
126
+ output["tags"] = tags
113
127
  return output
114
128
 
115
129
 
@@ -119,6 +133,8 @@ def new_version_entity(
119
133
  task_id=None,
120
134
  thumbnail_id=None,
121
135
  author=None,
136
+ status=None,
137
+ tags=None,
122
138
  attribs=None,
123
139
  data=None,
124
140
  entity_id=None
@@ -128,10 +144,12 @@ def new_version_entity(
128
144
  Args:
129
145
  version (int): Is considered as unique identifier of version
130
146
  under product.
131
- product_id (str): Id of parent product.
132
- task_id (Optional[str]]): Id of task under which product was created.
133
- thumbnail_id (Optional[str]]): Thumbnail related to version.
134
- author (Optional[str]]): Name of version author.
147
+ product_id (str): Parent product id.
148
+ task_id (Optional[str]): Task id under which product was created.
149
+ thumbnail_id (Optional[str]): Thumbnail related to version.
150
+ author (Optional[str]): Name of version author.
151
+ status (Optional[str]): Version status.
152
+ tags (Optional[List[str]]): List of tags.
135
153
  attribs (Optional[Dict[str, Any]]): Explicitly set attributes
136
154
  of version.
137
155
  data (Optional[Dict[str, Any]]): Version entity custom data.
@@ -164,6 +182,10 @@ def new_version_entity(
164
182
  output["thumbnailId"] = thumbnail_id
165
183
  if author:
166
184
  output["author"] = author
185
+ if tags:
186
+ output["tags"] = tags
187
+ if status:
188
+ output["status"] = status
167
189
  return output
168
190
 
169
191
 
@@ -173,6 +195,8 @@ def new_hero_version_entity(
173
195
  task_id=None,
174
196
  thumbnail_id=None,
175
197
  author=None,
198
+ status=None,
199
+ tags=None,
176
200
  attribs=None,
177
201
  data=None,
178
202
  entity_id=None
@@ -182,10 +206,12 @@ def new_hero_version_entity(
182
206
  Args:
183
207
  version (int): Is considered as unique identifier of version
184
208
  under product. Should be same as standard version if there is any.
185
- product_id (str): Id of parent product.
186
- task_id (Optional[str]): Id of task under which product was created.
209
+ product_id (str): Parent product id.
210
+ task_id (Optional[str]): Task id under which product was created.
187
211
  thumbnail_id (Optional[str]): Thumbnail related to version.
188
212
  author (Optional[str]): Name of version author.
213
+ status (Optional[str]): Version status.
214
+ tags (Optional[List[str]]): List of tags.
189
215
  attribs (Optional[Dict[str, Any]]): Explicitly set attributes
190
216
  of version.
191
217
  data (Optional[Dict[str, Any]]): Version entity data.
@@ -215,18 +241,32 @@ def new_hero_version_entity(
215
241
  output["thumbnailId"] = thumbnail_id
216
242
  if author:
217
243
  output["author"] = author
244
+ if tags:
245
+ output["tags"] = tags
246
+ if status:
247
+ output["status"] = status
218
248
  return output
219
249
 
220
250
 
221
251
  def new_representation_entity(
222
- name, version_id, attribs=None, data=None, entity_id=None
252
+ name,
253
+ version_id,
254
+ files,
255
+ status=None,
256
+ tags=None,
257
+ attribs=None,
258
+ data=None,
259
+ entity_id=None
223
260
  ):
224
261
  """Create skeleton data of representation entity.
225
262
 
226
263
  Args:
227
264
  name (str): Representation name considered as unique identifier
228
265
  of representation under version.
229
- version_id (str): Id of parent version.
266
+ version_id (str): Parent version id.
267
+ files (list[dict[str, str]]): List of files in representation.
268
+ status (Optional[str]): Representation status.
269
+ tags (Optional[List[str]]): List of tags.
230
270
  attribs (Optional[Dict[str, Any]]): Explicitly set attributes
231
271
  of representation.
232
272
  data (Optional[Dict[str, Any]]): Representation entity data.
@@ -243,27 +283,42 @@ def new_representation_entity(
243
283
  if data is None:
244
284
  data = {}
245
285
 
246
- return {
286
+ output = {
247
287
  "id": _create_or_convert_to_id(entity_id),
248
288
  "versionId": _create_or_convert_to_id(version_id),
289
+ "files": files,
249
290
  "name": name,
250
291
  "data": data,
251
292
  "attrib": attribs
252
293
  }
294
+ if tags:
295
+ output["tags"] = tags
296
+ if status:
297
+ output["status"] = status
298
+ return output
253
299
 
254
300
 
255
- def new_workfile_info_doc(
256
- filename, folder_id, task_name, files, data=None, entity_id=None
301
+ def new_workfile_info(
302
+ filepath,
303
+ task_id,
304
+ status=None,
305
+ tags=None,
306
+ attribs=None,
307
+ description=None,
308
+ data=None,
309
+ entity_id=None
257
310
  ):
258
311
  """Create skeleton data of workfile info entity.
259
312
 
260
313
  Workfile entity is at this moment used primarily for artist notes.
261
314
 
262
315
  Args:
263
- filename (str): Filename of workfile.
264
- folder_id (str): Id of folder under which workfile live.
265
- task_name (str): Task under which was workfile created.
266
- files (List[str]): List of rootless filepaths related to workfile.
316
+ filepath (str): Rootless workfile filepath.
317
+ task_id (str): Task under which was workfile created.
318
+ status (Optional[str]): Workfile status.
319
+ tags (Optional[List[str]]): Workfile tags.
320
+ attribs (Options[dic[str, Any]]): Explicitly set attributes.
321
+ description (Optional[str]): Workfile description.
267
322
  data (Optional[Dict[str, Any]]): Additional metadata.
268
323
  entity_id (Optional[str]): Predefined id of entity. New id is created
269
324
  if not passed.
@@ -272,17 +327,31 @@ def new_workfile_info_doc(
272
327
  Dict[str, Any]: Skeleton of workfile info entity.
273
328
  """
274
329
 
330
+ if attribs is None:
331
+ attribs = {}
332
+
333
+ if "extension" not in attribs:
334
+ attribs["extension"] = os.path.splitext(filepath)[-1]
335
+
336
+ if description:
337
+ attribs["description"] = description
338
+
275
339
  if not data:
276
340
  data = {}
277
341
 
278
- return {
342
+ output = {
279
343
  "id": _create_or_convert_to_id(entity_id),
280
- "parent": _create_or_convert_to_id(folder_id),
281
- "task_name": task_name,
282
- "filename": filename,
344
+ "taskId": task_id,
345
+ "path": filepath,
283
346
  "data": data,
284
- "files": files
347
+ "attrib": attribs
285
348
  }
349
+ if status:
350
+ output["status"] = status
351
+
352
+ if tags:
353
+ output["tags"] = tags
354
+ return output
286
355
 
287
356
 
288
357
  @six.add_metaclass(ABCMeta)