"""
Fluent accessor classes for UseCase resources.

Auto-generated from OpenAPI specification.
"""

from typing import TYPE_CHECKING, Any, Dict, Optional, Union

from ..models import (
    ModelResponse,
    PaginatedResponse,
    PolicyPackAttachment,
    PolicyPackAttachmentResponse,
    QuestionnaireAttachment,
    QuestionnaireAttachmentResponse,
    RiskControlLinkCreate,
    RiskControlLinkResponse,
    UseCaseControlResponse,
    UseCaseRiskScenarioCreate,
    UseCaseRiskScenarioResponse,
    UseCaseWorkflowResponse,
    UseCaseWorkflowUpdate,
    VendorResponse,
)

if TYPE_CHECKING:
    from ..client import AsyncCredoAI, CredoAI


# =============================================================================
# UseCase Fluent Accessors (Sync)
# =============================================================================


class UseCaseControlsAccessor:
    """Manage controls for a specific use_case.

    This accessor provides methods to list, patch
    controls associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").controls.list()
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the controls accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[UseCaseControlResponse]":
        """List controls associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing UseCaseControlResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/controls",
            params=params if params else None,
            response_model=PaginatedResponse[UseCaseControlResponse],
        )


class UseCasePolicyPacksAccessor:
    """Manage policy_packs for a specific use_case.

    This accessor provides methods to add, list, patch, remove
    policy_packs associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").policy_packs.list()
        >>> client.use_case("use_case-id").policy_packs.add("policy_pack-id")
        >>> client.use_case("use_case-id").policy_packs.remove("policy_pack-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the policy_packs accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[PolicyPackAttachmentResponse]":
        """List policy_packs associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing PolicyPackAttachmentResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/policy_packs",
            params=params if params else None,
            response_model=PaginatedResponse[PolicyPackAttachmentResponse],
        )

    def add(
        self, policy_pack: "Union[PolicyPackAttachment, PolicyPackAttachmentResponse]"
    ) -> "PolicyPackAttachmentResponse":
        """Add a policy_pack to this use_case.

        Args:
            policy_pack: A PolicyPackAttachment object, or a PolicyPackAttachmentResponse to extract fields from

        Returns:
            PolicyPackAttachmentResponse: The added policy_pack

        Examples:
            >>> # Using request model directly
            >>> use_case.policy_packs.add(PolicyPackAttachment(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.policy_packs.get("id")
            >>> use_case.policy_packs.add(fetched)
        """
        if isinstance(policy_pack, PolicyPackAttachment):
            data = policy_pack
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(policy_pack, field)
                for field in PolicyPackAttachment.model_fields
                if hasattr(policy_pack, field)
            }
            data = PolicyPackAttachment(**field_values)

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/policy_packs",
            data=data,
            response_model=PolicyPackAttachmentResponse,
        )

    def remove(self, policy_pack_id: str) -> None:
        """Remove a policy_pack from this use_case.

        Args:
            policy_pack_id: The ID of the policy_pack to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/policy_packs/{policy_pack_id}",
        )


class UseCaseQuestionnairesAccessor:
    """Manage questionnaires for a specific use_case.

    This accessor provides methods to add, list, patch, remove
    questionnaires associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").questionnaires.list()
        >>> client.use_case("use_case-id").questionnaires.add(QuestionnaireAttachment(key="...", version=1))
        >>> client.use_case("use_case-id").questionnaires.remove("questionnaire-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the questionnaires accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[QuestionnaireAttachmentResponse]":
        """List questionnaires associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing QuestionnaireAttachmentResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/questionnaires",
            params=params if params else None,
            response_model=PaginatedResponse[QuestionnaireAttachmentResponse],
        )

    def add(
        self,
        questionnaire: "Union[QuestionnaireAttachment, QuestionnaireAttachmentResponse]",
    ) -> "QuestionnaireAttachmentResponse":
        """Add a questionnaire to this use_case.

        Args:
            questionnaire: A QuestionnaireAttachment object, or a QuestionnaireAttachmentResponse to extract fields from

        Returns:
            QuestionnaireAttachmentResponse: The added questionnaire

        Examples:
            >>> # Using request model directly
            >>> use_case.questionnaires.add(QuestionnaireAttachment(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.questionnaires.get("id")
            >>> use_case.questionnaires.add(fetched)
        """
        if isinstance(questionnaire, QuestionnaireAttachment):
            data = questionnaire
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(questionnaire, field)
                for field in QuestionnaireAttachment.model_fields
                if hasattr(questionnaire, field)
            }
            data = QuestionnaireAttachment(**field_values)

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/questionnaires",
            data=data,
            response_model=QuestionnaireAttachmentResponse,
        )

    def remove(self, questionnaire_id: str) -> None:
        """Remove a questionnaire from this use_case.

        Args:
            questionnaire_id: The ID of the questionnaire to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/questionnaires/{questionnaire_id}",
        )


class UseCaseModelsAccessor:
    """Manage models for a specific use_case.

    This accessor provides methods to add, list, remove
    models associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").models.list()
        >>> client.use_case("use_case-id").models.add("model-id")
        >>> client.use_case("use_case-id").models.remove("model-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the models accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[ModelResponse]":
        """List models associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing ModelResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/models",
            params=params if params else None,
            response_model=PaginatedResponse[ModelResponse],
        )

    def add(self, model: "Union[str, ModelResponse]") -> "ModelResponse":
        """Add a model to this use_case.

        Args:
            model: The model ID as a string, or a ModelResponse object

        Returns:
            ModelResponse: The added model

        Examples:
            >>> # Using ID directly
            >>> use_case.models.add("model-123")
            >>> # Using a fetched/created response object
            >>> created = client.models.create(...)
            >>> use_case.models.add(created)
        """
        model_id = model if isinstance(model, str) else model.id

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/models",
            data={"id": model_id},
            response_model=ModelResponse,
        )

    def remove(self, model_id: str) -> None:
        """Remove a model from this use_case.

        Args:
            model_id: The ID of the model to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/models/{model_id}",
        )


class UseCaseVendorsAccessor:
    """Manage vendors for a specific use_case.

    This accessor provides methods to add, list, remove
    vendors associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").vendors.list()
        >>> client.use_case("use_case-id").vendors.add("vendor-id")
        >>> client.use_case("use_case-id").vendors.remove("vendor-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the vendors accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[VendorResponse]":
        """List vendors associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing VendorResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/vendors",
            params=params if params else None,
            response_model=PaginatedResponse[VendorResponse],
        )

    def add(self, vendor: "Union[str, VendorResponse]") -> "VendorResponse":
        """Add a vendor to this use_case.

        Args:
            vendor: The vendor ID as a string, or a VendorResponse object

        Returns:
            VendorResponse: The added vendor

        Examples:
            >>> # Using ID directly
            >>> use_case.vendors.add("vendor-123")
            >>> # Using a fetched/created response object
            >>> created = client.vendors.create(...)
            >>> use_case.vendors.add(created)
        """
        vendor_id = vendor if isinstance(vendor, str) else vendor.id

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/vendors",
            data={"id": vendor_id},
            response_model=VendorResponse,
        )

    def remove(self, vendor_id: str) -> None:
        """Remove a vendor from this use_case.

        Args:
            vendor_id: The ID of the vendor to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/vendors/{vendor_id}",
        )


