Ayon-Python-Api 0.1.16__tar.gz → 0.1.18__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.1.16 → ayon-python-api-0.1.18}/PKG-INFO +12 -4
  2. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/README.md +11 -3
  3. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/__init__.py +52 -2
  4. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/_api.py +262 -14
  5. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/constants.py +5 -2
  6. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/entity_hub.py +152 -16
  7. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/events.py +1 -1
  8. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/exceptions.py +11 -1
  9. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/graphql.py +119 -32
  10. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/graphql_queries.py +68 -11
  11. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/operations.py +3 -2
  12. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/server_api.py +876 -220
  13. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/version.py +1 -1
  14. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/PKG-INFO +12 -4
  15. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/pyproject.toml +1 -1
  16. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/LICENSE +0 -0
  17. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/thumbnails.py +0 -0
  18. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_api/utils.py +0 -0
  19. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  20. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  21. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/requires.txt +0 -0
  22. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/ayon_python_api.egg-info/top_level.txt +0 -0
  23. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/setup.cfg +0 -0
  24. {ayon-python-api-0.1.16 → ayon-python-api-0.1.18}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ayon-python-api
3
- Version: 0.1.16
3
+ Version: 0.1.18
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -19,7 +19,7 @@ Python client for connection server. Client must be (at least for some time) Pyt
19
19
 
20
20
  AYON Python api should support connection to server with raw REST functions and prepared functionality for work with entities. Must not contain only functionality that can be used with core server functionality.
21
21
 
22
- Module support singleton connection which is using `AYON_SERVER_URL` and `AYON_TOKEN` environment variables as source for connection. The singleton connection is using `ServerAPI` object. There can be created multiple connection to different server at one time, for that purpose use `ServerAPIBase` object.
22
+ Module support singleton connection which is using `AYON_SERVER_URL` and `AYON_API_KEY` environment variables as source for connection. The singleton connection is using `ServerAPI` object. There can be created multiple connection to different server at one time, for that purpose use `ServerAPIBase` object.
23
23
 
24
24
  ## Install
25
25
  AYON python api is available on PyPi:
@@ -65,8 +65,16 @@ If pip complain that `ayon-python-api` is already installed just uninstall exist
65
65
  - Add all available CRUD operation on entities using REST
66
66
  - Add folder and task changes to operations
67
67
  - Enhance entity hub
68
+ - Missing docstrings in EntityHub -> especially entity arguments are missing
69
+ - Better order of arguments for entity classes
70
+ - Move entity hub to first place
71
+ - Skip those which are invalid for the entity and fake it for base or remove it from base
68
72
  - Entity hub should use operations session to do changes
69
73
  - Entity hub could also handle 'subset', 'version' and 'representation' entities
70
- - Missing docstrings in EntityHub -> especially entity arguments are missing
71
- - Pass docstrings and arguments definitions from `ServerAPI` methods to global functions
74
+ - Missing 'statuses' on project
75
+ - Missing 'status' on folders
76
+ - Missing assignees on tasks
77
+ - Pass docstrings and arguments definitions from `ServerAPI` methods to global functions
78
+ - Split `ServerAPI` into smaller chunks (somehow), the class has 4k+ lines of code
79
+ - Add .pyi stub for ServerAPI
72
80
  - Missing websockets connection
@@ -3,7 +3,7 @@ Python client for connection server. Client must be (at least for some time) Pyt
3
3
 
4
4
  AYON Python api should support connection to server with raw REST functions and prepared functionality for work with entities. Must not contain only functionality that can be used with core server functionality.
5
5
 
6
- Module support singleton connection which is using `AYON_SERVER_URL` and `AYON_TOKEN` environment variables as source for connection. The singleton connection is using `ServerAPI` object. There can be created multiple connection to different server at one time, for that purpose use `ServerAPIBase` object.
6
+ Module support singleton connection which is using `AYON_SERVER_URL` and `AYON_API_KEY` environment variables as source for connection. The singleton connection is using `ServerAPI` object. There can be created multiple connection to different server at one time, for that purpose use `ServerAPIBase` object.
7
7
 
8
8
  ## Install
