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

from ...core.pydantic_utilities import UniversalBaseModel
import typing
from ...generated_types.types.risk import Risk
import pydantic
import typing_extensions
from ...core.serialization import FieldMetadata
from ...generated_types.types.country import Country
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class TradeTraversalFilters(UniversalBaseModel):
    risk_factors: typing.Optional[typing.List[Risk]] = pydantic.Field(default=None)
    """
    Risk leaf node filter. Only return supply chains that end with a supplier that has 1+ of the specified risk factors.
    """

    not_risk: typing_extensions.Annotated[typing.Optional[typing.List[Risk]], FieldMetadata(alias="-risk_factors")] = (
        pydantic.Field(default=None)
    )
    """
    Risk leaf node filter. Only return supply chains that end with a supplier that has none of the specified risk factors.
    """

    countries: typing.Optional[typing.List[Country]] = pydantic.Field(default=None)
    """
    Country leaf node filter. Only return supply chains that end with a supplier in 1+ of the specified countries.
    """

    not_countries: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="-countries")
    ] = pydantic.Field(default=None)
    """
    Country leaf node filter. Only return supply chains that end with a supplier in none of the specified countries.
    """

    product: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Product root edge filter. Only return supply chains that start with an edge that has 1+ of the specified HS codes.
    """

    not_product: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="-product")] = (
        pydantic.Field(default=None)
    )
    """
    Product root edge filter. Only return supply chains that start with an edge that has none of the specified HS codes.
    """

    component: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Component edge filter. Only return supply chains that contain at least one edge with 1+ of the specified HS codes.
    """

    not_component: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="-component")] = (
        pydantic.Field(default=None)
    )
    """
    Component edge filter. Only return supply chains that contain no edges with any of the specified HS codes.
    """

    min_date: typing.Optional[str] = pydantic.Field(default=None)
    """
    Minimum date edge filter in <YYYY-MM-DD> format. Only return supply chains with edge dates that are greater than or equal to this date.
    """

    max_date: typing.Optional[str] = pydantic.Field(default=None)
    """
    Maximum date edge filter in <YYYY-MM-DD> format. Only return supply chains with edge dates that are less than or equal to this date.
    """

    max_depth: typing.Optional[int] = pydantic.Field(default=None)
    """
    The maximum depth of the traversal, from 1 to 4 inclusive. Default is 4. Reduce if query is timing out.
    """

    limit: typing.Optional[int] = pydantic.Field(default=None)
    """
    The maximum number of results to return. Default is no limit.
    """

    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
