squarecloud-api 3.3.2__tar.gz → 3.4.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 (28) hide show
  1. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/PKG-INFO +27 -13
  2. squarecloud_api-3.4.1/README.md +60 -0
  3. squarecloud_api-3.4.1/pyproject.toml +79 -0
  4. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/__init__.py +2 -3
  5. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/app.py +119 -115
  6. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/cli/app.py +4 -4
  7. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/cli/main.py +12 -51
  8. squarecloud_api-3.4.1/squarecloud/client.py +727 -0
  9. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/data.py +12 -39
  10. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/errors.py +26 -15
  11. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/http/endpoints.py +298 -322
  12. squarecloud_api-3.4.1/squarecloud/http/http_client.py +658 -0
  13. squarecloud_api-3.4.1/squarecloud/listeners/__init__.py +185 -0
  14. squarecloud_api-3.4.1/squarecloud/listeners/capture_listener.py +154 -0
  15. squarecloud_api-3.4.1/squarecloud/listeners/request_listener.py +106 -0
  16. squarecloud_api-3.4.1/squarecloud/logging.py +58 -0
  17. squarecloud_api-3.4.1/squarecloud/utils.py +72 -0
  18. squarecloud_api-3.3.2/README.md +0 -47
  19. squarecloud_api-3.3.2/pyproject.toml +0 -68
  20. squarecloud_api-3.3.2/squarecloud/client.py +0 -623
  21. squarecloud_api-3.3.2/squarecloud/http/http_client.py +0 -479
  22. squarecloud_api-3.3.2/squarecloud/listeners.py +0 -173
  23. squarecloud_api-3.3.2/squarecloud/logs.py +0 -60
  24. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/LICENSE +0 -0
  25. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/cli/__init__.py +0 -0
  26. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/cli/files.py +0 -0
  27. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/file.py +0 -0
  28. {squarecloud_api-3.3.2 → squarecloud_api-3.4.1}/squarecloud/http/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: squarecloud-api
3
- Version: 3.3.2
3
+ Version: 3.4.1
4
4
  Summary: SquareCloud API wrapper
5
5
  Home-page: https://github.com/squarecloudofc/wrapper-api-py
6
6
  License: MIT
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.12
16
16
  Requires-Dist: aiohttp (==3.9.3)
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)
19
20
  Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
20
21
  Requires-Dist: rich (>=13.5.2,<14.0.0)
21
22
  Project-URL: Documentation, https://docs.squarecloud.app/sdks/py
@@ -26,19 +27,28 @@ Description-Content-Type: text/markdown
26
27
 
27
28
  [Square Cloud API]: https://docs.squarecloud.app/api-reference/
28
29
 
29
- [@alma]: https://github.com/Robert-Nogueira
30
+ [@allma]: https://github.com/Robert-Nogueira
30
31
 
31
- # squarecloud-api
32
32
 
33
- squarecloud-api is a wrapper for the [Square Cloud API] mainted by [@alma]
33
+ <div align="center">
34
+ <img alt="Square Cloud Banner" src="https://cdn.squarecloud.app/png/github-readme.png">
35
+ </div>
34
36
 
37
+ <h1 align="center">squarecloud-api</h1>
35
38
 
36
- ## Installing
39
+ <p align="center">A Python SDK for consuming the <a href="https://squarecloud.app" target="_blank">Square Cloud</a> API.</p>
37
40
 
38
- ````
41
+ ## Installation
42
+
43
+ ````shell
39
44
  pip install squarecloud-api
40
45
  ````
41
46
 
47
+ If you intend to use this SDK for command-line interface (CLI) operations, consider
48
+ installing it with pipx:
49
+ ````shell
50
+ pipx install squarecloud-api
51
+ ````
42
52
 
43
53
  ## Getting api key
44
54
 
@@ -46,16 +56,16 @@ to get your api key/token just go to the [Square Cloud] website and
46
56
  register/login, after that go