class UseCaseRiskScenariosAccessor:
    """Manage risk_scenarios for a specific use_case.

    This accessor provides methods to add, list, patch, remove
    risk_scenarios associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").risk_scenarios.list()
        >>> client.use_case("use_case-id").risk_scenarios.add("risk_scenario-id")
        >>> client.use_case("use_case-id").risk_scenarios.remove("risk_scenario-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the risk_scenarios accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[UseCaseRiskScenarioResponse]":
        """List risk_scenarios associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing UseCaseRiskScenarioResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios",
            params=params if params else None,
            response_model=PaginatedResponse[UseCaseRiskScenarioResponse],
        )

    def add(
        self,
        risk_scenario: "Union[UseCaseRiskScenarioCreate, UseCaseRiskScenarioResponse]",
    ) -> "UseCaseRiskScenarioResponse":
        """Add a risk_scenario to this use_case.

        Args:
            risk_scenario: A UseCaseRiskScenarioCreate object, or a UseCaseRiskScenarioResponse to extract fields from

        Returns:
            UseCaseRiskScenarioResponse: The added risk_scenario

        Examples:
            >>> # Using request model directly
            >>> use_case.risk_scenarios.add(UseCaseRiskScenarioCreate(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.risk_scenarios.get("id")
            >>> use_case.risk_scenarios.add(fetched)
        """
        if isinstance(risk_scenario, UseCaseRiskScenarioCreate):
            data = risk_scenario
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(risk_scenario, field)
                for field in UseCaseRiskScenarioCreate.model_fields
                if hasattr(risk_scenario, field)
            }
            data = UseCaseRiskScenarioCreate(**field_values)

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios",
            data=data,
            response_model=UseCaseRiskScenarioResponse,
        )

    def remove(self, risk_scenario_id: str) -> None:
        """Remove a risk_scenario from this use_case.

        Args:
            risk_scenario_id: The ID of the risk_scenario to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios/{risk_scenario_id}",
        )


class UseCaseRiskControlLinksAccessor:
    """Manage risk_control_links for a specific use_case.

    This accessor provides methods to add, list, remove
    risk_control_links associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").risk_control_links.list()
        >>> client.use_case("use_case-id").risk_control_links.add("risk_control_link-id")
        >>> client.use_case("use_case-id").risk_control_links.remove("risk_control_link-id")
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the risk_control_links accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[RiskControlLinkResponse]":
        """List risk_control_links associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing RiskControlLinkResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/risk_control_links",
            params=params if params else None,
            response_model=PaginatedResponse[RiskControlLinkResponse],
        )

    def add(
        self, risk_control_link: "Union[RiskControlLinkCreate, RiskControlLinkResponse]"
    ) -> "RiskControlLinkResponse":
        """Add a risk_control_link to this use_case.

        Args:
            risk_control_link: A RiskControlLinkCreate object, or a RiskControlLinkResponse to extract fields from

        Returns:
            RiskControlLinkResponse: The added risk_control_link

        Examples:
            >>> # Using request model directly
            >>> use_case.risk_control_links.add(RiskControlLinkCreate(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.risk_control_links.get("id")
            >>> use_case.risk_control_links.add(fetched)
        """
        if isinstance(risk_control_link, RiskControlLinkCreate):
            data = risk_control_link
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(risk_control_link, field)
                for field in RiskControlLinkCreate.model_fields
                if hasattr(risk_control_link, field)
            }
            data = RiskControlLinkCreate(**field_values)

        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/risk_control_links",
            data=data,
            response_model=RiskControlLinkResponse,
        )

    def remove(self, risk_control_link_id: str) -> None:
        """Remove a risk_control_link from this use_case.

        Args:
            risk_control_link_id: The ID of the risk_control_link to remove
        """
        self._client._make_request(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/risk_control_links/{risk_control_link_id}",
        )


class UseCaseWorkflowAccessor:
    """Access workflow for a specific use_case.

    This accessor provides methods to get, update
    the workflow associated with a use_case.

    Example:
        >>> client.use_case("use_case-id").workflow.get()
        >>> client.use_case("use_case-id").workflow.update(UseCaseWorkflowUpdate(...))
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the workflow accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    def get(self) -> "UseCaseWorkflowResponse":
        """Get the workflow for this use_case.

        Returns:
            UseCaseWorkflowResponse: The workflow data
        """
        return self._client._make_request(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/workflow",
            response_model=UseCaseWorkflowResponse,
        )

    def update(self, data: "UseCaseWorkflowUpdate") -> "UseCaseWorkflowResponse":
        """Update the workflow for this use_case.

        Args:
            data: The update data

        Returns:
            UseCaseWorkflowResponse: The updated workflow data
        """
        return self._client._make_request(
            method="PATCH",
            url=f"/use_cases/{self._use_case_id}/workflow",
            data=data,
            response_model=UseCaseWorkflowResponse,
        )

    def advance_step(self) -> "UseCaseWorkflowResponse":
        """Advance Use Case Workflow Step.

                Advance to the next step within the current workflow stage.

        Step progression: assessment → evidence_collection → clear

        Returns an error if already at a terminal step (clear or rejected).

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/advance_step",
            response_model=UseCaseWorkflowResponse,
        )

    def advance_stage(self) -> "UseCaseWorkflowResponse":
        """Advance Use Case Workflow Stage.

                Advance to the next workflow stage, resetting to assessment step.

        Uses the child_id of the current stage to determine the next stage.
        Returns an error if at the end stage or no next stage is defined.

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/advance_stage",
            response_model=UseCaseWorkflowResponse,
        )

    def reject(self) -> "UseCaseWorkflowResponse":
        """Reject Use Case in Workflow.

                Reject a use case by setting its workflow step to 'rejected'.

        The rejected step is a terminal state - the use case cannot progress
        further in the workflow until it is moved back to an earlier step.
        Returns an error if the use case is already in the rejected state.

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return self._client._make_request(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/reject",
            response_model=UseCaseWorkflowResponse,
        )


class UseCase:
    """Fluent accessor for a specific use_case.

    Provides access to related resources through property accessors that enable
    intuitive chaining.

    Example:
        >>> use_case = client.use_case("use_case-id")
        >>> use_case.controls.list()
        >>> use_case.policy_packs.list()
        >>> use_case.policy_packs.add("policy_pack-id")
        >>> use_case.questionnaires.list()
        >>> use_case.questionnaires.add(QuestionnaireAttachment(key="...", version=1))
        >>> use_case.models.list()
        >>> use_case.models.add("model-id")
        >>> use_case.vendors.list()
        >>> use_case.vendors.add("vendor-id")
        >>> use_case.risk_scenarios.list()
        >>> use_case.risk_scenarios.add("risk_scenario-id")
        >>> use_case.risk_control_links.list()
        >>> use_case.risk_control_links.add("risk_control_link-id")
        >>> use_case.workflow.get()
        >>> use_case.workflow.update(UseCaseWorkflowUpdate(...))
    """

    def __init__(self, client: "CredoAI", use_case_id: str):
        """Initialize the use_case accessor.

        Args:
            client: The CredoAI client instance
            use_case_id: The ID of the use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    @property
    def controls(self) -> "UseCaseControlsAccessor":
        """Access controls associated with this use_case.

        Returns:
            UseCaseControlsAccessor: Accessor for controls operations
        """
        return UseCaseControlsAccessor(self._client, self._use_case_id)

    @property
    def policy_packs(self) -> "UseCasePolicyPacksAccessor":
        """Access policy_packs associated with this use_case.

        Returns:
            UseCasePolicyPacksAccessor: Accessor for policy_packs operations
        """
        return UseCasePolicyPacksAccessor(self._client, self._use_case_id)

    @property
    def questionnaires(self) -> "UseCaseQuestionnairesAccessor":
        """Access questionnaires associated with this use_case.

        Returns:
            UseCaseQuestionnairesAccessor: Accessor for questionnaires operations
        """
        return UseCaseQuestionnairesAccessor(self._client, self._use_case_id)

    @property
    def models(self) -> "UseCaseModelsAccessor":
        """Access models associated with this use_case.

        Returns:
            UseCaseModelsAccessor: Accessor for models operations
        """
        return UseCaseModelsAccessor(self._client, self._use_case_id)

    @property
    def vendors(self) -> "UseCaseVendorsAccessor":
        """Access vendors associated with this use_case.

        Returns:
            UseCaseVendorsAccessor: Accessor for vendors operations
        """
        return UseCaseVendorsAccessor(self._client, self._use_case_id)

    @property
    def risk_scenarios(self) -> "UseCaseRiskScenariosAccessor":
        """Access risk_scenarios associated with this use_case.

        Returns:
            UseCaseRiskScenariosAccessor: Accessor for risk_scenarios operations
        """
        return UseCaseRiskScenariosAccessor(self._client, self._use_case_id)

    @property
    def risk_control_links(self) -> "UseCaseRiskControlLinksAccessor":
        """Access risk_control_links associated with this use_case.

        Returns:
            UseCaseRiskControlLinksAccessor: Accessor for risk_control_links operations
        """
        return UseCaseRiskControlLinksAccessor(self._client, self._use_case_id)

    @property
    def workflow(self) -> "UseCaseWorkflowAccessor":
        """Access workflow associated with this use_case.

        Returns:
            UseCaseWorkflowAccessor: Accessor for workflow operations
        """
        return UseCaseWorkflowAccessor(self._client, self._use_case_id)


# =============================================================================
# UseCase Fluent Accessors (Async)
# =============================================================================


class AsyncUseCaseControlsAccessor:
    """Async manage controls for a specific use_case.

    This accessor provides async methods to list, patch
    controls associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").controls.list()
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async controls accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[UseCaseControlResponse]":
        """List controls associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing UseCaseControlResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/controls",
            params=params if params else None,
            response_model=PaginatedResponse[UseCaseControlResponse],
        )


