squarecloud-api 3.8.1__tar.gz → 4.1.0__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 (42) hide show
  1. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0}/PKG-INFO +4 -8
  2. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0}/pyproject.toml +43 -41
  3. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/__init__.py +3 -1
  4. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/app.py +118 -45
  5. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/client.py +591 -53
  6. squarecloud_api-4.1.0/src/squarecloud/data/__init__.py +44 -0
  7. squarecloud_api-4.1.0/src/squarecloud/data/app.py +41 -0
  8. squarecloud_api-4.1.0/src/squarecloud/data/base.py +15 -0
  9. squarecloud_api-4.1.0/src/squarecloud/data/base_database.py +8 -0
  10. squarecloud_api-4.1.0/src/squarecloud/data/certificate.py +58 -0
  11. squarecloud_api-4.1.0/src/squarecloud/data/database.py +10 -0
  12. squarecloud_api-4.1.0/src/squarecloud/data/database_info.py +17 -0
  13. squarecloud_api-4.1.0/src/squarecloud/data/deploy_data.py +11 -0
  14. squarecloud_api-4.1.0/src/squarecloud/data/dns_record.py +8 -0
  15. squarecloud_api-4.1.0/src/squarecloud/data/domain_analytics.py +62 -0
  16. squarecloud_api-4.1.0/src/squarecloud/data/file_info.py +30 -0
  17. squarecloud_api-4.1.0/src/squarecloud/data/language.py +6 -0
  18. squarecloud_api-4.1.0/src/squarecloud/data/logs.py +15 -0
  19. squarecloud_api-4.1.0/src/squarecloud/data/plan.py +23 -0
  20. squarecloud_api-4.1.0/src/squarecloud/data/snapshot.py +34 -0
  21. squarecloud_api-4.1.0/src/squarecloud/data/snapshot_info.py +16 -0
  22. squarecloud_api-4.1.0/src/squarecloud/data/status.py +46 -0
  23. squarecloud_api-4.1.0/src/squarecloud/data/upload.py +37 -0
  24. squarecloud_api-4.1.0/src/squarecloud/data/user.py +26 -0
  25. squarecloud_api-4.1.0/src/squarecloud/data/workspace.py +53 -0
  26. squarecloud_api-4.1.0/src/squarecloud/http/endpoints.py +737 -0
  27. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/http/http_client.py +528 -6
  28. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/listeners/__init__.py +0 -31
  29. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/listeners/capture_listener.py +0 -45
  30. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/listeners/request_listener.py +0 -40
  31. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/utils.py +3 -3
  32. squarecloud_api-3.8.1/squarecloud/_internal/constants.py +0 -3
  33. squarecloud_api-3.8.1/squarecloud/_internal/decorators.py +0 -16
  34. squarecloud_api-3.8.1/squarecloud/data.py +0 -351
  35. squarecloud_api-3.8.1/squarecloud/http/endpoints.py +0 -358
  36. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0}/LICENSE +0 -0
  37. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0}/README.md +0 -0
  38. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/errors.py +0 -0
  39. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/file.py +0 -0
  40. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/http/__init__.py +0 -0
  41. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/logger.py +0 -0
  42. {squarecloud_api-3.8.1 → squarecloud_api-4.1.0/src}/squarecloud/py.typed +0 -0
@@ -1,22 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: squarecloud-api
3
- Version: 3.8.1
3
+ Version: 4.1.0
4
4
  Summary: SquareCloud API wrapper
5
5
  License: MIT
6
6
  License-File: LICENSE
7
7
  Author: Robert Nogueira
8
8
  Author-email: robertlucasnogueira@gmail.com
