ayon-python-api 1.2.10__tar.gz → 1.2.11__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.10 → ayon_python_api-1.2.11}/PKG-INFO +1 -1
  2. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/bundles_addons.py +5 -3
  3. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/dependency_packages.py +2 -2
  4. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/installers.py +2 -2
  5. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/thumbnails.py +4 -4
  6. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/server_api.py +64 -19
  7. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/version.py +1 -1
  8. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_python_api.egg-info/PKG-INFO +1 -1
  9. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/pyproject.toml +1 -1
  10. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/LICENSE +0 -0
  11. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/README.md +0 -0
  12. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/__init__.py +0 -0
  13. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api.py +0 -0
  14. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/__init__.py +0 -0
  15. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/actions.py +0 -0
  16. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/activities.py +0 -0
  17. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/attributes.py +0 -0
  18. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/base.py +0 -0
  19. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/events.py +0 -0
  20. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/folders.py +0 -0
  21. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/links.py +0 -0
  22. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/lists.py +0 -0
  23. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/products.py +0 -0
  24. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/projects.py +0 -0
  25. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/representations.py +0 -0
  26. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/secrets.py +0 -0
  27. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/tasks.py +0 -0
  28. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/versions.py +0 -0
  29. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/_api_helpers/workfiles.py +0 -0
  30. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/constants.py +0 -0
  31. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/entity_hub.py +0 -0
  32. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/events.py +0 -0
  33. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/exceptions.py +0 -0
  34. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/graphql.py +0 -0
  35. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/graphql_queries.py +0 -0
  36. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/operations.py +0 -0
  37. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/typing.py +0 -0
  38. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_api/utils.py +0 -0
  39. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_python_api.egg-info/SOURCES.txt +0 -0
  40. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_python_api.egg-info/dependency_links.txt +0 -0
  41. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_python_api.egg-info/requires.txt +0 -0
  42. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/ayon_python_api.egg-info/top_level.txt +0 -0
  43. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/setup.cfg +0 -0
  44. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/setup.py +0 -0
  45. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/tests/test_entity_hub.py +0 -0
  46. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/tests/test_folder_hierarchy.py +0 -0
  47. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/tests/test_get_events.py +0 -0
  48. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/tests/test_graphql_queries.py +0 -0
  49. {ayon_python_api-1.2.10 → ayon_python_api-1.2.11}/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.10
3
+ Version: 1.2.11
4
4
  Summary: AYON Python API
5
5
  Home-page: https://github.com/ynput/ayon-python-api
6
6
  Author: ynput.io
@@ -398,7 +398,7 @@ class BundlesAddonsAPI(BaseServerAPI):
398
398
 
399
399
  """
400
400
  response = self.upload_file(
401
- "addons/install",
401
+ "api/addons/install",
402
402
  src_filepath,
403
403
  progress=progress,
404
404
  request_type=RequestTypes.post,
@@ -448,9 +448,11 @@ class BundlesAddonsAPI(BaseServerAPI):
448
448
  "private",
449
449
  filename
450
450
  )
451
- url = f"{self.get_base_url()}/{endpoint}"
452
451
  self.download_file(
453
- url, dst_filepath, chunk_size=chunk_size, progress=progress
452
+ endpoint,
453
+ dst_filepath,
454
+ chunk_size=chunk_size,
455
+ progress=progress,
454
456
  )
455
457
  return dst_filepath
456
458
 
@@ -189,7 +189,7 @@ class DependencyPackagesAPI(BaseServerAPI):
189
189
  route = self._get_dependency_package_route(src_filename)
190
190
  package_filepath = os.path.join(dst_directory, dst_filename)
191
191
  self.download_file(
192
- route,
192
+ f"api/{route}",
193
193
  package_filepath,
194
194
  chunk_size=chunk_size,
195
195
  progress=progress
@@ -225,7 +225,7 @@ class DependencyPackagesAPI(BaseServerAPI):
225
225
  )
226
226
 
227
227
  route = self._get_dependency_package_route(dst_filename)
228
- self.upload_file(route, src_filepath, progress=progress)
228
+ self.upload_file(f"api/{route}", src_filepath, progress=progress)
229
229
 
230
230
  def _get_dependency_package_route(
231
231
  self, filename: Optional[str] = None
@@ -143,7 +143,7 @@ class InstallersAPI(BaseServerAPI):
143
143
 
144
144
  """