47
57
  to `dashboard` > `my account` > `Regenerate API/CLI KEY` and copy the key.
48
58
 
49
- > ## [Documentation](https://docs.squarecloud.app/sdks/py)
50
- > you can read the documentation [**here**](https://docs.squarecloud.app/sdks/py).
59
+ ## Documentation
60
+ Visit our [official documentation](https://docs.squarecloud.app/sdks/py) for more information about how to use this library.
61
+
62
+ ## Getting started
51
63
 
52
- ## Basic usage
53
64
  ```python
54
65
  import asyncio
55
-
56
66
  import squarecloud as square
57
67
 
58
- client = square.Client('API_KEY', debug=True)
68
+ client = square.Client('API_KEY')
59
69
 
60
70
  async def main():
61
71
  status = await client.app_status(app_id='application_id')
@@ -66,7 +76,11 @@ async def main():
66
76
  asyncio.run(main())
67
77
  ```
68
78
 
69
- ## License
79
+ ## Contributing
80
+
81
+ Feel free to contribute with suggestions or bug reports at our [GitHub repository](https://github.com/squarecloudofc/wrapper-api-py).
82
+
83
+ ## Authors
70
84
 
71
- MIT License
85
+ - [@allma]
72
86
 
@@ -0,0 +1,60 @@
1
+ [Square Cloud]: https://squarecloud.app
2
+
3
+ [Square Cloud API]: https://docs.squarecloud.app/api-reference/
4
+
5
+ [@allma]: https://github.com/Robert-Nogueira
6
+
7
+
8
+ <div align="center">
9
+ <img alt="Square Cloud Banner" src="https://cdn.squarecloud.app/png/github-readme.png">
10
+ </div>
11
+
12
+ <h1 align="center">squarecloud-api</h1>
13
+
14
+ <p align="center">A Python SDK for consuming the <a href="https://squarecloud.app" target="_blank">Square Cloud</a> API.</p>
15
+
16
+ ## Installation
17
+
18
+ ````shell
19
+ pip install squarecloud-api
20
+ ````
21
+
22
+ If you intend to use this SDK for command-line interface (CLI) operations, consider
23
+ installing it with pipx:
24
+ ````shell
25
+ pipx install squarecloud-api
26
+ ````
27
+
28
+ ## Getting api key
29
+
30
+ to get your api key/token just go to the [Square Cloud] website and
31
+ register/login, after that go
32
+ to `dashboard` > `my account` > `Regenerate API/CLI KEY` and copy the key.
33
+
34
+ ## Documentation
35
+ Visit our [official documentation](https://docs.squarecloud.app/sdks/py) for more information about how to use this library.
36
+
37
+ ## Getting started
38
+
39
+ ```python
40
+ import asyncio
41
+ import squarecloud as square
42
+
43
+ client = square.Client('API_KEY')
44
+
45
+ async def main():
46
+ status = await client.app_status(app_id='application_id')
47
+ print(status)
48
+ print(status.ram)
49
+ print(status.cpu)
50
+
51
+ asyncio.run(main())
52
+ ```
53
+
54
+ ## Contributing
55
+
56
+ Feel free to contribute with suggestions or bug reports at our [GitHub repository](https://github.com/squarecloudofc/wrapper-api-py).
57
+
58
+ ## Authors
59
+
60
+ - [@allma]
@@ -0,0 +1,79 @@
1
+ [tool.poetry]
2
+ name = 'squarecloud-api'
3
+ version = '3.4.1'
4
+ description = 'SquareCloud API wrapper'
5
+ authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
6
+ 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
+ [tool.poetry.dependencies]
13
+ python = '^3.9'
14
+ aiohttp = '3.9.3'
15
+ click = '^8.1.6'
16
+ rich = '^13.5.2'
17
+ pydantic = '^2.5.2'
18
+ python-dotenv = '^1.0.0'
19
+ pypi = "^2.1"
20
+
21
+ [tool.poetry.group.dev.dependencies]
22
+ pytest = '^7.4.3'
23
+ pytest-cov = '^4.1.0'
24
+ blue = '^0.9.1'
25
+ isort = '^5.12.0'
26
+ taskipy = '^1.12.0'
27
+ pytest-asyncio = '^0.21.1'
28
+ pre-commit = '^3.3.3'
29
+ ruff = '^0.0.289'
30
+ memory-profiler = '^0.61.0'
31
+ requests = '^2.31.0'
32
+ pytest-rerunfailures = "^13.0"
33
+
34
+
35
+ [[tool.poetry.source]]
36
+ name = 'pypi-test'
37
+ url = 'https://test.pypi.org/simple/'
38
+ priority = 'primary'
39
+
40
+ [build-system]
41
+ requires = ['poetry-core']
42
+ build-backend = 'poetry.core.masonry.api'
43
+
44
+ [tool.pytest.ini_options]
45
+ asyncio_mode = 'auto'
46
+ markers = [
47
+ 'app',
48
+ 'app_data',
49
+ 'listeners',
50
+ 'capture_listener',
51
+ 'request_listener',
52
+ 'files',
53
+ 'upload',
54
+ ]
55
+
56
+ [tool.isort]
57
+ profile = 'black'
58
+ line_length = 79
59
+
60
+ [tool.taskipy.tasks]
61
+ lint = 'isort . && blue . && ruff .'
62
+ pre_test = 'task lint'
63
+ test = 'pytest -vv -s --reruns 5 --only-rerun TooManyRequests --reruns-delay 60 -x --cov=tests tests'
64
+ post_test = 'coverage html'
65
+ cli = 'python -m squarecloud.cli.main'
66
+ publish-test = 'poetry publish -r pypi-test --build'
67
+ install-test = 'pip install -i https://test.pypi.org/pypi/ --extra-index-url https://pypi.org/simple --upgrade squarecloud-api'
68
+ docs = 'mkdocs serve'
69
+ clear-test-apps = 'python -m scripts.clear_test_apps'
70
+
71
+ [tool.poetry.scripts]
72
+ squarecloud = 'squarecloud.cli.main:safe_entry_point'
73
+
74
+ [tool.ruff]
75
+ line-length = 79
76
+ exclude = ['env']
77
+
78
+ [tool.ruff.per-file-ignores]
79
+ '__init__.py' = ['F401']
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from . import errors, utils
3
4
  from .client import Client, create_config_file
4
5
  from .data import (
5
6
  AppData,
@@ -7,13 +8,11 @@ from .data import (
7
8
  FileInfo,
8
9
  LogsData,
9
10
  PlanData,
10
- StatisticsData,
11
11
  StatusData,
12
12
  UploadData,
13
13
  UserData,
14
14
  )
15
15
  from .file import File
16
16
  from .http.endpoints import Endpoint
17
- from . import errors
18
17
 
19
- __version__ = '3.3.0'
18
+ __version__ = '3.4.1'
@@ -1,11 +1,13 @@
1
1
  from __future__ import annotations
2
2
 
3
- from abc import ABC
3
+ from functools import wraps
4
4
  from io import BytesIO
5
- from typing import TYPE_CHECKING, Callable
5
+ from typing import TYPE_CHECKING, Any, Callable
6
6
 
7
7
  from pydantic import PositiveInt
8
8
 
9
+ from squarecloud import errors
10
+
9
11
  from .data import (
10
12
  AppData,
11
13
  BackupData,
@@ -15,10 +17,10 @@ from .data import (
15
17
  LogsData,
16
18
  StatusData,
17
19
  )
18
- from .errors import SquareException
19
20
  from .file import File
20
21
  from .http import Endpoint, HTTPClient, Response
21
- from .listeners import CaptureListenerManager
22
+ from .listeners import Listener, ListenerConfig
23
+ from .listeners.capture_listener import CaptureListenerManager
22
24
 
23
25
  # avoid circular imports
24
26
  if TYPE_CHECKING:
@@ -40,8 +42,7 @@ class AppCache:
40
42
  attributes.
41
43
 
42
44
 
43
- :return: The instance of the class
44
- :rtype: None
45
+ :return: None
45
46
  """
46
47
  self._status: StatusData | None = None
47
48
  self._logs: LogsData | None = None
@@ -51,9 +52,10 @@ class AppCache:
51
52
  @property
52
53
  def status(self) -> StatusData:
53
54
  """
54
- The status function returns the status of the application.
55
+ The status method is a property that returns the cached StatusData of
56
+ the application.
55
57
 
56
- :return: The status of the application.
58
+ :return: A StatusData object.
57
59
  :rtype: StatusData
58
60
  """
59
61
  return self._status
@@ -61,7 +63,8 @@ class AppCache:
61
63
  @property
62
64
  def logs(self) -> LogsData:
63
65
  """
64
- The logs function the logs of the application.
66
+ The logs method is a property that returns the cached LogsData of
67
+ the application.
65
68
 
66
69
  :return: The logs of your application
67
70
  :rtype: LogsData
@@ -71,7 +74,8 @@ class AppCache:
71
74
  @property
72
75
  def backup(self) -> BackupData:
73
76
  """
74
- The backup function is used to create a backup of the application.
77
+ The backup method is a property that returns the cached BackupData of
78
+ the application.
75
79
 
76
80
  :return: The value of the _backup attribute
77
81
  :rtype: BackupData
@@ -81,7 +85,8 @@ class AppCache:
81
85
  @property
82
86
  def app_data(self) -> AppData:
83
87
  """
84
- The app_data function is a property that returns the AppData object.
88
+ The app_data method is a property that returns the cached AppData
89
+ object
85
90
 
86
91
  :return: The data from the app_data
87
92
  :rtype: AppData
@@ -90,12 +95,11 @@ class AppCache:
90
95
 
91
96
  def clear(self):
92
97
  """
93
- The clear function is used to clear the status, logs, backup and data
98
+ The clear method is used to clear the status, logs, backup and data
94
99
  variables.
95
100
 
96
101
  :param self: Refer to the class instance
97
102
  :return: None
98
- :rtype: None
99
103
  """
100
104
  self._status = None
101
105
  self._logs = None
@@ -104,17 +108,15 @@ class AppCache:
104
108
 
105
109
  def update(self, *args):
106
110
  """
107
- The update function is used to update the data of a given instance.
111
+ The update method is used to update the data of a given instance.
108
112
  It takes in an arbitrary number of arguments, and updates the
109
113
  corresponding data if it is one of the following types:
110
114
  StatusData, LogsData, BackupData or AppData.
111
115
  If any other type is provided as an argument to this function,
112
116
  a SquareException will be raised.
113
117
 
114
- :param self: Refer to the class instance
115
118
  :param args: Pass a variable number of arguments to a function
116
119
  :return: None
117
- :rtype: None
118
120
  """
119
121
  for arg in args:
120
122
  if isinstance(arg, StatusData):
@@ -135,16 +137,12 @@ class AppCache:
135
137
  AppData,
136
138
  ]
137
139
  ]
138
- raise SquareException(
140
+ raise errors.SquareException(
139
141
  f'you must provide stats of the following types:\n{types}'
140
142
  )
141
143
 
142
144
 
143
- class AbstractApplication(ABC):
144
- """Abstract application class"""
145
-
146
-
147
- class Application:
145
+ class Application(CaptureListenerManager):
148
146
  """Represents an application"""
149
147
 
150
148
  __slots__ = [
@@ -176,26 +174,24 @@ class Application:
176
174
  desc: str | None = None,
177
175
  ) -> None:
178
176
  """
179
- The `__init__` function is called when the class is instantiated.
177
+ The `__init__` method is called when the class is instantiated.
180
178
  It sets up all the attributes that are passed in as arguments,
181
179
  and does any other initialization your class needs before It's ready
182
180
  for use.
183
181
 
184
182
 
185
- :param self: Refer to the class instance.
186
- :param client: 'Client': Store a reference to the client that created
183
+ :param client: Store a reference to the client that created
187
184
  this app.
188
- :param http: HTTPClient: Make http requests to the api.
189
- :param id: str: The id of the app.
190
- :param tag: str: The tag of the app.
191
- :param ram: PositiveInt: The amount of ram that is allocated.
192
- :param lang: str: The programming language of the app.
193
- :param cluster: str: The cluster that the app is hosted on
194
- :param isWebsite: bool: Whether if the app is a website
195
- :param desc: str | None: Define the description of the app
185
+ :param http: Store a reference to the HTTPClient
186
+ :param id: The application id
187
+ :param tag: The tag of the app
188
+ :param ram: The amount of ram that is allocated
189
+ :param lang: The programming language of the app
190
+ :param cluster: The cluster that the app is hosted on
191
+ :param isWebsite: Whether if the app is a website
192
+ :param desc: Define the description of the app
196
193
 
197
194
  :return: None
198
- :rtype: None
199
195
  """
200
196
  self._id: str = id
201
197
  self._tag: str = tag
@@ -209,26 +205,26 @@ class Application:
209
205
  self._listener: CaptureListenerManager = CaptureListenerManager()
210
206
  self.cache: AppCache = AppCache()
211
207
  self.always_avoid_listeners: bool = False
208
+ super().__init__()
212
209
 
213
210
  def __repr__(self) -> str:
214
211
  """
215
- The __repr__ function is used to create a string representation of an
212
+ The `__repr__` method is used to create a string representation of an
216
213
  object.
217
214
  This is useful for debugging, logging and other instances where you
218
215
  would want a string representation of the object.
219
216
  The __repr__ function should return a string that would make sense to
220
217
  someone looking at the results in the interactive interpreter.
221
218
 
222
-
223
- :param self: Refer to the class instance
224
219
  :return: The class name, tag and id of the element
220
+ :rtype: str
225
221
  """
226
222
  return f'<{self.__class__.__name__} tag={self.tag} id={self.id}>'
227
223
 
228
224
  @property
229
225
  def client(self) -> 'Client':
230
226
  """
231
- The client function is a property that returns the client object.
227
+ The client method is a property that returns the client object.
232
228
 
233
229
  :return: The client instance
234
230
  :rtype: Client
@@ -239,7 +235,7 @@ class Application:
239
235
  def id(self) -> str:
240
236
  """
241
237
  The id function is a property that returns
242
- the id of the application.
238
+ the id of the application.
243
239
 
244
240
  :return: The id of the application
245
241
  :rtype: str
@@ -317,9 +313,57 @@ class Application:
317
313
  """
318
314
  return self._isWebsite
319
315
 
320
- def capture(self, endpoint: Endpoint) -> Callable:
316
+ @staticmethod
317
+ def _notify_listener(endpoint: Endpoint):
318
+ """
319
+ The _notify_listener function is a decorator that call a listener after
320
+ the decorated coroutine is called
321
+
322
+ :param endpoint: the endpoint for witch the listener will fetch
323
+ :return: a callable
324
+ """
325
+
326
+ def wrapper(func: Callable):
327
+ @wraps(func)
328
+ async def decorator(self: Application, *args, **kwargs) -> Any:
329
+ result = await func(self, *args, **kwargs)
330
+ avoid_listener = kwargs.pop('avoid_listener', False)
331
+ if not (avoid_listener or self.always_avoid_listeners):
332
+ await self.notify(
333
+ endpoint=endpoint,
334
+ before=self.cache.app_data,
335
+ after=result,
336
+ extra=kwargs.get('extra'),
337
+ )
338
+ return result
339
+
340
+ return decorator
341
+
342
+ return wrapper
343
+
344
+ @staticmethod
345
+ def _update_cache(func: Callable):
346
+ """
347
+ This is a decorator checks whether the kwargs `update_cache` in the
348
+ decorated coroutine is not False, and updates the application cache
349
+
350
+ :param func:
351
+ :return: a callable
352
+ """
353
+
354
+ @wraps(func)
355
+ async def wrapper(self, *args, **kwargs):
356
+ update_cache = kwargs.pop('update_cache', True)
357
+ result = await func(self, *args, **kwargs)
358
+ if update_cache:
359
+ self.cache.update(result)
360
+ return result
361
+
362
+ return wrapper
363
+
364
+ def capture(self, endpoint: Endpoint, **kwargs) -> Callable:
321
365
  """
322
- The capture function is a decorator that can be used to add a function
366
+ The capture function is a decorator that can be used to add a callable
323
367
  to be called when a request is made to the specified endpoint.
324
368
 
325
369
  :param self: Refer to the class instance.
@@ -328,14 +372,10 @@ class Application:
328
372
  :return: A decorator
329
373
  :rtype: Callable
330
374
  """
331
- allowed_endpoints: tuple[Endpoint, Endpoint, Endpoint, Endpoint] = (
332
- Endpoint.logs(),
333
- Endpoint.app_status(),
334
- Endpoint.backup(),
335
- Endpoint.app_data(),
336
- )
337
375
 
338
- def wrapper(func) -> None:
376
+ def wrapper(
377
+ call: Callable[[Endpoint, Endpoint], Any]
378
+ ) -> Callable[[Endpoint, Endpoint], Any]:
339
379
  """
340
380
  The wrapper function is a decorator that takes in the endpoint as
341
381
  an argument.
@@ -345,116 +385,80 @@ class Application:
345
385
  with the function passed to wrapper().
346
386
  Otherwise, it raises another SquareException.
347
387
 
348
- :param func: Pass the function to be wrapped
388
+ :param call: Pass the function to be wrapped
349
389
  :return: The wrapper function itself
350
390
  :rtype: None
391
+ :raises InvalidListener: Raised if the endpoint is already
392
+ registered
351
393
  """
352
- if endpoint not in allowed_endpoints:
353
- raise SquareException(
354
- f'the endpoint to capture must be {allowed_endpoints}'
355
- )
356
-
357
- if self._listener.get_capture_listener(endpoint) is None:
358
- return self._listener.add_capture_listener(endpoint, func)
359
- raise SquareException(
360
- f'Already exists an capture_listener for {endpoint}'
361
- f'{self._listener.get_capture_listener(endpoint)}'
394
+ for key, value in kwargs.items():
395
+ if key not in ListenerConfig.__annotations__:
396
+ raise ValueError(
397
+ f'Invalid listener configuration: "{key}={value}"'
398
+ )
399
+ config = ListenerConfig(**kwargs)
400
+ listener = Listener(
401
+ app=self,
402
+ client=self.client,
403
+ endpoint=endpoint,
404
+ callback=call,
405
+ config=config,
362
406
  )
407
+ self.include_listener(listener)
408
+ return call
363
409
 
364
410
  return wrapper
365
411
 
366
- async def data(
367
- self, avoid_listener: bool = None, update_cache: bool = True
368
- ) -> AppData:
412
+ @_update_cache
413
+ @_notify_listener(Endpoint.app_data())
414
+ async def data(self, *_args, **__kwargs) -> AppData:
369
415
  """
370
- The data function is used to retrieve the data of an app.
416
+ The data method is used to retrieve the data of this app.
371
417
 
372
- :param update_cache: if True, update the application cache
373
- :param avoid_listener: whether the capture listener will be called
374
418
  :param self: Refer to the class instance
375
419
  :return: A AppData object
376
420
  :rtype: AppData
377
421
  """
378
422
  app_data: AppData = await self.client.app_data(self.id)
379
- avoid_listener = avoid_listener or self.always_avoid_listeners
380
- if not avoid_listener:
381
- endpoint: Endpoint = Endpoint.app_data()
382
- await self._listener.on_capture(
383
- endpoint=endpoint,
384
- before=self.cache.app_data,
385
- after=app_data,
386
- )
387
- if update_cache:
388
- self.cache.update(app_data)
389
423
  return app_data
390
424
 
391
- async def logs(
392
- self, avoid_listener: bool = None, update_cache: bool = True
393
- ) -> LogsData:
425
+ @_update_cache
426
+ @_notify_listener(Endpoint.logs())
427
+ async def logs(self, *_args, **__kwargs) -> LogsData:
394
428
  """
395
- The logs function is used to get the application's logs.
429
+ The logs method is used to get the application's logs.
396
430
 
397
431
  :param self: Refer to the class instance
398
- :param update_cache: if True, update the application cache
399
- :param avoid_listener: whether the capture listener will be called
400
432
  :return: A LogsData object
401
433
  :rtype: LogsData
402
434
  """
403
435
  logs: LogsData = await self.client.get_logs(self.id)
404
- avoid_listener = avoid_listener or self.always_avoid_listeners
405
- if not avoid_listener:
406
- endpoint: Endpoint = Endpoint.logs()
407
- await self._listener.on_capture(
408
- endpoint=endpoint, before=self.cache.logs, after=logs
409
- )
410
- if update_cache:
411
- self.cache.update(logs)
412
436
  return logs
413
437
 
414
- async def status(
415
- self, avoid_listener: bool = None, update_cache: bool = True
416
- ) -> StatusData:
438
+ @_update_cache
439
+ @_notify_listener(Endpoint.app_status())
440
+ async def status(self, *_args, **__kwargs) -> StatusData:
417
441
  """
418
442
  The status function returns the status of an application.
419
443
 
420
444
  :param self: Refer to the class instance
421
- :param update_cache: if True, update the application cache
422
- :param avoid_listener: whether the capture listener will be called
423
445
  :return: A StatusData object
424
446
  :rtype: StatusData
425
447
  """
426
448
  status: StatusData = await self.client.app_status(self.id)
427
- avoid_listener = avoid_listener or self.always_avoid_listeners
428
- if not avoid_listener:
429
- endpoint: Endpoint = Endpoint.app_status()
430
- await self._listener.on_capture(
431
- endpoint=endpoint, before=self.cache.status, after=status
432
- )
433
- if update_cache:
434
- self.cache.update(status)
435
449
  return status
436
450
 
437
- async def backup(
438
- self, avoid_listener: bool = None, update_cache: bool = True
439
- ) -> BackupData:
451
+ @_update_cache
452
+ @_notify_listener(Endpoint.backup())
453
+ async def backup(self, *_args, **__kwargs) -> BackupData:
440
454
  """
441
455
  The backup function is used to create a backup of the application.
442
456
 
443
457
  :param self: Refer to the class instance
444
- :param update_cache: if True, update the application cache
445
- :param avoid_listener: whether the capture listener will be called
446
458
  :return: A BackupData object
447
459
  :rtype: BackupData
448
460
  """
449
461
  backup: BackupData = await self.client.backup(self.id)
450
- avoid_listener = avoid_listener or self.always_avoid_listeners
451
- if not avoid_listener:
452
- endpoint: Endpoint = Endpoint.backup()
453
- await self._listener.on_capture(
454
- endpoint=endpoint, before=self.cache.backup, after=backup
455
- )
456
- if update_cache:
457
- self.cache.update(backup)
458
462
  return backup
459
463
 
460
464
  async def start(self) -> Response: