from infra.log.module_logger import ModuleLogger from typing import Optional class CodeDepotHandler: def __init__(self) -> None: self.module_logger = ModuleLogger(sender_id="CodeDepotManager") async def check_depot_name_availabe(self, code_depot_name: str) -> bool: pass def check_code_depot_exist(self, code_depot_name: str) -> bool: pass async def __generate_new_code_depot_name( self, code_depot_name: str, gitea_code_depot_names: list[str] ) -> str: pass async def create_code_depot(self, product_id, code_depot_name) -> Optional[str]: pass def get_depot_ssh_url(self, code_depot_name: str) -> str: """Return the ssh url of the code depot Parameters: depot_name (str): the name of the depot Returns: str: the ssh url of the code depot """ if self.code_depot_ssh_port != "22": return f"git@{self.code_depot_domain_name}:{self.code_depot_ssh_port}/{self.gitea_org}/{code_depot_name}.git" else: return f"git@{self.code_depot_domain_name}/{self.gitea_org}/{code_depot_name}.git" def get_depot_http_url(self, code_depot_name: str) -> str: """Return the http url of the code depot Parameters: depot_name (str): the name of the depot Returns: str: the http url of the code depot """ if self.code_depot_http_port in ["443", "3443"]: return f"https://{self.code_depot_domain_name}:{self.code_depot_http_port}/{self.gitea_org}/{code_depot_name}.git" else: return f"http://{self.code_depot_domain_name}:{self.code_depot_http_port}/{self.gitea_org}/{code_depot_name}.git" def get_depot_http_url_with_user_name( self, code_depot_name: str, user_name: str ) -> str: """Return the http url of the code depot Parameters: depot_name (str): the name of the depot Returns: str: the http url of the code depot """ if self.code_depot_http_port in ["443", "3443"]: return f"https://{user_name}@{self.code_depot_domain_name}:{self.code_depot_http_port}/{self.gitea_org}/{code_depot_name}.git" else: return f"http://{user_name}@{self.code_depot_domain_name}:{self.code_depot_http_port}/{self.gitea_org}/{code_depot_name}.git" async def get_depot_users(self, code_depot_name: str) -> list[str]: pass async def update_depot_user_password(self, user_name: str, password: str) -> bool: pass async def create_depot_user( self, user_name: str, password: str, email: str ) -> bool: pass async def grant_user_depot_access( self, user_name: str, code_depot_name: str ) -> bool: pass async def generate_statistic_result( self, code_depot_name: str ) -> Optional[dict[str, any]]: pass async def analyze_code_depots(self): pass async def fetch_code_depot(self, code_depot_id: str) -> Optional[dict[str, any]]: pass