squarecloud-api 3.4.1__tar.gz → 3.5.1__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 (22) hide show
  1. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/PKG-INFO +2 -3
  2. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/pyproject.toml +3 -10
  3. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/__init__.py +5 -2
  4. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/app.py +36 -23
  5. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/cli/app.py +5 -9
  6. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/cli/main.py +2 -4
  7. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/client.py +19 -9
  8. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/data.py +9 -14
  9. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/http/endpoints.py +0 -15
  10. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/http/http_client.py +1 -1
  11. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/listeners/__init__.py +0 -16
  12. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/listeners/capture_listener.py +2 -3
  13. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/LICENSE +0 -0
  14. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/README.md +0 -0
  15. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/cli/__init__.py +0 -0
  16. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/cli/files.py +0 -0
  17. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/errors.py +0 -0
  18. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/file.py +0 -0
  19. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/http/__init__.py +0 -0
  20. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/listeners/request_listener.py +0 -0
  21. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/logging.py +0 -0
  22. {squarecloud_api-3.4.1 → squarecloud_api-3.5.1}/squarecloud/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: squarecloud-api
3
- Version: 3.4.1
3
+ Version: 3.5.1
4
4
  Summary: SquareCloud API wrapper
5
5
  Home-page: https://github.com/squarecloudofc/wrapper-api-py
6
6
  License: MIT
@@ -13,10 +13,9 @@ 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
- Requires-Dist: aiohttp (==3.9.3)
16
+ Requires-Dist: aiohttp (==3.9.5)
17
17
  Requires-Dist: click (>=8.1.6,<9.0.0)
18
18
  Requires-Dist: pydantic (>=2.5.2,<3.0.0)
19
- Requires-Dist: pypi (>=2.1,<3.0)
20
19
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
21
20
  Requires-Dist: rich (>=13.5.2,<14.0.0)
22
21
  Project-URL: Documentation, https://docs.squarecloud.app/sdks/py
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = 'squarecloud-api'
3
- version = '3.4.1'
3
+ version = '3.5.1'
4
4
  description = 'SquareCloud API wrapper'
5
5
  authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
6
6
  repository = 'https://github.com/squarecloudofc/wrapper-api-py'
@@ -11,31 +11,24 @@ packages = [{ include = 'squarecloud' }]
11
11
 
12
12
  [tool.poetry.dependencies]
13
13
  python = '^3.9'
14
- aiohttp = '3.9.3'
14
+ aiohttp = "3.9.5"
15
15
  click = '^8.1.6'
16
16
  rich = '^13.5.2'
17
17
  pydantic = '^2.5.2'
18
18
  python-dotenv = '^1.0.0'
19
- pypi = "^2.1"
20
19
 
21
20
  [tool.poetry.group.dev.dependencies]
22
21
  pytest = '^7.4.3'
23
22
  pytest-cov = '^4.1.0'
24
23
  blue = '^0.9.1'
25
24
  isort = '^5.12.0'
26
- taskipy = '^1.12.0'
27
25
  pytest-asyncio = '^0.21.1'
28
26
  pre-commit = '^3.3.3'
29
27
  ruff = '^0.0.289'
30
28
  memory-profiler = '^0.61.0'
31
29
  requests = '^2.31.0'
32
30
  pytest-rerunfailures = "^13.0"
33
-
34
-
35
- [[tool.poetry.source]]
36
- name = 'pypi-test'
37
- url = 'https://test.pypi.org/simple/'
38
- priority = 'primary'
31
+ taskipy = "^1.13.0"
39
32
 
40
33
  [build-system]
41
34
  requires = ['poetry-core']
