squarecloud-api 3.7.5__tar.gz → 3.8.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.7.5 → squarecloud_api-3.8.0}/PKG-INFO +1 -1
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/pyproject.toml +1 -1
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/__init__.py +4 -4
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/app.py +116 -12
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/client.py +165 -75
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/data.py +49 -39
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/http/endpoints.py +42 -6
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/http/http_client.py +71 -6
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/listeners/__init__.py +1 -1
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/listeners/capture_listener.py +2 -2
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/LICENSE +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/README.md +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/_internal/constants.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/_internal/decorators.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/errors.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/file.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/http/__init__.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/listeners/request_listener.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/logger.py +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/py.typed +0 -0
- {squarecloud_api-3.7.5 → squarecloud_api-3.8.0}/squarecloud/utils.py +0 -0
|
@@ -5,8 +5,6 @@ from .app import Application
|
|
|
5
5
|
from .client import Client
|
|
6
6
|
from .data import (
|
|
7
7
|
AppData,
|
|
8
|
-
Backup,
|
|
9
|
-
BackupInfo,
|
|
10
8
|
DeployData,
|
|
11
9
|
DNSRecord,
|
|
12
10
|
DomainAnalytics,
|
|
@@ -14,6 +12,8 @@ from .data import (
|
|
|
14
12
|
LogsData,
|
|
15
13
|
PlanData,
|
|
16
14
|
ResumedStatus,
|
|
15
|
+
Snapshot,
|
|
16
|
+
SnapshotInfo,
|
|
17
17
|
StatusData,
|
|
18
18
|
UploadData,
|
|
19
19
|
UserData,
|
|
@@ -29,8 +29,8 @@ __all__ = [
|
|
|
29
29
|
'Endpoint',
|
|
30
30
|
'Response',
|
|
31
31
|
'AppData',
|
|
32
|
-
'
|
|
33
|
-
'
|
|
32
|
+
'Snapshot',
|
|
33
|
+
'SnapshotInfo',
|
|
34
34
|
'DeployData',
|
|
35
35
|
'DNSRecord',
|
|
36
36
|
'DomainAnalytics',
|
|
@@ -4,18 +4,20 @@ from functools import wraps
|
|
|
4
4
|
from io import BytesIO
|
|
5
5
|
from typing import TYPE_CHECKING, Any, Callable, Coroutine, TypeVar
|
|
6
6
|
|
|
7
|
+
from typing_extensions import deprecated
|
|
8
|
+
|
|
7
9
|
from squarecloud import errors
|
|
8
10
|
|
|
9
11
|
from ._internal.decorators import validate
|
|
10
12
|
from .data import (
|
|
11
13
|
AppData,
|
|
12
|
-
Backup,
|
|
13
|
-
BackupInfo,
|
|
14
14
|
DeployData,
|
|
15
15
|
DNSRecord,
|
|
16
16
|
DomainAnalytics,
|
|
17
17
|
FileInfo,
|
|
18
18
|
LogsData,
|
|
19
|
+
Snapshot,
|
|
20
|
+
SnapshotInfo,
|
|
19
21
|
StatusData,
|
|
20
22
|
)
|
|
21
23
|
from .file import File
|
|
@@ -53,7 +55,7 @@ class AppCache:
|
|
|
53
55
|
"""
|
|
54
56
|
self._status: StatusData | None = None
|
|
55
57
|
self._logs: LogsData | None = None
|
|
56
|
-
self._backup:
|
|
58
|
+
self._backup: Snapshot | None = None
|
|
57
59
|
self._app_data: AppData | None = None
|
|
58
60
|
|
|
59
61
|
@property
|
|
@@ -79,7 +81,8 @@ class AppCache:
|
|
|
79
81
|
return self._logs
|
|
80
82
|
|
|
81
83
|
@property
|
|
82
|
-
|
|
84
|
+
@deprecated("this property will be removed in future versions, use the 'snapshot' property instead")
|
|
85
|
+
def backup(self) -> Snapshot:
|
|
83
86
|
"""
|
|
84
87
|
The backup method is a property that returns the cached Backup of
|
|
85
88
|
the application.
|
|
@@ -130,7 +133,7 @@ class AppCache:
|
|
|
130
133
|
self._status = arg
|
|
131
134
|
elif isinstance(arg, LogsData):
|
|
132
135
|
self._logs = arg
|
|
133
|
-
elif isinstance(arg,
|
|
136
|
+
elif isinstance(arg, Snapshot):
|
|
134
137
|
self._backup = arg
|
|
135
138
|
elif isinstance(arg, AppData):
|
|
136
139
|
self._app_data = arg
|
|
@@ -140,7 +143,7 @@ class AppCache:
|
|
|
140
143
|
for i in [
|
|
141
144
|
StatusData,
|
|
142
145
|
LogsData,
|
|
143
|
-
|
|
146
|
+
Snapshot,
|
|
144
147
|
AppData,
|
|
145
148
|
]
|
|
146
149
|
]
|
|
@@ -458,8 +461,9 @@ class Application(CaptureListenerManager):
|
|
|
458
461
|
return status
|
|
459
462
|
|
|
460
463
|
@_update_cache
|
|
461
|
-
@_notify_listener(Endpoint.
|
|
462
|
-
|
|
464
|
+
@_notify_listener(Endpoint.snapshot())
|
|
465
|
+
@deprecated("this method will be removed in future versions, use the 'snapshot' method instead")
|
|
466
|
+
async def backup(self, *_args, **_kwargs) -> Snapshot:
|
|
463
467
|
"""
|
|
464
468
|
The backup function is used to create a backup of the application.
|
|
465
469
|
|
|
@@ -467,8 +471,21 @@ class Application(CaptureListenerManager):
|
|
|
467
471
|
:return: A Backup object
|
|
468
472
|
:rtype: Backup
|
|
469
473
|
"""
|
|
470
|
-
backup:
|
|
474
|
+
backup: Snapshot = await self.client.snapshot(self.id)
|
|
471
475
|
return backup
|
|
476
|
+
|
|
477
|
+
@_update_cache
|
|
478
|
+
@_notify_listener(Endpoint.snapshot())
|
|
479
|
+
async def snapshot(self, *_args, **_kwargs) -> Snapshot:
|
|
480
|
+
"""
|
|
481
|
+
The Snapshot function is used to create a snapshot of the application.
|
|
482
|
+
|
|
483
|
+
:param self: Refer to the class instance
|
|
484
|
+
:return: A Snapshot object
|
|
485
|
+
:rtype: Snapshot
|
|
486
|
+
"""
|
|
487
|
+
snapshot: Snapshot = await self.client.snapshot(self.id)
|
|
488
|
+
return snapshot
|
|
472
489
|
|
|
473
490
|
async def start(self) -> Response:
|
|
474
491
|
"""
|
|
@@ -638,23 +655,61 @@ class Application(CaptureListenerManager):
|
|
|
638
655
|
return webhook
|
|
639
656
|
|
|
640
657
|
async def domain_analytics(self) -> DomainAnalytics:
|
|
658
|
+
"""
|
|
659
|
+
Retrieve analytics data for the application's domain.
|
|
660
|
+
|
|
661
|
+
:param self: Refer to the instance of the class.
|
|
662
|
+
:returns: An instance of :class:`DomainAnalytics` containing analytics data for the domain.
|
|
663
|
+
:rtype: DomainAnalytics
|
|
664
|
+
:raises Exception: If the analytics data could not be retrieved.
|
|
665
|
+
"""
|
|
641
666
|
analytics: DomainAnalytics = await self.client.domain_analytics(
|
|
642
667
|
self.id, avoid_listener=True
|
|
643
668
|
)
|
|
644
|
-
return analytics
|
|
669
|
+
return analytics
|
|
645
670
|
|
|
646
671
|
async def set_custom_domain(self, custom_domain: str) -> Response:
|
|
672
|
+
"""
|
|
673
|
+
Sets a custom domain for the application.
|
|
674
|
+
|
|
675
|
+
:param custom_domain: The custom domain to be assigned to the application.
|
|
676
|
+
:type custom_domain: str
|
|
677
|
+
:return: The response from the domain assignment operation.
|
|
678
|
+
:rtype: Response
|
|
679
|
+
"""
|
|
647
680
|
response: Response = await self.client.set_custom_domain(
|
|
648
681
|
self.id, custom_domain, avoid_listener=True
|
|
649
682
|
)
|
|
650
683
|
return response
|
|
651
684
|
|
|
652
|
-
|
|
653
|
-
|
|
685
|
+
@deprecated("this method will be removed in future versions, use the 'all_snapshots' method instead")
|
|
686
|
+
async def all_backups(self) -> list[SnapshotInfo]:
|
|
687
|
+
backups: list[SnapshotInfo] = await self.client.all_app_snapshots(self.id)
|
|
654
688
|
return backups
|
|
689
|
+
|
|
690
|
+
async def all_snapshots(self) -> list[SnapshotInfo]:
|
|
691
|
+
"""
|
|
692
|
+
Retrieve all snapshots of the application.
|
|
693
|
+
|
|
694
|
+
:return: A list of SnapshotInfo objects representing all snapshots of the application.
|
|
695
|
+
:rtype: list[SnapshotInfo]
|
|
696
|
+
"""
|
|
697
|
+
snapshots: list[SnapshotInfo] = await self.client.all_app_snapshots(self.id)
|
|
698
|
+
return snapshots
|
|
655
699
|
|
|
656
700
|
@validate
|
|
657
701
|
async def move_file(self, origin: str, dest: str) -> Response:
|
|
702
|
+
"""
|
|
703
|
+
Moves a file from the origin path to the destination path within the application.
|
|
704
|
+
|
|
705
|
+
:param origin: The source path of the file to be moved.
|
|
706
|
+
:type origin: str
|
|
707
|
+
:param dest: The destination path where the file should be moved.
|
|
708
|
+
:type dest: str
|
|
709
|
+
:return: A Response object containing the result of the file move operation.
|
|
710
|
+
:rtype: Response
|
|
711
|
+
"""
|
|
712
|
+
|
|
658
713
|
return await self.client.move_app_file(self.id, origin, dest)
|
|
659
714
|
|
|
660
715
|
async def current_integration(self) -> Response:
|
|
@@ -662,4 +717,53 @@ class Application(CaptureListenerManager):
|
|
|
662
717
|
|
|
663
718
|
@_notify_listener(Endpoint.dns_records())
|
|
664
719
|
async def dns_records(self) -> list[DNSRecord]:
|
|
720
|
+
"""
|
|
721
|
+
Retrieve the DNS records associated with the application.
|
|
722
|
+
|
|
723
|
+
:returns: A list of DNSRecord objects representing the DNS records.
|
|
724
|
+
:rtype: list[DNSRecord]
|
|
725
|
+
"""
|
|
726
|
+
|
|
665
727
|
return await self.client.dns_records(self.id)
|
|
728
|
+
|
|
729
|
+
async def get_envs(self) -> dict[str, str]:
|
|
730
|
+
"""
|
|
731
|
+
Get environment variables of the application.
|
|
732
|
+
|
|
733
|
+
:return: A dictionary of the environment variables that were set.
|
|
734
|
+
:rtype: dict[str, str]
|
|
735
|
+
"""
|
|
736
|
+
return await self.client.get_app_envs(self.id)
|
|
737
|
+
|
|
738
|
+
async def set_envs(self, envs: dict[str, str]) -> dict[str,str]:
|
|
739
|
+
"""
|
|
740
|
+
Set environment variables or edits for the application.
|
|
741
|
+
|
|
742
|
+
:param envs: A dictionary containing environment variable names and their corresponding values.
|
|
743
|
+
:type envs: dict[str, str]
|
|
744
|
+
:return: A dictionary of the environment variables that were set.
|
|
745
|
+
:rtype: dict[str, str]
|
|
746
|
+
"""
|
|
747
|
+
return await self.client.set_app_envs(self.id, envs)
|
|
748
|
+
|
|
749
|
+
async def delete_envs(self, keys: list[str]) -> dict[str,str]:
|
|
750
|
+
"""
|
|
751
|
+
Deletes environment variables from the application.
|
|
752
|
+
|
|
753
|
+
:param keys: A list of environment variable keys to be deleted.
|
|
754
|
+
:type keys: list[str]
|
|
755
|
+
:returns: A dictionary containing the remaining variables.
|
|
756
|
+
:rtype: dict[str, str]
|
|
757
|
+
"""
|
|
758
|
+
return await self.client.delete_app_envs(self.id, keys)
|
|
759
|
+
|
|
760
|
+
async def overwrite_env(self, envs: dict[str, str]) -> dict[str,str]:
|
|
761
|
+
"""
|
|
762
|
+
Overwrites the environment variables for the application.
|
|
763
|
+
|
|
764
|
+
:param envs: A dictionary containing the environment variables to set, where keys are variable names and values are their corresponding values.
|
|
765
|
+
:type envs: dict[str, str]
|
|
766
|
+
:return: A dictionary of the environment variables.
|
|
767
|
+
:rtype: dict[str, str]
|
|
768
|
+
"""
|
|
769
|
+
return await self.client.overwrite_app_envs(self.id, envs)
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from functools import wraps
|
|
6
6
|
from io import BytesIO
|
|
7
|
-
from typing import Any, Callable, Literal, ParamSpec,
|
|
7
|
+
from typing import Any, Callable, Literal, ParamSpec, TypeVar
|
|
8
8
|
|
|
9
9
|
from typing_extensions import deprecated
|
|
10
10
|
|
|
@@ -12,14 +12,14 @@ from ._internal.decorators import validate
|
|
|
12
12
|
from .app import Application
|
|
13
13
|
from .data import (
|
|
14
14
|
AppData,
|
|
15
|
-
Backup,
|
|
16
|
-
BackupInfo,
|
|
17
15
|
DeployData,
|
|
18
16
|
DNSRecord,
|
|
19
17
|
DomainAnalytics,
|
|
20
18
|
FileInfo,
|
|
21
19
|
LogsData,
|
|
22
20
|
ResumedStatus,
|
|
21
|
+
Snapshot,
|
|
22
|
+
SnapshotInfo,
|
|
23
23
|
StatusData,
|
|
24
24
|
UploadData,
|
|
25
25
|
UserData,
|
|
@@ -36,66 +36,6 @@ P = ParamSpec("P")
|
|
|
36
36
|
R = TypeVar("R")
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
@deprecated(
|
|
40
|
-
"create_config_file is deprecated, "
|
|
41
|
-
"use squarecloud.utils.ConfigFile instead."
|
|
42
|
-
)
|
|
43
|
-
def create_config_file(
|
|
44
|
-
path: str,
|
|
45
|
-
display_name: str,
|
|
46
|
-
main: str,
|
|
47
|
-
memory: int,
|
|
48
|
-
version: Literal["recommended", "latest"] = "recommended",
|
|
49
|
-
description: str | None = None,
|
|
50
|
-
subdomain: str | None = None,
|
|
51
|
-
start: str | None = None,
|
|
52
|
-
auto_restart: bool = False,
|
|
53
|
-
**kwargs,
|
|
54
|
-
) -> TextIO | str:
|
|
55
|
-
"""
|
|
56
|
-
The create_config_file function creates a squarecloud.app file in the
|
|
57
|
-
specified path, with the given parameters.
|
|
58
|
-
The function takes in 8 arguments:
|
|
59
|
-
|
|
60
|
-
:param path: str: Specify the path to the folder where you want to create
|
|
61
|
-
your config file
|
|
62
|
-
:param display_name: str: Set the display name of your app
|
|
63
|
-
:param main: str: Specify the file that will be executed when the app
|
|
64
|
-
is started
|
|
65
|
-
:param memory: int: Set the memory of the app
|
|
66
|
-
:param version: Literal['recommended', 'latest']: Ensure that the version
|
|
67
|
-
is either 'recommended' or 'latest'.
|
|
68
|
-
:param description: str | None: Specify a description for the app
|
|
69
|
-
:param subdomain: str | None: Specify the subdomain of your app
|
|
70
|
-
:param start: str | None: Specify the command that should be run when the
|
|
71
|
-
application starts
|
|
72
|
-
:param auto_restart: bool | None: Determine if the app should restart
|
|
73
|
-
automatically after a crash
|
|
74
|
-
:return: File content
|
|
75
|
-
:rtype: str
|
|
76
|
-
"""
|
|
77
|
-
content: str = ""
|
|
78
|
-
optionals: dict[str, Any] = {
|
|
79
|
-
"DISPLAY_NAME": display_name,
|
|
80
|
-
"MAIN": main,
|
|
81
|
-
"MEMORY": memory,
|
|
82
|
-
"VERSION": version,
|
|
83
|
-
"DESCRIPTION": description,
|
|
84
|
-
"SUBDOMAIN": subdomain,
|
|
85
|
-
"START": start,
|
|
86
|
-
"AUTORESTART": auto_restart,
|
|
87
|
-
}
|
|
88
|
-
for key, value in optionals.items():
|
|
89
|
-
if value:
|
|
90
|
-
string: str = f"{key}={value}\n"
|
|
91
|
-
content += string
|
|
92
|
-
if kwargs.get("save", True):
|
|
93
|
-
with open(f"./{path}/squarecloud.app", "w", encoding="utf-8") as file:
|
|
94
|
-
file.write(content)
|
|
95
|
-
return file
|
|
96
|
-
return content
|
|
97
|
-
|
|
98
|
-
|
|
99
39
|
class Client(RequestListenerManager):
|
|
100
40
|
"""A client for interacting with the SquareCloud API."""
|
|
101
41
|
|
|
@@ -338,15 +278,38 @@ class Client(RequestListenerManager):
|
|
|
338
278
|
return await self._http.restart_application(app_id)
|
|
339
279
|
|
|
340
280
|
@validate
|
|
341
|
-
@_notify_listener(Endpoint.
|
|
342
|
-
|
|
281
|
+
@_notify_listener(Endpoint.snapshot())
|
|
282
|
+
@deprecated("this method will be removed in future versions, use the 'snapshot' method instead")
|
|
283
|
+
async def backup(self, app_id: str, **_kwargs) -> Snapshot:
|
|
343
284
|
"""
|
|
344
285
|
The backup method is used to backup an application.
|
|
345
286
|
|
|
346
287
|
:param app_id: Specify the application id
|
|
347
288
|
:param _kwargs: Keyword arguments
|
|
348
|
-
:return: A
|
|
349
|
-
:rtype:
|
|
289
|
+
:return: A Snapshot object
|
|
290
|
+
:rtype: Snapshot
|
|
291
|
+
|
|
292
|
+
:raises NotFoundError: Raised when the request status code is 404
|
|
293
|
+
:raises BadRequestError: Raised when the request status code is 400
|
|
294
|
+
:raises AuthenticationFailure: Raised when the request status
|
|
295
|
+
code is 401
|
|
296
|
+
:raises TooManyRequestsError: Raised when the request status
|
|
297
|
+
code is 429
|
|
298
|
+
"""
|
|
299
|
+
response: Response = await self._http.snapshot(app_id)
|
|
300
|
+
payload: dict[str, Any] = response.response
|
|
301
|
+
return Snapshot(**payload)
|
|
302
|
+
|
|
303
|
+
@validate
|
|
304
|
+
@_notify_listener(Endpoint.snapshot())
|
|
305
|
+
async def snapshot(self, app_id: str, **_kwargs) -> Snapshot:
|
|
306
|
+
"""
|
|
307
|
+
The snapshot method is used to save a snapshot of an application.
|
|
308
|
+
|
|
309
|
+
:param app_id: Specify the application id
|
|
310
|
+
:param _kwargs: Keyword arguments
|
|
311
|
+
:return: A Snapshot object
|
|
312
|
+
:rtype: Snapshot
|
|
350
313
|
|
|
351
314
|
:raises NotFoundError: Raised when the request status code is 404
|
|
352
315
|
:raises BadRequestError: Raised when the request status code is 400
|
|
@@ -355,9 +318,9 @@ class Client(RequestListenerManager):
|
|
|
355
318
|
:raises TooManyRequestsError: Raised when the request status
|
|
356
319
|
code is 429
|
|
357
320
|
"""
|
|
358
|
-
response: Response = await self._http.
|
|
321
|
+
response: Response = await self._http.snapshot(app_id)
|
|
359
322
|
payload: dict[str, Any] = response.response
|
|
360
|
-
return
|
|
323
|
+
return Snapshot(**payload)
|
|
361
324
|
|
|
362
325
|
@validate
|
|
363
326
|
@_notify_listener(Endpoint.delete_app())
|
|
@@ -540,7 +503,7 @@ class Client(RequestListenerManager):
|
|
|
540
503
|
if not response.response:
|
|
541
504
|
return []
|
|
542
505
|
return [
|
|
543
|
-
FileInfo(**data, app_id=app_id, path=path + f"
|
|
506
|
+
FileInfo(**data, app_id=app_id, path=path + f"{data.get('name')}")
|
|
544
507
|
for data in response.response
|
|
545
508
|
]
|
|
546
509
|
|
|
@@ -733,21 +696,54 @@ class Client(RequestListenerManager):
|
|
|
733
696
|
response: Response = await self._http.domain_analytics(
|
|
734
697
|
app_id=app_id,
|
|
735
698
|
)
|
|
736
|
-
|
|
737
699
|
return DomainAnalytics(**response.response)
|
|
738
700
|
|
|
739
701
|
@validate
|
|
740
|
-
@_notify_listener(Endpoint.
|
|
702
|
+
@_notify_listener(Endpoint.all_snapshots())
|
|
703
|
+
@deprecated("this method will be removed in future versions, use the 'all_app_snapshots' method instead")
|
|
741
704
|
async def all_app_backups(
|
|
742
705
|
self, app_id: str, **_kwargs
|
|
743
|
-
) -> list[
|
|
744
|
-
response: Response = await self._http.
|
|
706
|
+
) -> list[SnapshotInfo]:
|
|
707
|
+
response: Response = await self._http.get_all_app_snapshots(
|
|
708
|
+
app_id=app_id
|
|
709
|
+
)
|
|
710
|
+
return [SnapshotInfo(**backup_data) for backup_data in response.response]
|
|
711
|
+
|
|
712
|
+
@validate
|
|
713
|
+
@_notify_listener(Endpoint.all_snapshots())
|
|
714
|
+
async def all_app_snapshots(
|
|
715
|
+
self, app_id: str, **_kwargs
|
|
716
|
+
) -> list[SnapshotInfo]:
|
|
717
|
+
"""
|
|
718
|
+
Retrieve all snapshots for a specific application.
|
|
719
|
+
This method fetches a list of snapshots associated with the
|
|
720
|
+
given application ID and returns them as a list of `SnapshotInfo` objects.
|
|
721
|
+
:param app_id: Specify the application by id.
|
|
722
|
+
:type app_id: str
|
|
723
|
+
:param _kwargs: Additional keyword arguments.
|
|
724
|
+
:type _kwargs: dict
|
|
725
|
+
:return: A list of `SnapshotInfo` objects representing the snapshots of
|
|
726
|
+
the specified application.
|
|
727
|
+
:rtype: list[SnapshotInfo]
|
|
728
|
+
"""
|
|
729
|
+
response: Response = await self._http.get_all_app_snapshots(
|
|
745
730
|
app_id=app_id
|
|
746
731
|
)
|
|
747
|
-
return [
|
|
732
|
+
return [SnapshotInfo(**snapshot_data) for snapshot_data in response.response]
|
|
748
733
|
|
|
749
734
|
@_notify_listener(Endpoint.all_apps_status())
|
|
750
735
|
async def all_apps_status(self, **_kwargs) -> list[ResumedStatus]:
|
|
736
|
+
"""
|
|
737
|
+
Retrieve the status of all applications.
|
|
738
|
+
This method fetches the status of all applications
|
|
739
|
+
and returns a list of `ResumedStatus` objects for applications
|
|
740
|
+
that are currently running.
|
|
741
|
+
:param _kwargs: Additional keyword arguments.
|
|
742
|
+
:type _kwargs: dict
|
|
743
|
+
:return: A list of `ResumedStatus` objects representing the status
|
|
744
|
+
of running applications.
|
|
745
|
+
:rtype: list[ResumedStatus]
|
|
746
|
+
"""
|
|
751
747
|
response: Response = await self._http.all_apps_status()
|
|
752
748
|
all_status = []
|
|
753
749
|
for status in response.response:
|
|
@@ -760,6 +756,19 @@ class Client(RequestListenerManager):
|
|
|
760
756
|
async def move_app_file(
|
|
761
757
|
self, app_id: str, origin: str, dest: str, **_kwargs
|
|
762
758
|
) -> Response:
|
|
759
|
+
"""
|
|
760
|
+
Moves a file within an application from the origin path to the destination path.
|
|
761
|
+
:param app_id: Specify the application by id.
|
|
762
|
+
:type app_id: str
|
|
763
|
+
:param origin: The current path of the file to be moved.
|
|
764
|
+
:type origin: str
|
|
765
|
+
:param dest: The target path where the file should be moved.
|
|
766
|
+
:type dest: str
|
|
767
|
+
:param _kwargs: Additional keyword arguments.
|
|
768
|
+
:type _kwargs: dict
|
|
769
|
+
:return: The response object containing the result of the move operation.
|
|
770
|
+
:rtype: Response
|
|
771
|
+
"""
|
|
763
772
|
response: Response = await self._http.move_app_file(
|
|
764
773
|
app_id=app_id, origin=origin, dest=dest
|
|
765
774
|
)
|
|
@@ -768,6 +777,14 @@ class Client(RequestListenerManager):
|
|
|
768
777
|
@validate
|
|
769
778
|
@_notify_listener(Endpoint.dns_records())
|
|
770
779
|
async def dns_records(self, app_id: str) -> list[DNSRecord]:
|
|
780
|
+
"""
|
|
781
|
+
Retrieve DNS records for a specific application.
|
|
782
|
+
:param app_id: Specify the application by id.
|
|
783
|
+
:type app_id: str
|
|
784
|
+
:return: A list of DNSRecord objects representing the DNS records of the application.
|
|
785
|
+
:rtype: list[DNSRecord]
|
|
786
|
+
"""
|
|
787
|
+
|
|
771
788
|
response: Response = await self._http.dns_records(app_id)
|
|
772
789
|
return [DNSRecord(**data) for data in response.response]
|
|
773
790
|
|
|
@@ -778,3 +795,76 @@ class Client(RequestListenerManager):
|
|
|
778
795
|
app_id
|
|
779
796
|
)
|
|
780
797
|
return response.response["webhook"]
|
|
798
|
+
|
|
799
|
+
async def get_app_envs(self, app_id: str) -> dict[str, str]:
|
|
800
|
+
"""
|
|
801
|
+
Retrieve the environment variables of a specific application.
|
|
802
|
+
:param app_id: Specify the application by id.
|
|
803
|
+
:type app_id: str
|
|
804
|
+
:return: A dictionary containing the environment variables as key-value pairs.
|
|
805
|
+
:rtype: dict[str, str]
|
|
806
|
+
"""
|
|
807
|
+
response: Response = await self._http.get_environment_variables(app_id)
|
|
808
|
+
return response.response
|
|
809
|
+
|
|
810
|
+
async def set_app_envs(self, app_id: str, envs: dict[str, str]) -> dict[str, str]:
|
|
811
|
+
"""
|
|
812
|
+
Sets or edits environment variables for a specific application.
|
|
813
|
+
This method sends a request to update the environment variables of the
|
|
814
|
+
specified application with the provided key-value pairs.
|
|
815
|
+
:param app_id: Specify the application by id.
|
|
816
|
+
:type app_id: str
|
|
817
|
+
:param envs: A dictionary containing the environment variables to set,
|
|
818
|
+
where the keys are variable names and the values are their
|
|
819
|
+
corresponding values.
|
|
820
|
+
:type envs: dict[str, str]
|
|
821
|
+
:return: A dictionary containing the updated environment with all variables.
|
|
822
|
+
:rtype: dict[str, str]
|
|
823
|
+
:raises HTTPException: If the HTTP request fails or returns an error response.
|
|
824
|
+
"""
|
|
825
|
+
|
|
826
|
+
response: Response = await self._http.set_environment_variable(app_id, envs)
|
|
827
|
+
return response.response
|
|
828
|
+
|
|
829
|
+
async def delete_app_envs(self, app_id: str, keys: list[str]) -> dict[str, str]:
|
|
830
|
+
"""
|
|
831
|
+
Deletes specified environment variables for a given application.
|
|
832
|
+
:param app_id: Specify the application by id.
|
|
833
|
+
:type app_id: str
|
|
834
|
+
:param keys: A list of keys representing the environment variables to be deleted.
|
|
835
|
+
:type keys: list[str]
|
|
836
|
+
:return: A dictionary containing the remaining variables.
|
|
837
|
+
:rtype: dict[str, str]
|
|
838
|
+
"""
|
|
839
|
+
response: Response = await self._http.delete_environment_variable(app_id, keys)
|
|
840
|
+
return response.response
|
|
841
|
+
|
|
842
|
+
async def overwrite_app_envs(self, app_id: str, envs: dict[str, str]) -> dict[str, str]:
|
|
843
|
+
"""
|
|
844
|
+
Overwrite the environment variables of a specific application.
|
|
845
|
+
This method sets the dictionary provided as the new environment for the application.
|
|
846
|
+
:param app_id: Specify the application by id.
|
|
847
|
+
:type app_id: str
|
|
848
|
+
:param envs: A dictionary containing the new environment variables to set
|
|
849
|
+
for the application. Keys and values must both be strings.
|
|
850
|
+
:type envs: dict[str, str]
|
|
851
|
+
:return: A dictionary containing the new environment after overwriting the
|
|
852
|
+
environment variables.
|
|
853
|
+
:rtype: dict[str, str]
|
|
854
|
+
"""
|
|
855
|
+
response: Response = await self._http.overwrite_environment_variables(app_id, envs)
|
|
856
|
+
return response.response
|
|
857
|
+
|
|
858
|
+
async def clear_app_envs(self, app_id: str) -> dict[str, str]:
|
|
859
|
+
"""
|
|
860
|
+
Clears all environment variables for the specified application.
|
|
861
|
+
This method overwrites the application's environment variables with an empty dictionary,
|
|
862
|
+
effectively removing all existing environment variables.
|
|
863
|
+
|
|
864
|
+
:param app_id: Specify the application by id.
|
|
865
|
+
:type app_id: str
|
|
866
|
+
:return: A dictionary containing the response from the server.
|
|
867
|
+
:rtype: dict[str, str]
|
|
868
|
+
"""
|
|
869
|
+
response: Response = await self._http.overwrite_environment_variables(app_id, {})
|
|
870
|
+
return response.response
|
|
@@ -195,19 +195,19 @@ class LogsData(BaseDataClass):
|
|
|
195
195
|
return isinstance(other, LogsData) and self.logs == other.logs
|
|
196
196
|
|
|
197
197
|
|
|
198
|
-
class
|
|
198
|
+
class SnapshotInfo(BaseDataClass):
|
|
199
199
|
name: str
|
|
200
200
|
size: int
|
|
201
201
|
modified: datetime
|
|
202
202
|
key: str
|
|
203
203
|
|
|
204
204
|
|
|
205
|
-
class
|
|
205
|
+
class Snapshot:
|
|
206
206
|
"""
|
|
207
|
-
|
|
207
|
+
Snapshot data class
|
|
208
208
|
|
|
209
|
-
:ivar url: Url for download your
|
|
210
|
-
:ivar key: The
|
|
209
|
+
:ivar url: Url for download your Snapshot
|
|
210
|
+
:ivar key: The Snapshot's key
|
|
211
211
|
|
|
212
212
|
:type url: str
|
|
213
213
|
:type key: str
|
|
@@ -219,12 +219,12 @@ class Backup:
|
|
|
219
219
|
self.url = url
|
|
220
220
|
self.key = key
|
|
221
221
|
|
|
222
|
-
def to_dict(self) ->
|
|
222
|
+
def to_dict(self) -> dict[str, str]:
|
|
223
223
|
return {'url': self.url, 'key': self.key}
|
|
224
224
|
|
|
225
225
|
async def download(self, path: str = './') -> zipfile.ZipFile:
|
|
226
226
|
file_name = os.path.basename(self.url.split('?')[0])
|
|
227
|
-
content = await HTTPClient.
|
|
227
|
+
content = await HTTPClient.fetch_snapshot_content(self.url)
|
|
228
228
|
with zipfile.ZipFile(f'{path}/{file_name}', 'w') as zip_file:
|
|
229
229
|
zip_file.writestr(f'{path}/{file_name}', content)
|
|
230
230
|
return zip_file
|
|
@@ -283,9 +283,9 @@ class FileInfo(BaseDataClass):
|
|
|
283
283
|
app_id: str
|
|
284
284
|
type: Literal['file', 'directory']
|
|
285
285
|
name: str
|
|
286
|
-
lastModified: int | float | None # noqa: N815: Ignore mixedCase naming convention
|
|
287
286
|
path: str
|
|
288
287
|
size: int = 0
|
|
288
|
+
lastModified: int | float | None = None # noqa: N815: Ignore mixedCase naming convention
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
class DeployData(BaseDataClass):
|
|
@@ -294,38 +294,48 @@ class DeployData(BaseDataClass):
|
|
|
294
294
|
date: datetime
|
|
295
295
|
|
|
296
296
|
|
|
297
|
-
class AnalyticsTotal(BaseDataClass):
|
|
298
|
-
visits: int
|
|
299
|
-
megabytes: float
|
|
300
|
-
bytes: int
|
|
301
|
-
|
|
302
|
-
|
|
303
297
|
class DomainAnalytics(BaseDataClass):
|
|
304
|
-
class
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
298
|
+
class BaseAnalytics(BaseDataClass):
|
|
299
|
+
visits: int
|
|
300
|
+
requests: int
|
|
301
|
+
bytes: int
|
|
302
|
+
date: str
|
|
303
|
+
@property
|
|
304
|
+
def date_time(self) -> datetime:
|
|
305
|
+
"retrieves the date as a datetime object"
|
|
306
|
+
return datetime.fromisoformat(self.date)
|
|
307
|
+
class ExtraBaseAnalytics(BaseAnalytics):
|
|
308
|
+
type: str
|
|
309
|
+
class Visits(BaseAnalytics):
|
|
310
|
+
pass
|
|
311
|
+
class Countries(ExtraBaseAnalytics):
|
|
312
|
+
pass
|
|
313
|
+
class Devices(ExtraBaseAnalytics):
|
|
314
|
+
pass
|
|
315
|
+
class Os(ExtraBaseAnalytics):
|
|
316
|
+
pass
|
|
317
|
+
class Browsers(ExtraBaseAnalytics):
|
|
318
|
+
pass
|
|
319
|
+
class Protocols(ExtraBaseAnalytics):
|
|
320
|
+
pass
|
|
321
|
+
class Methods(ExtraBaseAnalytics):
|
|
322
|
+
pass
|
|
323
|
+
class Paths(ExtraBaseAnalytics):
|
|
324
|
+
pass
|
|
325
|
+
class Referers(ExtraBaseAnalytics):
|
|
326
|
+
pass
|
|
327
|
+
class Providers(ExtraBaseAnalytics):
|
|
328
|
+
pass
|
|
329
|
+
visits: list[Visits]
|
|
330
|
+
countries: list[Countries]
|
|
331
|
+
devices: list[Devices]
|
|
332
|
+
os: list[Os]
|
|
333
|
+
browsers: list[Browsers]
|
|
334
|
+
protocols: list[Protocols]
|
|
335
|
+
methods: list[Methods]
|
|
336
|
+
paths: list[Paths]
|
|
337
|
+
referers: list[Referers]
|
|
338
|
+
providers: list[Providers]
|
|
329
339
|
|
|
330
340
|
|
|
331
341
|
class DNSRecord(BaseDataClass):
|
|
@@ -9,12 +9,12 @@ class Endpoint:
|
|
|
9
9
|
'APP_DATA': {'METHOD': 'GET', 'PATH': '/apps/{app_id}'},
|
|
10
10
|
'APP_STATUS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/status'},
|
|
11
11
|
'ALL_APPS_STATUS': {'METHOD': 'GET', 'PATH': '/apps/status'},
|
|
12
|
-
'
|
|
12
|
+
'ALL_SNAPSHOTS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/snapshots'},
|
|
13
13
|
'LOGS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/logs'},
|
|
14
14
|
'START': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/start'},
|
|
15
15
|
'STOP': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/stop'},
|
|
16
16
|
'RESTART': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/restart'},
|
|
17
|
-
'
|
|
17
|
+
'SNAPSHOT': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/snapshots'},
|
|
18
18
|
'COMMIT': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/commit'},
|
|
19
19
|
'DELETE_APP': {'METHOD': 'DELETE', 'PATH': '/apps/{app_id}'},
|
|
20
20
|
'UPLOAD_APP': {'METHOD': 'POST', 'PATH': '/apps'},
|
|
@@ -56,6 +56,10 @@ class Endpoint:
|
|
|
56
56
|
'PATH': '/apps/{app_id}/network/analytics',
|
|
57
57
|
},
|
|
58
58
|
'DNSRECORDS': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/network/dns'},
|
|
59
|
+
'ENVS_GET': {'METHOD': 'GET', 'PATH': '/apps/{app_id}/envs'},
|
|
60
|
+
'ENVS_PUT': {'METHOD': 'PUT', 'PATH': '/apps/{app_id}/envs'},
|
|
61
|
+
'ENVS_POST': {'METHOD': 'POST', 'PATH': '/apps/{app_id}/envs'},
|
|
62
|
+
'ENVS_DELETE': {'METHOD': 'DELETE', 'PATH': '/apps/{app_id}/envs'},
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
def __init__(self, name: str) -> None:
|
|
@@ -145,12 +149,12 @@ class Endpoint:
|
|
|
145
149
|
return cls('RESTART')
|
|
146
150
|
|
|
147
151
|
@classmethod
|
|
148
|
-
def
|
|
152
|
+
def snapshot(cls) -> Endpoint:
|
|
149
153
|
"""
|
|
150
154
|
Returns an Endpoint object that represents the
|
|
151
155
|
/apps/{app_id}/snapshots endpoint.
|
|
152
156
|
"""
|
|
153
|
-
return cls('
|
|
157
|
+
return cls('SNAPSHOT')
|
|
154
158
|
|
|
155
159
|
@classmethod
|
|
156
160
|
def commit(cls) -> Endpoint:
|
|
@@ -241,12 +245,12 @@ class Endpoint:
|
|
|
241
245
|
return cls('CUSTOM_DOMAIN')
|
|
242
246
|
|
|
243
247
|
@classmethod
|
|
244
|
-
def
|
|
248
|
+
def all_snapshots(cls) -> Endpoint:
|
|
245
249
|
"""
|
|
246
250
|
Returns an Endpoint object that represents the
|
|
247
251
|
/apps/{app_id}/snapshots endpoint.
|
|
248
252
|
"""
|
|
249
|
-
return cls('
|
|
253
|
+
return cls('ALL_SNAPSHOTS')
|
|
250
254
|
|
|
251
255
|
@classmethod
|
|
252
256
|
def all_apps_status(cls) -> Endpoint:
|
|
@@ -279,6 +283,38 @@ class Endpoint:
|
|
|
279
283
|
/apps/{app_id}/network/dns
|
|
280
284
|
"""
|
|
281
285
|
return cls('DNSRECORDS')
|
|
286
|
+
|
|
287
|
+
@classmethod
|
|
288
|
+
def envs_get(cls) -> Endpoint:
|
|
289
|
+
"""
|
|
290
|
+
Returns an Endpoint object that represents the
|
|
291
|
+
/apps/{app_id}/envs GET endpoint.
|
|
292
|
+
"""
|
|
293
|
+
return cls('ENVS_GET')
|
|
294
|
+
|
|
295
|
+
@classmethod
|
|
296
|
+
def envs_put(cls) -> Endpoint:
|
|
297
|
+
"""
|
|
298
|
+
Returns an Endpoint object that represents the
|
|
299
|
+
/apps/{app_id}/envs PUT endpoint.
|
|
300
|
+
"""
|
|
301
|
+
return cls('ENVS_PUT')
|
|
302
|
+
|
|
303
|
+
@classmethod
|
|
304
|
+
def envs_post(cls) -> Endpoint:
|
|
305
|
+
"""
|
|
306
|
+
Returns an Endpoint object that represents the
|
|
307
|
+
/apps/{app_id}/envs POST endpoint.
|
|
308
|
+
"""
|
|
309
|
+
return cls('ENVS_POST')
|
|
310
|
+
|
|
311
|
+
@classmethod
|
|
312
|
+
def envs_delete(cls) -> Endpoint:
|
|
313
|
+
"""
|
|
314
|
+
Returns an Endpoint object that represents the
|
|
315
|
+
/apps/{app_id}/envs DELETE endpoint.
|
|
316
|
+
"""
|
|
317
|
+
return cls('ENVS_DELETE')
|
|
282
318
|
|
|
283
319
|
|
|
284
320
|
# pylint: disable=too-few-public-methods
|
|
@@ -231,7 +231,7 @@ class HTTPClient:
|
|
|
231
231
|
return response
|
|
232
232
|
|
|
233
233
|
@classmethod
|
|
234
|
-
async def
|
|
234
|
+
async def fetch_snapshot_content(cls, url: str) -> bytes:
|
|
235
235
|
async with aiohttp.ClientSession() as session:
|
|
236
236
|
async with session.get(url) as response:
|
|
237
237
|
return await response.read()
|
|
@@ -348,7 +348,7 @@ class HTTPClient:
|
|
|
348
348
|
response: Response = await self.request(route)
|
|
349
349
|
return response
|
|
350
350
|
|
|
351
|
-
async def
|
|
351
|
+
async def snapshot(self, app_id: str) -> Response:
|
|
352
352
|
"""
|
|
353
353
|
Backup a hosted application
|
|
354
354
|
|
|
@@ -363,7 +363,7 @@ class HTTPClient:
|
|
|
363
363
|
:raises TooManyRequestsError: Raised when the request status
|
|
364
364
|
code is 429
|
|
365
365
|
"""
|
|
366
|
-
route: Router = Router(Endpoint.
|
|
366
|
+
route: Router = Router(Endpoint.snapshot(), app_id=app_id)
|
|
367
367
|
response: Response = await self.request(route)
|
|
368
368
|
return response
|
|
369
369
|
|
|
@@ -512,7 +512,7 @@ class HTTPClient:
|
|
|
512
512
|
"""
|
|
513
513
|
route: Router = Router(Endpoint.files_create(), app_id=app_id)
|
|
514
514
|
response: Response = await self.request(
|
|
515
|
-
route, json={'
|
|
515
|
+
route, json={'content': file, 'path': '/' + path}
|
|
516
516
|
)
|
|
517
517
|
return response
|
|
518
518
|
|
|
@@ -655,7 +655,7 @@ class HTTPClient:
|
|
|
655
655
|
response: Response = await self.request(route)
|
|
656
656
|
return response
|
|
657
657
|
|
|
658
|
-
async def
|
|
658
|
+
async def get_all_app_snapshots(self, app_id: str) -> Response:
|
|
659
659
|
"""
|
|
660
660
|
Returns a list of all backups of the specified application
|
|
661
661
|
|
|
@@ -669,7 +669,7 @@ class HTTPClient:
|
|
|
669
669
|
:raises TooManyRequestsError: Raised when the request status
|
|
670
670
|
code is 429
|
|
671
671
|
"""
|
|
672
|
-
route: Router = Router(Endpoint.
|
|
672
|
+
route: Router = Router(Endpoint.all_snapshots(), app_id=app_id)
|
|
673
673
|
response: Response = await self.request(route)
|
|
674
674
|
return response
|
|
675
675
|
|
|
@@ -757,3 +757,68 @@ class HTTPClient:
|
|
|
757
757
|
:rtype: Response | None
|
|
758
758
|
"""
|
|
759
759
|
return self._last_response
|
|
760
|
+
|
|
761
|
+
async def get_environment_variables(self, app_id: str) -> Response:
|
|
762
|
+
"""
|
|
763
|
+
Retrieve the environment variables for a specific application.
|
|
764
|
+
|
|
765
|
+
:param app_id: The unique identifier of the application.
|
|
766
|
+
:type app_id: str
|
|
767
|
+
:return: The response containing the environment variables.
|
|
768
|
+
:rtype: Response
|
|
769
|
+
"""
|
|
770
|
+
route: Router = Router(Endpoint.envs_get(), app_id=app_id)
|
|
771
|
+
response: Response = await self.request(route)
|
|
772
|
+
return response
|
|
773
|
+
|
|
774
|
+
async def set_environment_variable(self, app_id: str, keys: dict[str, str]) -> Response:
|
|
775
|
+
"""
|
|
776
|
+
Sets environment variables for a specific application.
|
|
777
|
+
This method sends a request to set the specified environment variables
|
|
778
|
+
for the application identified by the given `app_id`.
|
|
779
|
+
:param app_id: The ID of the application for which the environment
|
|
780
|
+
variables will be set.
|
|
781
|
+
:type app_id: str
|
|
782
|
+
:param keys: A dictionary containing the environment variable names
|
|
783
|
+
as keys and their corresponding values.
|
|
784
|
+
:type keys: dict[str, str]
|
|
785
|
+
:return: The response object containing the result of the operation.
|
|
786
|
+
:rtype: Response
|
|
787
|
+
"""
|
|
788
|
+
|
|
789
|
+
route: Router = Router(Endpoint.envs_post(), app_id=app_id)
|
|
790
|
+
response: Response = await self.request(route, json={"envs": keys})
|
|
791
|
+
return response
|
|
792
|
+
|
|
793
|
+
async def delete_environment_variable(self, app_id: str, keys: list[str]) -> Response:
|
|
794
|
+
"""
|
|
795
|
+
Deletes one or more environment variables for a specific application.
|
|
796
|
+
:param app_id: The ID of the application whose environment variables are to be deleted.
|
|
797
|
+
:type app_id: str
|
|
798
|
+
:param keys: A list of environment variable keys to be deleted.
|
|
799
|
+
:type keys: list[str]
|
|
800
|
+
:return: The response object containing the result of the deletion operation.
|
|
801
|
+
:rtype: Response
|
|
802
|
+
"""
|
|
803
|
+
route: Router = Router(Endpoint.envs_delete(), app_id=app_id)
|
|
804
|
+
response: Response = await self.request(route, json={"envs": keys})
|
|
805
|
+
return response
|
|
806
|
+
|
|
807
|
+
async def overwrite_environment_variables(self, app_id: str, keys: dict[str, str]) -> Response:
|
|
808
|
+
"""
|
|
809
|
+
Overwrites the environment variables for a specific application.
|
|
810
|
+
This method sends a request to update the environment variables of the
|
|
811
|
+
specified application with the provided key-value pairs.
|
|
812
|
+
:param app_id: The ID of the application whose environment variables
|
|
813
|
+
are to be overwritten.
|
|
814
|
+
:type app_id: str
|
|
815
|
+
:param keys: A dictionary containing the environment variable keys and
|
|
816
|
+
their corresponding values to be set.
|
|
817
|
+
:type keys: dict[str, str]
|
|
818
|
+
:return: The response object containing the result of the operation.
|
|
819
|
+
:rtype: Response
|
|
820
|
+
"""
|
|
821
|
+
|
|
822
|
+
route: Router = Router(Endpoint.envs_put(), app_id=app_id)
|
|
823
|
+
response: Response = await self.request(route, json={"envs": keys})
|
|
824
|
+
return response
|
|
@@ -15,7 +15,7 @@ ListenerDataTypes = Union[
|
|
|
15
15
|
data.AppData,
|
|
16
16
|
data.StatusData,
|
|
17
17
|
data.LogsData,
|
|
18
|
-
data.
|
|
18
|
+
data.Snapshot,
|
|
19
19
|
]
|
|
20
20
|
|
|
21
21
|
|
|
@@ -38,7 +38,7 @@ class CaptureListenerManager(ListenerManager):
|
|
|
38
38
|
allowed_endpoints: tuple[Endpoint, Endpoint, Endpoint, Endpoint] = (
|
|
39
39
|
Endpoint.logs(),
|
|
40
40
|
Endpoint.app_status(),
|
|
41
|
-
Endpoint.
|
|
41
|
+
Endpoint.snapshot(),
|
|
42
42
|
Endpoint.app_data(),
|
|
43
43
|
)
|
|
44
44
|
|
|
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
|
|
File without changes
|