from cloudera.ai.inference.api.serving_api import ServingApi
from cloudera.ai.inference.api_client import ApiClient
from cloudera.ai.inference.configuration import Configuration


def create_client(host: str, token: str, *, verify_ssl: bool = True) -> ServingApi:
    """Create an authenticated ServingApi client.

    Args:
        host: The service domain, e.g. "https://ml-abc123.example.com"
        token: Token for authentication
        verify_ssl: Whether to verify SSL certificates. Default True.

    Returns:
        An authenticated ServingApi instance ready to use.

    Example::

        from cloudera.ai.inference import create_client

        client = create_client(
            host="https://ml-abc123.example.com",
            token="<cdp-token>",
        )
        response = client.serving_list_endpoints(...)
    """
    config = Configuration(host=host)
    config.verify_ssl = verify_ssl
    return ServingApi(
        ApiClient(
            configuration=config,
            header_name="Authorization",
            header_value=f"Bearer {token}",
        )
    )
