squarecloud-api 3.5.1__tar.gz → 3.6.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.
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/PKG-INFO +1 -1
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/pyproject.toml +2 -7
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/__init__.py +5 -2
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/app.py +25 -12
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/client.py +42 -5
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/data.py +39 -8
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/http/endpoints.py +84 -45
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/http/http_client.py +26 -1
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/listeners/__init__.py +1 -1
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/listeners/capture_listener.py +1 -1
- squarecloud_api-3.5.1/squarecloud/cli/__init__.py +0 -22
- squarecloud_api-3.5.1/squarecloud/cli/app.py +0 -439
- squarecloud_api-3.5.1/squarecloud/cli/files.py +0 -197
- squarecloud_api-3.5.1/squarecloud/cli/main.py +0 -172
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/LICENSE +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/README.md +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/errors.py +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/file.py +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/http/__init__.py +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/listeners/request_listener.py +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/logging.py +0 -0
- {squarecloud_api-3.5.1 → squarecloud_api-3.6.0}/squarecloud/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = 'squarecloud-api'
|
|
3
|
-
version = '3.
|
|
3
|
+
version = '3.6.0'
|
|
4
4
|
description = 'SquareCloud API wrapper'
|
|
5
5
|
authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
|
|
6
6
|
repository = 'https://github.com/squarecloudofc/wrapper-api-py'
|
|
@@ -53,17 +53,12 @@ line_length = 79
|
|
|
53
53
|
[tool.taskipy.tasks]
|
|
54
54
|
lint = 'isort . && blue . && ruff .'
|
|
55
55
|
pre_test = 'task lint'
|
|
56
|
-
test = 'pytest -vv -s --reruns 5 --only-rerun TooManyRequests --reruns-delay
|
|
56
|
+
test = 'pytest -vv -s --reruns 5 --only-rerun TooManyRequests --reruns-delay 90 -x --cov=tests tests'
|
|
57
57
|
post_test = 'coverage html'
|
|
58
|
-
cli = 'python -m squarecloud.cli.main'
|
|
59
58
|
publish-test = 'poetry publish -r pypi-test --build'
|
|
60
59
|
install-test = 'pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple --upgrade squarecloud-api'
|
|
61
|
-
docs = 'mkdocs serve'
|
|
62
60
|
clear-test-apps = 'python -m scripts.clear_test_apps'
|
|
63
61
|
|
|
64
|
-
[tool.poetry.scripts]
|
|
65
|
-
squarecloud = 'squarecloud.cli.main:safe_entry_point'
|
|
66
|
-
|
|
67
62
|
[tool.ruff]
|
|
68
63
|
line-length = 79
|
|
69
64
|
exclude = ['env']
|
|
@@ -5,7 +5,8 @@ from .app import Application
|
|
|
5
5
|
from .client import Client
|
|
6
6
|
from .data import (
|
|
7
7
|
AppData,
|
|
8
|
-
|
|
8
|
+
Backup,
|
|
9
|
+
BackupInfo,
|
|
9
10
|
DeployData,
|
|
10
11
|
DomainAnalytics,
|
|
11
12
|
FileInfo,
|
|
@@ -14,8 +15,10 @@ from .data import (
|
|
|
14
15
|
StatusData,
|
|
15
16
|
UploadData,
|
|
16
17
|
UserData,
|
|
18
|
+
ResumedStatus,
|
|
19
|
+
DNSRecord,
|
|
17
20
|
)
|
|
18
21
|
from .file import File
|
|
19
22
|
from .http.endpoints import Endpoint
|
|
20
23
|
|
|
21
|
-
__version__ = '3.
|
|
24
|
+
__version__ = '3.6.0'
|
|
@@ -10,8 +10,10 @@ from squarecloud import errors
|
|
|
10
10
|
|
|
11
11
|
from .data import (
|
|
12
12
|
AppData,
|
|
13
|
-
|
|
13
|
+
Backup,
|
|
14
|
+
BackupInfo,
|
|
14
15
|
DeployData,
|
|
16
|
+
DNSRecord,
|
|
15
17
|
DomainAnalytics,
|
|
16
18
|
FileInfo,
|
|
17
19
|
LogsData,
|
|
@@ -46,7 +48,7 @@ class AppCache:
|
|
|
46
48
|
"""
|
|
47
49
|
self._status: StatusData | None = None
|
|
48
50
|
self._logs: LogsData | None = None
|
|
49
|
-
self._backup:
|
|
51
|
+
self._backup: Backup | None = None
|
|
50
52
|
self._app_data: AppData | None = None
|
|
51
53
|
|
|
52
54
|
@property
|
|
@@ -72,13 +74,13 @@ class AppCache:
|
|
|
72
74
|
return self._logs
|
|
73
75
|
|
|
74
76
|
@property
|
|
75
|
-
def backup(self) ->
|
|
77
|
+
def backup(self) -> Backup:
|
|
76
78
|
"""
|
|
77
|
-
The backup method is a property that returns the cached
|
|
79
|
+
The backup method is a property that returns the cached Backup of
|
|
78
80
|
the application.
|
|
79
81
|
|
|
80
82
|
:return: The value of the _backup attribute
|
|
81
|
-
:rtype:
|
|
83
|
+
:rtype: Backup
|
|
82
84
|
"""
|
|
83
85
|
return self._backup
|
|
84
86
|
|
|
@@ -111,7 +113,7 @@ class AppCache:
|
|
|
111
113
|
The update method is used to update the data of a given instance.
|
|
112
114
|
It takes in an arbitrary number of arguments, and updates the
|
|
113
115
|
corresponding data if it is one of the following types:
|
|
114
|
-
StatusData, LogsData,
|
|
116
|
+
StatusData, LogsData, Backup or AppData.
|
|
115
117
|
If any other type is provided as an argument to this function,
|
|
116
118
|
a SquareException will be raised.
|
|
117
119
|
|
|
@@ -123,7 +125,7 @@ class AppCache:
|
|
|
123
125
|
self._status = arg
|
|
124
126
|
elif isinstance(arg, LogsData):
|
|
125
127
|
self._logs = arg
|
|
126
|
-
elif isinstance(arg,
|
|
128
|
+
elif isinstance(arg, Backup):
|
|
127
129
|
self._backup = arg
|
|
128
130
|
elif isinstance(arg, AppData):
|
|
129
131
|
self._app_data = arg
|
|
@@ -133,7 +135,7 @@ class AppCache:
|
|
|
133
135
|
for i in [
|
|
134
136
|
StatusData,
|
|
135
137
|
LogsData,
|
|
136
|
-
|
|
138
|
+
Backup,
|
|
137
139
|
AppData,
|
|
138
140
|
]
|
|
139
141
|
]
|
|
@@ -463,15 +465,15 @@ class Application(CaptureListenerManager):
|
|
|
463
465
|
|
|
464
466
|
@_update_cache
|
|
465
467
|
@_notify_listener(Endpoint.backup())
|
|
466
|
-
async def backup(self, *_args, **__kwargs) ->
|
|
468
|
+
async def backup(self, *_args, **__kwargs) -> Backup:
|
|
467
469
|
"""
|
|
468
470
|
The backup function is used to create a backup of the application.
|
|
469
471
|
|
|
470
472
|
:param self: Refer to the class instance
|
|
471
|
-
:return: A
|
|
472
|
-
:rtype:
|
|
473
|
+
:return: A Backup object
|
|
474
|
+
:rtype: Backup
|
|
473
475
|
"""
|
|
474
|
-
backup:
|
|
476
|
+
backup: Backup = await self.client.backup(self.id)
|
|
475
477
|
return backup
|
|
476
478
|
|
|
477
479
|
async def start(self) -> Response:
|
|
@@ -647,3 +649,14 @@ class Application(CaptureListenerManager):
|
|
|
647
649
|
self.id, custom_domain, avoid_listener=True
|
|
648
650
|
)
|
|
649
651
|
return response
|
|
652
|
+
|
|
653
|
+
async def all_backups(self):
|
|
654
|
+
backups: list[BackupInfo] = await self.client.all_app_backups(self.id)
|
|
655
|
+
return backups
|
|
656
|
+
|
|
657
|
+
async def move_file(self, origin: str, dest: str):
|
|
658
|
+
return await self.client.move_app_file(self.id, origin, dest)
|
|
659
|
+
|
|
660
|
+
@_notify_listener(Endpoint.dns_records())
|
|
661
|
+
async def dns_records(self) -> list[DNSRecord]:
|
|
662
|
+
return await self.client.dns_records(self.id)
|
|
@@ -10,11 +10,14 @@ from typing_extensions import deprecated
|
|
|
10
10
|
from .app import Application
|
|
11
11
|
from .data import (
|
|
12
12
|
AppData,
|
|
13
|
-
|
|
13
|
+
Backup,
|
|
14
|
+
BackupInfo,
|
|
14
15
|
DeployData,
|
|
16
|
+
DNSRecord,
|
|
15
17
|
DomainAnalytics,
|
|
16
18
|
FileInfo,
|
|
17
19
|
LogsData,
|
|
20
|
+
ResumedStatus,
|
|
18
21
|
StatusData,
|
|
19
22
|
UploadData,
|
|
20
23
|
UserData,
|
|
@@ -329,14 +332,14 @@ class Client(RequestListenerManager):
|
|
|
329
332
|
return await self._http.restart_application(app_id)
|
|
330
333
|
|
|
331
334
|
@_notify_listener(Endpoint.backup())
|
|
332
|
-
async def backup(self, app_id: str, **_kwargs) ->
|
|
335
|
+
async def backup(self, app_id: str, **_kwargs) -> Backup:
|
|
333
336
|
"""
|
|
334
337
|
The backup method is used to backup an application.
|
|
335
338
|
|
|
336
339
|
:param app_id: Specify the application id
|
|
337
340
|
:param _kwargs: Keyword arguments
|
|
338
|
-
:return: A
|
|
339
|
-
:rtype:
|
|
341
|
+
:return: A Backup object
|
|
342
|
+
:rtype: Backup
|
|
340
343
|
|
|
341
344
|
:raises NotFoundError: Raised when the request status code is 404
|
|
342
345
|
:raises BadRequestError: Raised when the request status code is 400
|
|
@@ -347,7 +350,9 @@ class Client(RequestListenerManager):
|
|
|
347
350
|
"""
|
|
348
351
|
response: Response = await self._http.backup(app_id)
|
|
349
352
|
payload: dict[str, Any] = response.response
|
|
350
|
-
return
|
|
353
|
+
return Backup(**payload)
|
|
354
|
+
|
|
355
|
+
# async def app_backups(self) -> list[BackupInfo]:
|
|
351
356
|
|
|
352
357
|
@_notify_listener(Endpoint.delete_app())
|
|
353
358
|
async def delete_app(self, app_id: str, **_kwargs) -> Response:
|
|
@@ -735,3 +740,35 @@ class Client(RequestListenerManager):
|
|
|
735
740
|
app_id=app_id,
|
|
736
741
|
)
|
|
737
742
|
return DomainAnalytics(**response.response)
|
|
743
|
+
|
|
744
|
+
@_notify_listener(Endpoint.all_backups())
|
|
745
|
+
async def all_app_backups(
|
|
746
|
+
self, app_id: str, **_kwargs
|
|
747
|
+
) -> list[BackupInfo]:
|
|
748
|
+
response: Response = await self._http.get_all_app_backups(
|
|
749
|
+
app_id=app_id
|
|
750
|
+
)
|
|
751
|
+
return [BackupInfo(**backup_data) for backup_data in response.response]
|
|
752
|
+
|
|
753
|
+
@_notify_listener(Endpoint.all_apps_status())
|
|
754
|
+
async def all_apps_status(self, **_kwargs) -> list[ResumedStatus]:
|
|
755
|
+
response: Response = await self._http.all_apps_status()
|
|
756
|
+
all_status = []
|
|
757
|
+
for status in response.response:
|
|
758
|
+
if status['running'] is True:
|
|
759
|
+
all_status.append(ResumedStatus(**status))
|
|
760
|
+
return all_status
|
|
761
|
+
|
|
762
|
+
@_notify_listener(Endpoint.move_file())
|
|
763
|
+
async def move_app_file(
|
|
764
|
+
self, app_id: str, origin: str, dest: str, **_kwargs
|
|
765
|
+
) -> Response:
|
|
766
|
+
response: Response = await self._http.move_app_file(
|
|
767
|
+
app_id=app_id, origin=origin, dest=dest
|
|
768
|
+
)
|
|
769
|
+
return response
|
|
770
|
+
|
|
771
|
+
@_notify_listener(Endpoint.dns_records())
|
|
772
|
+
async def dns_records(self, app_id: str) -> list[DNSRecord]:
|
|
773
|
+
response: Response = await self._http.dns_records(app_id)
|
|
774
|
+
return [DNSRecord(**data) for data in response.response]
|
|
@@ -6,9 +6,6 @@ from typing import Any, Dict, Literal, Optional
|
|
|
6
6
|
from pydantic import confloat, conint
|
|
7
7
|
from pydantic.dataclasses import dataclass
|
|
8
8
|
|
|
9
|
-
# pylint: disable=too-many-instance-attributes
|
|
10
|
-
# pylint: disable=invalid-name
|
|
11
|
-
|
|
12
9
|
|
|
13
10
|
@dataclass(frozen=True)
|
|
14
11
|
class PlanData:
|
|
@@ -78,6 +75,14 @@ class StatusData:
|
|
|
78
75
|
return self.__dict__.copy()
|
|
79
76
|
|
|
80
77
|
|
|
78
|
+
@dataclass(frozen=True)
|
|
79
|
+
class ResumedStatus:
|
|
80
|
+
id: str
|
|
81
|
+
running: bool
|
|
82
|
+
cpu: str
|
|
83
|
+
ram: str
|
|
84
|
+
|
|
85
|
+
|
|
81
86
|
@dataclass(frozen=True)
|
|
82
87
|
class AppData:
|
|
83
88
|
"""
|
|
@@ -197,16 +202,27 @@ class LogsData:
|
|
|
197
202
|
|
|
198
203
|
|
|
199
204
|
@dataclass(frozen=True)
|
|
200
|
-
class
|
|
205
|
+
class BackupInfo:
|
|
206
|
+
name: str
|
|
207
|
+
size: int
|
|
208
|
+
modified: datetime
|
|
209
|
+
key: str
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass(frozen=True)
|
|
213
|
+
class Backup:
|
|
201
214
|
"""
|
|
202
215
|
Backup data class
|
|
203
216
|
|
|
204
|
-
:ivar
|
|
217
|
+
:ivar url: Url for download your backup
|
|
218
|
+
:ivar key: The backup's key
|
|
205
219
|
|
|
206
|
-
:type
|
|
220
|
+
:type url: str
|
|
221
|
+
:type key: str
|
|
207
222
|
"""
|
|
208
223
|
|
|
209
|
-
|
|
224
|
+
url: str
|
|
225
|
+
key: str
|
|
210
226
|
|
|
211
227
|
def to_dict(self):
|
|
212
228
|
return self.__dict__.copy()
|
|
@@ -285,10 +301,17 @@ class DeployData:
|
|
|
285
301
|
return self.__dict__.copy()
|
|
286
302
|
|
|
287
303
|
|
|
304
|
+
@dataclass(frozen=True)
|
|
305
|
+
class AnalyticsTotal:
|
|
306
|
+
visits: int
|
|
307
|
+
megabytes: float
|
|
308
|
+
bytes: int
|
|
309
|
+
|
|
310
|
+
|
|
288
311
|
@dataclass(frozen=True)
|
|
289
312
|
class DomainAnalytics:
|
|
290
313
|
hostname: str
|
|
291
|
-
total: list[
|
|
314
|
+
total: list[AnalyticsTotal]
|
|
292
315
|
countries: list[Any]
|
|
293
316
|
methods: list[Any]
|
|
294
317
|
referers: list[Any]
|
|
@@ -301,3 +324,11 @@ class DomainAnalytics:
|
|
|
301
324
|
|
|
302
325
|
def to_dict(self):
|
|
303
326
|
return self.__dict__.copy()
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
@dataclass(frozen=True)
|
|
330
|
+
class DNSRecord:
|
|
331
|
+
type: str
|
|
332
|
+
name: str
|
|
333
|
+
value: str
|
|
334
|
+
status: str
|
|
@@ -2,20 +2,22 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
class Endpoint:
|
|
5
|
-
"""
|
|
5
|
+
"""Class representing an API endpoint."""
|
|
6
6
|
|
|
7
7
|
ENDPOINTS_V2 = {
|
|
8
|
-
'USER': {'METHOD': 'GET', 'PATH': '/
|
|
8
|
+
'USER': {'METHOD': 'GET', 'PATH': '/users/me'},
|
|
9
9
|
'APP_DATA': {'METHOD': 'GET', 'PATH': '/apps/{app_id}'},
|
|
10
10
|
'APP_STATUS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/status'},
|
|
11
|
+
'ALL_APPS_STATUS': {'METHOD': 'GET', 'PATH': '/apps/status'},
|
|
12
|
+
'ALL_BACKUPS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/backups'},
|
|
11
13
|
'LOGS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/logs'},
|
|
12
14
|
'START': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/start'},
|
|
13
15
|
'STOP': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/stop'},
|
|
14
16
|
'RESTART': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/restart'},
|
|
15
|
-
'BACKUP': {'METHOD': '
|
|
17
|
+
'BACKUP': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/backups'},
|
|
16
18
|
'COMMIT': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/commit'},
|
|
17
|
-
'DELETE_APP': {'METHOD': 'DELETE', 'PATH': '/apps/{app_id}
|
|
18
|
-
'UPLOAD_APP': {'METHOD': 'POST', 'PATH': '/apps
|
|
19
|
+
'DELETE_APP': {'METHOD': 'DELETE', 'PATH': '/apps/{app_id}'},
|
|
20
|
+
'UPLOAD_APP': {'METHOD': 'POST', 'PATH': '/apps'},
|
|
19
21
|
'FILES_LIST': {
|
|
20
22
|
'METHOD': 'GET',
|
|
21
23
|
'PATH': '/apps/{app_id}/files/list?path={path}',
|
|
@@ -25,43 +27,43 @@ class Endpoint:
|
|
|
25
27
|
'PATH': '/apps/{app_id}/files/read?path={path}',
|
|
26
28
|
},
|
|
27
29
|
'FILES_CREATE': {
|
|
28
|
-
'METHOD': '
|
|
29
|
-
'PATH': '/apps/{app_id}/files
|
|
30
|
+
'METHOD': 'PUT',
|
|
31
|
+
'PATH': '/apps/{app_id}/files',
|
|
30
32
|
},
|
|
31
33
|
'FILES_DELETE': {
|
|
32
34
|
'METHOD': 'DELETE',
|
|
33
35
|
'PATH': '/apps/{app_id}/files/delete?path={path}',
|
|
34
36
|
},
|
|
37
|
+
'MOVE_FILE': {'METHOD': 'PATCH', 'PATH': '/apps/{app_id}/files'},
|
|
35
38
|
'LAST_DEPLOYS': {
|
|
36
39
|
'METHOD': 'GET',
|
|
37
|
-
'PATH': '/apps/{app_id}/
|
|
40
|
+
'PATH': '/apps/{app_id}/deployments',
|
|
41
|
+
},
|
|
42
|
+
'CURRENT_WEBHOOK': {
|
|
43
|
+
'METHOD': 'GET',
|
|
44
|
+
'PATH': '/apps/{app_id}/deployments/current',
|
|
38
45
|
},
|
|
39
46
|
'GITHUB_INTEGRATION': {
|
|
40
47
|
'METHOD': 'POST',
|
|
41
|
-
'PATH': '/apps/{app_id}/deploy/
|
|
48
|
+
'PATH': '/apps/{app_id}/deploy/webhook',
|
|
42
49
|
},
|
|
43
50
|
'CUSTOM_DOMAIN': {
|
|
44
51
|
'METHOD': 'POST',
|
|
45
|
-
'PATH': '/apps/{app_id}/network/custom
|
|
52
|
+
'PATH': '/apps/{app_id}/network/custom',
|
|
46
53
|
},
|
|
47
54
|
'DOMAIN_ANALYTICS': {
|
|
48
55
|
'METHOD': 'GET',
|
|
49
56
|
'PATH': '/apps/{app_id}/network/analytics',
|
|
50
57
|
},
|
|
58
|
+
'DNSRECORDS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/network/dns'},
|
|
51
59
|
}
|
|
52
60
|
|
|
53
61
|
def __init__(self, name: str) -> None:
|
|
54
62
|
"""
|
|
55
|
-
|
|
56
|
-
It sets up the instance of the class, and defines its attributes.
|
|
57
|
-
The __init__ function takes in a name parameter, which it uses to look
|
|
58
|
-
up an endpoint from ENDPOINTS_V2.
|
|
59
|
-
ENDPOINTS_V2 is a dictionary that contains all of our endpoints for
|
|
60
|
-
version 2 of our API.
|
|
63
|
+
Initialize an Endpoint instance with the given name.
|
|
61
64
|
|
|
62
|
-
:param
|
|
63
|
-
:
|
|
64
|
-
:return: None
|
|
65
|
+
:param name: The name of the endpoint.
|
|
66
|
+
:raises ValueError: If the endpoint name is invalid.
|
|
65
67
|
"""
|
|
66
68
|
if not (endpoint := self.ENDPOINTS_V2.get(name)):
|
|
67
69
|
raise ValueError(f"Invalid endpoint: '{name}'")
|
|
@@ -69,38 +71,36 @@ class Endpoint:
|
|
|
69
71
|
self.method: str = endpoint['METHOD']
|
|
70
72
|
self.path: str = endpoint['PATH']
|
|
71
73
|
|
|
72
|
-
def __eq__(self, other:
|
|
74
|
+
def __eq__(self, other: object) -> bool:
|
|
73
75
|
"""
|
|
74
|
-
|
|
75
|
-
It returns True if they are equal, and False otherwise.
|
|
76
|
+
Compare two Endpoint instances for equality.
|
|
76
77
|
|
|
77
|
-
:param
|
|
78
|
-
:
|
|
79
|
-
endpoint
|
|
80
|
-
:return: A boolean value
|
|
78
|
+
:param other: The other Endpoint instance to compare.
|
|
79
|
+
:return: True if both instances have the same name, otherwise False.
|
|
81
80
|
"""
|
|
82
81
|
return isinstance(other, Endpoint) and self.name == other.name
|
|
83
82
|
|
|
84
|
-
def __repr__(self):
|
|
83
|
+
def __repr__(self) -> str:
|
|
85
84
|
"""
|
|
86
|
-
|
|
87
|
-
string representation of an object.
|
|
88
|
-
This is how you would make an object of the class. The goal of
|
|
85
|
+
Return the official string representation of the Endpoint instance.
|
|
89
86
|
|
|
90
|
-
:
|
|
91
|
-
:return: A string that is the representation of an object
|
|
87
|
+
:return: A string representation of the Endpoint instance.
|
|
92
88
|
"""
|
|
93
89
|
return f"{Endpoint.__name__}('{self.name}')"
|
|
94
90
|
|
|
95
91
|
@classmethod
|
|
96
92
|
def user(cls) -> Endpoint:
|
|
97
|
-
"""
|
|
93
|
+
"""
|
|
94
|
+
Returns an Endpoint object that represents the
|
|
95
|
+
/user endpoint.
|
|
96
|
+
"""
|
|
98
97
|
return cls('USER')
|
|
99
98
|
|
|
100
99
|
@classmethod
|
|
101
100
|
def app_data(cls) -> Endpoint:
|
|
102
101
|
"""
|
|
103
|
-
Returns an Endpoint object that represents the
|
|
102
|
+
Returns an Endpoint object that represents the
|
|
103
|
+
/apps/{app_id} endpoint.
|
|
104
104
|
"""
|
|
105
105
|
return cls('APP_DATA')
|
|
106
106
|
|
|
@@ -148,7 +148,7 @@ class Endpoint:
|
|
|
148
148
|
def backup(cls) -> Endpoint:
|
|
149
149
|
"""
|
|
150
150
|
Returns an Endpoint object that represents the
|
|
151
|
-
/apps/{app_id}/
|
|
151
|
+
/apps/{app_id}/backups endpoint.
|
|
152
152
|
"""
|
|
153
153
|
return cls('BACKUP')
|
|
154
154
|
|
|
@@ -164,7 +164,7 @@ class Endpoint:
|
|
|
164
164
|
def delete_app(cls) -> Endpoint:
|
|
165
165
|
"""
|
|
166
166
|
Returns an Endpoint object that represents the
|
|
167
|
-
/apps/{app_id}
|
|
167
|
+
/apps/{app_id} endpoint.
|
|
168
168
|
"""
|
|
169
169
|
return cls('DELETE_APP')
|
|
170
170
|
|
|
@@ -172,7 +172,7 @@ class Endpoint:
|
|
|
172
172
|
def upload(cls) -> Endpoint:
|
|
173
173
|
"""
|
|
174
174
|
Returns an Endpoint object that represents the
|
|
175
|
-
/apps
|
|
175
|
+
/apps endpoint.
|
|
176
176
|
"""
|
|
177
177
|
return cls('UPLOAD_APP')
|
|
178
178
|
|
|
@@ -209,24 +209,23 @@ class Endpoint:
|
|
|
209
209
|
return cls('FILES_DELETE')
|
|
210
210
|
|
|
211
211
|
@classmethod
|
|
212
|
-
def last_deploys(cls):
|
|
212
|
+
def last_deploys(cls) -> Endpoint:
|
|
213
213
|
"""
|
|
214
214
|
Returns an Endpoint object that represents the
|
|
215
|
-
/apps/{app_id}/
|
|
215
|
+
/apps/{app_id}/deployments endpoint.
|
|
216
216
|
"""
|
|
217
|
-
|
|
218
217
|
return cls('LAST_DEPLOYS')
|
|
219
218
|
|
|
220
219
|
@classmethod
|
|
221
|
-
def github_integration(cls):
|
|
220
|
+
def github_integration(cls) -> Endpoint:
|
|
222
221
|
"""
|
|
223
222
|
Returns an Endpoint object that represents the
|
|
224
|
-
/apps/{app_id}/deploy/
|
|
223
|
+
/apps/{app_id}/deploy/webhook endpoint.
|
|
225
224
|
"""
|
|
226
225
|
return cls('GITHUB_INTEGRATION')
|
|
227
226
|
|
|
228
227
|
@classmethod
|
|
229
|
-
def domain_analytics(cls):
|
|
228
|
+
def domain_analytics(cls) -> Endpoint:
|
|
230
229
|
"""
|
|
231
230
|
Returns an Endpoint object that represents the
|
|
232
231
|
/apps/{app_id}/network/analytics endpoint.
|
|
@@ -234,13 +233,53 @@ class Endpoint:
|
|
|
234
233
|
return cls('DOMAIN_ANALYTICS')
|
|
235
234
|
|
|
236
235
|
@classmethod
|
|
237
|
-
def custom_domain(cls):
|
|
236
|
+
def custom_domain(cls) -> Endpoint:
|
|
238
237
|
"""
|
|
239
238
|
Returns an Endpoint object that represents the
|
|
240
|
-
/apps/{app_id}/network/custom
|
|
239
|
+
/apps/{app_id}/network/custom endpoint.
|
|
241
240
|
"""
|
|
242
241
|
return cls('CUSTOM_DOMAIN')
|
|
243
242
|
|
|
243
|
+
@classmethod
|
|
244
|
+
def all_backups(cls) -> Endpoint:
|
|
245
|
+
"""
|
|
246
|
+
Returns an Endpoint object that represents the
|
|
247
|
+
/apps/{app_id}/backups endpoint.
|
|
248
|
+
"""
|
|
249
|
+
return cls('ALL_BACKUPS')
|
|
250
|
+
|
|
251
|
+
@classmethod
|
|
252
|
+
def all_apps_status(cls) -> Endpoint:
|
|
253
|
+
"""
|
|
254
|
+
Returns an Endpoint object that represents the
|
|
255
|
+
/apps/status endpoint.
|
|
256
|
+
"""
|
|
257
|
+
return cls('ALL_APPS_STATUS')
|
|
258
|
+
|
|
259
|
+
@classmethod
|
|
260
|
+
def current_webhook(cls) -> Endpoint:
|
|
261
|
+
"""
|
|
262
|
+
Returns an Endpoint object that represents the
|
|
263
|
+
/apps/{app_id}/deployments/current endpoint.
|
|
264
|
+
"""
|
|
265
|
+
return cls('CURRENT_WEBHOOK')
|
|
266
|
+
|
|
267
|
+
@classmethod
|
|
268
|
+
def move_file(cls) -> Endpoint:
|
|
269
|
+
"""
|
|
270
|
+
Returns an Endpoint object that represents the
|
|
271
|
+
/apps/{app_id}/files
|
|
272
|
+
"""
|
|
273
|
+
return cls('MOVE_FILE')
|
|
274
|
+
|
|
275
|
+
@classmethod
|
|
276
|
+
def dns_records(cls) -> Endpoint:
|
|
277
|
+
"""
|
|
278
|
+
Returns an Endpoint object that represents the
|
|
279
|
+
/apps/{app_id}/network/dns
|
|
280
|
+
"""
|
|
281
|
+
return cls('DNSRECORDS')
|
|
282
|
+
|
|
244
283
|
|
|
245
284
|
# pylint: disable=too-few-public-methods
|
|
246
285
|
class Router:
|
|
@@ -164,7 +164,7 @@ class HTTPClient:
|
|
|
164
164
|
"""
|
|
165
165
|
headers = {
|
|
166
166
|
'Authorization': self.api_key,
|
|
167
|
-
'User-Agent': 'squarecloud-api/3.
|
|
167
|
+
'User-Agent': 'squarecloud-api/3.6.0',
|
|
168
168
|
}
|
|
169
169
|
extra_error_kwargs: dict[str, Any] = {}
|
|
170
170
|
|
|
@@ -647,6 +647,31 @@ class HTTPClient:
|
|
|
647
647
|
response: Response = await self.request(route)
|
|
648
648
|
return response
|
|
649
649
|
|
|
650
|
+
async def get_all_app_backups(self, app_id: str) -> Response:
|
|
651
|
+
"""
|
|
652
|
+
Returns a list of all backups of the specified application
|
|
653
|
+
:return:
|
|
654
|
+
"""
|
|
655
|
+
route: Router = Router(Endpoint.all_backups(), app_id=app_id)
|
|
656
|
+
response: Response = await self.request(route)
|
|
657
|
+
return response
|
|
658
|
+
|
|
659
|
+
async def all_apps_status(self) -> Response:
|
|
660
|
+
route: Router = Router(Endpoint.all_apps_status())
|
|
661
|
+
response: Response = await self.request(route)
|
|
662
|
+
return response
|
|
663
|
+
|
|
664
|
+
async def move_app_file(self, app_id: str, origin: str, dest: str):
|
|
665
|
+
route: Router = Router(Endpoint.move_file(), app_id=app_id)
|
|
666
|
+
body = {'path': origin, 'to': dest}
|
|
667
|
+
response: Response = await self.request(route, json=body)
|
|
668
|
+
return response
|
|
669
|
+
|
|
670
|
+
async def dns_records(self, app_id: str) -> Response:
|
|
671
|
+
route: Router = Router(Endpoint.dns_records(), app_id=app_id)
|
|
672
|
+
response: Response = await self.request(route)
|
|
673
|
+
return response
|
|
674
|
+
|
|
650
675
|
@property
|
|
651
676
|
def last_response(self) -> Response | None:
|
|
652
677
|
"""
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
from functools import wraps
|
|
3
|
-
|
|
4
|
-
import click
|
|
5
|
-
|
|
6
|
-
from squarecloud import __version__
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def run_async(func):
|
|
10
|
-
@wraps(func)
|
|
11
|
-
def wrapper(*args, **kwargs):
|
|
12
|
-
return asyncio.run(func(*args, **kwargs))
|
|
13
|
-
|
|
14
|
-
return wrapper
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@click.group()
|
|
18
|
-
@click.version_option(
|
|
19
|
-
__version__, '--version', '-v', prog_name='squarecloud-api'
|
|
20
|
-
)
|
|
21
|
-
def cli():
|
|
22
|
-
pass
|