Ayon-Python-Api 0.1.11__tar.gz → 0.1.12__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.
- {ayon-python-api-0.1.11/ayon_python_api.egg-info → ayon-python-api-0.1.12}/PKG-INFO +1 -1
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/__init__.py +33 -12
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/_api.py +104 -8
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/server_api.py +403 -31
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/utils.py +23 -3
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/version.py +1 -1
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12/ayon_python_api.egg-info}/PKG-INFO +1 -1
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/pyproject.toml +1 -1
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/LICENSE +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/README.md +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/constants.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/entity_hub.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/events.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/exceptions.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/graphql.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/graphql_queries.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/operations.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_api/thumbnails.py +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_python_api.egg-info/SOURCES.txt +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_python_api.egg-info/dependency_links.txt +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_python_api.egg-info/requires.txt +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_python_api.egg-info/top_level.txt +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/setup.cfg +0 -0
- {ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/setup.py +0 -0
|
@@ -11,6 +11,7 @@ from ._api import (
|
|
|
11
11
|
ServiceContext,
|
|
12
12
|
|
|
13
13
|
init_service,
|
|
14
|
+
get_service_name,
|
|
14
15
|
get_service_addon_name,
|
|
15
16
|
get_service_addon_version,
|
|
16
17
|
get_service_addon_settings,
|
|
@@ -21,8 +22,12 @@ from ._api import (
|
|
|
21
22
|
change_token,
|
|
22
23
|
set_environments,
|
|
23
24
|
get_server_api_connection,
|
|
25
|
+
get_site_id,
|
|
24
26
|
set_site_id,
|
|
27
|
+
get_client_version,
|
|
25
28
|
set_client_version,
|
|
29
|
+
get_default_settings_variant,
|
|
30
|
+
set_default_settings_variant,
|
|
26
31
|
|
|
27
32
|
get_base_url,
|
|
28
33
|
get_rest_url,
|
|
@@ -60,12 +65,6 @@ from ._api import (
|
|
|
60
65
|
upload_dependency_package,
|
|
61
66
|
delete_dependency_package,
|
|
62
67
|
|
|
63
|
-
get_full_production_settings,
|
|
64
|
-
get_production_settings,
|
|
65
|
-
get_full_project_settings,
|
|
66
|
-
get_project_settings,
|
|
67
|
-
get_addon_settings,
|
|
68
|
-
|
|
69
68
|
get_user,
|
|
70
69
|
get_users,
|
|
71
70
|
|
|
@@ -74,6 +73,18 @@ from ._api import (
|
|
|
74
73
|
|
|
75
74
|
get_project_anatomy_preset,
|
|
76
75
|
get_project_anatomy_presets,
|
|
76
|
+
get_project_roots_by_site,
|
|
77
|
+
get_project_roots_for_site,
|
|
78
|
+
|
|
79
|
+
get_addon_site_settings_schema,
|
|
80
|
+
get_addon_settings_schema,
|
|
81
|
+
|
|
82
|
+
get_addon_studio_settings,
|
|
83
|
+
get_addon_project_settings,
|
|
84
|
+
get_addon_settings,
|
|
85
|
+
get_addons_studio_settings,
|
|
86
|
+
get_addons_project_settings,
|
|
87
|
+
get_addons_settings,
|
|
77
88
|
|
|
78
89
|
get_projects,
|
|
79
90
|
get_project,
|
|
@@ -127,6 +138,7 @@ __all__ = (
|
|
|
127
138
|
"ServiceContext",
|
|
128
139
|
|
|
129
140
|
"init_service",
|
|
141
|
+
"get_service_name",
|
|
130
142
|
"get_service_addon_name",
|
|
131
143
|
"get_service_addon_version",
|
|
132
144
|
"get_service_addon_settings",
|
|
@@ -137,8 +149,12 @@ __all__ = (
|
|
|
137
149
|
"change_token",
|
|
138
150
|
"set_environments",
|
|
139
151
|
"get_server_api_connection",
|
|
152
|
+
"get_site_id",
|
|
140
153
|
"set_site_id",
|
|
154
|
+
"get_client_version",
|
|
141
155
|
"set_client_version",
|
|
156
|
+
"get_default_settings_variant",
|
|
157
|
+
"set_default_settings_variant",
|
|
142
158
|
|
|
143
159
|
"get_base_url",
|
|
144
160
|
"get_rest_url",
|
|
@@ -176,12 +192,6 @@ __all__ = (
|
|
|
176
192
|
"upload_dependency_package",
|
|
177
193
|
"delete_dependency_package",
|
|
178
194
|
|
|
179
|
-
"get_full_production_settings",
|
|
180
|
-
"get_production_settings",
|
|
181
|
-
"get_full_project_settings",
|
|
182
|
-
"get_project_settings",
|
|
183
|
-
"get_addon_settings",
|
|
184
|
-
|
|
185
195
|
"get_user",
|
|
186
196
|
"get_users",
|
|
187
197
|
|
|
@@ -190,6 +200,17 @@ __all__ = (
|
|
|
190
200
|
|
|
191
201
|
"get_project_anatomy_preset",
|
|
192
202
|
"get_project_anatomy_presets",
|
|
203
|
+
"get_project_roots_by_site",
|
|
204
|
+
"get_project_roots_for_site",
|
|
205
|
+
|
|
206
|
+
"get_addon_site_settings_schema",
|
|
207
|
+
"get_addon_settings_schema",
|
|
208
|
+
"get_addon_studio_settings",
|
|
209
|
+
"get_addon_project_settings",
|
|
210
|
+
"get_addon_settings",
|
|
211
|
+
"get_addons_studio_settings",
|
|
212
|
+
"get_addons_project_settings",
|
|
213
|
+
"get_addons_settings",
|
|
193
214
|
|
|
194
215
|
"get_projects",
|
|
195
216
|
"get_project",
|
|
@@ -208,6 +208,9 @@ def init_service(*args, **kwargs):
|
|
|
208
208
|
def get_service_addon_name():
|
|
209
209
|
"""Name of addon which initialized service connection.
|
|
210
210
|
|
|
211
|
+
Service context must be initialized to be able to use this function. Call
|
|
212
|
+
'init_service' on you service start to do so.
|
|
213
|
+
|
|
211
214
|
Returns:
|
|
212
215
|
Union[str, None]: Name of addon or None.
|
|
213
216
|
"""
|
|
@@ -218,6 +221,9 @@ def get_service_addon_name():
|
|
|
218
221
|
def get_service_addon_version():
|
|
219
222
|
"""Version of addon which initialized service connection.
|
|
220
223
|
|
|
224
|
+
Service context must be initialized to be able to use this function. Call
|
|
225
|
+
'init_service' on you service start to do so.
|
|
226
|
+
|
|
221
227
|
Returns:
|
|
222
228
|
Union[str, None]: Version of addon or None.
|
|
223
229
|
"""
|
|
@@ -225,9 +231,25 @@ def get_service_addon_version():
|
|
|
225
231
|
return ServiceContext.addon_version
|
|
226
232
|
|
|
227
233
|
|
|
234
|
+
def get_service_name():
|
|
235
|
+
"""Name of service.
|
|
236
|
+
|
|
237
|
+
Service context must be initialized to be able to use this function. Call
|
|
238
|
+
'init_service' on you service start to do so.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
Union[str, None]: Name of service if service was registered.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
return ServiceContext.service_name
|
|
245
|
+
|
|
246
|
+
|
|
228
247
|
def get_service_addon_settings():
|
|
229
248
|
"""Addon settings of service which initialized service.
|
|
230
249
|
|
|
250
|
+
Service context must be initialized to be able to use this function. Call
|
|
251
|
+
'init_service' on you service start to do so.
|
|
252
|
+
|
|
231
253
|
Returns:
|
|
232
254
|
Dict[str, Any]: Addon settings.
|
|
233
255
|
|
|
@@ -309,6 +331,11 @@ def get_server_api_connection():
|
|
|
309
331
|
return GlobalContext.get_server_api_connection()
|
|
310
332
|
|
|
311
333
|
|
|
334
|
+
def get_site_id():
|
|
335
|
+
con = get_server_api_connection()
|
|
336
|
+
return con.get_site_id()
|
|
337
|
+
|
|
338
|
+
|
|
312
339
|
def set_site_id(site_id):
|
|
313
340
|
"""Set site id of already connected client connection.
|
|
314
341
|
|
|
@@ -322,6 +349,19 @@ def set_site_id(site_id):
|
|
|
322
349
|
con.set_site_id(site_id)
|
|
323
350
|
|
|
324
351
|
|
|
352
|
+
def get_client_version():
|
|
353
|
+
"""Version of client used to connect to server.
|
|
354
|
+
|
|
355
|
+
Client version is AYON client build desktop application.
|
|
356
|
+
|
|
357
|
+
Returns:
|
|
358
|
+
str: Client version string used in connection.
|
|
359
|
+
"""
|
|
360
|
+
|
|
361
|
+
con = get_server_api_connection()
|
|
362
|
+
return con.get_client_version()
|
|
363
|
+
|
|
364
|
+
|
|
325
365
|
def set_client_version(client_version):
|
|
326
366
|
"""Set version of already connected client connection.
|
|
327
367
|
|
|
@@ -335,6 +375,32 @@ def set_client_version(client_version):
|
|
|
335
375
|
con.set_client_version(client_version)
|
|
336
376
|
|
|
337
377
|
|
|
378
|
+
def get_default_settings_variant():
|
|
379
|
+
"""Default variant used for settings.
|
|
380
|
+
|
|
381
|
+
Returns:
|
|
382
|
+
Union[str, None]: name of variant or None.
|
|
383
|
+
"""
|
|
384
|
+
|
|
385
|
+
con = get_server_api_connection()
|
|
386
|
+
return con.get_client_version()
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def set_default_settings_variant(variant):
|
|
390
|
+
"""Change default variant for addon settings.
|
|
391
|
+
|
|
392
|
+
Note:
|
|
393
|
+
It is recommended to set only 'production' or 'staging' variants
|
|
394
|
+
as default variant.
|
|
395
|
+
|
|
396
|
+
Args:
|
|
397
|
+
variant (Union[str, None]): Settings variant name.
|
|
398
|
+
"""
|
|
399
|
+
|
|
400
|
+
con = get_server_api_connection()
|
|
401
|
+
return con.set_default_settings_variant(variant)
|
|
402
|
+
|
|
403
|
+
|
|
338
404
|
def get_base_url():
|
|
339
405
|
con = get_server_api_connection()
|
|
340
406
|
return con.get_base_url()
|
|
@@ -495,24 +561,34 @@ def get_project_anatomy_preset(*args, **kwargs):
|
|
|
495
561
|
return con.get_project_anatomy_preset(*args, **kwargs)
|
|
496
562
|
|
|
497
563
|
|
|
498
|
-
def
|
|
564
|
+
def get_project_roots_by_site(*args, **kwargs):
|
|
499
565
|
con = get_server_api_connection()
|
|
500
|
-
return con.
|
|
566
|
+
return con.get_project_roots(*args, **kwargs)
|
|
501
567
|
|
|
502
568
|
|
|
503
|
-
def
|
|
569
|
+
def get_project_roots_for_site(*args, **kwargs):
|
|
504
570
|
con = get_server_api_connection()
|
|
505
|
-
return con.
|
|
571
|
+
return con.get_project_roots_for_site(*args, **kwargs)
|
|
506
572
|
|
|
507
573
|
|
|
508
|
-
def
|
|
574
|
+
def get_addon_settings_schema(*args, **kwargs):
|
|
509
575
|
con = get_server_api_connection()
|
|
510
|
-
return con.
|
|
576
|
+
return con.get_addon_settings_schema(*args, **kwargs)
|
|
511
577
|
|
|
512
578
|
|
|
513
|
-
def
|
|
579
|
+
def get_addon_site_settings_schema(*args, **kwargs):
|
|
514
580
|
con = get_server_api_connection()
|
|
515
|
-
return con.
|
|
581
|
+
return con.get_addon_site_settings_schema(*args, **kwargs)
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
def get_addon_studio_settings(*args, **kwargs):
|
|
585
|
+
con = get_server_api_connection()
|
|
586
|
+
return con.get_addon_studio_settings(*args, **kwargs)
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
def get_addon_project_settings(*args, **kwargs):
|
|
590
|
+
con = get_server_api_connection()
|
|
591
|
+
return con.get_addon_project_settings(*args, **kwargs)
|
|
516
592
|
|
|
517
593
|
|
|
518
594
|
def get_addon_settings(*args, **kwargs):
|
|
@@ -520,6 +596,26 @@ def get_addon_settings(*args, **kwargs):
|
|
|
520
596
|
return con.get_addon_settings(*args, **kwargs)
|
|
521
597
|
|
|
522
598
|
|
|
599
|
+
def get_addon_site_settings(*args, **kwargs):
|
|
600
|
+
con = get_server_api_connection()
|
|
601
|
+
return con.get_addon_site_settings(*args, **kwargs)
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def get_addons_studio_settings(*args, **kwargs):
|
|
605
|
+
con = get_server_api_connection()
|
|
606
|
+
return con.get_addons_studio_settings(*args, **kwargs)
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def get_addons_project_settings(*args, **kwargs):
|
|
610
|
+
con = get_server_api_connection()
|
|
611
|
+
return con.get_addons_project_settings(*args, **kwargs)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def get_addons_settings(*args, **kwargs):
|
|
615
|
+
con = get_server_api_connection()
|
|
616
|
+
return con.get_addons_settings(*args, **kwargs)
|
|
617
|
+
|
|
618
|
+
|
|
523
619
|
def get_project(*args, **kwargs):
|
|
524
620
|
con = get_server_api_connection()
|
|
525
621
|
return con.get_project(*args, **kwargs)
|
|
@@ -48,6 +48,7 @@ from .exceptions import (
|
|
|
48
48
|
ServerError,
|
|
49
49
|
)
|
|
50
50
|
from .utils import (
|
|
51
|
+
prepare_query_string,
|
|
51
52
|
logout_from_server,
|
|
52
53
|
create_entity_id,
|
|
53
54
|
entity_data_json_default,
|
|
@@ -151,7 +152,10 @@ class RestApiResponse(object):
|
|
|
151
152
|
return self.data[key]
|
|
152
153
|
|
|
153
154
|
def get(self, key, default=None):
|
|
154
|
-
|
|
155
|
+
data = self.data
|
|
156
|
+
if isinstance(data, dict):
|
|
157
|
+
return self.data.get(key, default)
|
|
158
|
+
return default
|
|
155
159
|
|
|
156
160
|
|
|
157
161
|
class GraphQlResponse:
|
|
@@ -286,6 +290,9 @@ class ServerAPI(object):
|
|
|
286
290
|
connection is created from the same machine under same user.
|
|
287
291
|
client_version (str): Version of client application (used in
|
|
288
292
|
desktop client application).
|
|
293
|
+
default_settings_variant (Union[str, None]): Settings variant used by
|
|
294
|
+
default if a method for settings won't get any (by default is
|
|
295
|
+
'production').
|
|
289
296
|
"""
|
|
290
297
|
|
|
291
298
|
def __init__(
|
|
@@ -293,7 +300,8 @@ class ServerAPI(object):
|
|
|
293
300
|
base_url,
|
|
294
301
|
token=None,
|
|
295
302
|
site_id=None,
|
|
296
|
-
client_version=None
|
|
303
|
+
client_version=None,
|
|
304
|
+
default_settings_variant=None
|
|
297
305
|
):
|
|
298
306
|
if not base_url:
|
|
299
307
|
raise ValueError("Invalid server URL {}".format(str(base_url)))
|
|
@@ -306,6 +314,7 @@ class ServerAPI(object):
|
|
|
306
314
|
self._access_token = token
|
|
307
315
|
self._site_id = site_id
|
|
308
316
|
self._client_version = client_version
|
|
317
|
+
self._default_settings_variant = default_settings_variant
|
|
309
318
|
self._access_token_is_service = None
|
|
310
319
|
self._token_is_valid = None
|
|
311
320
|
self._server_available = None
|
|
@@ -345,12 +354,36 @@ class ServerAPI(object):
|
|
|
345
354
|
|
|
346
355
|
@property
|
|
347
356
|
def access_token(self):
|
|
357
|
+
"""Access token used for authorization to server.
|
|
358
|
+
|
|
359
|
+
Returns:
|
|
360
|
+
Union[str, None]: Token string or None if not authorized yet.
|
|
361
|
+
"""
|
|
362
|
+
|
|
348
363
|
return self._access_token
|
|
349
364
|
|
|
350
365
|
def get_site_id(self):
|
|
366
|
+
"""Site id used for connection.
|
|
367
|
+
|
|
368
|
+
Site id tells server from which machine/site is connection created and
|
|
369
|
+
is used for default site overrides when settings are received.
|
|
370
|
+
|
|
371
|
+
Returns:
|
|
372
|
+
Union[str, None]: Site id value or None if not filled.
|
|
373
|
+
"""
|
|
374
|
+
|
|
351
375
|
return self._site_id
|
|
352
376
|
|
|
353
377
|
def set_site_id(self, site_id):
|
|
378
|
+
"""Change site id of connection.
|
|
379
|
+
|
|
380
|
+
Behave as specific site for server. It affects default behavior of
|
|
381
|
+
settings getter methods.
|
|
382
|
+
|
|
383
|
+
Args:
|
|
384
|
+
site_id (Union[str, None]): Site id value, or 'None' to unset.
|
|
385
|
+
"""
|
|
386
|
+
|
|
354
387
|
if self._site_id == site_id:
|
|
355
388
|
return
|
|
356
389
|
self._site_id = site_id
|
|
@@ -387,6 +420,33 @@ class ServerAPI(object):
|
|
|
387
420
|
|
|
388
421
|
client_version = property(get_client_version, set_client_version)
|
|
389
422
|
|
|
423
|
+
def get_default_settings_variant(self):
|
|
424
|
+
"""Default variant used for settings.
|
|
425
|
+
|
|
426
|
+
Returns:
|
|
427
|
+
Union[str, None]: name of variant or None.
|
|
428
|
+
"""
|
|
429
|
+
|
|
430
|
+
return self._default_settings_variant
|
|
431
|
+
|
|
432
|
+
def set_default_settings_variant(self, variant):
|
|
433
|
+
"""Change default variant for addon settings.
|
|
434
|
+
|
|
435
|
+
Note:
|
|
436
|
+
It is recommended to set only 'production' or 'staging' variants
|
|
437
|
+
as default variant.
|
|
438
|
+
|
|
439
|
+
Args:
|
|
440
|
+
variant (Union[str, None]): Settings variant name.
|
|
441
|
+
"""
|
|
442
|
+
|
|
443
|
+
self._default_settings_variant = variant
|
|
444
|
+
|
|
445
|
+
default_settings_variant = property(
|
|
446
|
+
get_default_settings_variant,
|
|
447
|
+
set_default_settings_variant
|
|
448
|
+
)
|
|
449
|
+
|
|
390
450
|
def get_default_service_username(self):
|
|
391
451
|
"""Default username used for callbacks when used with service API key.
|
|
392
452
|
|
|
@@ -1052,6 +1112,7 @@ class ServerAPI(object):
|
|
|
1052
1112
|
|
|
1053
1113
|
finally:
|
|
1054
1114
|
progress.set_transfer_done()
|
|
1115
|
+
return progress
|
|
1055
1116
|
|
|
1056
1117
|
def _upload_file(self, url, filepath, progress):
|
|
1057
1118
|
kwargs = {}
|
|
@@ -1508,55 +1569,366 @@ class ServerAPI(object):
|
|
|
1508
1569
|
result = self.get("anatomy/presets/{}".format(preset_name))
|
|
1509
1570
|
return result.data
|
|
1510
1571
|
|
|
1511
|
-
def
|
|
1512
|
-
|
|
1513
|
-
response = self.get("settings/production")
|
|
1514
|
-
if response.status == 200:
|
|
1515
|
-
return response.data
|
|
1516
|
-
return None
|
|
1572
|
+
def get_project_roots_by_site(self, project_name):
|
|
1573
|
+
"""Root overrides per site name.
|
|
1517
1574
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1575
|
+
Method is based on logged user and can't be received for any other
|
|
1576
|
+
user on server.
|
|
1520
1577
|
|
|
1521
|
-
|
|
1522
|
-
def get_full_project_settings(self, project_name):
|
|
1523
|
-
result = self.get("projects/{}/settings".format(project_name))
|
|
1524
|
-
if result.status == 200:
|
|
1525
|
-
return result.data
|
|
1526
|
-
return None
|
|
1578
|
+
Output will contain only roots per site id used by logged user.
|
|
1527
1579
|
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1580
|
+
Args:
|
|
1581
|
+
project_name (str): Name of project.
|
|
1582
|
+
|
|
1583
|
+
Returns:
|
|
1584
|
+
dict[str, dict[str, str]]: Root values by root name by site id.
|
|
1585
|
+
"""
|
|
1586
|
+
|
|
1587
|
+
result = self.get("projects/{}/roots".format(project_name))
|
|
1588
|
+
result.raise_for_status()
|
|
1589
|
+
return result.data
|
|
1590
|
+
|
|
1591
|
+
def get_project_roots_for_site(self, project_name, site_id=None):
|
|
1592
|
+
"""Root overrides for site.
|
|
1531
1593
|
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1594
|
+
If site id is not passed a site set in current api object is used
|
|
1595
|
+
instead.
|
|
1596
|
+
|
|
1597
|
+
Args:
|
|
1598
|
+
project_name (str): Name of project.
|
|
1599
|
+
site_id (Optional[str]): Id of site for which want to receive
|
|
1600
|
+
site overrides.
|
|
1601
|
+
|
|
1602
|
+
Returns:
|
|
1603
|
+
dict[str, str]: Root values by root name or None if
|
|
1604
|
+
site does not have overrides.
|
|
1605
|
+
"""
|
|
1606
|
+
|
|
1607
|
+
if site_id is None:
|
|
1608
|
+
site_id = self.site_id
|
|
1609
|
+
|
|
1610
|
+
if site_id is None:
|
|
1611
|
+
return {}
|
|
1612
|
+
roots = self.get_project_roots(project_name)
|
|
1613
|
+
return roots.get(site_id, {})
|
|
1614
|
+
|
|
1615
|
+
def get_addon_settings_schema(
|
|
1616
|
+
self, addon_name, addon_version, project_name=None
|
|
1617
|
+
):
|
|
1618
|
+
"""Sudio/Project settings schema of an addon.
|
|
1619
|
+
|
|
1620
|
+
Project schema may look differently as some enums are based on project
|
|
1621
|
+
values.
|
|
1622
|
+
|
|
1623
|
+
Args:
|
|
1624
|
+
addon_name (str): Name of addon.
|
|
1625
|
+
addon_version (str): Version of addon.
|
|
1626
|
+
project_name (Union[str, None]): Schema for specific project or
|
|
1627
|
+
default studio schemas.
|
|
1628
|
+
|
|
1629
|
+
Returns:
|
|
1630
|
+
dict[str, Any]: Schema of studio/project settings.
|
|
1631
|
+
"""
|
|
1632
|
+
|
|
1633
|
+
endpoint = "addons/{}/{}/schema".format(addon_name, addon_version)
|
|
1634
|
+
if project_name:
|
|
1635
|
+
endpoint += "/{}".format(project_name)
|
|
1636
|
+
result = self.get(endpoint)
|
|
1637
|
+
result.raise_for_status()
|
|
1638
|
+
return result.data
|
|
1639
|
+
|
|
1640
|
+
def get_addon_site_settings_schema(self, addon_name, addon_version):
|
|
1641
|
+
"""Site settings schema of an addon.
|
|
1642
|
+
|
|
1643
|
+
Args:
|
|
1644
|
+
addon_name (str): Name of addon.
|
|
1645
|
+
addon_version (str): Version of addon.
|
|
1646
|
+
|
|
1647
|
+
Returns:
|
|
1648
|
+
dict[str, Any]: Schema of site settings.
|
|
1649
|
+
"""
|
|
1650
|
+
|
|
1651
|
+
result = self.get("addons/{}/{}/siteSettings/schema".format(
|
|
1652
|
+
addon_name, addon_version
|
|
1653
|
+
))
|
|
1654
|
+
result.raise_for_status()
|
|
1655
|
+
return result.data
|
|
1656
|
+
|
|
1657
|
+
def get_addon_studio_settings(
|
|
1658
|
+
self,
|
|
1659
|
+
addon_name,
|
|
1660
|
+
addon_version,
|
|
1661
|
+
variant=None
|
|
1662
|
+
):
|
|
1663
|
+
"""Addon studio settings.
|
|
1664
|
+
|
|
1665
|
+
Receive studio settings for specific version of an addon.
|
|
1666
|
+
|
|
1667
|
+
Args:
|
|
1668
|
+
addon_name (str): Name of addon.
|
|
1669
|
+
addon_version (str): Version of addon.
|
|
1670
|
+
variant (str): Name of settings variant. By default, is used
|
|
1671
|
+
'default_settings_variant' passed on init.
|
|
1672
|
+
|
|
1673
|
+
Returns:
|
|
1674
|
+
dict[str, Any]: Addon settings.
|
|
1675
|
+
"""
|
|
1676
|
+
|
|
1677
|
+
if variant is None:
|
|
1678
|
+
variant = self.default_settings_variant
|
|
1679
|
+
|
|
1680
|
+
query_items = {}
|
|
1681
|
+
if variant:
|
|
1682
|
+
query_items["variant"] = variant
|
|
1683
|
+
query = prepare_query_string(query_items)
|
|
1536
1684
|
|
|
1537
|
-
def get_addon_studio_settings(self, addon_name, addon_version):
|
|
1538
1685
|
result = self.get(
|
|
1539
|
-
"addons/{}/{}/settings".format(addon_name, addon_version)
|
|
1686
|
+
"addons/{}/{}/settings{}".format(addon_name, addon_version, query)
|
|
1540
1687
|
)
|
|
1541
1688
|
result.raise_for_status()
|
|
1542
1689
|
return result.data
|
|
1543
1690
|
|
|
1544
1691
|
def get_addon_project_settings(
|
|
1545
|
-
self,
|
|
1692
|
+
self,
|
|
1693
|
+
addon_name,
|
|
1694
|
+
addon_version,
|
|
1695
|
+
project_name,
|
|
1696
|
+
variant=None,
|
|
1697
|
+
site_id=None,
|
|
1698
|
+
use_site=True
|
|
1546
1699
|
):
|
|
1700
|
+
"""Addon project settings.
|
|
1701
|
+
|
|
1702
|
+
Receive project settings for specific version of an addon. The settings
|
|
1703
|
+
may be with site overrides when enabled.
|
|
1704
|
+
|
|
1705
|
+
Site id is filled with current connection site id if not passed. To
|
|
1706
|
+
make sure any site id is used set 'use_site' to 'False'.
|
|
1707
|
+
|
|
1708
|
+
Args:
|
|
1709
|
+
addon_name (str): Name of addon.
|
|
1710
|
+
addon_version (str): Version of addon.
|
|
1711
|
+
project_name (str): Name of project for which the settings are
|
|
1712
|
+
received.
|
|
1713
|
+
variant (str): Name of settings variant. By default, is used
|
|
1714
|
+
'production'.
|
|
1715
|
+
site_id (str): Name of site which is used for site overrides. Is
|
|
1716
|
+
filled with connection 'site_id' attribute if not passed.
|
|
1717
|
+
use_site (bool): To force disable option of using site overrides
|
|
1718
|
+
set to 'False'. In that case won't be applied any site
|
|
1719
|
+
overrides.
|
|
1720
|
+
|
|
1721
|
+
Returns:
|
|
1722
|
+
dict[str, Any]: Addon settings.
|
|
1723
|
+
"""
|
|
1724
|
+
|
|
1725
|
+
if not use_site:
|
|
1726
|
+
site_id = None
|
|
1727
|
+
elif not site_id:
|
|
1728
|
+
site_id = self.site_id
|
|
1729
|
+
|
|
1730
|
+
query_items = {}
|
|
1731
|
+
if site_id:
|
|
1732
|
+
query_items["site"] = site_id
|
|
1733
|
+
|
|
1734
|
+
if variant is None:
|
|
1735
|
+
variant = self.default_settings_variant
|
|
1736
|
+
|
|
1737
|
+
if variant:
|
|
1738
|
+
query_items["variant"] = variant
|
|
1739
|
+
|
|
1740
|
+
query = prepare_query_string(query_items)
|
|
1547
1741
|
result = self.get(
|
|
1548
|
-
"addons/{}/{}/settings/{}".format(
|
|
1549
|
-
addon_name, addon_version, project_name
|
|
1742
|
+
"addons/{}/{}/settings/{}{}".format(
|
|
1743
|
+
addon_name, addon_version, project_name, query
|
|
1550
1744
|
)
|
|
1551
1745
|
)
|
|
1552
1746
|
result.raise_for_status()
|
|
1553
1747
|
return result.data
|
|
1554
1748
|
|
|
1555
|
-
def get_addon_settings(
|
|
1749
|
+
def get_addon_settings(
|
|
1750
|
+
self,
|
|
1751
|
+
addon_name,
|
|
1752
|
+
addon_version,
|
|
1753
|
+
project_name=None,
|
|
1754
|
+
variant=None,
|
|
1755
|
+
site_id=None,
|
|
1756
|
+
use_site=True
|
|
1757
|
+
):
|
|
1758
|
+
"""Receive addon settings.
|
|
1759
|
+
|
|
1760
|
+
Receive addon settings based on project name value. Some arguments may
|
|
1761
|
+
be ignored if 'project_name' is set to 'None'.
|
|
1762
|
+
|
|
1763
|
+
Args:
|
|
1764
|
+
addon_name (str): Name of addon.
|
|
1765
|
+
addon_version (str): Version of addon.
|
|
1766
|
+
project_name (str): Name of project for which the settings are
|
|
1767
|
+
received. A studio settings values are received if is 'None'.
|
|
1768
|
+
variant (str): Name of settings variant. By default, is used
|
|
1769
|
+
'production'.
|
|
1770
|
+
site_id (str): Name of site which is used for site overrides. Is
|
|
1771
|
+
filled with connection 'site_id' attribute if not passed.
|
|
1772
|
+
use_site (bool): To force disable option of using site overrides
|
|
1773
|
+
set to 'False'. In that case won't be applied any site
|
|
1774
|
+
overrides.
|
|
1775
|
+
|
|
1776
|
+
Returns:
|
|
1777
|
+
dict[str, Any]: Addon settings.
|
|
1778
|
+
"""
|
|
1779
|
+
|
|
1556
1780
|
if project_name is None:
|
|
1557
|
-
return self.get_addon_studio_settings(
|
|
1781
|
+
return self.get_addon_studio_settings(
|
|
1782
|
+
addon_name, addon_version, variant
|
|
1783
|
+
)
|
|
1558
1784
|
return self.get_addon_project_settings(
|
|
1559
|
-
addon_name, addon_version, project_name
|
|
1785
|
+
addon_name, addon_version, project_name, variant, site_id, use_site
|
|
1786
|
+
)
|
|
1787
|
+
|
|
1788
|
+
def get_addon_site_settings(
|
|
1789
|
+
self, addon_name, addon_version, site_id=None
|
|
1790
|
+
):
|
|
1791
|
+
"""Site settings of an addon.
|
|
1792
|
+
|
|
1793
|
+
If site id is not available an empty dictionary is returned.
|
|
1794
|
+
|
|
1795
|
+
Args:
|
|
1796
|
+
addon_name (str): Name of addon.
|
|
1797
|
+
addon_version (str): Version of addon.
|
|
1798
|
+
site_id (str): Name of site for which should be settings returned.
|
|
1799
|
+
using 'site_id' attribute if not passed.
|
|
1800
|
+
|
|
1801
|
+
Returns:
|
|
1802
|
+
dict[str, Any]: Site settings.
|
|
1803
|
+
"""
|
|
1804
|
+
|
|
1805
|
+
if site_id is None:
|
|
1806
|
+
site_id = self.site_id
|
|
1807
|
+
|
|
1808
|
+
if not site_id:
|
|
1809
|
+
return {}
|
|
1810
|
+
|
|
1811
|
+
query = prepare_query_string({"site": site_id})
|
|
1812
|
+
result = self.get("addons/{}/{}/siteSettings{}".format(
|
|
1813
|
+
addon_name, addon_version, query
|
|
1814
|
+
))
|
|
1815
|
+
result.raise_for_status()
|
|
1816
|
+
return result.data
|
|
1817
|
+
|
|
1818
|
+
def get_addons_studio_settings(self, variant=None, only_values=True):
|
|
1819
|
+
"""All addons settings in one bulk.
|
|
1820
|
+
|
|
1821
|
+
Args:
|
|
1822
|
+
variant (Literal[production, staging]): Variant of settings. By
|
|
1823
|
+
default, is used 'production'.
|
|
1824
|
+
only_values (Optional[bool]): Output will contain only settings
|
|
1825
|
+
values without metadata about addons.
|
|
1826
|
+
|
|
1827
|
+
Returns:
|
|
1828
|
+
dict[str, Any]: Settings of all addons on server.
|
|
1829
|
+
"""
|
|
1830
|
+
|
|
1831
|
+
query_values = {}
|
|
1832
|
+
if variant:
|
|
1833
|
+
query_values["variant"] = variant
|
|
1834
|
+
query = prepare_query_string(query_values)
|
|
1835
|
+
response = self.get("settings/addons{}".format(query))
|
|
1836
|
+
response.raise_for_status()
|
|
1837
|
+
output = response.data
|
|
1838
|
+
if only_values:
|
|
1839
|
+
output = output["settings"]
|
|
1840
|
+
return output
|
|
1841
|
+
|
|
1842
|
+
def get_addons_project_settings(
|
|
1843
|
+
self,
|
|
1844
|
+
project_name,
|
|
1845
|
+
variant=None,
|
|
1846
|
+
site_id=None,
|
|
1847
|
+
use_site=True,
|
|
1848
|
+
only_values=True
|
|
1849
|
+
):
|
|
1850
|
+
"""Project settings of all addons.
|
|
1851
|
+
|
|
1852
|
+
Server returns information about used addon versions, so full output
|
|
1853
|
+
looks like:
|
|
1854
|
+
{
|
|
1855
|
+
"settings": {...},
|
|
1856
|
+
"addons": {...}
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
The output can be limited to only values. To do so is 'only_values'
|
|
1860
|
+
argument which is by default set to 'True'. In that case output
|
|
1861
|
+
contains only value of 'settings' key.
|
|
1862
|
+
|
|
1863
|
+
Args:
|
|
1864
|
+
project_name (str): Name of project for which are settings
|
|
1865
|
+
received.
|
|
1866
|
+
variant (Optional[Literal[production, staging]]): Variant of
|
|
1867
|
+
settings. By default, is used 'production'.
|
|
1868
|
+
site_id (Optional[str]): Id of site for which want to receive
|
|
1869
|
+
site overrides.
|
|
1870
|
+
use_site (bool): To force disable option of using site overrides
|
|
1871
|
+
set to 'False'. In that case won't be applied any site
|
|
1872
|
+
overrides.
|
|
1873
|
+
only_values (Optional[bool]): Output will contain only settings
|
|
1874
|
+
values without metadata about addons.
|
|
1875
|
+
|
|
1876
|
+
Returns:
|
|
1877
|
+
dict[str, Any]: Settings of all addons on server for passed
|
|
1878
|
+
project.
|
|
1879
|
+
"""
|
|
1880
|
+
|
|
1881
|
+
query_values = {
|
|
1882
|
+
"project": project_name
|
|
1883
|
+
}
|
|
1884
|
+
if variant:
|
|
1885
|
+
query_values["variant"] = variant
|
|
1886
|
+
|
|
1887
|
+
if use_site:
|
|
1888
|
+
if not site_id:
|
|
1889
|
+
site_id = self.default_settings_variant
|
|
1890
|
+
if site_id:
|
|
1891
|
+
query_values["site"] = site_id
|
|
1892
|
+
query = prepare_query_string(query_values)
|
|
1893
|
+
response = self.get("settings/addons{}".format(query))
|
|
1894
|
+
response.raise_for_status()
|
|
1895
|
+
output = response.data
|
|
1896
|
+
if only_values:
|
|
1897
|
+
output = output["settings"]
|
|
1898
|
+
return output
|
|
1899
|
+
|
|
1900
|
+
def get_addons_settings(
|
|
1901
|
+
self,
|
|
1902
|
+
project_name=None,
|
|
1903
|
+
variant=None,
|
|
1904
|
+
site_id=None,
|
|
1905
|
+
use_site=True,
|
|
1906
|
+
only_values=True
|
|
1907
|
+
):
|
|
1908
|
+
"""Universal function to receive all addon settings.
|
|
1909
|
+
|
|
1910
|
+
Based on 'project_name' will receive studio settings or project
|
|
1911
|
+
settings. In case project is not passed is 'site_id' ignored.
|
|
1912
|
+
|
|
1913
|
+
Args:
|
|
1914
|
+
project_name (Optional[str]): Name of project for which should be
|
|
1915
|
+
settings received.
|
|
1916
|
+
variant (Optional[Literal[production, staging]]): Settings variant.
|
|
1917
|
+
By default, is used 'production'.
|
|
1918
|
+
site_id (Optional[str]): Id of site for which want to receive
|
|
1919
|
+
site overrides.
|
|
1920
|
+
use_site (bool): To force disable option of using site overrides
|
|
1921
|
+
set to 'False'. In that case won't be applied any site
|
|
1922
|
+
overrides.
|
|
1923
|
+
only_values (Optional[bool]): Only settings values will be
|
|
1924
|
+
returned. By default, is set to 'True'.
|
|
1925
|
+
"""
|
|
1926
|
+
|
|
1927
|
+
if project_name is None:
|
|
1928
|
+
return self.get_addons_studio_settings(variant, only_values)
|
|
1929
|
+
|
|
1930
|
+
return self.get_addons_project_settings(
|
|
1931
|
+
project_name, variant, site_id, use_site, only_values
|
|
1560
1932
|
)
|
|
1561
1933
|
|
|
1562
1934
|
# Entity getters
|
|
@@ -3,14 +3,16 @@ import datetime
|
|
|
3
3
|
import uuid
|
|
4
4
|
import string
|
|
5
5
|
try:
|
|
6
|
-
|
|
6
|
+
# Python 3
|
|
7
|
+
from urllib.parse import urlparse, urlencode
|
|
7
8
|
except ImportError:
|
|
8
|
-
|
|
9
|
+
# Python 2
|
|
10
|
+
from urlparse import urlparse
|
|
11
|
+
from urllib import urlencode
|
|
9
12
|
|
|
10
13
|
import requests
|
|
11
14
|
import unidecode
|
|
12
15
|
|
|
13
|
-
|
|
14
16
|
from .exceptions import UrlError
|
|
15
17
|
|
|
16
18
|
REMOVED_VALUE = object()
|
|
@@ -18,6 +20,24 @@ SLUGIFY_WHITELIST = string.ascii_letters + string.digits
|
|
|
18
20
|
SLUGIFY_SEP_WHITELIST = " ,./\\;:!|*^#@~+-_="
|
|
19
21
|
|
|
20
22
|
|
|
23
|
+
def prepare_query_string(key_values):
|
|
24
|
+
"""Prepare data to query string.
|
|
25
|
+
|
|
26
|
+
If there are any values a query starting with '?' is returned otherwise
|
|
27
|
+
an empty string.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
dict[str, Any]: Query values.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
str: Query string.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
if not key_values:
|
|
37
|
+
return ""
|
|
38
|
+
return "?{}".format(urlencode(key_values))
|
|
39
|
+
|
|
40
|
+
|
|
21
41
|
def create_entity_id():
|
|
22
42
|
return uuid.uuid1().hex
|
|
23
43
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""Package declaring Python API for Ayon server."""
|
|
2
|
-
__version__ = "0.1.
|
|
2
|
+
__version__ = "0.1.12"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ayon-python-api-0.1.11 → ayon-python-api-0.1.12}/ayon_python_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|