class AsyncUseCasePolicyPacksAccessor:
    """Async manage policy_packs for a specific use_case.

    This accessor provides async methods to add, list, patch, remove
    policy_packs associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").policy_packs.list()
        >>> await client.use_case("use_case-id").policy_packs.add("policy_pack-id")
        >>> await client.use_case("use_case-id").policy_packs.remove("policy_pack-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async policy_packs accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[PolicyPackAttachmentResponse]":
        """List policy_packs associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing PolicyPackAttachmentResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/policy_packs",
            params=params if params else None,
            response_model=PaginatedResponse[PolicyPackAttachmentResponse],
        )

    async def add(
        self, policy_pack: "Union[PolicyPackAttachment, PolicyPackAttachmentResponse]"
    ) -> "PolicyPackAttachmentResponse":
        """Add a policy_pack to this use_case.

        Args:
            policy_pack: A PolicyPackAttachment object, or a PolicyPackAttachmentResponse to extract fields from

        Returns:
            PolicyPackAttachmentResponse: The added policy_pack

        Examples:
            >>> # Using request model directly
            >>> use_case.policy_packs.add(PolicyPackAttachment(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.policy_packs.get("id")
            >>> use_case.policy_packs.add(fetched)
        """
        if isinstance(policy_pack, PolicyPackAttachment):
            data = policy_pack
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(policy_pack, field)
                for field in PolicyPackAttachment.model_fields
                if hasattr(policy_pack, field)
            }
            data = PolicyPackAttachment(**field_values)

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/policy_packs",
            data=data,
            response_model=PolicyPackAttachmentResponse,
        )

    async def remove(self, policy_pack_id: str) -> None:
        """Remove a policy_pack from this use_case.

        Args:
            policy_pack_id: The ID of the policy_pack to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/policy_packs/{policy_pack_id}",
        )


class AsyncUseCaseQuestionnairesAccessor:
    """Async manage questionnaires for a specific use_case.

    This accessor provides async methods to add, list, patch, remove
    questionnaires associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").questionnaires.list()
        >>> await client.use_case("use_case-id").questionnaires.add(QuestionnaireAttachment(key="...", version=1))
        >>> await client.use_case("use_case-id").questionnaires.remove("questionnaire-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async questionnaires accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[QuestionnaireAttachmentResponse]":
        """List questionnaires associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing QuestionnaireAttachmentResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/questionnaires",
            params=params if params else None,
            response_model=PaginatedResponse[QuestionnaireAttachmentResponse],
        )

    async def add(
        self,
        questionnaire: "Union[QuestionnaireAttachment, QuestionnaireAttachmentResponse]",
    ) -> "QuestionnaireAttachmentResponse":
        """Add a questionnaire to this use_case.

        Args:
            questionnaire: A QuestionnaireAttachment object, or a QuestionnaireAttachmentResponse to extract fields from

        Returns:
            QuestionnaireAttachmentResponse: The added questionnaire

        Examples:
            >>> # Using request model directly
            >>> use_case.questionnaires.add(QuestionnaireAttachment(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.questionnaires.get("id")
            >>> use_case.questionnaires.add(fetched)
        """
        if isinstance(questionnaire, QuestionnaireAttachment):
            data = questionnaire
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(questionnaire, field)
                for field in QuestionnaireAttachment.model_fields
                if hasattr(questionnaire, field)
            }
            data = QuestionnaireAttachment(**field_values)

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/questionnaires",
            data=data,
            response_model=QuestionnaireAttachmentResponse,
        )

    async def remove(self, questionnaire_id: str) -> None:
        """Remove a questionnaire from this use_case.

        Args:
            questionnaire_id: The ID of the questionnaire to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/questionnaires/{questionnaire_id}",
        )


class AsyncUseCaseModelsAccessor:
    """Async manage models for a specific use_case.

    This accessor provides async methods to add, list, remove
    models associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").models.list()
        >>> await client.use_case("use_case-id").models.add("model-id")
        >>> await client.use_case("use_case-id").models.remove("model-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async models accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[ModelResponse]":
        """List models associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing ModelResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/models",
            params=params if params else None,
            response_model=PaginatedResponse[ModelResponse],
        )

    async def add(self, model: "Union[str, ModelResponse]") -> "ModelResponse":
        """Add a model to this use_case.

        Args:
            model: The model ID as a string, or a ModelResponse object

        Returns:
            ModelResponse: The added model

        Examples:
            >>> # Using ID directly
            >>> use_case.models.add("model-123")
            >>> # Using a fetched/created response object
            >>> created = client.models.create(...)
            >>> use_case.models.add(created)
        """
        model_id = model if isinstance(model, str) else model.id

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/models",
            data={"id": model_id},
            response_model=ModelResponse,
        )

    async def remove(self, model_id: str) -> None:
        """Remove a model from this use_case.

        Args:
            model_id: The ID of the model to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/models/{model_id}",
        )


class AsyncUseCaseVendorsAccessor:
    """Async manage vendors for a specific use_case.

    This accessor provides async methods to add, list, remove
    vendors associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").vendors.list()
        >>> await client.use_case("use_case-id").vendors.add("vendor-id")
        >>> await client.use_case("use_case-id").vendors.remove("vendor-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async vendors accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[VendorResponse]":
        """List vendors associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing VendorResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/vendors",
            params=params if params else None,
            response_model=PaginatedResponse[VendorResponse],
        )

    async def add(self, vendor: "Union[str, VendorResponse]") -> "VendorResponse":
        """Add a vendor to this use_case.

        Args:
            vendor: The vendor ID as a string, or a VendorResponse object

        Returns:
            VendorResponse: The added vendor

        Examples:
            >>> # Using ID directly
            >>> use_case.vendors.add("vendor-123")
            >>> # Using a fetched/created response object
            >>> created = client.vendors.create(...)
            >>> use_case.vendors.add(created)
        """
        vendor_id = vendor if isinstance(vendor, str) else vendor.id

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/vendors",
            data={"id": vendor_id},
            response_model=VendorResponse,
        )

    async def remove(self, vendor_id: str) -> None:
        """Remove a vendor from this use_case.

        Args:
            vendor_id: The ID of the vendor to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/vendors/{vendor_id}",
        )


