import requests from typing import Optional from datetime import datetime# from secnex.kit.config.config import Config from secnex.kit.models.tenant import Tenant class TenantClient: def __init__(self, config: Config) -> None: self.config = config def create(self, name: str) -> tuple[Optional[str], int, bool]: """Create a new tenant""" url = f"{self.config.host}/tenants" headers = { "Content-Type": "application/json", "Authorization": f"Bearer 1234567890", } response = requests.post(url, headers=headers, json={"name": name}) result = response.json() success = False tenant_id = None if "id" in result["body"]: success = True tenant_id = result["body"]["id"] return tenant_id, response.status_code, success def get_all(self) -> list[Tenant]: """Get all tenants""" url = f"{self.config.host}/tenants" headers = { "Content-Type": "application/json", "Authorization": f"Bearer 1234567890", } response = requests.get(url, headers=headers) result = response.json() tenants = result["body"]["tenants"] return [Tenant(**tenant) for tenant in tenants]