-
Notifications
You must be signed in to change notification settings - Fork 0
/
extensions_client.py
31 lines (27 loc) · 1.28 KB
/
extensions_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from base_plesk_client import BasePleskClient
from plesk_api_error import PleskAPIError, PleskAPIErrorCode
class ExtensionsClient(BasePleskClient):
"""Client for extensions-related API calls."""
def get_extensions(self):
"""Fetches installed extensions."""
return self.send_request("extensions")
def get_extension_detail(self, extension_id):
"""Fetches detailed information about a specific installed extension."""
endpoint = "extensions" # Specify the endpoint being called
if not extension_id:
# Include endpoint and request data (extension_id) in the error message
raise PleskAPIError(
message="Extension ID must be provided",
status_code=PleskAPIErrorCode.EXTENSION_ERROR.value, # Example status code
endpoint=endpoint,
request_data={"extension_id": extension_id}
)
try:
return self.send_request(f"{endpoint}/{extension_id}")
except Exception as e:
# Catch potential exceptions and raise them as PleskAPIError with context
raise PleskAPIError(
message=str(e),
endpoint=endpoint,
request_data={"extension_id": extension_id}
) from e