class AsyncUseCaseRiskScenariosAccessor:
    """Async manage risk_scenarios for a specific use_case.

    This accessor provides async methods to add, list, patch, remove
    risk_scenarios associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").risk_scenarios.list()
        >>> await client.use_case("use_case-id").risk_scenarios.add("risk_scenario-id")
        >>> await client.use_case("use_case-id").risk_scenarios.remove("risk_scenario-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async risk_scenarios accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[UseCaseRiskScenarioResponse]":
        """List risk_scenarios associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing UseCaseRiskScenarioResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios",
            params=params if params else None,
            response_model=PaginatedResponse[UseCaseRiskScenarioResponse],
        )

    async def add(
        self,
        risk_scenario: "Union[UseCaseRiskScenarioCreate, UseCaseRiskScenarioResponse]",
    ) -> "UseCaseRiskScenarioResponse":
        """Add a risk_scenario to this use_case.

        Args:
            risk_scenario: A UseCaseRiskScenarioCreate object, or a UseCaseRiskScenarioResponse to extract fields from

        Returns:
            UseCaseRiskScenarioResponse: The added risk_scenario

        Examples:
            >>> # Using request model directly
            >>> use_case.risk_scenarios.add(UseCaseRiskScenarioCreate(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.risk_scenarios.get("id")
            >>> use_case.risk_scenarios.add(fetched)
        """
        if isinstance(risk_scenario, UseCaseRiskScenarioCreate):
            data = risk_scenario
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(risk_scenario, field)
                for field in UseCaseRiskScenarioCreate.model_fields
                if hasattr(risk_scenario, field)
            }
            data = UseCaseRiskScenarioCreate(**field_values)

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios",
            data=data,
            response_model=UseCaseRiskScenarioResponse,
        )

    async def remove(self, risk_scenario_id: str) -> None:
        """Remove a risk_scenario from this use_case.

        Args:
            risk_scenario_id: The ID of the risk_scenario to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/risk_scenarios/{risk_scenario_id}",
        )


class AsyncUseCaseRiskControlLinksAccessor:
    """Async manage risk_control_links for a specific use_case.

    This accessor provides async methods to add, list, remove
    risk_control_links associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").risk_control_links.list()
        >>> await client.use_case("use_case-id").risk_control_links.add("risk_control_link-id")
        >>> await client.use_case("use_case-id").risk_control_links.remove("risk_control_link-id")
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async risk_control_links accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def list(
        self,
        cursor: Optional[str] = None,
        limit: Optional[int] = None,
    ) -> "PaginatedResponse[RiskControlLinkResponse]":
        """List risk_control_links associated with this use_case.

        Args:
            cursor: Pagination cursor for next page
            limit: Maximum number of results to return

        Returns:
            PaginatedResponse containing RiskControlLinkResponse items
        """
        params: Dict[str, Any] = {}
        if cursor is not None:
            params["cursor"] = cursor
        if limit is not None:
            params["limit"] = limit

        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/risk_control_links",
            params=params if params else None,
            response_model=PaginatedResponse[RiskControlLinkResponse],
        )

    async def add(
        self, risk_control_link: "Union[RiskControlLinkCreate, RiskControlLinkResponse]"
    ) -> "RiskControlLinkResponse":
        """Add a risk_control_link to this use_case.

        Args:
            risk_control_link: A RiskControlLinkCreate object, or a RiskControlLinkResponse to extract fields from

        Returns:
            RiskControlLinkResponse: The added risk_control_link

        Examples:
            >>> # Using request model directly
            >>> use_case.risk_control_links.add(RiskControlLinkCreate(...))
            >>> # Using a fetched response object (extracts matching fields)
            >>> fetched = client.risk_control_links.get("id")
            >>> use_case.risk_control_links.add(fetched)
        """
        if isinstance(risk_control_link, RiskControlLinkCreate):
            data = risk_control_link
        else:
            # Extract fields from response object to create request model
            field_values = {
                field: getattr(risk_control_link, field)
                for field in RiskControlLinkCreate.model_fields
                if hasattr(risk_control_link, field)
            }
            data = RiskControlLinkCreate(**field_values)

        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/risk_control_links",
            data=data,
            response_model=RiskControlLinkResponse,
        )

    async def remove(self, risk_control_link_id: str) -> None:
        """Remove a risk_control_link from this use_case.

        Args:
            risk_control_link_id: The ID of the risk_control_link to remove
        """
        await self._client._make_request_async(
            method="DELETE",
            url=f"/use_cases/{self._use_case_id}/risk_control_links/{risk_control_link_id}",
        )