9
- Requires-Python: >=3.13,<4.0
9
+ Requires-Python: >=3.13,<3.15
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
- Provides-Extra: pydantic
15
- Requires-Dist: aiohttp (>=3.13.2,<4.0.0)
16
- Requires-Dist: pydantic (>=2.12.5,<3.0.0) ; extra == "pydantic"
17
- Requires-Dist: typing-extensions (>=4.15.0,<5.0.0)
18
- Project-URL: Documentation, https://docs.squarecloud.app/sdks/py
19
- Project-URL: Repository, https://github.com/squarecloudofc/wrapper-api-py
14
+ Requires-Dist: aiohttp (>=3.13.2,<3.14.0)
15
+ Requires-Dist: typing-extensions (>=4.15.0,<4.16.0)
20
16
  Description-Content-Type: text/markdown
21
17
 
22
18
  [Square Cloud]: https://squarecloud.app
@@ -1,46 +1,48 @@
1
- [tool.poetry]
2
- name = 'squarecloud-api'
3
- version = '3.8.1'
4
- description = 'SquareCloud API wrapper'
5
- authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
1
+ [project]
2
+ name = "squarecloud-api"
3
+ version = "4.1.0"
4
+ description = "SquareCloud API wrapper"
5
+ authors = [
6
+ {name = "Robert Nogueira",email = "robertlucasnogueira@gmail.com"}
7
+ ]
6
8
  repository = 'https://github.com/squarecloudofc/wrapper-api-py'
7
- documentation = 'https://docs.squarecloud.app/sdks/py'
8
- license = 'MIT License'
9
- readme = 'README.md'
10
- packages = [{ include = "squarecloud" }]
11
-
12
-
13
- [tool.poetry.dependencies]
14
- python = '^3.13'
15
- typing-extensions = "^4.15.0"
16
- aiohttp = "^3.13.2"
17
- pydantic = "^2.12.5"
18
-
19
- [tool.poetry.extras]
20
- pydantic = ["pydantic"]
21
-
22
- [tool.poetry.group.dev.dependencies]
23
- isort = "^7.0.0"
24
- pre-commit = "^4.5.0"
25
- pytest = "^9.0.2"
26
- pytest-asyncio = "^1.3.0"
27
- pytest-cov = "^6.0.0"
28
- pytest-rerunfailures = "^16.1"
29
- ruff = "^0.14.9"
30
- taskipy = "^1.14.1"
31
- bandit = {extras = ["toml"], version = "^1.9.2"}
32
- cz-conventional-gitmoji = "^0.7.0"
33
- memory-profiler = "^0.61.0"
34
- requests = "^2.32.5"
35
- python-dotenv = "^1.2.1"
36
- safety = "^3.7.0"
37
- vulture = "^2.14"
38
- mypy-extensions = "^1.1.0"
39
- commitizen = "^4.10.1"
9
+ documentation = 'https://docs.squarecloud.app/en/sdks/py/client'
10
+ license = {text = "MIT License"}
11
+ readme = "README.md"
12
+ requires-python = ">=3.13,<3.15"
13
+
14
+ dependencies = [
15
+ "aiohttp~=3.13.2",
16
+ "typing-extensions~=4.15.0",
17
+ ]
18
+
19
+ [tool.poetry]
20
+ packages = [{ from= "src", include = "squarecloud" }]
40
21
 
41
22
  [build-system]
42
- requires = ['poetry-core']
43
- build-backend = 'poetry.core.masonry.api'
23
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
24
+ build-backend = "poetry.core.masonry.api"
25
+
26
+ [dependency-groups]
27
+ dev = [
28
+ "bandit[toml]~=1.9.2",
29
+ "commitizen~=4.10.1",
30
+ "cz-conventional-gitmoji~=0.7.0",
31
+ "isort~=7.0.0",
32
+ "memory-profiler~=0.61.0",
33
+ "mypy-extensions~=1.1.0",
34
+ "pre-commit~=4.5.0",
35
+ "pytest~=9.0.2",
36
+ "pytest-asyncio~=1.3.0",
37
+ "pytest-cov~=7.1.0",
38
+ "pytest-rerunfailures~=16.1",
39
+ "python-dotenv~=1.2.1",
40
+ "requests~=2.32.5",
41
+ "ruff~=0.14.9",
42
+ "safety~=3.7.0",
43
+ "taskipy~=1.14.1",
44
+ "vulture~=2.14",
45
+ ]
44
46
 
