azure.communication.administration package¶
-
class
azure.communication.administration.
CommunicationIdentityClient
(endpoint: str, credential: str, **kwargs: Any)[source]¶ Azure Communication Services Identity client.
- Parameters
endpoint (str) – The endpoint url for Azure Communication Service resource.
credential – The credentials with which to authenticate. The value is an account shared access key
Example:
: utf-8 ------------------------------------------------------------------- ght (c) Microsoft Corporation. All rights reserved. ed under the MIT License. See License.txt in the project root for e information. -------------------------------------------------------------------- entity_sample.py ION: e samples demonstrate identity client samples. uthenticating a client via a connection string on identity_samples.py s mmunicationIdentityClientSamples(object): __init__(self): self.connection_string = os.getenv('AZURE_COMMUNICATION_SERVICE_CONNECTION_STRING') issue_token(self): from azure.communication.administration import CommunicationIdentityClient identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() tokenresponse = identity_client.issue_token(user, scopes=["chat"]) print(tokenresponse) revoke_tokens(self): from azure.communication.administration import CommunicationIdentityClient identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() tokenresponse = identity_client.issue_token(user, scopes=["chat"]) identity_client.revoke_tokens(user) print(tokenresponse) create_user(self): from azure.communication.administration import CommunicationIdentityClient identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() print(user.identifier) delete_user(self): from azure.communication.administration import CommunicationIdentityClient identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string) user = identity_client.create_user() identity_client.delete_user(user) e__ == '__main__': le = CommunicationIdentityClientSamples() le.create_user() le.delete_user() le.issue_token() le.revoke_tokens()
-
create_user
(**kwargs) → azure.communication.administration._shared.models.CommunicationUser[source]¶ create a single Communication user
return: CommunicationUser rtype: ~azure.communication.administration.CommunicationUser
-
delete_user
(communication_user: CommunicationUser, **kwargs: Any) → None[source]¶ Triggers revocation event for user and deletes all its data.
- Parameters
communication_user (CommunicationUser) – Azure Communication User to delete
- Returns
None
- Return type
-
classmethod
from_connection_string
(conn_str: str, **kwargs: Any) → CommunicationIdentityClient[source]¶ Create CommunicationIdentityClient from a Connection String.
- Parameters
conn_str (str) – A connection string to an Azure Communication Service resource.
- Returns
Instance of CommunicationIdentityClient.
- Return type
CommunicationIdentityClient
Example:
-
issue_token
(user: CommunicationUser, scopes: List[str], **kwargs: Any) → CommunicationIdentityToken[source]¶ Generates a new token for an identity.
- Parameters
user (CommunicationUser) – Azure Communication User
scopes (list[str]) – List of scopes to be added to the token.
- Returns
CommunicationIdentityToken
- Return type
-
revoke_tokens
(user: CommunicationUser, issued_before: Optional[datetime.datetime] = None, **kwargs: Any) → None[source]¶ Schedule revocation of all tokens of an identity.
- Parameters
user () – Azure Communication User.
issued_before () – All tokens that are issued prior to this time should get revoked.
- Returns
None
- Return type
-
class
azure.communication.administration.
CommunicationTokenRequest
(*, scopes: List[str], **kwargs)[source]¶ CommunicationTokenRequest.
All required parameters must be populated in order to send to Azure.
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
-
class
azure.communication.administration.
CommunicationIdentityToken
(*, id: str, token: str, expires_on: datetime.datetime, **kwargs)[source]¶ CommunicationIdentityToken.
All required parameters must be populated in order to send to Azure.
- Parameters
-
as_dict
(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)¶ Return a dict that can be JSONify using json.dump.
Advanced usage might optionaly use a callback as parameter:
Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.
The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.
See the three examples in this file:
attribute_transformer
full_restapi_key_transformer
last_restapi_key_transformer
If you want XML serialization, you can pass the kwargs is_xml=True.
- Parameters
key_transformer (function) – A key transformer function.
- Returns
A dict JSON compatible object
- Return type
-
classmethod
deserialize
(data, content_type=None)¶ Parse a str using the RestAPI syntax and return a model.
-
classmethod
enable_additional_properties_sending
()¶
-
classmethod
from_dict
(data, key_extractors=None, content_type=None)¶ Parse a dict using given key extractor return a model.
By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)
-
classmethod
is_xml_model
()¶
-
serialize
(keep_readonly=False, **kwargs)¶ Return the JSON that would be sent to azure from this model.
This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).
If you want XML serialization, you can pass the kwargs is_xml=True.
-
class
azure.communication.administration.
CommunicationUser
(identifier)[source]¶ Represents a user in Azure Communication Service. :ivar identifier: Communication user identifier. :vartype identifier: str :param identifier: Identifier to initialize CommunicationUser. :type identifier: str
-
class
azure.communication.administration.
PhoneNumber
(value)[source]¶ Represents a phone number. :ivar value: Value for a phone number. :vartype value: str :param value: Value to initialize PhoneNumber. :type value: str
-
class
azure.communication.administration.
UnknownIdentifier
(identifier)[source]¶ 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 identifier: Unknown communication identifier. :vartype identifier: str :param identifier: Value to initialize UnknownIdentifier. :type identifier: str