class AsyncUseCaseWorkflowAccessor:
    """Async access workflow for a specific use_case.

    This accessor provides async methods to get, update
    the workflow associated with a use_case.

    Example:
        >>> await client.use_case("use_case-id").workflow.get()
        >>> await client.use_case("use_case-id").workflow.update(UseCaseWorkflowUpdate(...))
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async workflow accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the parent use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    async def get(self) -> "UseCaseWorkflowResponse":
        """Get the workflow for this use_case.

        Returns:
            UseCaseWorkflowResponse: The workflow data
        """
        return await self._client._make_request_async(
            method="GET",
            url=f"/use_cases/{self._use_case_id}/workflow",
            response_model=UseCaseWorkflowResponse,
        )

    async def update(self, data: "UseCaseWorkflowUpdate") -> "UseCaseWorkflowResponse":
        """Update the workflow for this use_case.

        Args:
            data: The update data

        Returns:
            UseCaseWorkflowResponse: The updated workflow data
        """
        return await self._client._make_request_async(
            method="PATCH",
            url=f"/use_cases/{self._use_case_id}/workflow",
            data=data,
            response_model=UseCaseWorkflowResponse,
        )

    async def advance_step(self) -> "UseCaseWorkflowResponse":
        """Advance Use Case Workflow Step.

                Advance to the next step within the current workflow stage.

        Step progression: assessment → evidence_collection → clear

        Returns an error if already at a terminal step (clear or rejected).

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/advance_step",
            response_model=UseCaseWorkflowResponse,
        )

    async def advance_stage(self) -> "UseCaseWorkflowResponse":
        """Advance Use Case Workflow Stage.

                Advance to the next workflow stage, resetting to assessment step.

        Uses the child_id of the current stage to determine the next stage.
        Returns an error if at the end stage or no next stage is defined.

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/advance_stage",
            response_model=UseCaseWorkflowResponse,
        )

    async def reject(self) -> "UseCaseWorkflowResponse":
        """Reject Use Case in Workflow.

                Reject a use case by setting its workflow step to 'rejected'.

        The rejected step is a terminal state - the use case cannot progress
        further in the workflow until it is moved back to an earlier step.
        Returns an error if the use case is already in the rejected state.

                Returns:
                    UseCaseWorkflowResponse: The updated workflow data
        """
        return await self._client._make_request_async(
            method="POST",
            url=f"/use_cases/{self._use_case_id}/workflow/reject",
            response_model=UseCaseWorkflowResponse,
        )


class AsyncUseCase:
    """Async fluent accessor for a specific use_case.

    Provides access to related resources through property accessors that enable
    intuitive chaining with async/await.

    Example:
        >>> use_case = client.use_case("use_case-id")
        >>> await use_case.controls.list()
        >>> await use_case.policy_packs.list()
        >>> await use_case.policy_packs.add("policy_pack-id")
        >>> await use_case.questionnaires.list()
        >>> await use_case.questionnaires.add(QuestionnaireAttachment(key="...", version=1))
        >>> await use_case.models.list()
        >>> await use_case.models.add("model-id")
        >>> await use_case.vendors.list()
        >>> await use_case.vendors.add("vendor-id")
        >>> await use_case.risk_scenarios.list()
        >>> await use_case.risk_scenarios.add("risk_scenario-id")
        >>> await use_case.risk_control_links.list()
        >>> await use_case.risk_control_links.add("risk_control_link-id")
        >>> await use_case.workflow.get()
        >>> await use_case.workflow.update(UseCaseWorkflowUpdate(...))
    """

    def __init__(self, client: "AsyncCredoAI", use_case_id: str):
        """Initialize the async use_case accessor.

        Args:
            client: The AsyncCredoAI client instance
            use_case_id: The ID of the use_case
        """
        self._client = client
        self._use_case_id = use_case_id

    @property
    def controls(self) -> "AsyncUseCaseControlsAccessor":
        """Access controls associated with this use_case.

        Returns:
            AsyncUseCaseControlsAccessor: Async accessor for controls operations
        """
        return AsyncUseCaseControlsAccessor(self._client, self._use_case_id)

    @property
    def policy_packs(self) -> "AsyncUseCasePolicyPacksAccessor":
        """Access policy_packs associated with this use_case.

        Returns:
            AsyncUseCasePolicyPacksAccessor: Async accessor for policy_packs operations
        """
        return AsyncUseCasePolicyPacksAccessor(self._client, self._use_case_id)

    @property
    def questionnaires(self) -> "AsyncUseCaseQuestionnairesAccessor":
        """Access questionnaires associated with this use_case.

        Returns:
            AsyncUseCaseQuestionnairesAccessor: Async accessor for questionnaires operations
        """
        return AsyncUseCaseQuestionnairesAccessor(self._client, self._use_case_id)

    @property
    def models(self) -> "AsyncUseCaseModelsAccessor":
        """Access models associated with this use_case.

        Returns:
            AsyncUseCaseModelsAccessor: Async accessor for models operations
        """
        return AsyncUseCaseModelsAccessor(self._client, self._use_case_id)

    @property
    def vendors(self) -> "AsyncUseCaseVendorsAccessor":
        """Access vendors associated with this use_case.

        Returns:
            AsyncUseCaseVendorsAccessor: Async accessor for vendors operations
        """
        return AsyncUseCaseVendorsAccessor(self._client, self._use_case_id)

    @property
    def risk_scenarios(self) -> "AsyncUseCaseRiskScenariosAccessor":
        """Access risk_scenarios associated with this use_case.

        Returns:
            AsyncUseCaseRiskScenariosAccessor: Async accessor for risk_scenarios operations
        """
        return AsyncUseCaseRiskScenariosAccessor(self._client, self._use_case_id)

    @property
    def risk_control_links(self) -> "AsyncUseCaseRiskControlLinksAccessor":
        """Access risk_control_links associated with this use_case.

        Returns:
            AsyncUseCaseRiskControlLinksAccessor: Async accessor for risk_control_links operations
        """
        return AsyncUseCaseRiskControlLinksAccessor(self._client, self._use_case_id)

    @property
    def workflow(self) -> "AsyncUseCaseWorkflowAccessor":
        """Access workflow associated with this use_case.

        Returns:
            AsyncUseCaseWorkflowAccessor: Async accessor for workflow operations
        """
        return AsyncUseCaseWorkflowAccessor(self._client, self._use_case_id)


# =============================================================================
# Export list
# =============================================================================

__all__ = [
    "UseCase",
    "AsyncUseCase",
    "UseCaseControlsAccessor",
    "AsyncUseCaseControlsAccessor",
    "UseCasePolicyPacksAccessor",
    "AsyncUseCasePolicyPacksAccessor",
    "UseCaseQuestionnairesAccessor",
    "AsyncUseCaseQuestionnairesAccessor",
    "UseCaseModelsAccessor",
    "AsyncUseCaseModelsAccessor",
    "UseCaseVendorsAccessor",
    "AsyncUseCaseVendorsAccessor",
    "UseCaseRiskScenariosAccessor",
    "AsyncUseCaseRiskScenariosAccessor",
    "UseCaseRiskControlLinksAccessor",
    "AsyncUseCaseRiskControlLinksAccessor",
    "UseCaseWorkflowAccessor",
    "AsyncUseCaseWorkflowAccessor",
]