9
9
  AYON python api is available on PyPi:
@@ -49,8 +49,16 @@ If pip complain that `ayon-python-api` is already installed just uninstall exist
49
49
  - Add all available CRUD operation on entities using REST
50
50
  - Add folder and task changes to operations
51
51
  - Enhance entity hub
52
+ - Missing docstrings in EntityHub -> especially entity arguments are missing
53
+ - Better order of arguments for entity classes
54
+ - Move entity hub to first place
55
+ - Skip those which are invalid for the entity and fake it for base or remove it from base
52
56
  - Entity hub should use operations session to do changes
53
57
  - Entity hub could also handle 'subset', 'version' and 'representation' entities
54
- - Missing docstrings in EntityHub -> especially entity arguments are missing
55
- - Pass docstrings and arguments definitions from `ServerAPI` methods to global functions
58
+ - Missing 'statuses' on project
59
+ - Missing 'status' on folders
60
+ - Missing assignees on tasks
61
+ - Pass docstrings and arguments definitions from `ServerAPI` methods to global functions
62
+ - Split `ServerAPI` into smaller chunks (somehow), the class has 4k+ lines of code
63
+ - Add .pyi stub for ServerAPI
56
64
  - Missing websockets connection
@@ -56,6 +56,7 @@ from ._api import (
56
56
  query_graphql,
57
57
 
58
58
  get_addons_info,
59
+ get_addon_url,
59
60
  download_addon_private_file,
60
61
 
61
62
  get_dependencies_info,
@@ -121,11 +122,35 @@ from ._api import (
121
122
  get_representation_parents,
122
123
  get_repre_ids_by_context_filters,
123
124
 
124
- create_thumbnail,
125
125
  get_thumbnail,
126
126
  get_folder_thumbnail,
127
127
  get_version_thumbnail,
128
128
  get_workfile_thumbnail,
129
+ create_thumbnail,
130
+ update_thumbnail,
131
+
132
+ get_full_link_type_name,
133
+ get_link_types,
134
+ get_link_type,
135
+ create_link_type,
136
+ delete_link_type,
137
+ make_sure_link_type_exists,
138
+
139
+ create_link,
140
+ delete_link,
141
+ get_entities_links,
142
+ get_folder_links,
143
+ get_folders_links,
144
+ get_task_links,
145
+ get_tasks_links,
146
+ get_subset_links,
147
+ get_subsets_links,
148
+ get_version_links,
149
+ get_versions_links,
150
+ get_representations_links,
151
+ get_representation_links,
152
+
153
+ send_batch_operations,
129
154
  )
130
155
 
131
156
 
@@ -184,6 +209,7 @@ __all__ = (
184
209
  "query_graphql",
185
210
 
186
211
  "get_addons_info",
212
+ "get_addon_url",
187
213
  "download_addon_private_file",
188
214
 
189
215
  "get_dependencies_info",
@@ -248,9 +274,33 @@ __all__ = (
248
274
  "get_representation_parents",
249
275
  "get_repre_ids_by_context_filters",
250
276
 
251
- "create_thumbnail",
252
277
  "get_thumbnail",
253
278
  "get_folder_thumbnail",
254
279
  "get_version_thumbnail",
255
280
  "get_workfile_thumbnail",
281
+ "create_thumbnail",
282
+ "update_thumbnail",
283
+
284
+ "get_full_link_type_name",
285
+ "get_link_types",
286
+ "get_link_type",
287
+ "create_link_type",
288
+ "delete_link_type",
289
+ "make_sure_link_type_exists",
290
+
291
+ "create_link",
292
+ "delete_link",
293
+ "get_entities_links",
294
+ "get_folder_links",
295
+ "get_folders_links",
296
+ "get_task_links",
297
+ "get_tasks_links",
298
+ "get_subset_links",
299
+ "get_subsets_links",
300
+ "get_version_links",
301
+ "get_versions_links",
302
+ "get_representations_links",
303
+ "get_representation_links",
304
+
305
+ "send_batch_operations",
256
306
  )
@@ -11,7 +11,7 @@ import socket
11
11
 
12
12
  from .constants import (
13
13
  SERVER_URL_ENV_KEY,
14
- SERVER_TOKEN_ENV_KEY,
14
+ SERVER_API_ENV_KEY,
15
15
  )
16
16
  from .server_api import ServerAPI
17
17
  from .exceptions import FailedServiceInit
@@ -21,7 +21,7 @@ class GlobalServerAPI(ServerAPI):
21
21
  """Extended server api which also handles storing tokens and url.
22
22
 
23
23
  Created object expect to have set environment variables
24
- 'AYON_SERVER_URL'. Also is expecting filled 'AYON_TOKEN'
24
+ 'AYON_SERVER_URL'. Also is expecting filled 'AYON_API_KEY'
25
25
  but that can be filled afterwards with calling 'login' method.
26
26
  """
27
27
 
@@ -44,7 +44,7 @@ class GlobalServerAPI(ServerAPI):
44
44
  previous_token = self._access_token
45
45
  super(GlobalServerAPI, self).login(username, password)
46
46
  if self.has_valid_token and previous_token != self._access_token:
47
- os.environ[SERVER_TOKEN_ENV_KEY] = self._access_token
47
+ os.environ[SERVER_API_ENV_KEY] = self._access_token
48
48
 
49
49
  @staticmethod
50
50
  def get_url():
@@ -52,7 +52,7 @@ class GlobalServerAPI(ServerAPI):
52
52
 
53
53
  @staticmethod
54
54
  def get_token():
55
- return os.environ.get(SERVER_TOKEN_ENV_KEY)
55
+ return os.environ.get(SERVER_API_ENV_KEY)
56
56
 
57
57
  @staticmethod
58
58
  def set_environments(url, token):
@@ -64,7 +64,7 @@ class GlobalServerAPI(ServerAPI):
64
64
  """
65
65
 
66
66
  os.environ[SERVER_URL_ENV_KEY] = url or ""
67
- os.environ[SERVER_TOKEN_ENV_KEY] = token or ""
67
+ os.environ[SERVER_API_ENV_KEY] = token or ""
68
68
 
69
69
 
70
70
  class GlobalContext:
@@ -151,7 +151,7 @@ class ServiceContext:
151
151
  connect=True
152
152
  ):
153
153
  token = cls.get_value_from_envs(
154
- ("AY_API_KEY", "AYON_TOKEN"),
154
+ ("AY_API_KEY", "AYON_API_KEY"),
155
155
  token
156
156
  )
157
157
  server_url = cls.get_value_from_envs(
@@ -322,7 +322,7 @@ def get_server_api_connection():
322
322
  """Access to global scope object of GlobalServerAPI.
323
323
 
324
324
  This access expect to have set environment variables 'AYON_SERVER_URL'
325
- and 'AYON_TOKEN'.
325
+ and 'AYON_API_KEY'.
326
326
 
327
327
  Returns:
328
328
  GlobalServerAPI: Object of connection to server.
@@ -521,6 +521,11 @@ def get_addons_info(*args, **kwargs):
521
521
  return con.get_addons_info(*args, **kwargs)
522
522
 
523
523
 
524
+ def get_addon_url(addon_name, addon_version, *subpaths):
525
+ con = get_server_api_connection()
526
+ return con.get_addon_url(addon_name, addon_version, *subpaths)
527
+
528
+
524
529
  def download_addon_private_file(*args, **kwargs):
525
530
  con = get_server_api_connection()
526
531
  return con.download_addon_private_file(*args, **kwargs)
@@ -776,11 +781,6 @@ def delete_project(project_name):
776
781
  return con.delete_project(project_name)
777
782
 
778
783
 
779
- def create_thumbnail(project_name, src_filepath):
780
- con = get_server_api_connection()
781
- return con.create_thumbnail(project_name, src_filepath)
782
-
783
-
784
784
  def get_thumbnail(project_name, entity_type, entity_id, thumbnail_id=None):
785
785
  con = get_server_api_connection()
786
786
  con.get_thumbnail(project_name, entity_type, entity_id, thumbnail_id)
@@ -801,11 +801,259 @@ def get_workfile_thumbnail(project_name, workfile_id, thumbnail_id=None):
801
801
  return con.get_workfile_thumbnail(project_name, workfile_id, thumbnail_id)
802
802
 
803
803
 
804
- def create_thumbnail(project_name, src_filepath):
804
+ def create_thumbnail(project_name, src_filepath, thumbnail_id=None):
805
+ con = get_server_api_connection()
806
+ return con.create_thumbnail(project_name, src_filepath, thumbnail_id)
807
+
808
+
809
+ def update_thumbnail(project_name, thumbnail_id, src_filepath):
805
810
  con = get_server_api_connection()
806
- return con.create_thumbnail(project_name, src_filepath)
811
+ return con.update_thumbnail(project_name, thumbnail_id, src_filepath)
807
812
 
808
813
 
809
814
  def get_default_fields_for_type(entity_type):
810
815
  con = get_server_api_connection()
811
816
  return con.get_default_fields_for_type(entity_type)
817
+
818
+
819
+ def get_full_link_type_name(link_type_name, input_type, output_type):
820
+ con = get_server_api_connection()
821
+ return con.get_full_link_type_name(
822
+ link_type_name, input_type, output_type)
823
+
824
+
825
+ def get_link_types(project_name):
826
+ con = get_server_api_connection()
827
+ return con.get_link_types(project_name)
828
+
829
+
830
+ def get_link_type(project_name, link_type_name, input_type, output_type):
831
+ con = get_server_api_connection()
832
+ return con.get_link_type(
833
+ project_name, link_type_name, input_type, output_type)
834
+
835
+
836
+ def create_link_type(
837
+ project_name, link_type_name, input_type, output_type, data=None):
838
+ con = get_server_api_connection()
839
+ return con.create_link_type(
840
+ project_name, link_type_name, input_type, output_type, data=data)
841
+
842
+
843
+ def delete_link_type(project_name, link_type_name, input_type, output_type):
844
+ con = get_server_api_connection()
845
+ return con.delete_link_type(
846
+ project_name, link_type_name, input_type, output_type)
847
+
848
+
849
+ def make_sure_link_type_exists(
850
+ project_name, link_type_name, input_type, output_type, data=None
851
+ ):
852
+ con = get_server_api_connection()
853
+ return con.make_sure_link_type_exists(
854
+ project_name, link_type_name, input_type, output_type, data=data
855
+ )
856
+
857
+
858
+ def create_link(
859
+ project_name,
860
+ link_type_name,
861
+ input_id,
862
+ input_type,
863
+ output_id,
864
+ output_type
865
+ ):
866
+ con = get_server_api_connection()
867
+ return con.create_link(
868
+ project_name,
869
+ link_type_name,
870
+ input_id, input_type,
871
+ output_id, output_type
872
+ )
873
+
874
+
875
+ def delete_link(project_name, link_id):
876
+ con = get_server_api_connection()
877
+ return con.delete_link(project_name, link_id)
878
+
879
+
880
+ def get_entities_links(
881
+ project_name,
882
+ entity_type,
883
+ entity_ids=None,
884
+ link_types=None,
885
+ link_direction=None
886
+ ):
887
+ con = get_server_api_connection()
888
+ return con.get_entities_links(
889
+ project_name,
890
+ entity_type,
891
+ entity_ids,
892
+ link_types,
893
+ link_direction
894
+ )
895
+
896
+
897
+ def get_folders_links(
898
+ project_name,
899
+ folder_ids=None,
900
+ link_types=None,
901
+ link_direction=None
902
+ ):
903
+ con = get_server_api_connection()
904
+ return con.get_folders_links(
905
+ project_name,
906
+ folder_ids,
907
+ link_types,
908
+ link_direction
909
+ )
910
+
911
+
912
+ def get_folder_links(
913
+ project_name,
914
+ folder_id,
915
+ link_types=None,
916
+ link_direction=None
917
+ ):
918
+ con = get_server_api_connection()
919
+ return con.get_folder_links(
920
+ project_name,
921
+ folder_id,
922
+ link_types,
923
+ link_direction
924
+ )
925
+
926
+
927
+ def get_tasks_links(
928
+ project_name,
929
+ task_ids=None,
930
+ link_types=None,
931
+ link_direction=None
932
+ ):
933
+ con = get_server_api_connection()
934
+ return con.get_tasks_links(
935
+ project_name,
936
+ task_ids,
937
+ link_types,
938
+ link_direction
939
+ )
940
+
941
+
942
+ def get_task_links(
943
+ project_name,
944
+ task_id,
945
+ link_types=None,
946
+ link_direction=None
947
+ ):
948
+ con = get_server_api_connection()
949
+ return con.get_task_links(
950
+ project_name,
951
+ task_id,
952
+ link_types,
953
+ link_direction
954
+ )
955
+
956
+
957
+ def get_subsets_links(
958
+ project_name,
959
+ subset_ids=None,
960
+ link_types=None,
961
+ link_direction=None
962
+ ):
963
+ con = get_server_api_connection()
964
+ return con.get_subsets_links(
965
+ project_name,
966
+ subset_ids,
967
+ link_types,
968
+ link_direction
969
+ )
970
+
971
+
972
+ def get_subset_links(
973
+ project_name,
974
+ subset_id,
975
+ link_types=None,
976
+ link_direction=None
977
+ ):
978
+ con = get_server_api_connection()
979
+ return con.get_subset_links(
980
+ project_name,
981
+ subset_id,
982
+ link_types,
983
+ link_direction
984
+ )
985
+
986
+
987
+ def get_versions_links(
988
+ project_name,
989
+ version_ids=None,
990
+ link_types=None,
991
+ link_direction=None
992
+ ):
993
+ con = get_server_api_connection()
994
+ return con.get_versions_links(
995
+ project_name,
996
+ version_ids,
997
+ link_types,
998
+ link_direction
999
+ )
1000
+
1001
+
1002
+ def get_version_links(
1003
+ project_name,
1004
+ version_id,
1005
+ link_types=None,
1006
+ link_direction=None
1007
+ ):
1008
+ con = get_server_api_connection()
1009
+ return con.get_version_links(
1010
+ project_name,
1011
+ version_id,
1012
+ link_types,
1013
+ link_direction
1014
+ )
1015
+
1016
+
1017
+ def get_representations_links(
1018
+ project_name,
1019
+ representation_ids=None,
1020
+ link_types=None,
1021
+ link_direction=None
1022
+ ):
1023
+ con = get_server_api_connection()
1024
+ return con.get_representations_links(
1025
+ project_name,
1026
+ representation_ids,
1027
+ link_types,
1028
+ link_direction
1029
+ )
1030
+
1031
+
1032
+ def get_representation_links(
1033
+ project_name,
1034
+ representation_id,
1035
+ link_types=None,
1036
+ link_direction=None
1037
+ ):
1038
+ con = get_server_api_connection()
1039
+ return con.get_representation_links(
1040
+ project_name,
1041
+ representation_id,
1042
+ link_types,
1043
+ link_direction
1044
+ )
1045
+
1046
+
1047
+ def send_batch_operations(
1048
+ project_name,
1049
+ operations,
1050
+ can_fail=False,
1051
+ raise_on_fail=True
1052
+ ):
1053
+ con = get_server_api_connection()
1054
+ return con.send_batch_operations(
1055
+ project_name,
1056
+ operations,
1057
+ can_fail=can_fail,
1058
+ raise_on_fail=raise_on_fail
1059
+ )
@@ -1,5 +1,8 @@
1
+ # Environments where server url and api key are stored for global connection
1
2
  SERVER_URL_ENV_KEY = "AYON_SERVER_URL"
2
- SERVER_TOKEN_ENV_KEY = "AYON_TOKEN"
3
+ SERVER_API_ENV_KEY = "AYON_API_KEY"
4
+ # Backwards compatibility
5
+ SERVER_TOKEN_ENV_KEY = SERVER_API_ENV_KEY
3
6
 
4
7
  # --- Project ---
5
8
  DEFAULT_PROJECT_FIELDS = {
@@ -102,4 +105,4 @@ DEFAULT_EVENT_FIELDS = {
102
105
  "topic",
103
106
  "updatedAt",
104
107
  "user",
105
- }
108
+ }