squarecloud-api 3.4.0__tar.gz → 3.5.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.4.0 → squarecloud_api-3.5.0}/PKG-INFO +1 -1
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/pyproject.toml +3 -2
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/__init__.py +3 -2
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/app.py +35 -22
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/cli/app.py +2 -3
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/cli/main.py +2 -4
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/client.py +10 -5
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/data.py +9 -14
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/http/endpoints.py +0 -15
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/http/http_client.py +1 -1
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/listeners/__init__.py +0 -16
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/listeners/capture_listener.py +1 -2
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/LICENSE +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/README.md +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/cli/__init__.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/cli/files.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/errors.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/file.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/http/__init__.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/listeners/request_listener.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.0}/squarecloud/logging.py +0 -0
- {squarecloud_api-3.4.0 → squarecloud_api-3.5.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.5.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'
|
|
@@ -66,9 +66,10 @@ cli = 'python -m squarecloud.cli.main'
|
|
|
66
66
|
publish-test = 'poetry publish -r pypi-test --build'
|
|
67
67
|
install-test = 'pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple --upgrade squarecloud-api'
|
|
68
68
|
docs = 'mkdocs serve'
|
|
69
|
+
clear-test-apps = 'python -m scripts.clear_test_apps'
|
|
69
70
|
|
|
70
71
|
[tool.poetry.scripts]
|
|
71
|
-
|
|
72
|
+
squarecloud = 'squarecloud.cli.main:safe_entry_point'
|
|
72
73
|
|
|
73
74
|
[tool.ruff]
|
|
74
75
|
line-length = 79
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from . import errors, utils
|
|
4
|
-
from .
|
|
4
|
+
from .app import Application
|
|
5
|
+
from .client import Client
|
|
5
6
|
from .data import (
|
|
6
7
|
AppData,
|
|
7
8
|
BackupData,
|
|
@@ -15,4 +16,4 @@ from .data import (
|
|
|
15
16
|
from .file import File
|
|
16
17
|
from .http.endpoints import Endpoint
|
|
17
18
|
|
|
18
|
-
__version__ = '3.
|
|
19
|
+
__version__ = '3.5.0'
|
|
@@ -152,12 +152,13 @@ class Application(CaptureListenerManager):
|
|
|
152
152
|
'_data',
|
|
153
153
|
'cache',
|
|
154
154
|
'_id',
|
|
155
|
-
'
|
|
155
|
+
'_name',
|
|
156
156
|
'_desc',
|
|
157
|
+
'_domain',
|
|
158
|
+
'_custom',
|
|
157
159
|
'_ram',
|
|
158
160
|
'_lang',
|
|
159
161
|
'_cluster',
|
|
160
|
-
'_isWebsite',
|
|
161
162
|
'always_avoid_listeners',
|
|
162
163
|
]
|
|
163
164
|
|
|
@@ -166,11 +167,12 @@ class Application(CaptureListenerManager):
|
|
|
166
167
|
client: 'Client',
|
|
167
168
|
http: HTTPClient,
|
|
168
169
|
id: str,
|
|
169
|
-
|
|
170
|
+
name: str,
|
|
170
171
|
ram: PositiveInt,
|
|
171
172
|
lang: str,
|
|
172
173
|
cluster: str,
|
|
173
|
-
|
|
174
|
+
domain: str | None,
|
|
175
|
+
custom: str | None,
|
|
174
176
|
desc: str | None = None,
|
|
175
177
|
) -> None:
|
|
176
178
|
"""
|
|
@@ -184,22 +186,24 @@ class Application(CaptureListenerManager):
|
|
|
184
186
|
this app.
|
|
185
187
|
:param http: Store a reference to the HTTPClient
|
|
186
188
|
:param id: The application id
|
|
187
|
-
:param
|
|
189
|
+
:param name: The tag of the app
|
|
188
190
|
:param ram: The amount of ram that is allocated
|
|
189
191
|
:param lang: The programming language of the app
|
|
190
192
|
:param cluster: The cluster that the app is hosted on
|
|
191
|
-
:param isWebsite: Whether if the app is a website
|
|
192
193
|
:param desc: Define the description of the app
|
|
194
|
+
:param domain: Define the domain of the app
|
|
195
|
+
:param custom: Define the custom domain of the app
|
|
193
196
|
|
|
194
197
|
:return: None
|
|
195
198
|
"""
|
|
196
199
|
self._id: str = id
|
|
197
|
-
self.
|
|
200
|
+
self._name: str = name
|
|
201
|
+
self._domain: str | None = domain
|
|
202
|
+
self._custom: str | None = custom
|
|
198
203
|
self._desc: str | None = desc
|
|
199
204
|
self._ram: PositiveInt = ram
|
|
200
205
|
self._lang: str = lang
|
|
201
206
|
self._cluster: str = cluster
|
|
202
|
-
self._isWebsite: bool = isWebsite
|
|
203
207
|
self._client: 'Client' = client
|
|
204
208
|
self._http: HTTPClient = http
|
|
205
209
|
self._listener: CaptureListenerManager = CaptureListenerManager()
|
|
@@ -243,14 +247,14 @@ class Application(CaptureListenerManager):
|
|
|
243
247
|
return self._id
|
|
244
248
|
|
|
245
249
|
@property
|
|
246
|
-
def
|
|
250
|
+
def name(self) -> str:
|
|
247
251
|
"""
|
|
248
252
|
The tag function is a property that returns the application tag.
|
|
249
253
|
|
|
250
254
|
:return: The tag of the application
|
|
251
255
|
:rtype: str
|
|
252
256
|
"""
|
|
253
|
-
return self.
|
|
257
|
+
return self._name
|
|
254
258
|
|
|
255
259
|
@property
|
|
256
260
|
def desc(self) -> str | None:
|
|
@@ -275,9 +279,7 @@ class Application(CaptureListenerManager):
|
|
|
275
279
|
return self._ram
|
|
276
280
|
|
|
277
281
|
@property
|
|
278
|
-
def lang(
|
|
279
|
-
self,
|
|
280
|
-
) -> str:
|
|
282
|
+
def lang(self) -> str:
|
|
281
283
|
"""
|
|
282
284
|
The lang function is a property that returns the application's
|
|
283
285
|
programing language.
|
|
@@ -288,9 +290,7 @@ class Application(CaptureListenerManager):
|
|
|
288
290
|
return self._lang
|
|
289
291
|
|
|
290
292
|
@property
|
|
291
|
-
def cluster(
|
|
292
|
-
self,
|
|
293
|
-
) -> str:
|
|
293
|
+
def cluster(self) -> str:
|
|
294
294
|
"""
|
|
295
295
|
The cluster function is a property that returns the
|
|
296
296
|
cluster that the application is
|
|
@@ -303,15 +303,28 @@ class Application(CaptureListenerManager):
|
|
|
303
303
|
return self._cluster
|
|
304
304
|
|
|
305
305
|
@property
|
|
306
|
-
def
|
|
306
|
+
def domain(self) -> str | None:
|
|
307
|
+
"""
|
|
308
|
+
The domain function is a property that returns the
|
|
309
|
+
application's domain.
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
:return: The application's domain
|
|
313
|
+
:rtype: str | None
|
|
307
314
|
"""
|
|
308
|
-
|
|
309
|
-
indicating whether th application is a website.
|
|
315
|
+
return self._domain
|
|
310
316
|
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
@property
|
|
318
|
+
def custom(self) -> str | None:
|
|
319
|
+
"""
|
|
320
|
+
The custom function is a property that returns the
|
|
321
|
+
application's custom domain.
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
:return: The application's domain
|
|
325
|
+
:rtype: str | None
|
|
313
326
|
"""
|
|
314
|
-
return self.
|
|
327
|
+
return self._custom
|
|
315
328
|
|
|
316
329
|
@staticmethod
|
|
317
330
|
def _notify_listener(endpoint: Endpoint):
|
|
@@ -53,12 +53,11 @@ async def app_group(ctx: Context, app_id: str, token: str):
|
|
|
53
53
|
with Console().status('loading'):
|
|
54
54
|
app = await client.app(app_id)
|
|
55
55
|
table = Table(title=app.tag, header_style='purple')
|
|
56
|
-
table.add_column('
|
|
56
|
+
table.add_column('Name', justify='center')
|
|
57
57
|
table.add_column('ID', justify='center')
|
|
58
58
|
table.add_column('RAM', justify='center')
|
|
59
59
|
table.add_column('Language', justify='center')
|
|
60
60
|
table.add_column('Description', justify='center')
|
|
61
|
-
table.add_column('Is Website', justify='center')
|
|
62
61
|
table.add_column('Cluster', justify='center')
|
|
63
62
|
|
|
64
63
|
table.add_row(
|
|
@@ -128,7 +127,7 @@ async def app_list(ctx: Context, token: str):
|
|
|
128
127
|
return
|
|
129
128
|
table = Table(title='App List', header_style='purple')
|
|
130
129
|
|
|
131
|
-
table.add_column('
|
|
130
|
+
table.add_column('Name', justify='center')
|
|
132
131
|
table.add_column('ID', justify='center')
|
|
133
132
|
table.add_column('RAM', justify='center')
|
|
134
133
|
table.add_column('Language', justify='center')
|
|
@@ -127,13 +127,11 @@ def create_config(
|
|
|
127
127
|
default='Y',
|
|
128
128
|
)
|
|
129
129
|
if r:
|
|
130
|
-
path = prompt(
|
|
131
|
-
'where do you want to save the file', default='squarecloud.app'
|
|
132
|
-
)
|
|
130
|
+
path = prompt('where do you want to save the file', default='.')
|
|
133
131
|
config_file.save(path)
|
|
134
132
|
print(
|
|
135
133
|
Panel(
|
|
136
|
-
f'\u2728 file saved successfully at {path}',
|
|
134
|
+
f'\u2728 file saved successfully at {path}/squarecloud.app',
|
|
137
135
|
border_style='green',
|
|
138
136
|
style='green',
|
|
139
137
|
)
|
|
@@ -8,7 +8,7 @@ from typing import Any, Callable, Literal, TextIO
|
|
|
8
8
|
from typing_extensions import deprecated
|
|
9
9
|
|
|
10
10
|
from .app import Application
|
|
11
|
-
from .data import (
|
|
11
|
+
from .data import (
|
|
12
12
|
AppData,
|
|
13
13
|
BackupData,
|
|
14
14
|
DeployData,
|
|
@@ -412,6 +412,9 @@ class Client(RequestListenerManager):
|
|
|
412
412
|
if not app_data:
|
|
413
413
|
raise ApplicationNotFound(app_id=app_id)
|
|
414
414
|
app_data = app_data.pop()
|
|
415
|
+
app_data['language'] = app_data.pop('lang')
|
|
416
|
+
app_data = AppData(**app_data).to_dict()
|
|
417
|
+
app_data['lang'] = app_data.pop('language')
|
|
415
418
|
return Application(client=self, http=self._http, **app_data)
|
|
416
419
|
|
|
417
420
|
@_notify_listener(Endpoint.user())
|
|
@@ -433,10 +436,12 @@ class Client(RequestListenerManager):
|
|
|
433
436
|
response: Response = await self._http.fetch_user_info()
|
|
434
437
|
payload = response.response
|
|
435
438
|
apps_data: list = payload['applications']
|
|
436
|
-
apps: list[Application] = [
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
439
|
+
apps: list[Application] = []
|
|
440
|
+
for data in apps_data:
|
|
441
|
+
data['language'] = data.pop('lang')
|
|
442
|
+
data = AppData(**data).to_dict()
|
|
443
|
+
data['lang'] = data.pop('language')
|
|
444
|
+
apps.append(Application(client=self, http=self._http, **data))
|
|
440
445
|
return apps
|
|
441
446
|
|
|
442
447
|
@_notify_listener(Endpoint.upload())
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
|
-
from typing import Any, Dict, Literal
|
|
4
|
+
from typing import Any, Dict, Literal, Optional
|
|
5
5
|
|
|
6
6
|
from pydantic import confloat, conint
|
|
7
7
|
from pydantic.dataclasses import dataclass
|
|
@@ -88,15 +88,12 @@ class AppData:
|
|
|
88
88
|
:ivar cluster: The cluster that the app is hosted on
|
|
89
89
|
:ivar ram: The amount of RAM that application is using
|
|
90
90
|
:ivar language The programming language of the app.:
|
|
91
|
-
:ivar isWebsite: Whether if the app is a website
|
|
92
91
|
|
|
93
92
|
:type id: str
|
|
94
93
|
:type name: str
|
|
95
94
|
:type cluster: str
|
|
96
95
|
:type ram: confloat(ge=0);
|
|
97
96
|
:type language: Language
|
|
98
|
-
:type isWebsite: bool
|
|
99
|
-
:type gitIntegration: bool
|
|
100
97
|
:type domain: str | None = None
|
|
101
98
|
:type custom: str | None = None
|
|
102
99
|
:type desc: str | None = None
|
|
@@ -106,10 +103,8 @@ class AppData:
|
|
|
106
103
|
name: str
|
|
107
104
|
cluster: str
|
|
108
105
|
ram: confloat(ge=0)
|
|
109
|
-
language: str
|
|
106
|
+
language: Optional[str]
|
|
110
107
|
cluster: str
|
|
111
|
-
isWebsite: bool
|
|
112
|
-
gitIntegration: bool
|
|
113
108
|
domain: str | None = None
|
|
114
109
|
custom: str | None = None
|
|
115
110
|
desc: str | None = None
|
|
@@ -124,18 +119,18 @@ class UserData:
|
|
|
124
119
|
User data class
|
|
125
120
|
|
|
126
121
|
:ivar id: User ID;
|
|
127
|
-
:ivar
|
|
122
|
+
:ivar name: Username
|
|
128
123
|
:ivar plan: User plan
|
|
129
124
|
:ivar email: User email
|
|
130
125
|
|
|
131
126
|
:type id: conint(ge=0)
|
|
132
|
-
:type
|
|
127
|
+
:type name: str
|
|
133
128
|
:type plan: PlanData
|
|
134
129
|
:type email: str | None = None
|
|
135
130
|
"""
|
|
136
131
|
|
|
137
132
|
id: conint(ge=0)
|
|
138
|
-
|
|
133
|
+
name: str
|
|
139
134
|
plan: PlanData
|
|
140
135
|
email: str | None = None
|
|
141
136
|
|
|
@@ -223,7 +218,7 @@ class UploadData:
|
|
|
223
218
|
Upload data class
|
|
224
219
|
|
|
225
220
|
:ivar id: ID of the uploaded application
|
|
226
|
-
:ivar
|
|
221
|
+
:ivar name: Tag of the uploaded application
|
|
227
222
|
:ivar language: Programming language of the uploaded application
|
|
228
223
|
:ivar ram: Ram allocated for the uploaded application
|
|
229
224
|
:ivar cpu: Cpu of the uploaded application
|
|
@@ -231,7 +226,7 @@ class UploadData:
|
|
|
231
226
|
:ivar subdomain: Subdomain of the uploaded application (only in websites)
|
|
232
227
|
|
|
233
228
|
:type id: str
|
|
234
|
-
:type
|
|
229
|
+
:type name: str
|
|
235
230
|
:type language: Language
|
|
236
231
|
:type ram: confloat(ge=0)
|
|
237
232
|
:type cpu: confloat(ge=0)
|
|
@@ -240,7 +235,7 @@ class UploadData:
|
|
|
240
235
|
"""
|
|
241
236
|
|
|
242
237
|
id: str
|
|
243
|
-
|
|
238
|
+
name: str
|
|
244
239
|
language: Language
|
|
245
240
|
ram: confloat(ge=0)
|
|
246
241
|
cpu: confloat(ge=0)
|
|
@@ -272,9 +267,9 @@ class FileInfo:
|
|
|
272
267
|
app_id: str
|
|
273
268
|
type: Literal['file', 'directory']
|
|
274
269
|
name: str
|
|
275
|
-
size: confloat(ge=0)
|
|
276
270
|
lastModified: conint(ge=0) | float
|
|
277
271
|
path: str
|
|
272
|
+
size: confloat(ge=0.0) = 0.0
|
|
278
273
|
|
|
279
274
|
def to_dict(self):
|
|
280
275
|
return self.__dict__.copy()
|
|
@@ -4,21 +4,6 @@ from __future__ import annotations
|
|
|
4
4
|
class Endpoint:
|
|
5
5
|
"""Endpoint"""
|
|
6
6
|
|
|
7
|
-
# ENDPOINTS_V1 = {
|
|
8
|
-
# 'USER_ME': {'METHOD': 'GET', 'PATH': '/user'},
|
|
9
|
-
# 'USER_INFO': {'METHOD': 'GET', 'PATH': '/user/{user_id}'},
|
|
10
|
-
# 'APP_STATUS': {'METHOD': 'GET', 'PATH': '/status/{app_id}'},
|
|
11
|
-
# 'LOGS': {'METHOD': 'GET', 'PATH': '/logs/{app_id}'},
|
|
12
|
-
# 'FULL_LOGS': {'METHOD': 'GET', 'PATH': '/full-logs/{app_id}'},
|
|
13
|
-
# 'START': {'METHOD': 'POST', 'PATH': '/start/{app_id}'},
|
|
14
|
-
# 'STOP': {'METHOD': 'POST', 'PATH': '/stop/{app_id}'},
|
|
15
|
-
# 'RESTART': {'METHOD': 'POST', 'PATH': '/restart/{app_id}'},
|
|
16
|
-
# 'BACKUP': {'METHOD': 'GET', 'PATH': '/backup/{app_id}'},
|
|
17
|
-
# 'COMMIT': {'METHOD': 'POST', 'PATH': '/commit/{app_id}'},
|
|
18
|
-
# 'DELETE': {'METHOD': 'POST', 'PATH': '/delete/{app_id}'},
|
|
19
|
-
# 'UPLOAD': {'METHOD': 'POST', 'PATH': '/upload'},
|
|
20
|
-
# }
|
|
21
|
-
|
|
22
7
|
ENDPOINTS_V2 = {
|
|
23
8
|
'USER': {'METHOD': 'GET', 'PATH': '/user'},
|
|
24
9
|
'APP_DATA': {'METHOD': 'GET', 'PATH': '/apps/{app_id}'},
|
|
@@ -160,22 +160,6 @@ class ListenerManager:
|
|
|
160
160
|
result = None
|
|
161
161
|
return result
|
|
162
162
|
|
|
163
|
-
# async def notify(
|
|
164
|
-
# self,
|
|
165
|
-
# endpoint: Endpoint,
|
|
166
|
-
# extra: Any = None,
|
|
167
|
-
# **kwargs,
|
|
168
|
-
# ) -> Any | Exception:
|
|
169
|
-
# """
|
|
170
|
-
# The notify method is called when a capture event occurs.
|
|
171
|
-
#
|
|
172
|
-
# :param self: Refer to the class instance
|
|
173
|
-
# :param endpoint: Endpoint: Get the endpoint that is being called
|
|
174
|
-
# :param extra:
|
|
175
|
-
# :return: The result of the call function
|
|
176
|
-
# """
|
|
177
|
-
# pass
|
|
178
|
-
|
|
179
163
|
|
|
180
164
|
ListenerDataTypes = Union[
|
|
181
165
|
data.AppData,
|
|
@@ -72,7 +72,6 @@ class CaptureListenerManager(ListenerManager):
|
|
|
72
72
|
:param extra:
|
|
73
73
|
:return: The result of the call function
|
|
74
74
|
"""
|
|
75
|
-
# TODO ATUALIZAR DOCSTRINGS AQUI
|
|
76
75
|
|
|
77
76
|
def filter_annotations(annotations: list[Any]) -> Any:
|
|
78
77
|
for item in annotations:
|
|
@@ -95,7 +94,7 @@ class CaptureListenerManager(ListenerManager):
|
|
|
95
94
|
kwargs['extra'] = extra
|
|
96
95
|
info_msg: str = (
|
|
97
96
|
f'ENDPOINT: {listener.endpoint}\n'
|
|
98
|
-
f'APP-TAG: {listener.app.
|
|
97
|
+
f'APP-TAG: {listener.app.name}\n'
|
|
99
98
|
f'APP-ID: {listener.app.id}'
|
|
100
99
|
)
|
|
101
100
|
if extra:
|
|
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
|