# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
import pydantic
import typing
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class ApiOperationPolicy(UniversalBaseModel):
    """
    Policy to allow operations if only using the specified resource.
    """

    allow_any_resource: bool = pydantic.Field()
    """
    If any resource is allowed for the operation.
    """

    allowed_resources: typing.Optional[typing.Dict[str, typing.List[str]]] = pydantic.Field(default=None)
    """
    Object with keys of resource paths to a list of allowed resources.
    A resource path starts with either body, path, or implicit.
    A body or path resource is within the operation body, and an implicit
    resource is a resource implied by the request.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
