# 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
from ...generated_types.types.country import Country
import typing_extensions
from ...core.serialization import FieldMetadata
from .project_entities_fuzzy_filter import ProjectEntitiesFuzzyFilter
from .project_entities_exact_filter import ProjectEntitiesExactFilter
from ...generated_types.types.company_status import CompanyStatus
from ...shared_types.types.case_status import CaseStatus
from ...shared_types.types.match_strength_enum import MatchStrengthEnum
from ...shared_types.types.match_count import MatchCount
from .project_entities_custom_field_filter import ProjectEntitiesCustomFieldFilter
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class ProjectEntitiesFilter(UniversalBaseModel):
    risk_factor: typing.Optional[typing.List[Risk]] = pydantic.Field(default=None)
    """
    Filter by [risk factor](/sayari-library/ontology/risk-factors) ID.
    """

    risk_category: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by risk factor `category`, e.g. `sanctions`. At least one risk factor from each provided category must be present.
    """

    upstream_product: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) product ID.
    """

    shipment_country: typing.Optional[typing.List[Country]] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at any tier.
    """

    tier_1_shipment_country: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="tier1_shipment_country")
    ] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at tier 1.
    """

    tier_2_shipment_country: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="tier2_shipment_country")
    ] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at tier 2.
    """

    tier_3_shipment_country: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="tier3_shipment_country")
    ] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at tier 3.
    """

    tier_4_shipment_country: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="tier4_shipment_country")
    ] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at tier 4.
    """

    tier_5_shipment_country: typing_extensions.Annotated[
        typing.Optional[typing.List[Country]], FieldMetadata(alias="tier5_shipment_country")
    ] = pydantic.Field(default=None)
    """
    Filter by upstream (supply chain) [country](/sayari-library/ontology/enumerated-types#country) at tier 5.
    """

    country: typing.Optional[typing.List[Country]] = pydantic.Field(default=None)
    """
    Filter by [country](/sayari-library/ontology/enumerated-types#country).
    """

    business_purpose: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by HS code, HS code description, or business description.
    """

    label: typing.Optional[ProjectEntitiesFuzzyFilter] = pydantic.Field(default=None)
    """
    Filter by entity label with fuzzy matching.
    """

    city: typing.Optional[ProjectEntitiesFuzzyFilter] = pydantic.Field(default=None)
    """
    Filter by entity city with fuzzy matching.
    """

    state: typing.Optional[ProjectEntitiesFuzzyFilter] = pydantic.Field(default=None)
    """
    Filter by entity address state with fuzzy matching.
    """

    identifier: typing.Optional[ProjectEntitiesFuzzyFilter] = pydantic.Field(default=None)
    """
    Filter by entity identifier attributes with fuzzy matching.
    """

    source: typing.Optional[ProjectEntitiesExactFilter] = pydantic.Field(default=None)
    """
    Filter by entity source ID.
    """

    status: typing.Optional[typing.List[CompanyStatus]] = pydantic.Field(default=None)
    """
    Filter by entity [company status](/sayari-library/ontology/enumerated-types#company-status).
    """

    bounds: typing.Optional[str] = pydantic.Field(default=None)
    """
    Filter by a geographical bounding box. The value is a pipe-delimited set of four values representing the top, left, bottom, and right sides of the bounding box, in that order. The pipes should be URL-encoded as `%7C`. The top coordinate must greater than the bottom coordinate, and the left coordinate must be less than the right coordinate. A sample is `55.680357237879136|-71.53607290158526|41.10876347746233|-40.963927098414736`
    """

    match_entity_id: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by match entity ID.
    """

    entity_type: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by entity type.
    """

    tag: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by tag ID.
    """

    upload: typing.Optional[typing.List[str]] = pydantic.Field(default=None)
    """
    Filter by upload ID.
    """

    case_status: typing.Optional[typing.List[CaseStatus]] = pydantic.Field(default=None)
    """
    Filter by case status.
    """

    match_strength: typing.Optional[typing.List[MatchStrengthEnum]] = pydantic.Field(default=None)
    """
    Filter by match strength.
    """

    match_count: typing.Optional[MatchCount] = pydantic.Field(default=None)
    """
    Filter by match count.
    """

    attribute: typing.Optional[ProjectEntitiesCustomFieldFilter] = pydantic.Field(default=None)
    """
    Filter by custom field.
    """

    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
