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

import datetime as dt
import typing

from ...core.datetime_utils import serialize_datetime
from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
from .bucket_agg import BucketAgg
from .hs_code_agg import HsCodeAgg
from .tier_count_agg import TierCountAgg


class ProjectEntitiesAggs(pydantic_v1.BaseModel):
    """
    Aggregation buckets for entities in a project.
    """

    hit_count: typing.Optional[typing.List[BucketAgg]] = None
    country: typing.Optional[typing.List[BucketAgg]] = None
    upstream_country: typing.Optional[typing.List[BucketAgg]] = None
    upstream_country_tiers: typing.Optional[TierCountAgg] = None
    risk: typing.Optional[typing.List[BucketAgg]] = None
    upstream_risk: typing.Optional[typing.List[BucketAgg]] = None
    upstream_risk_tiers: typing.Optional[TierCountAgg] = None
    source: typing.Optional[typing.List[BucketAgg]] = None
    business_purpose: typing.Optional[typing.List[BucketAgg]] = None
    tag_ids: typing.Optional[typing.List[BucketAgg]] = None
    case_statuses: typing.Optional[typing.List[BucketAgg]] = None
    shipment_counts: typing.Optional[typing.List[BucketAgg]] = None
    shipped_hs_codes: typing.Optional[HsCodeAgg] = None
    received_hs_codes: typing.Optional[HsCodeAgg] = None
    match_results: typing.Optional[typing.List[BucketAgg]] = None
    location: typing.Optional[typing.List[BucketAgg]] = None
    source_type: typing.Optional[typing.List[BucketAgg]] = None
    region: typing.Optional[typing.List[BucketAgg]] = None

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}

        return deep_union_pydantic_dicts(
            super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
        )

    class Config:
        frozen = True
        smart_union = True
        extra = pydantic_v1.Extra.allow
        json_encoders = {dt.datetime: serialize_datetime}
