"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from .applicationscope import ApplicationScope
from moovio_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ShareScopesTypedDict(TypedDict):
    r"""Describes the scopes being shared from a subject account to a principal account."""

    principal_account_id: str
    r"""The account ID that will receive access to the scopes."""
    allow_scopes: NotRequired[List[ApplicationScope]]
    r"""The list of scopes to share with the principal account. If none are provided, all intersecting scopes are added."""


class ShareScopes(BaseModel):
    r"""Describes the scopes being shared from a subject account to a principal account."""

    principal_account_id: Annotated[str, pydantic.Field(alias="principalAccountID")]
    r"""The account ID that will receive access to the scopes."""

    allow_scopes: Annotated[
        Optional[List[ApplicationScope]], pydantic.Field(alias="allowScopes")
    ] = None
    r"""The list of scopes to share with the principal account. If none are provided, all intersecting scopes are added."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["allowScopes"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    ShareScopes.model_rebuild()
except NameError:
    pass
