import logging from typing import Any, Dict from requests import Session # type: ignore from src.external_clients.authorization import BaseClient from src.external_clients.cms.client import Config from src.external_clients.cms.exceptions import CMSError log = logging.getLogger(__name__) class CMSClient(BaseClient): """Apollp API app_client.""" dna_prefix = "sme-dna|" error_cls = CMSError def __init__(self, session: Session, config: Config): super().__init__(session, config) async def check_health(self): return True def __update_user_id(self, user_id: str) -> str: return user_id if self.dna_prefix in user_id else self.dna_prefix + user_id def _make_end_url(self, url): return self.config.cms_service_url + url def _get(self, end_url: str, method: str = "GET"): return super()._make_request(end_url, method) def _post(self, end_url: str, data: Dict[str, Any], method: str = "POST"): return super()._make_request(end_url, method, body=data) def _put(self, end_url: str, data: Dict[str, Any], method: str = "PUT"): return super()._make_request(end_url, method, body=data) def _delete(self, end_url: str, data: Dict[str, Any], method: str = "DELETE"): return super()._make_request(end_url, method, body=data) def get_artist_objects(self): url = "artist_objects_list" end_url = self._make_end_url(url) return self._get(end_url) def get_label_objects(self): url = "label_objects_list" end_url = self._make_end_url(url) return self._get(end_url)