from typing import Any, Dict, List, Optional, Union
from metorial_util_endpoint import BaseMetorialEndpoint, MetorialEndpointManager, MetorialRequest
from ..resources import mapDashboardInstanceCustomProvidersDeploymentsListOutput, DashboardInstanceCustomProvidersDeploymentsListOutput, mapDashboardInstanceCustomProvidersDeploymentsListQuery, DashboardInstanceCustomProvidersDeploymentsListQuery, mapDashboardInstanceCustomProvidersDeploymentsGetOutput, DashboardInstanceCustomProvidersDeploymentsGetOutput, mapDashboardInstanceCustomProvidersDeploymentsGetLogsOutput, DashboardInstanceCustomProvidersDeploymentsGetLogsOutput

class MetorialDashboardInstanceCustomProvidersDeploymentsEndpoint(BaseMetorialEndpoint):
    """Deployments track the build and deployment process of custom provider versions. View deployment status and logs."""

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

    def list(self, instance_id: str, *, limit: Optional[float] = None, after: Optional[str] = None, before: Optional[str] = None, cursor: Optional[str] = None, order: Optional[str] = None, status: Optional[Union[str, List[str]]] = None, id: Optional[Union[str, List[str]]] = None, custom_provider_version_id: Optional[Union[str, List[str]]] = None, custom_provider_id: Optional[Union[str, List[str]]] = None, created_at: Optional[Dict[str, Any]] = None, updated_at: Optional[Dict[str, Any]] = None) -> DashboardInstanceCustomProvidersDeploymentsListOutput:
        """
    List custom provider deployments
    Returns a paginated list of deployments for a custom provider.

    :param instance_id: str
    :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 status: Optional[Union[str, List[str]]] (optional)
    :param id: Optional[Union[str, List[str]]] (optional)
    :param custom_provider_version_id: Optional[Union[str, List[str]]] (optional)
    :param custom_provider_id: Optional[Union[str, List[str]]] (optional)
    :param created_at: Optional[Dict[str, Any]] (optional)
    :param updated_at: Optional[Dict[str, Any]] (optional)
    :return: DashboardInstanceCustomProvidersDeploymentsListOutput
    """
        # 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
        if status is not None:
            query_dict["status"] = status
        if id is not None:
            query_dict["id"] = id
        if custom_provider_version_id is not None:
            query_dict["custom_provider_version_id"] = custom_provider_version_id
        if custom_provider_id is not None:
            query_dict["custom_provider_id"] = custom_provider_id
        if created_at is not None:
            query_dict["created_at"] = created_at
        if updated_at is not None:
            query_dict["updated_at"] = updated_at

        request = MetorialRequest(
            path=['dashboard', 'instances', instance_id, 'custom-provider-deployments'],
            query=query_dict
        )
        return self._get(request).transform(mapDashboardInstanceCustomProvidersDeploymentsListOutput.from_dict)

    def get(self, instance_id: str, custom_provider_deployment_id: str) -> DashboardInstanceCustomProvidersDeploymentsGetOutput:
        """
    Get custom provider deployment
    Retrieves a specific deployment.

    :param instance_id: str
    :param custom_provider_deployment_id: str
    :return: DashboardInstanceCustomProvidersDeploymentsGetOutput
    """
        request = MetorialRequest(
            path=['dashboard', 'instances', instance_id, 'custom-provider-deployments', custom_provider_deployment_id]
        )
        return self._get(request).transform(mapDashboardInstanceCustomProvidersDeploymentsGetOutput.from_dict)

    def get_logs(self, instance_id: str, custom_provider_deployment_id: str) -> DashboardInstanceCustomProvidersDeploymentsGetLogsOutput:
        """
    Get deployment logs
    Retrieves the build and deployment logs for a deployment.

    :param instance_id: str
    :param custom_provider_deployment_id: str
    :return: DashboardInstanceCustomProvidersDeploymentsGetLogsOutput
    """
        request = MetorialRequest(
            path=['dashboard', 'instances', instance_id, 'custom-provider-deployments', custom_provider_deployment_id, 'logs']
        )
        return self._get(request).transform(mapDashboardInstanceCustomProvidersDeploymentsGetLogsOutput.from_dict)