45
47
  [tool.pytest.ini_options]
46
48
  asyncio_mode = 'auto'
@@ -143,4 +145,4 @@ B704 = "markupsafe_markup_xss" # Potential XSS via MarkupSafe
143
145
  name = "cz_gitmoji"
144
146
 
145
147
  [tool.ruff.lint.per-file-ignores]
146
- '__init__.py' = ['F401']
148
+ '__init__.py' = ['F401']
@@ -17,6 +17,7 @@ from .data import (
17
17
  StatusData,
18
18
  UploadData,
19
19
  UserData,
20
+ Workspace,
20
21
  )
21
22
  from .file import File
22
23
  from .http.endpoints import Endpoint
@@ -41,8 +42,9 @@ __all__ = [
41
42
  'StatusData',
42
43
  'UploadData',
43
44
  'UserData',
45
+ 'Workspace',
44
46
  'errors',
45
47
  'utils',
46
48
  ]
47
49
 
48
- __version__ = '3.8.1'
50
+ __version__ = '4.1.0'
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from collections.abc import AsyncGenerator
3
4
  from datetime import datetime
4
5
  from functools import wraps
5
6
  from io import BytesIO
@@ -9,7 +10,6 @@ from typing_extensions import deprecated
9
10
 
10
11
  from squarecloud import errors
11
12
 
12
- from ._internal.decorators import validate
13
13
  from .data import (
14
14
  AppData,
15
15
  DeployData,
@@ -41,7 +41,6 @@ class AppCache:
41
41
  __slots__ = (
42
42
  '_status',
43
43
  '_logs',
44
- '_backup',
45
44
  '_app_data',
46
45
  '_snapshot'
47
46
  )
@@ -57,7 +56,6 @@ class AppCache:
57
56
  """
58
57
  self._status: StatusData | None = None
59
58
  self._logs: LogsData | None = None
60
- self._backup: Snapshot | None = None
61
59
  self._snapshot: Snapshot | None = None
62
60
  self._app_data: AppData | None = None
63
61
 
@@ -83,18 +81,6 @@ class AppCache:
83
81
  """
84
82
  return self._logs
85
83
 
86
- @property
87
- @deprecated("this property will be removed in future versions, use the 'snapshot' property instead")
88
- def backup(self) -> Snapshot:
89
- """
90
- The backup method is a property that returns the cached Backup of
91
- the application.
92
-
93
- :return: The value of the _backup attribute
94
- :rtype: Backup
95
- """
96
- return self._backup
97
-
98
84
  @property
99
85
  def snapshot(self) -> Snapshot:
100
86
  """
@@ -119,7 +105,7 @@ class AppCache:
119
105
 
120
106
  def clear(self) -> None:
121
107
  """
122
- The clear method is used to clear the status, logs, backup and data
108
+ The clear method is used to clear the status, logs, snapshot and data
123
109
  variables.
124
110
 
125
111
  :param self: Refer to the class instance
@@ -127,7 +113,6 @@ class AppCache:
127
113
  """
128
114
  self._status = None
129
115
  self._logs = None
130
- self._backup = None
131
116
  self._app_data = None
132
117
  self._snapshot = None
133
118
 
@@ -136,7 +121,7 @@ class AppCache:
136
121
  The update method is used to update the data of a given instance.
137
122
  It takes in an arbitrary number of arguments, and updates the
138
123
  corresponding data if it is one of the following types:
139
- StatusData, LogsData, Backup or AppData.
124
+ StatusData, LogsData, Snapshot or AppData.
140
125
  If any other type is provided as an argument to this function,
141
126
  a SquareException will be raised.
142
127
 
@@ -149,7 +134,6 @@ class AppCache:
149
134
  elif isinstance(arg, LogsData):
150
135
  self._logs = arg
151
136
  elif isinstance(arg, Snapshot):
152
- self._backup = arg
153
137
  self._snapshot = arg
154
138
  elif isinstance(arg, AppData):
155
139
  self._app_data = arg
@@ -491,20 +475,6 @@ class Application(CaptureListenerManager):
491
475
  status: StatusData = await self.client.app_status(self.id)
492
476
  return status
493
477
 
494
- @_update_cache
495
- @_notify_listener(Endpoint.snapshot())
496
- @deprecated("this method will be removed in future versions, use the 'snapshot' method instead")
497
- async def backup(self, *_args, **_kwargs) -> Snapshot:
498
- """
499
- The backup function is used to create a backup of the application.
500
-
501
- :param self: Refer to the class instance
502
- :return: A Backup object
503
- :rtype: Backup
504
- """
505
- backup: Snapshot = await self.client.snapshot(self.id)
506
- return backup
507
-
508
478
  @_update_cache
509
479
  @_notify_listener(Endpoint.snapshot())
510
480
  async def snapshot(self, *_args, **_kwargs) -> Snapshot:
@@ -570,7 +540,7 @@ class Application(CaptureListenerManager):
570
540
  )
571
541
  return response
572
542
 
573
- @validate
543
+
574
544
  async def commit(self, file: File) -> Response:
575
545
  """
576
546
  The commit function is used to commit the application.
@@ -586,7 +556,7 @@ class Application(CaptureListenerManager):
586
556
  )