@@ -1,10 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from . import errors, utils
4
- from .client import Client, create_config_file
4
+ from .app import Application
5
+ from .client import Client
5
6
  from .data import (
6
7
  AppData,
7
8
  BackupData,
9
+ DeployData,
10
+ DomainAnalytics,
8
11
  FileInfo,
9
12
  LogsData,
10
13
  PlanData,
@@ -15,4 +18,4 @@ from .data import (
15
18
  from .file import File
16
19
  from .http.endpoints import Endpoint
17
20
 
18
- __version__ = '3.4.1'
21
+ __version__ = '3.5.1'
@@ -152,12 +152,13 @@ class Application(CaptureListenerManager):
152
152
  '_data',
153
153
  'cache',
154
154
  '_id',
155
- '_tag',
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
- tag: str,
170
+ name: str,
170
171
  ram: PositiveInt,
171
172
  lang: str,
172
173
  cluster: str,
173
- isWebsite: bool,
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 tag: The tag of the app
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._tag: str = tag
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()
@@ -219,7 +223,7 @@ class Application(CaptureListenerManager):
219
223
  :return: The class name, tag and id of the element
220
224
  :rtype: str
221
225
  """
222
- return f'<{self.__class__.__name__} tag={self.tag} id={self.id}>'
226
+ return f'<{self.__class__.__name__} tag={self.name} id={self.id}>'
223
227
 
224
228
  @property
225
229
  def client(self) -> 'Client':
@@ -243,14 +247,14 @@ class Application(CaptureListenerManager):
243
247
  return self._id
244
248
 
245
249
  @property
246
- def tag(self) -> str:
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._tag
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 is_website(self) -> bool:
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
- The is_website function is a property that returns a boolean value
309
- indicating whether th application is a website.
315
+ return self._domain
310
316
 
311
- :return: A boolean value, true or false
312
- :rtype: bool
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._isWebsite
327
+ return self._custom
315
328
 
316
329
  @staticmethod
317
330
  def _notify_listener(endpoint: Endpoint):
@@ -52,22 +52,20 @@ async def app_group(ctx: Context, app_id: str, token: str):
52
52
  if not ctx.invoked_subcommand:
53
53
  with Console().status('loading'):
54
54
  app = await client.app(app_id)
55
- table = Table(title=app.tag, header_style='purple')
56
- table.add_column('Tag', justify='center')
55
+ table = Table(title=app.name, header_style='purple')
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(
65
- app.tag,
64
+ app.name,
66
65
  app.id,
67
66
  str(app.ram),
68
67
  app.lang,
69
68
  app.desc,
70
- str(app.is_website),
71
69
  app.cluster,
72
70
  style='green',
73
71
  )
@@ -128,21 +126,19 @@ async def app_list(ctx: Context, token: str):
128
126
  return
129
127
  table = Table(title='App List', header_style='purple')
130
128
 
131
- table.add_column('Tag', justify='center')
129
+ table.add_column('Name', justify='center')
132
130
  table.add_column('ID', justify='center')
133
131
  table.add_column('RAM', justify='center')
134
132
  table.add_column('Language', justify='center')
135
133
  table.add_column('Description', justify='center')
136
- table.add_column('Is Website', justify='center')
137
134
  table.add_column('Cluster', justify='center')
138
135
  for app in apps:
139
136
  table.add_row(
140
- app.tag,
137
+ app.name,
141
138
  app.id,
142
139
  str(app.ram),
143
140
  app.lang,
144
141
  app.desc,
145
- str(app.is_website),
146
142
  app.cluster,
147
143
  style='green',
148
144
  )
@@ -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
  )
@@ -3,12 +3,12 @@ from __future__ import annotations
3
3
 
4
4
  from functools import wraps
5
5
  from io import BytesIO
6
- from typing import Any, Callable, Literal, TextIO
6
+ from typing import Any, Callable, Literal, ParamSpec, TextIO, TypeVar
7
7
 
8
8
  from typing_extensions import deprecated
9
9
 
10
10
  from .app import Application
11
- from .data import ( # LogsData,
11
+ from .data import (
12
12
  AppData,
13
13
  BackupData,
14
14
  DeployData,
@@ -27,6 +27,9 @@ from .listeners import Listener, ListenerConfig
27
27
  from .listeners.request_listener import RequestListenerManager
28
28
  from .logging import logger
29
29
 
30
+ P = ParamSpec('P')
31
+ R = TypeVar('R')
32
+
30
33
 
31
34
  @deprecated(
32
35
  'create_config_file is deprecated, '
@@ -180,10 +183,12 @@ class Client(RequestListenerManager):
180
183
  :return: a callable
181
184
  """
182
185
 
183
- def wrapper(func: Callable):
186
+ def wrapper(func: Callable[P, R]) -> Callable[P, R]:
184
187
  @wraps(func)
185
- async def decorator(self: Client, *args, **kwargs) -> Response:
186
- result: Any
188
+ async def decorator(
189
+ self: Client, *args: P.args, **kwargs: P.kwargs
190
+ ) -> R:
191
+ # result: Any
187
192
  response: Response
188
193
  result = await func(self, *args, **kwargs)
189
194
  response = self._http.last_response
@@ -412,6 +417,9 @@ class Client(RequestListenerManager):
412
417
  if not app_data:
413
418
  raise ApplicationNotFound(app_id=app_id)
414
419
  app_data = app_data.pop()
420
+ app_data['language'] = app_data.pop('lang')
421
+ app_data = AppData(**app_data).to_dict()
422
+ app_data['lang'] = app_data.pop('language')
415
423
  return Application(client=self, http=self._http, **app_data)
416
424
 
417
425
  @_notify_listener(Endpoint.user())
@@ -433,10 +441,12 @@ class Client(RequestListenerManager):
433
441
  response: Response = await self._http.fetch_user_info()
434
442
  payload = response.response
435
443
  apps_data: list = payload['applications']
436
- apps: list[Application] = [
437
- Application(client=self, http=self._http, **data)
438
- for data in apps_data
439
- ]
444
+ apps: list[Application] = []
445
+ for data in apps_data:
446
+ data['language'] = data.pop('lang')
447
+ data = AppData(**data).to_dict()
448
+ data['lang'] = data.pop('language')
449
+ apps.append(Application(client=self, http=self._http, **data))
440
450
  return apps
441
451
 
442
452
  @_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 tag: Username
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 tag: str
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
- tag: str
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 tag: Tag of the uploaded application
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 tag: str
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
- tag: str
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}'},
@@ -164,7 +164,7 @@ class HTTPClient:
164
164
  """
165
165
  headers = {
166
166
  'Authorization': self.api_key,
167
- 'User-Agent': 'squarecloud-api/3.2.1',
167
+ 'User-Agent': 'squarecloud-api/3.5.1',
168
168
  }
169
169
  extra_error_kwargs: dict[str, Any] = {}
170
170
 
@@ -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.tag}\n'
97
+ f'APP-TAG: {listener.app.name}\n'
99
98
  f'APP-ID: {listener.app.id}'
100
99
  )
101
100
  if extra:
@@ -146,7 +145,7 @@ class CaptureListenerManager(ListenerManager):
146
145
  logger.error(
147
146
  f'Failed to call listener "{listener.callback.__name__}.\n'
148
147
  f'Error: {exc.__repr__()}.\n'
149
- f'APP-TAG: {listener.app.tag}\n'
148
+ f'APP-TAG: {listener.app.name}\n'
150
149
  f'APP-ID: {listener.app.id}',
151
150
  extra={'type': 'listener'},
152
151
  )
File without changes