azure.communication.sms package¶
-
class
azure.communication.sms.
SmsClient
(endpoint: str, credential: str, **kwargs: Any)[source]¶ A client to interact with the AzureCommunicationService Sms gateway.
This client provides operations to send an SMS via a phone number.
- Parameters
-
classmethod
from_connection_string
(conn_str: str, **kwargs: Any) → SmsClient[source]¶ Create SmsClient from a Connection String.
- Parameters
conn_str (str) – A connection string to an Azure Communication Service resource.
- Returns
Instance of SmsClient.
- Return type
SmsClient
Example:
-
send
(from_phone_number: ~ azure.communication.sms.PhoneNumber, to_phone_numbers: list[~ azure.communication.sms.PhoneNumber], message: str, **kwargs: Any) → SendSmsResponse[source]¶ Sends SMSs to phone numbers.
- Parameters
from_phone_number (PhoneNumber) – the sender of the SMS.
to_phone_numbers (list[PhoneNumber]) – the list of recipients of the SMS.
message (str) – The message in the SMS
- Keyword Arguments
send_sms_options – the options object to configure delivery reporting.
- Returns
The response object with the message_id
- Return type
SendMessageResponse: ~azure.communication.sms.models.SendMessageResponse
-
class
azure.communication.sms.
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.sms.
SendSmsOptions
(*, enable_delivery_report: Optional[bool] = None, **kwargs)[source]¶ Optional configuration for sending SMS messages.
- Parameters
enable_delivery_report (bool) – Enable this flag to receive a delivery report for this message on the Azure Resource EventGrid.
-
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.sms.
SendSmsResponse
(*, message_id: Optional[str] = None, **kwargs)[source]¶ Response for a successful send Sms request.
- Parameters
message_id (str) – The identifier of the outgoing SMS message.
-
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.