587
557
  return response
588
558
 
589
- @validate
559
+
590
560
  async def files_list(self, path: str) -> list[FileInfo]:
591
561
  """
592
562
  The files_list function returns a list of files and folders in the
@@ -604,7 +574,7 @@ class Application(CaptureListenerManager):
604
574
  )
605
575
  return response
606
576
 
607
- @validate
577
+
608
578
  async def read_file(self, path: str) -> BytesIO:
609
579
  """
610
580
  The read_file function reads the contents of a file from an app.
@@ -619,7 +589,7 @@ class Application(CaptureListenerManager):
619
589
  )
620
590
  return response
621
591
 
622
- @validate
592
+
623
593
  async def create_file(self, file: File, path: str) -> Response:
624
594
  """
625
595
  The create_file function creates a file in the specified path.
@@ -638,7 +608,7 @@ class Application(CaptureListenerManager):
638
608
  )
639
609
  return response
640
610
 
641
- @validate
611
+
642
612
  async def delete_file(self, path: str) -> Response:
643
613
  """
644
614
  The delete_file function deletes a file from the app.
@@ -668,7 +638,7 @@ class Application(CaptureListenerManager):
668
638
  )
669
639
  return response
670
640
 
671
- @validate
641
+
672
642
  async def github_integration(self, access_token: str) -> str:
673
643
  """
674
644
  The create_github_integration function returns a webhook to integrate
@@ -713,11 +683,6 @@ class Application(CaptureListenerManager):
713
683
  )
714
684
  return response
715
685
 
716
- @deprecated("this method will be removed in future versions, use the 'all_snapshots' method instead")
717
- async def all_backups(self) -> list[SnapshotInfo]:
718
- backups: list[SnapshotInfo] = await self.client.all_app_snapshots(self.id)
719
- return backups
720
-
721
686
  async def all_snapshots(self) -> list[SnapshotInfo]:
722
687
  """
723
688
  Retrieve all snapshots of the application.
@@ -728,7 +693,7 @@ class Application(CaptureListenerManager):
728
693
  snapshots: list[SnapshotInfo] = await self.client.all_app_snapshots(self.id)
729
694
  return snapshots
730
695
 
731
- @validate
696
+
732
697
  async def move_file(self, origin: str, dest: str) -> Response:
733
698
  """
734
699
  Moves a file from the origin path to the destination path within the application.
@@ -798,3 +763,111 @@ class Application(CaptureListenerManager):
798
763
  :rtype: dict[str, str]
799
764
  """
800
765
  return await self.client.overwrite_app_envs(self.id, envs)
