import copy
import datetime
from typing import Any, Iterator, Literal, Optional, Union

from lseg_analytics.core.common._resource_base import ResourceBase
from lseg_analytics.core.exceptions import (
    LibraryException,
    ResourceNotFound,
    check_exception_and_raise,
    check_id,
)

from lseg_analytics.pricing._client.client import Client
from lseg_analytics.pricing.async_handler._async_response import (
    AsyncPollingResponse,
    AsyncRequestResponse,
    check_async_polling_response,
    check_async_request_response,
)

from ._logger import logger

__all__ = ["polling"]


def polling(*, operation_id: str) -> AsyncPollingResponse:
    """
    Polling endpoint to get the status of the long-running operations.

    Parameters
    ----------
    operation_id : str
        The operation identifier.

    Returns
    --------
    AsyncPollingResponse


    Examples
    --------


    """

    try:
        logger.info("Calling polling")

        response = check_async_polling_response(Client().job_manager.polling(operation_id=operation_id))

        output = response
        logger.info("Called polling")

        return output
    except Exception as err:
        logger.error("Error polling.")
        check_exception_and_raise(err, logger)
