Module coolipy.services.coolify_api.projects
Classes
class Projects (http_service: HttpService, base_service_url: str)
-
Handles operations related to projects in the Coolify API.
Initializes the Coolify API service with an HTTP service instance and a specific service URL.
Args
http_service
:HttpService
- Instance of the HttpService class for making HTTP requests.
base_service_url
:str
- The endpoint URL for the specific service (e.g., '/servers', '/teams').
Expand source code
class Projects(CoolifyApiBase): """ Handles operations related to projects in the Coolify API. """ def list(self) -> CoolifyAPIResponse: """ Retrieve all projects. Returns: CoolifyAPIResponse: Response containing a list of projects. """ content = self._http.get(self._base_url) return self._handle_response( content, return_type=COOLIFY_RETURN_TYPES.list, model=ProjectsModel ) def get(self, project_uuid: str) -> CoolifyAPIResponse: """ Retrieve a project by UUID. Args: project_uuid (str): The UUID of the project. Returns: CoolifyAPIResponse: Response containing the project details. """ content = self._http.get(f"{self._base_url}/{project_uuid}") return self._handle_response( content, return_type=COOLIFY_RETURN_TYPES.single, model=ProjectsModel ) def update( self, project_uuid: str, project_updated_description: str ) -> CoolifyAPIResponse: """ Update the description of a project. Args: project_uuid (str): The UUID of the project. project_updated_description (str): The new description for the project. Returns: CoolifyAPIResponse: Response from the API after updating the project. """ resp = self._http.patch( f"{self._base_url}/{project_uuid}", data=json.dumps({"description": project_updated_description}), ) return self._handle_response( resp, return_type=COOLIFY_RETURN_TYPES.single, model=ProjectsModel ) def delete(self, project_uuid: str) -> CoolifyAPIResponse: """ Delete a project by UUID. Args: project_uuid (str): The UUID of the project. Returns: CoolifyAPIResponse: Response from the API after deletion. """ resp = self._http.delete(f"{self._base_url}/{project_uuid}") return self._handle_response(resp, return_type=COOLIFY_RETURN_TYPES.raw) def environment( self, project_uuid: str, environment_name: str ) -> CoolifyAPIResponse: """ Retrieve environment details for a specific project. Args: project_uuid (str): The UUID of the project. environment_name (str): The name of the environment. Returns: CoolifyAPIResponse: Response containing the environment details. """ resp = self._http.get(f"{self._base_url}/{project_uuid}/{environment_name}") return self._handle_response( resp, return_type=COOLIFY_RETURN_TYPES.single, model=EnvironmentsModel ) def create(self, project_name: str, project_description: str) -> CoolifyAPIResponse: """ Create a new project. Args: project_name (str): The name of the new project. project_description (str): The description of the new project. Returns: CoolifyAPIResponse: Response containing the created project details. """ post_data = json.dumps( {"name": project_name, "description": project_description} ) resp = self._http.post(self._base_url, data=post_data) return self._handle_response( resp, return_type=COOLIFY_RETURN_TYPES.single, model=ProjectsModel )
Ancestors
Methods
def create(self, project_name: str, project_description: str) ‑> CoolifyAPIResponse
-
Create a new project.
Args
project_name
:str
- The name of the new project.
project_description
:str
- The description of the new project.
Returns
CoolifyAPIResponse
- Response containing the created project details.
def delete(self, project_uuid: str) ‑> CoolifyAPIResponse
-
Delete a project by UUID.
Args
project_uuid
:str
- The UUID of the project.
Returns
CoolifyAPIResponse
- Response from the API after deletion.
def environment(self, project_uuid: str, environment_name: str) ‑> CoolifyAPIResponse
-
Retrieve environment details for a specific project.
Args
project_uuid
:str
- The UUID of the project.
environment_name
:str
- The name of the environment.
Returns
CoolifyAPIResponse
- Response containing the environment details.
def get(self, project_uuid: str) ‑> CoolifyAPIResponse
-
Retrieve a project by UUID.
Args
project_uuid
:str
- The UUID of the project.
Returns
CoolifyAPIResponse
- Response containing the project details.
def list(self) ‑> CoolifyAPIResponse
-
Retrieve all projects.
Returns
CoolifyAPIResponse
- Response containing a list of projects.
def update(self, project_uuid: str, project_updated_description: str) ‑> CoolifyAPIResponse
-
Update the description of a project.
Args
project_uuid
:str
- The UUID of the project.
project_updated_description
:str
- The new description for the project.
Returns
CoolifyAPIResponse
- Response from the API after updating the project.