766
+
767
+ async def metrics(self) -> dict[str, Any]:
768
+ """
769
+ Get the last 24h of metrics for the application
770
+ (288 points, sampled every 5 minutes).
771
+ Available only for apps with at least 512 MB of RAM.
772
+
773
+ :return: The raw metrics payload.
774
+ :rtype: dict[str, Any]
775
+ """
776
+ return await self.client.app_metrics(self.id)
777
+
778
+ def realtime(self) -> AsyncGenerator[dict[str, Any] | str, None]:
779
+ """
780
+ Stream realtime status events (SSE) for the application.
781
+
782
+ Usage::
783
+
784
+ async for event in app.realtime():
785
+ print(event)
786
+
787
+ :return: An async generator of decoded events.
788
+ :rtype: AsyncGenerator[dict[str, Any] | str, None]
789
+ """
790
+ return self.client.realtime(self.id)
791
+
792
+ async def link_github_app(
793
+ self, repository_name: str, repository_branch: str
794
+ ) -> dict[str, Any]:
795
+ """
796
+ Link a GitHub repository via the Square Cloud GitHub App.
797
+ Requires a session token (JWT); API keys are not accepted.
798
+
799
+ :param repository_name: Full repository name (e.g. octocat/hello-world).
800
+ :param repository_branch: Repository branch.
801
+ :return: The linked repository information.
802
+ :rtype: dict[str, Any]
803
+ """
804
+ return await self.client.link_github_app(
805
+ self.id, repository_name, repository_branch
806
+ )
807
+
808
+ async def unlink_github_app(self) -> Response:
809
+ """
810
+ Unlink the GitHub App repository from the application.
811
+ Requires a session token (JWT); API keys are not accepted.
812
+
813
+ :return: A Response object.
814
+ :rtype: Response
815
+ """
816
+ return await self.client.unlink_github_app(self.id)
817
+
818
+ async def network_errors(
819
+ self,
820
+ start: str | datetime,
821
+ end: str | datetime,
822
+ include_4xx: bool = False,
823
+ ) -> dict[str, Any]:
824
+ """
825
+ Get the aggregated edge error breakdown (4xx/5xx) for the
826
+ application's domains. Defaults to 5xx only.
827
+
828
+ :param start: ISO 8601 start timestamp (or datetime).
829
+ :param end: ISO 8601 end timestamp (or datetime).
830
+ :param include_4xx: Include 4xx alongside 5xx.
831
+ :return: The raw errors payload.
832
+ :rtype: dict[str, Any]
833
+ """
834
+ return await self.client.network_errors(
835
+ self.id, start, end, include_4xx
836
+ )
837
+
838
+ async def network_logs(
839
+ self, start: str | datetime, end: str | datetime
840
+ ) -> dict[str, Any]:
841
+ """
842
+ Get the per-request edge logs for the application's domains.
843
+ Requires Pro plan or higher.
844
+
845
+ :param start: ISO 8601 start timestamp (or datetime).
846
+ :param end: ISO 8601 end timestamp (or datetime).
847
+ :return: The raw logs payload.
848
+ :rtype: dict[str, Any]
849
+ """
850
+ return await self.client.network_logs(self.id, start, end)
851
+
852
+ async def network_performance(
853
+ self, start: str | datetime, end: str | datetime
854
+ ) -> dict[str, Any]:
855
+ """
856
+ Get edge and origin latency percentiles (p50/p95/p99) for the
857
+ application's domains. Requires Pro plan or higher.
858
+
859
+ :param start: ISO 8601 start timestamp (or datetime).
860
+ :param end: ISO 8601 end timestamp (or datetime).
861
+ :return: The raw performance payload.
862
+ :rtype: dict[str, Any]
863
+ """
864
+ return await self.client.network_performance(self.id, start, end)
865
+
866
+ async def purge_cache(self) -> Response:
867
+ """
868
+ Purge the entire edge cache for the application's domains.
869
+
870
+ :return: A Response object.
871
+ :rtype: Response
872
+ """
873
+ return await self.client.purge_cache(self.id)