from typing import Any, Dict, List, Optional, Union
from metorial_util_endpoint import BaseMetorialEndpoint, MetorialEndpointManager, MetorialRequest
from ..resources import mapDashboardInstanceProvidersTriggersListOutput, DashboardInstanceProvidersTriggersListOutput, mapDashboardInstanceProvidersTriggersListQuery, DashboardInstanceProvidersTriggersListQuery, mapDashboardInstanceProvidersTriggersGetOutput, DashboardInstanceProvidersTriggersGetOutput

class MetorialProvidersTriggersEndpoint(BaseMetorialEndpoint):
    """A provider trigger describes an event source a provider can emit for callbacks. Use triggers to discover which callback subscriptions a provider version supports."""

    def __init__(self, config: MetorialEndpointManager):
        super().__init__(config)

    def list(self, *, provider_version_id: str, limit: Optional[float] = None, after: Optional[str] = None, before: Optional[str] = None, cursor: Optional[str] = None, order: Optional[str] = None) -> DashboardInstanceProvidersTriggersListOutput:
        """
    List provider triggers
    Returns a paginated list of provider triggers for a specific provider version.

    :param limit: Optional[float] (optional)
    :param after: Optional[str] (optional)
    :param before: Optional[str] (optional)
    :param cursor: Optional[str] (optional)
    :param order: Optional[str] (optional)
    :param provider_version_id: str
    :return: DashboardInstanceProvidersTriggersListOutput
    """
        # Build query parameters from keyword arguments
        query_dict = {}
        if limit is not None:
            query_dict["limit"] = limit
        if after is not None:
            query_dict["after"] = after
        if before is not None:
            query_dict["before"] = before
        if cursor is not None:
            query_dict["cursor"] = cursor
        if order is not None:
            query_dict["order"] = order
        query_dict["provider_version_id"] = provider_version_id

        request = MetorialRequest(
            path=['provider-triggers'],
            query=query_dict
        )
        return self._get(request).transform(mapDashboardInstanceProvidersTriggersListOutput.from_dict)

    def get(self, provider_trigger_id: str) -> DashboardInstanceProvidersTriggersGetOutput:
        """
    Get provider trigger
    Retrieves a specific provider trigger by ID.

    :param provider_trigger_id: str
    :return: DashboardInstanceProvidersTriggersGetOutput
    """
        request = MetorialRequest(
            path=['provider-triggers', provider_trigger_id]
        )
        return self._get(request).transform(mapDashboardInstanceProvidersTriggersGetOutput.from_dict)