ayon-python-api 1.0.6__tar.gz → 1.0.7__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.6 → ayon-python-api-1.0.7}/PKG-INFO +1 -1
  2. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/__init__.py +2 -0
  3. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/_api.py +38 -1
  4. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/graphql_queries.py +9 -1
  5. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/server_api.py +65 -4
  6. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/utils.py +8 -1
  7. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/version.py +1 -1
  8. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_python_api.egg-info/PKG-INFO +1 -1
  9. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/pyproject.toml +2 -2
  10. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/LICENSE +0 -0
  11. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/README.md +0 -0
  12. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/constants.py +0 -0
  13. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/entity_hub.py +0 -0
  14. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/events.py +0 -0
  15. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/exceptions.py +0 -0
  16. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/graphql.py +0 -0
  17. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_api/operations.py +0 -0
  18. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  19. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  20. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_python_api.egg-info/requires.txt +0 -0
  21. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/ayon_python_api.egg-info/top_level.txt +0 -0
  22. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/setup.cfg +0 -0
  23. {ayon-python-api-1.0.6 → ayon-python-api-1.0.7}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -46,6 +46,7 @@ from ._api import (
46
46
  get_server_version,
47
47
  get_server_version_tuple,
48
48
  get_users,
49
+ get_user_by_name,
49
50
  get_user,
50
51
  raw_post,
51
52
  raw_put,
@@ -268,6 +269,7 @@ __all__ = (
268
269
  "get_server_version",
269
270
  "get_server_version_tuple",
270
271
  "get_users",
272
+ "get_user_by_name",
271
273
  "get_user",
272
274
  "raw_post",
273
275
  "raw_put",
@@ -594,9 +594,13 @@ def get_server_version_tuple():
594
594
  def get_users(*args, **kwargs):
595
595
  """Get Users.
596
596
 
597
+ Only administrators and managers can fetch all users. For other users
598
+ it is required to pass in 'project_name' filter.
599
+
597
600
  Args:
601
+ project_name (Optional[str]): Project name.
598
602
  usernames (Optional[Iterable[str]]): Filter by usernames.
599
- fields (Optional[Iterable[str]]): fields to be queried
603
+ fields (Optional[Iterable[str]]): Fields to be queried
600
604
  for users.
601
605
 
602
606
  Returns:
@@ -607,7 +611,38 @@ def get_users(*args, **kwargs):
607
611
  return con.get_users(*args, **kwargs)
608
612
 
609
613
 
614
+ def get_user_by_name(*args, **kwargs):
615
+ """Get user by name using GraphQl.
616
+
617
+ Only administrators and managers can fetch all users. For other users
618
+ it is required to pass in 'project_name' filter.
619
+
620
+ Args:
621
+ username (str): Username.
622
+ project_name (Optional[str]): Define scope of project.
623
+ fields (Optional[Iterable[str]]): Fields to be queried
624
+ for users.
625
+
626
+ Returns:
627
+ Union[dict[str, Any], None]: User info or None if user is not
628
+ found.
629
+
630
+ """
631
+ con = get_server_api_connection()
632
+ return con.get_user_by_name(*args, **kwargs)
633
+
634
+
610
635
  def get_user(*args, **kwargs):
636
+ """Get user info using REST endpoit.
637
+
638
+ Args:
639
+ username (Optional[str]): Username.
640
+
641
+ Returns:
642
+ Union[dict[str, Any], None]: User info or None if user is not
643
+ found.
644
+
645
+ """
611
646
  con = get_server_api_connection()
612
647
  return con.get_user(*args, **kwargs)
613
648
 
@@ -3310,6 +3345,7 @@ def get_representations_hierarchy(*args, **kwargs):
3310
3345
  representation_ids (Iterable[str]): Representation ids.
3311
3346
  project_fields (Optional[Iterable[str]]): Project fields.
3312
3347
  folder_fields (Optional[Iterable[str]]): Folder fields.
3348
+ task_fields (Optional[Iterable[str]]): Task fields.
3313
3349
  product_fields (Optional[Iterable[str]]): Product fields.
3314
3350
  version_fields (Optional[Iterable[str]]): Version fields.
3315
3351
  representation_fields (Optional[Iterable[str]]): Representation
@@ -3334,6 +3370,7 @@ def get_representation_hierarchy(*args, **kwargs):
3334
3370
  representation_id (str): Representation id.
3335
3371
  project_fields (Optional[Iterable[str]]): Project fields.
3336
3372
  folder_fields (Optional[Iterable[str]]): Folder fields.
3373
+ task_fields (Optional[Iterable[str]]): Task fields.
3337
3374
  product_fields (Optional[Iterable[str]]): Product fields.
3338
3375
  version_fields (Optional[Iterable[str]]): Version fields.
3339
3376
  representation_fields (Optional[Iterable[str]]): Representation
@@ -466,6 +466,7 @@ def representations_parents_qraphql_query(
466
466
 
467
467
  def representations_hierarchy_qraphql_query(
468
468
  folder_fields,
469
+ task_fields,
469
470
  product_fields,
470
471
  version_fields,
471
472
  representation_fields,
@@ -486,12 +487,17 @@ def representations_hierarchy_qraphql_query(
486
487
 
487
488
  repres_field.set_filter("ids", repre_ids_var)
488
489
  version_field = None
489
- if folder_fields or product_fields or version_fields:
490
+ if folder_fields or task_fields or product_fields or version_fields:
490
491
  version_field = repres_field.add_field("version")
491
492
  if version_fields:
492
493
  for key, value in fields_to_dict(version_fields).items():
493
494
  fields_queue.append((key, value, version_field))
494
495
 
496
+ if task_fields:
497
+ task_field = version_field.add_field("task")
498
+ for key, value in fields_to_dict(task_fields).items():
499
+ fields_queue.append((key, value, task_field))
500
+
495
501
  product_field = None
496
502
  if folder_fields or product_fields:
497
503
  product_field = version_field.add_field("product")
@@ -600,9 +606,11 @@ def events_graphql_query(fields):
600
606
  def users_graphql_query(fields):
601
607
  query = GraphQlQuery("Users")
602
608
  names_var = query.add_variable("userNames", "[String!]")
609
+ project_name_var = query.add_variable("projectName", "String!")
603
610
 
604
611
  users_field = query.add_field_with_edges("users")
605
612
  users_field.set_filter("names", names_var)
613
+ users_field.set_filter("projectName", project_name_var)
606
614
 
607
615
  nested_fields = fields_to_dict(set(fields))
608
616
 
@@ -1028,12 +1028,16 @@ class ServerAPI(object):
1028
1028
  self._access_token_is_service = None
1029
1029
  return None
1030
1030
 
1031
- def get_users(self, usernames=None, fields=None):
1031
+ def get_users(self, project_name=None, usernames=None, fields=None):
1032
1032
  """Get Users.
1033
1033
 
1034
+ Only administrators and managers can fetch all users. For other users
1035
+ it is required to pass in 'project_name' filter.
1036
+
1034
1037
  Args:
1038
+ project_name (Optional[str]): Project name.
1035
1039
  usernames (Optional[Iterable[str]]): Filter by usernames.
1036
- fields (Optional[Iterable[str]]): fields to be queried
1040
+ fields (Optional[Iterable[str]]): Fields to be queried
1037
1041
  for users.
1038
1042
 
1039
1043
  Returns:
@@ -1047,6 +1051,9 @@ class ServerAPI(object):
1047
1051
  return
1048
1052
  filters["userNames"] = list(usernames)
1049
1053
 
1054
+ if project_name is not None:
1055
+ filters["projectName"] = project_name
1056
+
1050
1057
  if not fields:
1051
1058
  fields = self.get_default_fields_for_type("user")
1052
1059
 
@@ -1060,7 +1067,45 @@ class ServerAPI(object):
1060
1067
  user["accessGroups"])
1061
1068
  yield user
1062
1069
 
1070
+ def get_user_by_name(self, username, project_name=None, fields=None):
1071
+ """Get user by name using GraphQl.
1072
+
1073
+ Only administrators and managers can fetch all users. For other users
1074
+ it is required to pass in 'project_name' filter.
1075
+
1076
+ Args:
1077
+ username (str): Username.
1078
+ project_name (Optional[str]): Define scope of project.
1079
+ fields (Optional[Iterable[str]]): Fields to be queried
1080
+ for users.
1081
+
1082
+ Returns:
1083
+ Union[dict[str, Any], None]: User info or None if user is not
1084
+ found.
1085
+
1086
+ """
1087
+ if not username:
1088
+ return None
1089
+
1090
+ for user in self.get_users(
1091
+ project_name=project_name,
1092
+ usernames={username},
1093
+ fields=fields,
1094
+ ):
1095
+ return user
1096
+ return None
1097
+
1063
1098
  def get_user(self, username=None):
1099
+ """Get user info using REST endpoit.
1100
+
1101
+ Args:
1102
+ username (Optional[str]): Username.
1103
+
1104
+ Returns:
1105
+ Union[dict[str, Any], None]: User info or None if user is not
1106
+ found.
1107
+
1108
+ """
1064
1109
  if username is None:
1065
1110
  output = self._get_user_info()
1066
1111
  if output is None:
@@ -6336,6 +6381,7 @@ class ServerAPI(object):
6336
6381
  representation_ids,
6337
6382
  project_fields=None,
6338
6383
  folder_fields=None,
6384
+ task_fields=None,
6339
6385
  product_fields=None,
6340
6386
  version_fields=None,
6341
6387
  representation_fields=None,
@@ -6353,6 +6399,7 @@ class ServerAPI(object):
6353
6399
  representation_ids (Iterable[str]): Representation ids.
6354
6400
  project_fields (Optional[Iterable[str]]): Project fields.
6355
6401
  folder_fields (Optional[Iterable[str]]): Folder fields.
6402
+ task_fields (Optional[Iterable[str]]): Task fields.
6356
6403
  product_fields (Optional[Iterable[str]]): Product fields.
6357
6404
  version_fields (Optional[Iterable[str]]): Version fields.
6358
6405
  representation_fields (Optional[Iterable[str]]): Representation
@@ -6383,7 +6430,7 @@ class ServerAPI(object):
6383
6430
  repre_ids = set(representation_ids)
6384
6431
  output = {
6385
6432
  repre_id: RepresentationHierarchy(
6386
- project, None, None, None, None
6433
+ project, None, None, None, None, None
6387
6434
  )
6388
6435
  for repre_id in representation_ids
6389
6436
  }
@@ -6393,6 +6440,11 @@ class ServerAPI(object):
6393
6440
  else:
6394
6441
  folder_fields = set(folder_fields)
6395
6442
 
6443
+ if task_fields is None:
6444
+ task_fields = self.get_default_fields_for_type("task")
6445
+ else:
6446
+ task_fields = set(task_fields)
6447
+
6396
6448
  if product_fields is None:
6397
6449
  product_fields = self.get_default_fields_for_type("product")
6398
6450
  else:
@@ -6414,6 +6466,7 @@ class ServerAPI(object):
6414
6466
 
6415
6467
  query = representations_hierarchy_qraphql_query(
6416
6468
  folder_fields,
6469
+ task_fields,
6417
6470
  product_fields,
6418
6471
  version_fields,
6419
6472
  representation_fields,
@@ -6426,12 +6479,16 @@ class ServerAPI(object):
6426
6479
  repre_id = repre["id"]
6427
6480
  version = repre.pop("version", {})
6428
6481
  product = version.pop("product", {})
6482
+ task = version.pop("task", None)
6429
6483
  folder = product.pop("folder", {})
6430
6484
  self._convert_entity_data(version)
6431
6485
  self._convert_entity_data(product)
6432
6486
  self._convert_entity_data(folder)
6487
+ if task:
6488
+ self._convert_entity_data(task)
6489
+
6433
6490
  output[repre_id] = RepresentationHierarchy(
6434
- project, folder, product, version, repre
6491
+ project, folder, task, product, version, repre
6435
6492
  )
6436
6493
 
6437
6494
  return output
@@ -6442,6 +6499,7 @@ class ServerAPI(object):
6442
6499
  representation_id,
6443
6500
  project_fields=None,
6444
6501
  folder_fields=None,
6502
+ task_fields=None,
6445
6503
  product_fields=None,
6446
6504
  version_fields=None,
6447
6505
  representation_fields=None,
@@ -6455,6 +6513,7 @@ class ServerAPI(object):
6455
6513
  representation_id (str): Representation id.
6456
6514
  project_fields (Optional[Iterable[str]]): Project fields.
6457
6515
  folder_fields (Optional[Iterable[str]]): Folder fields.
6516
+ task_fields (Optional[Iterable[str]]): Task fields.
6458
6517
  product_fields (Optional[Iterable[str]]): Product fields.
6459
6518
  version_fields (Optional[Iterable[str]]): Version fields.
6460
6519
  representation_fields (Optional[Iterable[str]]): Representation
@@ -6472,6 +6531,7 @@ class ServerAPI(object):
6472
6531
  [representation_id],
6473
6532
  project_fields=project_fields,
6474
6533
  folder_fields=folder_fields,
6534
+ task_fields=task_fields,
6475
6535
  product_fields=product_fields,
6476
6536
  version_fields=version_fields,
6477
6537
  representation_fields=representation_fields,
@@ -6509,6 +6569,7 @@ class ServerAPI(object):
6509
6569
  representation_ids,
6510
6570
  project_fields=project_fields,
6511
6571
  folder_fields=folder_fields,
6572
+ task_fields=set(),
6512
6573
  product_fields=product_fields,
6513
6574
  version_fields=version_fields,
6514
6575
  representation_fields={"id"},
@@ -29,7 +29,14 @@ RepresentationParents = collections.namedtuple(
29
29
 
30
30
  RepresentationHierarchy = collections.namedtuple(
31
31
  "RepresentationHierarchy",
32
- ("project", "folder", "product", "version", "representation")
32
+ (
33
+ "project",
34
+ "folder",
35
+ "task",
36
+ "product",
37
+ "version",
38
+ "representation",
39
+ )
33
40
  )
34
41
 
35
42
 
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for AYON server."""
2
- __version__ = "1.0.6"
2
+ __version__ = "1.0.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 1.0.6
3
+ Version: 1.0.7
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.6"
3
+ version = "1.0.7"
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.6"
32
+ version = "1.0.7"
33
33
  description = "AYON Python API"
34
34
  authors = [
35
35
  "ynput.io <info@ynput.io>"
File without changes