azure.communication.phonenumbers.siprouting package

class azure.communication.phonenumbers.siprouting.SipRoutingClient(endpoint: str, credential: TokenCredential, **kwargs: Any)[source]

A client to interact with the AzureCommunicationService SIP routing gateway. This client provides operations to retrieve and manage SIP routing configuration.

Parameters
  • endpoint (str) – The endpoint url for Azure Communication Service resource.

  • credential (TokenCredential) – The credentials with which to authenticate.

Keyword Arguments

api_version (str) – Api Version. Default value is “2021-05-01-preview”. Note that overriding this default value may result in unsupported behavior.

close()None[source]
delete_trunk(trunk_fqdn: str, **kwargs: Any)None[source]

Deletes SIP trunk.

Parameters

trunk_fqdn (str) – FQDN of the trunk to be deleted.

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError, ValueError

classmethod from_connection_string(conn_str: str, **kwargs: Any)SipRoutingClient[source]

Factory method for creating client from connection string.

Parameters

conn_str (str) – Connection string containing endpoint and credentials.

Returns

The newly created client.

Return type

SipRoutingClient

get_trunk(trunk_fqdn: str, **kwargs: Any)Optional[SipTrunk][source]

Retrieve a single SIP trunk.

Parameters

trunk_fqdn (str) – FQDN of the desired SIP trunk.

Returns

SIP trunk with specified trunk_fqdn. If it doesn’t exist, returns None.

Return type

SipTrunk or None

Raises

~azure.core.exceptions.HttpResponseError, ValueError, LookupError

list_routes(**kwargs: Any)Iterable[SipTrunkRoute][source]

Retrieves an iterable of currently configured SIP routes.

Returns

Current SIP routes configuration.

Return type

Iterable[SipTrunkRoute]

Raises

~azure.core.exceptions.HttpResponseError

list_trunks(**kwargs: Any)Iterable[SipTrunk][source]

Retrieves an iterable of currently configured SIP trunks.

Returns

Current SIP trunks configuration.

Return type

Iterable[SipTrunk]

Raises

~azure.core.exceptions.HttpResponseError

set_routes(routes: List[SipTrunkRoute], **kwargs: Any)None[source]

Overwrites the list of SIP routes.

Parameters

routes (List[SipTrunkRoute]) – New list of routes to be set.

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError, ValueError

set_trunk(trunk: SipTrunk, **kwargs: Any)None[source]

Modifies SIP trunk with the given FQDN. If it doesn’t exist, adds a new trunk.

Parameters

trunk (SipTrunk) – Trunk object to be set.

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError, ValueError

set_trunks(trunks: List[SipTrunk], **kwargs: Any)None[source]

Overwrites the list of SIP trunks.

Parameters

trunks (List[SipTrunk]) – New list of trunks to be set.

Returns

None

Return type

None

Raises

~azure.core.exceptions.HttpResponseError, ValueError

class azure.communication.phonenumbers.siprouting.SipTrunk(**kwargs)[source]

Represents a SIP trunk for routing calls. See RFC 4904.

Variables
  • fqdn (str) – FQDN of the trunk.

  • sip_signaling_port (int) – Gets or sets SIP signaling port of the trunk.

Keyword Arguments
  • fqdn (str) – FQDN of the trunk.

  • sip_signaling_port (int) – Gets or sets SIP signaling port of the trunk.

class azure.communication.phonenumbers.siprouting.SipTrunkRoute(*, name: str, number_pattern: str, description: Optional[str] = None, trunks: Optional[List[str]] = None, **kwargs)[source]

Represents a trunk route for routing calls.

All required parameters must be populated in order to send to Azure.

Variables
  • description (str) – Gets or sets description of the route.

  • name (str) – Required. Gets or sets name of the route.

  • number_pattern (str) – Required. Gets or sets regex number pattern for routing calls. .NET regex format is supported. The regex should match only digits with an optional ‘+’ prefix without spaces. I.e. “^+[1-9][0-9]{3,23}$”.

  • trunks (list[str]) – Gets or sets list of SIP trunks for routing calls. Trunks are represented as FQDN.

Keyword Arguments
  • description (str) – Gets or sets description of the route.

  • name (str) – Required. Gets or sets name of the route.

  • number_pattern (str) – Required. Gets or sets regex number pattern for routing calls. .NET regex format is supported. The regex should match only digits with an optional ‘+’ prefix without spaces. I.e. “^+[1-9][0-9]{3,23}$”.

  • trunks (list[str]) – Gets or sets list of SIP trunks for routing calls. Trunks are represented as FQDN.

as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionally 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

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

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)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

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.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list