145
145
  return self.download_file(
146
- f"desktop/installers/{filename}",
146
+ f"api/desktop/installers/{filename}",
147
147
  dst_filepath,
148
148
  chunk_size=chunk_size,
149
149
  progress=progress
@@ -168,7 +168,7 @@ class InstallersAPI(BaseServerAPI):
168
168
 
169
169
  """
170
170
  return self.upload_file(
171
- f"desktop/installers/{dst_filename}",
171
+ f"api/desktop/installers/{dst_filename}",
172
172
  src_filepath,
173
173
  progress=progress
174
174
  )
@@ -256,7 +256,7 @@ class ThumbnailsAPI(BaseServerAPI):
256
256
 
257
257
  mime_type = get_media_mime_type(src_filepath)
258
258
  response = self.upload_file(
259
- f"projects/{project_name}/thumbnails",
259
+ f"api/projects/{project_name}/thumbnails",
260
260
  src_filepath,
261
261
  request_type=RequestTypes.post,
262
262
  headers={"Content-Type": mime_type},
@@ -295,7 +295,7 @@ class ThumbnailsAPI(BaseServerAPI):
295
295
 
296
296
  mime_type = get_media_mime_type_for_stream(stream)
297
297
  response = self.upload_file_from_stream(
298
- f"projects/{project_name}/thumbnails",
298
+ f"api/projects/{project_name}/thumbnails",
299
299
  stream,
300
300
  request_type=RequestTypes.post,
301
301
  headers={"Content-Type": mime_type},
@@ -325,7 +325,7 @@ class ThumbnailsAPI(BaseServerAPI):
325
325
 
326
326
  mime_type = get_media_mime_type(src_filepath)
327
327
  response = self.upload_file(
328
- f"projects/{project_name}/thumbnails/{thumbnail_id}",
328
+ f"api/projects/{project_name}/thumbnails/{thumbnail_id}",
329
329
  src_filepath,
330
330
  request_type=RequestTypes.put,
331
331
  headers={"Content-Type": mime_type},
@@ -351,7 +351,7 @@ class ThumbnailsAPI(BaseServerAPI):
351
351
  """
352
352
  mime_type = get_media_mime_type_for_stream(stream)
353
353
  response = self.upload_file_from_stream(
354
- f"projects/{project_name}/thumbnails/{thumbnail_id}",
354
+ f"api/projects/{project_name}/thumbnails/{thumbnail_id}",
355
355
  stream,
356
356
  request_type=RequestTypes.put,
357
357
  headers={"Content-Type": mime_type},
@@ -1352,7 +1352,7 @@ class ServerAPI(
1352
1352
 
1353
1353
  def _download_file_to_stream(
1354
1354
  self,
1355
- url: str,
1355
+ endpoint: str,
1356
1356
  stream: StreamType,
1357
1357
  chunk_size: int,
1358
1358
  progress: TransferProgress,
@@ -1367,7 +1367,11 @@ class ServerAPI(
1367
1367
  else:
1368
1368
  get_func = self._session_functions_mapping[RequestTypes.get]
1369
1369
 
1370
+ url = self._endpoint_to_url(endpoint, use_rest=False)
1371
+ progress.set_source_url(url)
1372
+
1370
1373
  retries = self.get_default_max_retries()
1374
+ api_prepended = False
1371
1375
  for attempt in range(retries):
1372
1376
  # Continue in download
1373
1377
  offset = progress.get_transferred_size()
@@ -1376,6 +1380,18 @@ class ServerAPI(
1376
1380
 
1377
1381
  try:
1378
1382
  with get_func(url, **kwargs) as response:
1383
+ # Auto-fix missing 'api/'
1384
+ if response.status_code == 405 and not api_prepended:
1385
+ api_prepended = True
1386
+ if (
1387
+ not endpoint.startswith(self._base_url)
1388
+ and not endpoint.startswith("api/")
1389
+ ):
1390
+ url = self._endpoint_to_url(
1391
+ endpoint, use_rest=True
1392
+ )
1393
+ progress.set_destination_url(url)
1394
+ continue
1379
1395
  response.raise_for_status()
1380
1396
  if progress.get_content_size() is None:
1381
1397
  progress.set_content_size(
@@ -1395,6 +1411,12 @@ class ServerAPI(
1395
1411
  raise
1396
1412
  progress.next_attempt()
1397
1413
 
1414
+ if api_prepended:
1415
+ self.log.warning(
1416
+ f"Auto-fixed endpoint '{endpoint}' -> 'api/{endpoint}'."
1417
+ " Please fix the endpoit passed to the function."
1418
+ )
1419
+
1398
1420
  def download_file_to_stream(
1399
1421
  self,
1400
1422
  endpoint: str,
@@ -1427,17 +1449,14 @@ class ServerAPI(
1427
1449
  if not chunk_size:
1428
1450
  chunk_size = self.default_download_chunk_size
1429
1451
 
1430
- url = self._endpoint_to_url(endpoint, use_rest=False)
1431
-
1432
1452
  if progress is None:
1433
1453
  progress = TransferProgress()
1434
1454
 
1435
- progress.set_source_url(url)
1436
1455
  progress.set_started()
1437
1456
 
1438
1457
  try:
1439
1458
  self._download_file_to_stream(
1440
- url, stream, chunk_size, progress
1459
+ endpoint, stream, chunk_size, progress
1441
1460
  )
1442
1461
 
1443
1462
  except Exception as exc:
@@ -1585,13 +1604,7 @@ class ServerAPI(
1585
1604
  bytes: Chunk of file.
1586
1605
 
1587
1606
  """
1588
- # Get size of file
1589
- file_stream.seek(0, io.SEEK_END)
1590
- size = file_stream.tell()
1591
1607
  file_stream.seek(0)
1592
- # Set content size to progress object
1593
- progress.set_content_size(size)
1594
-
1595
1608
  while True:
1596
1609
  chunk = file_stream.read(chunk_size)
1597
1610
  if not chunk:
@@ -1601,7 +1614,7 @@ class ServerAPI(
1601
1614
 
1602
1615
  def _upload_file(
1603
1616
  self,
1604
- url: str,
1617
+ endpoint: str,
1605
1618
  stream: StreamType,
1606
1619
  progress: TransferProgress,
1607
1620
  request_type: Optional[RequestType] = None,
@@ -1611,7 +1624,7 @@ class ServerAPI(
1611
1624
  """Upload file to server.
1612
1625
 
1613
1626
  Args:
1614
- url (str): Url where file will be uploaded.
1627
+ endpoint (str): Endpoint used to upload.
1615
1628
  stream (StreamType): File stream.
1616
1629
  progress (TransferProgress): Object that gives ability to track
1617
1630
  progress.
@@ -1629,6 +1642,10 @@ class ServerAPI(
1629
1642
  if request_type is None:
1630
1643
  request_type = RequestTypes.put
1631
1644
 
1645
+ endpoint = endpoint.lstrip("/")
1646
+ url = self._endpoint_to_url(endpoint, use_rest=False)
1647
+ progress.set_destination_url(url)
1648
+
1632
1649
  if self._session is None:
1633
1650
  headers = kwargs.setdefault("headers", {})
1634
1651
  for key, value in self.get_headers().items():
@@ -1643,6 +1660,14 @@ class ServerAPI(
1643
1660
 
1644
1661
  retries = self.get_default_max_retries()
1645
1662
  response = None
1663
+
1664
+ # Get size of file
1665
+ stream.seek(0, io.SEEK_END)
1666
+ size = stream.tell()
1667
+ # Set content size to progress object
1668
+ progress.set_content_size(size)
1669
+
1670
+ api_prepended = False
1646
1671
  for attempt in range(retries):
1647
1672
  try:
1648
1673
  response = post_func(
@@ -1652,6 +1677,16 @@ class ServerAPI(
1652
1677
  ),
1653
1678
  **kwargs
1654
1679
  )
1680
+ # Auto-fix missing 'api/'
1681
+ if response.status_code == 405 and not api_prepended:
1682
+ api_prepended = True
1683
+ if (
1684
+ not endpoint.startswith(self._base_url)
1685
+ and not endpoint.startswith("api/")
1686
+ ):
1687
+ url = self._endpoint_to_url(endpoint, use_rest=True)
1688
+ progress.set_destination_url(url)
1689
+ continue
1655
1690
  break
1656
1691
 
1657
1692
  except (
@@ -1664,6 +1699,11 @@ class ServerAPI(
1664
1699
  progress.reset_transferred()
1665
1700
 
1666
1701
  response.raise_for_status()
1702
+ if api_prepended:
1703
+ self.log.warning(
1704
+ f"Auto-fixed endpoint '{endpoint}' -> 'api/{endpoint}'."
1705
+ " Please fix the endpoit passed to the function."
1706
+ )
1667
1707
  return response
1668
1708
 
1669
1709
  def upload_file_from_stream(
@@ -1694,19 +1734,20 @@ class ServerAPI(
1694
1734
  requests.Response: Response object
1695
1735
 
1696
1736
  """
1697
- url = self._endpoint_to_url(endpoint)
1698
-
1699
1737
  # Create dummy object so the function does not have to check
1700
1738
  # 'progress' variable everywhere
1701
1739
  if progress is None:
1702
1740
  progress = TransferProgress()
1703
1741
 
1704
- progress.set_destination_url(url)
1705
1742
  progress.set_started()
1706
1743
 
1707
1744
  try:
1708
1745
  return self._upload_file(
1709
- url, stream, progress, request_type, **kwargs
1746
+ endpoint,
1747
+ stream,
1748
+ progress,
1749
+ request_type,
1750
+ **kwargs
1710
1751
  )
1711
1752
 
1712
1753
  except Exception as exc:
@@ -1751,7 +1792,11 @@ class ServerAPI(
1751
1792
 
1752
1793
  with open(filepath, "rb") as stream:
1753
1794
  return self.upload_file_from_stream(
1754
- endpoint, stream, progress, request_type, **kwargs
1795
+ endpoint,
1796
+ stream,
1797
+ progress,
1798
+ request_type,
1799
+ **kwargs
1755
1800
  )
1756
1801
 
1757
1802
  def upload_reviewable(
@@ -1813,7 +1858,7 @@ class ServerAPI(
1813
1858
 
1814
1859
  query = prepare_query_string({"label": label or None})
1815
1860
  endpoint = (
1816
- f"/projects/{project_name}"
1861
+ f"api/projects/{project_name}"
1817
1862
  f"/versions/{version_id}/reviewables{query}"
1818
1863
  )
1819
1864
  return self.upload_file(
@@ -1,2 +1,2 @@
1
1
  """Package declaring Python API for AYON server."""
2
- __version__ = "1.2.10"
2
+ __version__ = "1.2.11"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ayon_python_api
3
- Version: 1.2.10
3
+ Version: 1.2.11
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.10"
3
+ version = "1.2.11"
4
4
  description = "AYON Python API"
5
5
  license = {file = "LICENSE"}
6
6
  readme = {file = "README.md", content-type = "text/markdown"}