# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
# pylint: skip-file
from enum import Enum, EnumMeta
from six import with_metaclass
from typing import Mapping, Optional, Union, Any
try:
from typing import Protocol, TypedDict
except ImportError:
from typing_extensions import Protocol, TypedDict
from azure.core import CaseInsensitiveEnumMeta
[docs]class CommunicationIdentifierKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""Communication Identifier Kind."""
UNKNOWN = "unknown"
COMMUNICATION_USER = "communication_user"
PHONE_NUMBER = "phone_number"
MICROSOFT_TEAMS_USER = "microsoft_teams_user"
class CommunicationCloudEnvironment(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)):
"""The cloud enviornment that the identifier belongs to"""
PUBLIC = "PUBLIC"
DOD = "DOD"
GCCH = "GCCH"
[docs]class CommunicationIdentifier(Protocol):
"""Communication Identifier.
:ivar str raw_id: Optional raw ID of the identifier.
:ivar kind: The type of identifier.
:vartype kind: str or CommunicationIdentifierKind
:ivar Mapping[str, Any] properties: The properties of the identifier.
"""
raw_id = None # type: Optional[str]
kind = None # type: Optional[Union[CommunicationIdentifierKind, str]]
properties = {} # type: Mapping[str, Any]
CommunicationUserProperties = TypedDict(
'CommunicationUserProperties',
id=str
)
[docs]class CommunicationUserIdentifier(object):
"""Represents a user in Azure Communication Service.
:ivar str raw_id: Optional raw ID of the identifier.
:ivar kind: The type of identifier.
:vartype kind: str or CommunicationIdentifierKind
:ivar Mapping[str, Any] properties: The properties of the identifier.
The keys in this mapping include:
- `id`(str): ID of the Communication user as returned from Azure Communication Identity.
:param str id: ID of the Communication user as returned from Azure Communication Identity.
"""
kind = CommunicationIdentifierKind.COMMUNICATION_USER
def __init__(self, id, **kwargs):
# type: (str, Any) -> None
self.raw_id = kwargs.get('raw_id')
self.properties = CommunicationUserProperties(id=id)
PhoneNumberProperties = TypedDict(
'PhoneNumberProperties',
value=str
)
class PhoneNumberIdentifier(object):
"""Represents a phone number.
:ivar str raw_id: Optional raw ID of the identifier.
:ivar kind: The type of identifier.
:vartype kind: str or CommunicationIdentifierKind
:ivar Mapping properties: The properties of the identifier.
The keys in this mapping include:
- `value`(str): The phone number in E.164 format.
:param str value: The phone number.
"""
kind = CommunicationIdentifierKind.PHONE_NUMBER
def __init__(self, value, **kwargs):
# type: (str, Any) -> None
self.raw_id = kwargs.get('raw_id')
self.properties = PhoneNumberProperties(value=value)
class UnknownIdentifier(object):
"""Represents an identifier of an unknown type.
It will be encountered in communications with endpoints that are not
identifiable by this version of the SDK.
:ivar str raw_id: Optional raw ID of the identifier.
:ivar kind: The type of identifier.
:vartype kind: str or CommunicationIdentifierKind
:ivar Mapping properties: The properties of the identifier.
:param str identifier: The ID of the identifier.
"""
kind = CommunicationIdentifierKind.UNKNOWN
def __init__(self, identifier):
# type: (str) -> None
self.raw_id = identifier
self.properties = {}
MicrosoftTeamsUserProperties = TypedDict(
'MicrosoftTeamsUserProperties',
user_id=str,
is_anonymous=bool,
cloud=Union[CommunicationCloudEnvironment, str]
)
class MicrosoftTeamsUserIdentifier(object):
"""Represents an identifier for a Microsoft Teams user.
:ivar str raw_id: Optional raw ID of the identifier.
:ivar kind: The type of identifier.
:vartype kind: str or CommunicationIdentifierKind
:ivar Mapping properties: The properties of the identifier.
The keys in this mapping include:
- `user_id`(str): The id of the Microsoft Teams user. If the user isn't anonymous,
the id is the AAD object id of the user.
- `is_anonymous` (bool): Set this to true if the user is anonymous for example when joining
a meeting with a share link.
- `cloud` (str): Cloud environment that this identifier belongs to.
:param str user_id: Microsoft Teams user id.
:keyword bool is_anonymous: `True` if the identifier is anonymous. Default value is `False`.
:keyword cloud: Cloud environment that the user belongs to. Default value is `PUBLIC`.
:paramtype cloud: str or ~azure.communication.chat.CommunicationCloudEnvironment
"""
kind = CommunicationIdentifierKind.MICROSOFT_TEAMS_USER
def __init__(self, user_id, **kwargs):
# type: (str, Any) -> None
self.raw_id = kwargs.get('raw_id')
self.properties = MicrosoftTeamsUserProperties(
user_id=user_id,
is_anonymous=kwargs.get('is_anonymous', False),
cloud=kwargs.get('cloud') or CommunicationCloudEnvironment.PUBLIC
)