squarecloud-api 3.6.0__tar.gz → 3.6.2__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.6.0 → squarecloud_api-3.6.2}/LICENSE +19 -19
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/PKG-INFO +4 -5
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/pyproject.toml +8 -6
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/__init__.py +3 -3
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/app.py +5 -4
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/client.py +8 -0
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/data.py +43 -24
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/file.py +61 -61
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/http/__init__.py +2 -2
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/http/endpoints.py +6 -6
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/http/http_client.py +73 -4
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/listeners/__init__.py +6 -4
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/listeners/capture_listener.py +4 -2
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/listeners/request_listener.py +5 -1
- squarecloud_api-3.6.2/squarecloud/teste_foda.py +0 -0
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/README.md +0 -0
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/errors.py +0 -0
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/logging.py +0 -0
- {squarecloud_api-3.6.0 → squarecloud_api-3.6.2}/squarecloud/utils.py +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Robert Nogueira
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
-
the Software without restriction, including without limitation the rights to
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
-
subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Robert Nogueira
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
20
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: squarecloud-api
|
|
3
|
-
Version: 3.6.
|
|
3
|
+
Version: 3.6.2
|
|
4
4
|
Summary: SquareCloud API wrapper
|
|
5
5
|
Home-page: https://github.com/squarecloudofc/wrapper-api-py
|
|
6
6
|
License: MIT
|
|
@@ -13,11 +13,10 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Provides-Extra: pydantic
|
|
16
17
|
Requires-Dist: aiohttp (==3.9.5)
|
|
17
|
-
Requires-Dist:
|
|
18
|
-
Requires-Dist:
|
|
19
|
-
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
|
20
|
-
Requires-Dist: rich (>=13.5.2,<14.0.0)
|
|
18
|
+
Requires-Dist: pydantic (>=2.8.2,<3.0.0) ; extra == "pydantic"
|
|
19
|
+
Requires-Dist: taskipy (>=1.13.0,<2.0.0)
|
|
21
20
|
Project-URL: Documentation, https://docs.squarecloud.app/sdks/py
|
|
22
21
|
Project-URL: Repository, https://github.com/squarecloudofc/wrapper-api-py
|
|
23
22
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = 'squarecloud-api'
|
|
3
|
-
version = '3.6.
|
|
3
|
+
version = '3.6.2'
|
|
4
4
|
description = 'SquareCloud API wrapper'
|
|
5
5
|
authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
|
|
6
6
|
repository = 'https://github.com/squarecloudofc/wrapper-api-py'
|
|
@@ -12,10 +12,11 @@ packages = [{ include = 'squarecloud' }]
|
|
|
12
12
|
[tool.poetry.dependencies]
|
|
13
13
|
python = '^3.9'
|
|
14
14
|
aiohttp = "3.9.5"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
taskipy = "^1.13.0"
|
|
16
|
+
pydantic = {version = "^2.8.2", optional = true}
|
|
17
|
+
|
|
18
|
+
[tool.poetry.extras]
|
|
19
|
+
pydantic = ["pydantic"]
|
|
19
20
|
|
|
20
21
|
[tool.poetry.group.dev.dependencies]
|
|
21
22
|
pytest = '^7.4.3'
|
|
@@ -28,7 +29,8 @@ ruff = '^0.0.289'
|
|
|
28
29
|
memory-profiler = '^0.61.0'
|
|
29
30
|
requests = '^2.31.0'
|
|
30
31
|
pytest-rerunfailures = "^13.0"
|
|
31
|
-
|
|
32
|
+
python-dotenv = "^1.0.1"
|
|
33
|
+
rich = "^13.7.1"
|
|
32
34
|
|
|
33
35
|
[build-system]
|
|
34
36
|
requires = ['poetry-core']
|
|
@@ -8,17 +8,17 @@ from .data import (
|
|
|
8
8
|
Backup,
|
|
9
9
|
BackupInfo,
|
|
10
10
|
DeployData,
|
|
11
|
+
DNSRecord,
|
|
11
12
|
DomainAnalytics,
|
|
12
13
|
FileInfo,
|
|
13
14
|
LogsData,
|
|
14
15
|
PlanData,
|
|
16
|
+
ResumedStatus,
|
|
15
17
|
StatusData,
|
|
16
18
|
UploadData,
|
|
17
19
|
UserData,
|
|
18
|
-
ResumedStatus,
|
|
19
|
-
DNSRecord,
|
|
20
20
|
)
|
|
21
21
|
from .file import File
|
|
22
22
|
from .http.endpoints import Endpoint
|
|
23
23
|
|
|
24
|
-
__version__ = '3.6.
|
|
24
|
+
__version__ = '3.6.2'
|
|
@@ -4,8 +4,6 @@ from functools import wraps
|
|
|
4
4
|
from io import BytesIO
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Callable
|
|
6
6
|
|
|
7
|
-
from pydantic import PositiveInt
|
|
8
|
-
|
|
9
7
|
from squarecloud import errors
|
|
10
8
|
|
|
11
9
|
from .data import (
|
|
@@ -170,7 +168,7 @@ class Application(CaptureListenerManager):
|
|
|
170
168
|
http: HTTPClient,
|
|
171
169
|
id: str,
|
|
172
170
|
name: str,
|
|
173
|
-
ram:
|
|
171
|
+
ram: int,
|
|
174
172
|
lang: str,
|
|
175
173
|
cluster: str,
|
|
176
174
|
domain: str | None,
|
|
@@ -203,7 +201,7 @@ class Application(CaptureListenerManager):
|
|
|
203
201
|
self._domain: str | None = domain
|
|
204
202
|
self._custom: str | None = custom
|
|
205
203
|
self._desc: str | None = desc
|
|
206
|
-
self._ram:
|
|
204
|
+
self._ram: int = ram
|
|
207
205
|
self._lang: str = lang
|
|
208
206
|
self._cluster: str = cluster
|
|
209
207
|
self._client: 'Client' = client
|
|
@@ -657,6 +655,9 @@ class Application(CaptureListenerManager):
|
|
|
657
655
|
async def move_file(self, origin: str, dest: str):
|
|
658
656
|
return await self.client.move_app_file(self.id, origin, dest)
|
|
659
657
|
|
|
658
|
+
async def current_integration(self):
|
|
659
|
+
return await self.client.current_app_integration(self.id)
|
|
660
|
+
|
|
660
661
|
@_notify_listener(Endpoint.dns_records())
|
|
661
662
|
async def dns_records(self) -> list[DNSRecord]:
|
|
662
663
|
return await self.client.dns_records(self.id)
|
|
@@ -739,6 +739,7 @@ class Client(RequestListenerManager):
|
|
|
739
739
|
response: Response = await self._http.domain_analytics(
|
|
740
740
|
app_id=app_id,
|
|
741
741
|
)
|
|
742
|
+
|
|
742
743
|
return DomainAnalytics(**response.response)
|
|
743
744
|
|
|
744
745
|
@_notify_listener(Endpoint.all_backups())
|
|
@@ -772,3 +773,10 @@ class Client(RequestListenerManager):
|
|
|
772
773
|
async def dns_records(self, app_id: str) -> list[DNSRecord]:
|
|
773
774
|
response: Response = await self._http.dns_records(app_id)
|
|
774
775
|
return [DNSRecord(**data) for data in response.response]
|
|
776
|
+
|
|
777
|
+
@_notify_listener(Endpoint.current_integration())
|
|
778
|
+
async def current_app_integration(self, app_id: str) -> str | None:
|
|
779
|
+
response: Response = await self._http.get_app_current_integration(
|
|
780
|
+
app_id
|
|
781
|
+
)
|
|
782
|
+
return response.response['webhook']
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
|
+
from importlib.util import find_spec
|
|
4
5
|
from typing import Any, Dict, Literal, Optional
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
from pydantic.dataclasses import dataclass
|
|
7
|
+
if find_spec('pydantic'):
|
|
8
|
+
from pydantic.dataclasses import dataclass
|
|
9
|
+
else:
|
|
10
|
+
from dataclasses import dataclass
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
@dataclass(frozen=True)
|
|
@@ -67,9 +70,9 @@ class StatusData:
|
|
|
67
70
|
running: bool
|
|
68
71
|
storage: str
|
|
69
72
|
network: Dict[str, Any]
|
|
70
|
-
requests:
|
|
71
|
-
uptime:
|
|
72
|
-
time:
|
|
73
|
+
requests: int
|
|
74
|
+
uptime: int | None = None
|
|
75
|
+
time: int | None = None
|
|
73
76
|
|
|
74
77
|
def to_dict(self):
|
|
75
78
|
return self.__dict__.copy()
|
|
@@ -107,7 +110,7 @@ class AppData:
|
|
|
107
110
|
id: str
|
|
108
111
|
name: str
|
|
109
112
|
cluster: str
|
|
110
|
-
ram:
|
|
113
|
+
ram: float
|
|
111
114
|
language: Optional[str]
|
|
112
115
|
cluster: str
|
|
113
116
|
domain: str | None = None
|
|
@@ -128,13 +131,13 @@ class UserData:
|
|
|
128
131
|
:ivar plan: User plan
|
|
129
132
|
:ivar email: User email
|
|
130
133
|
|
|
131
|
-
:type id:
|
|
134
|
+
:type id: int
|
|
132
135
|
:type name: str
|
|
133
136
|
:type plan: PlanData
|
|
134
137
|
:type email: str | None = None
|
|
135
138
|
"""
|
|
136
139
|
|
|
137
|
-
id:
|
|
140
|
+
id: int
|
|
138
141
|
name: str
|
|
139
142
|
plan: PlanData
|
|
140
143
|
email: str | None = None
|
|
@@ -253,9 +256,9 @@ class UploadData:
|
|
|
253
256
|
id: str
|
|
254
257
|
name: str
|
|
255
258
|
language: Language
|
|
256
|
-
ram:
|
|
257
|
-
cpu:
|
|
258
|
-
|
|
259
|
+
ram: float
|
|
260
|
+
cpu: float
|
|
261
|
+
domain: str | None = None
|
|
259
262
|
description: str | None = None
|
|
260
263
|
|
|
261
264
|
def to_dict(self):
|
|
@@ -283,9 +286,9 @@ class FileInfo:
|
|
|
283
286
|
app_id: str
|
|
284
287
|
type: Literal['file', 'directory']
|
|
285
288
|
name: str
|
|
286
|
-
lastModified:
|
|
289
|
+
lastModified: int | float
|
|
287
290
|
path: str
|
|
288
|
-
size:
|
|
291
|
+
size: int = 0
|
|
289
292
|
|
|
290
293
|
def to_dict(self):
|
|
291
294
|
return self.__dict__.copy()
|
|
@@ -310,17 +313,33 @@ class AnalyticsTotal:
|
|
|
310
313
|
|
|
311
314
|
@dataclass(frozen=True)
|
|
312
315
|
class DomainAnalytics:
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
316
|
+
@dataclass(frozen=True)
|
|
317
|
+
class Analytics:
|
|
318
|
+
total: list[AnalyticsTotal]
|
|
319
|
+
countries: list[Any]
|
|
320
|
+
methods: list[Any]
|
|
321
|
+
referers: list[Any]
|
|
322
|
+
browsers: list[Any]
|
|
323
|
+
deviceTypes: list[Any]
|
|
324
|
+
operatingSystems: list[Any]
|
|
325
|
+
agents: list[Any]
|
|
326
|
+
hosts: list[Any]
|
|
327
|
+
paths: list[Any]
|
|
328
|
+
|
|
329
|
+
def to_dict(self):
|
|
330
|
+
return self.__dict__.copy()
|
|
331
|
+
|
|
332
|
+
@dataclass(frozen=True)
|
|
333
|
+
class Domain:
|
|
334
|
+
hostname: str
|
|
335
|
+
analytics: DomainAnalytics.Analytics | None
|
|
336
|
+
|
|
337
|
+
@dataclass(frozen=True)
|
|
338
|
+
class Custom:
|
|
339
|
+
analytics: DomainAnalytics.Analytics | None
|
|
340
|
+
|
|
341
|
+
domain: Domain
|
|
342
|
+
custom: Custom
|
|
324
343
|
|
|
325
344
|
def to_dict(self):
|
|
326
345
|
return self.__dict__.copy()
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import io
|
|
4
|
-
import os
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
from squarecloud import errors
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class File:
|
|
11
|
-
"""
|
|
12
|
-
File object
|
|
13
|
-
|
|
14
|
-
You can use a file already opened or pass the file path.
|
|
15
|
-
NOTE: To pass binary data, consider usage of `io.BytesIO`.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
__slots__ = ('bytes', 'filename')
|
|
19
|
-
|
|
20
|
-
def __init__(
|
|
21
|
-
self,
|
|
22
|
-
fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase,
|
|
23
|
-
filename: str | None = None,
|
|
24
|
-
):
|
|
25
|
-
|
|
26
|
-
"""
|
|
27
|
-
The __init__ function is called when the class is instantiated.
|
|
28
|
-
It sets up the instance of the class, and it's where you put all your
|
|
29
|
-
initialization code.
|
|
30
|
-
The __init__ function takes at least one argument: self, which refers
|
|
31
|
-
to the object being created.
|
|
32
|
-
|
|
33
|
-
:param self: Refer to the class instance
|
|
34
|
-
:param fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase: Define
|
|
35
|
-
the file path,
|
|
36
|
-
:param filename: str | None: Set the filename attribute of the class
|
|
37
|
-
:return: None
|
|
38
|
-
"""
|
|
39
|
-
if isinstance(fp, io.BufferedIOBase):
|
|
40
|
-
if not (fp.seekable() and fp.readable()):
|
|
41
|
-
raise ValueError(
|
|
42
|
-
f'File buffer {fp!r} must be seekable and readable'
|
|
43
|
-
)
|
|
44
|
-
self.bytes: io.BufferedIOBase = fp
|
|
45
|
-
else:
|
|
46
|
-
# Verificar se fp é bytes (dados binários) e criar um io.BytesIO
|
|
47
|
-
if isinstance(fp, bytes):
|
|
48
|
-
self.bytes = io.BytesIO(fp)
|
|
49
|
-
else:
|
|
50
|
-
self.bytes = open(fp, 'rb')
|
|
51
|
-
|
|
52
|
-
if filename is None:
|
|
53
|
-
if isinstance(fp, str):
|
|
54
|
-
_, filename = os.path.split(fp)
|
|
55
|
-
else:
|
|
56
|
-
filename = getattr(fp, 'name', None)
|
|
57
|
-
|
|
58
|
-
if not filename:
|
|
59
|
-
raise errors.SquareException('You need provide a filename')
|
|
60
|
-
|
|
61
|
-
self.filename: str | None = filename
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import io
|
|
4
|
+
import os
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from squarecloud import errors
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class File:
|
|
11
|
+
"""
|
|
12
|
+
File object
|
|
13
|
+
|
|
14
|
+
You can use a file already opened or pass the file path.
|
|
15
|
+
NOTE: To pass binary data, consider usage of `io.BytesIO`.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
__slots__ = ('bytes', 'filename')
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase,
|
|
23
|
+
filename: str | None = None,
|
|
24
|
+
):
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
The __init__ function is called when the class is instantiated.
|
|
28
|
+
It sets up the instance of the class, and it's where you put all your
|
|
29
|
+
initialization code.
|
|
30
|
+
The __init__ function takes at least one argument: self, which refers
|
|
31
|
+
to the object being created.
|
|
32
|
+
|
|
33
|
+
:param self: Refer to the class instance
|
|
34
|
+
:param fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase: Define
|
|
35
|
+
the file path,
|
|
36
|
+
:param filename: str | None: Set the filename attribute of the class
|
|
37
|
+
:return: None
|
|
38
|
+
"""
|
|
39
|
+
if isinstance(fp, io.BufferedIOBase):
|
|
40
|
+
if not (fp.seekable() and fp.readable()):
|
|
41
|
+
raise ValueError(
|
|
42
|
+
f'File buffer {fp!r} must be seekable and readable'
|
|
43
|
+
)
|
|
44
|
+
self.bytes: io.BufferedIOBase = fp
|
|
45
|
+
else:
|
|
46
|
+
# Verificar se fp é bytes (dados binários) e criar um io.BytesIO
|
|
47
|
+
if isinstance(fp, bytes):
|
|
48
|
+
self.bytes = io.BytesIO(fp)
|
|
49
|
+
else:
|
|
50
|
+
self.bytes = open(fp, 'rb')
|
|
51
|
+
|
|
52
|
+
if filename is None:
|
|
53
|
+
if isinstance(fp, str):
|
|
54
|
+
_, filename = os.path.split(fp)
|
|
55
|
+
else:
|
|
56
|
+
filename = getattr(fp, 'name', None)
|
|
57
|
+
|
|
58
|
+
if not filename:
|
|
59
|
+
raise errors.SquareException('You need provide a filename')
|
|
60
|
+
|
|
61
|
+
self.filename: str | None = filename
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
from .endpoints import Endpoint
|
|
2
|
-
from .http_client import HTTPClient, Response
|
|
1
|
+
from .endpoints import Endpoint
|
|
2
|
+
from .http_client import HTTPClient, Response
|
|
@@ -20,11 +20,11 @@ class Endpoint:
|
|
|
20
20
|
'UPLOAD_APP': {'METHOD': 'POST', 'PATH': '/apps'},
|
|
21
21
|
'FILES_LIST': {
|
|
22
22
|
'METHOD': 'GET',
|
|
23
|
-
'PATH': '/apps/{app_id}/files
|
|
23
|
+
'PATH': '/apps/{app_id}/files?path={path}',
|
|
24
24
|
},
|
|
25
25
|
'FILES_READ': {
|
|
26
26
|
'METHOD': 'GET',
|
|
27
|
-
'PATH': '/apps/{app_id}/files/
|
|
27
|
+
'PATH': '/apps/{app_id}/files/content?path={path}',
|
|
28
28
|
},
|
|
29
29
|
'FILES_CREATE': {
|
|
30
30
|
'METHOD': 'PUT',
|
|
@@ -32,14 +32,14 @@ class Endpoint:
|
|
|
32
32
|
},
|
|
33
33
|
'FILES_DELETE': {
|
|
34
34
|
'METHOD': 'DELETE',
|
|
35
|
-
'PATH': '/apps/{app_id}/files
|
|
35
|
+
'PATH': '/apps/{app_id}/files',
|
|
36
36
|
},
|
|
37
37
|
'MOVE_FILE': {'METHOD': 'PATCH', 'PATH': '/apps/{app_id}/files'},
|
|
38
38
|
'LAST_DEPLOYS': {
|
|
39
39
|
'METHOD': 'GET',
|
|
40
40
|
'PATH': '/apps/{app_id}/deployments',
|
|
41
41
|
},
|
|
42
|
-
'
|
|
42
|
+
'CURRENT_INTEGRATION': {
|
|
43
43
|
'METHOD': 'GET',
|
|
44
44
|
'PATH': '/apps/{app_id}/deployments/current',
|
|
45
45
|
},
|
|
@@ -257,12 +257,12 @@ class Endpoint:
|
|
|
257
257
|
return cls('ALL_APPS_STATUS')
|
|
258
258
|
|
|
259
259
|
@classmethod
|
|
260
|
-
def
|
|
260
|
+
def current_integration(cls) -> Endpoint:
|
|
261
261
|
"""
|
|
262
262
|
Returns an Endpoint object that represents the
|
|
263
263
|
/apps/{app_id}/deployments/current endpoint.
|
|
264
264
|
"""
|
|
265
|
-
return cls('
|
|
265
|
+
return cls('CURRENT_INTEGRATION')
|
|
266
266
|
|
|
267
267
|
@classmethod
|
|
268
268
|
def move_file(cls) -> Endpoint:
|
|
@@ -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.5.1',
|
|
168
168
|
}
|
|
169
169
|
extra_error_kwargs: dict[str, Any] = {}
|
|
170
170
|
|
|
@@ -528,9 +528,11 @@ class HTTPClient:
|
|
|
528
528
|
code is 429
|
|
529
529
|
"""
|
|
530
530
|
route: Router = Router(
|
|
531
|
-
Endpoint.files_delete(),
|
|
531
|
+
Endpoint.files_delete(),
|
|
532
|
+
app_id=app_id,
|
|
532
533
|
)
|
|
533
|
-
|
|
534
|
+
body = {'path': path}
|
|
535
|
+
response: Response = await self.request(route, json=body)
|
|
534
536
|
return response
|
|
535
537
|
|
|
536
538
|
async def get_app_data(self, app_id: str) -> Response:
|
|
@@ -635,6 +637,7 @@ class HTTPClient:
|
|
|
635
637
|
|
|
636
638
|
:param app_id: The application id
|
|
637
639
|
:return: A Response object
|
|
640
|
+
:rtype: Response
|
|
638
641
|
|
|
639
642
|
:raises NotFoundError: Raised when the request status code is 404
|
|
640
643
|
:raises BadRequestError: Raised when the request status code is 400
|
|
@@ -650,28 +653,94 @@ class HTTPClient:
|
|
|
650
653
|
async def get_all_app_backups(self, app_id: str) -> Response:
|
|
651
654
|
"""
|
|
652
655
|
Returns a list of all backups of the specified application
|
|
653
|
-
|
|
656
|
+
|
|
657
|
+
:return: A Response object
|
|
658
|
+
:rtype: Response
|
|
659
|
+
|
|
660
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
661
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
662
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
663
|
+
code is 401
|
|
664
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
665
|
+
code is 429
|
|
654
666
|
"""
|
|
655
667
|
route: Router = Router(Endpoint.all_backups(), app_id=app_id)
|
|
656
668
|
response: Response = await self.request(route)
|
|
657
669
|
return response
|
|
658
670
|
|
|
659
671
|
async def all_apps_status(self) -> Response:
|
|
672
|
+
"""
|
|
673
|
+
Returns all applications status
|
|
674
|
+
|
|
675
|
+
:return: A Response object
|
|
676
|
+
:rtype: Response
|
|
677
|
+
|
|
678
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
679
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
680
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
681
|
+
code is 401
|
|
682
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
683
|
+
code is 429
|
|
684
|
+
"""
|
|
660
685
|
route: Router = Router(Endpoint.all_apps_status())
|
|
661
686
|
response: Response = await self.request(route)
|
|
662
687
|
return response
|
|
663
688
|
|
|
664
689
|
async def move_app_file(self, app_id: str, origin: str, dest: str):
|
|
690
|
+
"""
|
|
691
|
+
Make a http request to move an app file.
|
|
692
|
+
|
|
693
|
+
:return: A Response object
|
|
694
|
+
:rtype: Response
|
|
695
|
+
|
|
696
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
697
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
698
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
699
|
+
code is 401
|
|
700
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
701
|
+
code is 429
|
|
702
|
+
"""
|
|
665
703
|
route: Router = Router(Endpoint.move_file(), app_id=app_id)
|
|
666
704
|
body = {'path': origin, 'to': dest}
|
|
667
705
|
response: Response = await self.request(route, json=body)
|
|
668
706
|
return response
|
|
669
707
|
|
|
670
708
|
async def dns_records(self, app_id: str) -> Response:
|
|
709
|
+
"""
|
|
710
|
+
Returns dns information of the specified application
|
|
711
|
+
|
|
712
|
+
:return: A Response object
|
|
713
|
+
:rtype: Response
|
|
714
|
+
|
|
715
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
716
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
717
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
718
|
+
code is 401
|
|
719
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
720
|
+
code is 429
|
|
721
|
+
"""
|
|
671
722
|
route: Router = Router(Endpoint.dns_records(), app_id=app_id)
|
|
672
723
|
response: Response = await self.request(route)
|
|
673
724
|
return response
|
|
674
725
|
|
|
726
|
+
async def get_app_current_integration(self, app_id: str) -> Response:
|
|
727
|
+
"""
|
|
728
|
+
Returns the webhook url of the application current integration
|
|
729
|
+
|
|
730
|
+
:return: A Response object
|
|
731
|
+
:rtype: Response
|
|
732
|
+
|
|
733
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
734
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
735
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
736
|
+
code is 401
|
|
737
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
738
|
+
code is 429
|
|
739
|
+
"""
|
|
740
|
+
route: Router = Router(Endpoint.current_integration(), app_id=app_id)
|
|
741
|
+
response: Response = await self.request(route)
|
|
742
|
+
return response
|
|
743
|
+
|
|
675
744
|
@property
|
|
676
745
|
def last_response(self) -> Response | None:
|
|
677
746
|
"""
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import types
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
+
from importlib.util import find_spec
|
|
4
5
|
from types import MappingProxyType
|
|
5
6
|
from typing import TYPE_CHECKING, Any, Callable, Optional, Type, Union
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
if find_spec('pydantic'):
|
|
9
|
+
import pydantic
|
|
10
|
+
from pydantic import BaseModel
|
|
9
11
|
|
|
10
12
|
from .. import data, errors
|
|
11
13
|
from ..http.endpoints import Endpoint
|
|
@@ -137,9 +139,9 @@ class ListenerManager:
|
|
|
137
139
|
|
|
138
140
|
@classmethod
|
|
139
141
|
def cast_to_pydantic_model(
|
|
140
|
-
cls, model: Type[BaseModel], values: dict[Any, Any]
|
|
142
|
+
cls, model: Type['BaseModel'], values: dict[Any, Any]
|
|
141
143
|
):
|
|
142
|
-
result: BaseModel | None | dict = values
|
|
144
|
+
result: 'BaseModel' | None | dict = values
|
|
143
145
|
if isinstance(model, types.UnionType):
|
|
144
146
|
for ty in model.__args__:
|
|
145
147
|
if ty is None:
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import logging
|
|
3
3
|
import types
|
|
4
|
+
from importlib.util import find_spec
|
|
4
5
|
from typing import Any, Union
|
|
5
6
|
|
|
6
|
-
import pydantic
|
|
7
|
-
|
|
8
7
|
from .. import data, errors
|
|
9
8
|
from ..http import Endpoint
|
|
10
9
|
from . import Listener, ListenerManager
|
|
11
10
|
|
|
11
|
+
if find_spec('pydantic'):
|
|
12
|
+
import pydantic
|
|
13
|
+
|
|
12
14
|
ListenerDataTypes = Union[
|
|
13
15
|
data.AppData,
|
|
14
16
|
data.StatusData,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import inspect
|
|
2
2
|
import logging
|
|
3
3
|
import types
|
|
4
|
+
from importlib.util import find_spec
|
|
4
5
|
from typing import Any
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
if using_pydantic := find_spec('pydantic'):
|
|
8
|
+
import pydantic
|
|
7
9
|
|
|
8
10
|
from ..http import Endpoint, Response
|
|
9
11
|
from . import ListenerManager
|
|
@@ -37,6 +39,7 @@ class RequestListenerManager(ListenerManager):
|
|
|
37
39
|
:param response: Response: Get the response from the endpoint
|
|
38
40
|
:return: The result of the call function
|
|
39
41
|
"""
|
|
42
|
+
global using_pydantic
|
|
40
43
|
|
|
41
44
|
def filter_annotations(annotations: list[Any]) -> Any:
|
|
42
45
|
for item in annotations:
|
|
@@ -62,6 +65,7 @@ class RequestListenerManager(ListenerManager):
|
|
|
62
65
|
call_extra_param is not None
|
|
63
66
|
and annotation is not None
|
|
64
67
|
and annotation != call_extra_param.empty
|
|
68
|
+
and using_pydantic
|
|
65
69
|
):
|
|
66
70
|
annotation: Any = call_extra_param.annotation
|
|
67
71
|
cast_result = self.cast_to_pydantic_model(annotation, extra)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|