# 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 .actor import Actor
from .sharing_permission import SharingPermission
from .sharing_scope_id import SharingScopeId

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class Sharing(pydantic.BaseModel):
    """
    The Sharing object encompasses information about how and with whom a resource was shared.
    """

    actors: typing.Optional[typing.List[Actor]] = pydantic.Field(default=None)
    """
    The actor(s) with whom the resource has been shared. Note that with the addition of groups to the Actor object, sharing with a group can be represented by an Actor object with an empty user field and a populated groups field.
    """

    anonymous: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if anonymous access is enabled for sharing.
    """

    can_reshare: typing.Optional[bool] = pydantic.Field(default=None)
    """
    True if the recipients have permission to re-share the resource.
    """

    permissions: typing.Optional[typing.List[SharingPermission]] = pydantic.Field(default=None)
    """
    List of permissions granted.
    """

    scope: typing.Optional[str] = pydantic.Field(default=None)
    """
    The scope, normalized to the caption of the scope_id value.
    """

    scope_id: typing.Optional[SharingScopeId] = pydantic.Field(default=None)
    """
    The normalized identifier of the sharing scope.
    """

    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: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

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