diff --git a/sdk/communication/azure-communication-networktraversal/CHANGELOG.md b/sdk/communication/azure-communication-networktraversal/CHANGELOG.md index e4cfa026e6f6..ab81b08b0c85 100644 --- a/sdk/communication/azure-communication-networktraversal/CHANGELOG.md +++ b/sdk/communication/azure-communication-networktraversal/CHANGELOG.md @@ -1,6 +1,21 @@ # Release History +## 1.0.0-beta.2 (2021-11-18) + +### Features Added + +- Made User Identity an optional parameter when getting a Relay Configuration. +- Added RouteType as optional parameter when getting a Relay Configuration so users can + choose the routing type protocol of the requested Relay Configuration. + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.0.0b1 (2021-08-16) + - Preview release of `azure-communication-networktraversal`. The first preview of the Azure Communication Relay Client has the following features: @@ -8,6 +23,7 @@ The first preview of the Azure Communication Relay Client has the following feat - get a Relay Configuration by creating a CommunicationRelayClient ### Added + - Added CommunicationRelayClient in preview. - Added CommunicationRelayClient.get_relay_configuration in preview. diff --git a/sdk/communication/azure-communication-networktraversal/README.md b/sdk/communication/azure-communication-networktraversal/README.md index d6760ce27e81..b661e58a929a 100644 --- a/sdk/communication/azure-communication-networktraversal/README.md +++ b/sdk/communication/azure-communication-networktraversal/README.md @@ -58,7 +58,7 @@ identity_client = CommunicationIdentityClient.from_connection_string(self.connec relay_client = CommunicationRelayClient.from_connection_string(self.connection_string) ``` -### Getting the relay configuration +### Getting the relay configuration providing a user ```python # We need a user from Identity @@ -77,6 +77,42 @@ for iceServer in config.ice_servers: print('Url:' + url) ``` +### Getting the relay configuration without providing a user + +```python +relay_configuration = relay_client.get_relay_configuration() + +for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url:' + url) +``` + +### Getting the relay configuration without providing a RouteType + +```python +# We need a user from Identity +user = identity_client.create_user() +relay_configuration = relay_client.get_relay_configuration(user, RouteType.NEAREST) + +for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url:' + url) +``` + # Troubleshooting The Azure Communication Relay client will raise exceptions defined in [Azure Core][azure_core]. diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/__init__.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/__init__.py index 6b34c6a0afb5..aa3aa4febf32 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/__init__.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/__init__.py @@ -6,3 +6,4 @@ # pylint: disable=bad-option-value, unused-import from ._communication_relay_client import CommunicationRelayClient +from ._generated.models import RouteType diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_communication_relay_client.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_communication_relay_client.py index c4eb0fc83c7b..fdbcddc566fb 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_communication_relay_client.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_communication_relay_client.py @@ -4,7 +4,7 @@ # Licensed under the MIT License. # ------------------------------------ -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING from azure.core.tracing.decorator import distributed_trace @@ -18,6 +18,7 @@ if TYPE_CHECKING: from azure.core.credentials import TokenCredential from azure.communication.identity import CommunicationUserIdentifier + from azure.communication.networktraversal import RouteType class CommunicationRelayClient(object): """Azure Communication Services Relay client. @@ -86,17 +87,22 @@ def from_connection_string( def get_relay_configuration( self, user=None, # type: CommunicationUserIdentifier + route_type=None, # type: Optional[Union[str, "RouteType"]] **kwargs # type: Any ): - # type: (Any) -> CommunicationRelayConfiguration + # type: (...) -> CommunicationRelayConfiguration """get a Communication Relay configuration - :param: CommunicationUserIdentifier user: A user from which we will get an id + :param user: Azure Communication User + :type user: ~azure.communication.identity.CommunicationUserIdentifier + :param route_type: Azure Communication Route Type + :type route_type: ~azure.communication.networktraversal.RouteType :return: CommunicationRelayConfiguration - :rtype: ~azure.communication.networktraversal.CommunicationRelayConfiguration + :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration """ if user is None: return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( - None, **kwargs) + None, route_type, **kwargs) return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( user.properties['id'], + route_type, **kwargs) diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_communication_network_traversal_client.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_communication_network_traversal_client.py index 232315d13b62..afc2c120fbba 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_communication_network_traversal_client.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_communication_network_traversal_client.py @@ -31,6 +31,9 @@ class CommunicationNetworkTraversalClient(object): :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that + overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -40,7 +43,7 @@ def __init__( ): # type: (...) -> None _base_url = '{endpoint}' - self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs) + self._config = CommunicationNetworkTraversalClientConfiguration(endpoint=endpoint, **kwargs) self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_configuration.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_configuration.py index 2e7175c2d548..23b7c48186ca 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_configuration.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_configuration.py @@ -25,6 +25,8 @@ class CommunicationNetworkTraversalClientConfiguration(Configuration): :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -33,12 +35,14 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-06-21-preview" + self.api_version = api_version kwargs.setdefault('sdk_moniker', 'communicationnetworktraversalclient/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/__init__.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/__init__.py index ec77cdaca90a..c71626ac5e17 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/__init__.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/__init__.py @@ -8,3 +8,9 @@ from ._communication_network_traversal_client import CommunicationNetworkTraversalClient __all__ = ['CommunicationNetworkTraversalClient'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_communication_network_traversal_client.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_communication_network_traversal_client.py index cb1e98300c1d..306d55bcf1b7 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_communication_network_traversal_client.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_communication_network_traversal_client.py @@ -26,6 +26,9 @@ class CommunicationNetworkTraversalClient: :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that + overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -34,7 +37,7 @@ def __init__( **kwargs: Any ) -> None: _base_url = '{endpoint}' - self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs) + self._config = CommunicationNetworkTraversalClientConfiguration(endpoint=endpoint, **kwargs) self._client = AsyncPipelineClient(base_url=_base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_configuration.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_configuration.py index be91851bbf30..8caa9bc6f914 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_configuration.py @@ -21,6 +21,8 @@ class CommunicationNetworkTraversalClientConfiguration(Configuration): :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. :type endpoint: str + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that overriding this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -28,12 +30,14 @@ def __init__( endpoint: str, **kwargs: Any ) -> None: + super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str + if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") - super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs) self.endpoint = endpoint - self.api_version = "2021-06-21-preview" + self.api_version = api_version kwargs.setdefault('sdk_moniker', 'communicationnetworktraversalclient/{}'.format(VERSION)) self._configure(**kwargs) diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/operations/_communication_network_traversal_operations.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/operations/_communication_network_traversal_operations.py index c093ef0e412f..2c0527b05e3b 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/operations/_communication_network_traversal_operations.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/operations/_communication_network_traversal_operations.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -18,7 +18,6 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._communication_network_traversal_operations import build_issue_relay_configuration_request - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -48,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def issue_relay_configuration( self, id: Optional[str] = None, + route_type: Optional[Union[str, "_models.RouteType"]] = None, **kwargs: Any ) -> "_models.CommunicationRelayConfiguration": """Issue a configuration for an STUN/TURN server for an existing identity. @@ -56,6 +56,12 @@ async def issue_relay_configuration( :param id: An existing ACS identity. :type id: str + :param route_type: The routing methodology to where the ICE server will be located from the + client. + :type route_type: str or ~azure.communication.networktraversal.models.RouteType + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that + overriding this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CommunicationRelayConfiguration, or the result of cls(response) :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration @@ -67,15 +73,17 @@ async def issue_relay_configuration( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - _body = _models.CommunicationRelayConfigurationRequest(id=id) + _body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type) if _body is not None: json = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') else: json = None request = build_issue_relay_configuration_request( + api_version=api_version, content_type=content_type, json=json, template_url=self.issue_relay_configuration.metadata['url'], @@ -86,7 +94,7 @@ async def issue_relay_configuration( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = await self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/__init__.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/__init__.py index ca88ae3e261e..44beaa0e11b1 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/__init__.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/__init__.py @@ -19,10 +19,15 @@ from ._models import CommunicationRelayConfiguration # type: ignore from ._models import CommunicationRelayConfigurationRequest # type: ignore +from ._communication_network_traversal_client_enums import ( + RouteType, +) + __all__ = [ 'CommunicationError', 'CommunicationErrorResponse', 'CommunicationIceServer', 'CommunicationRelayConfiguration', 'CommunicationRelayConfigurationRequest', + 'RouteType', ] diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_communication_network_traversal_client_enums.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_communication_network_traversal_client_enums.py new file mode 100644 index 000000000000..4ec5d071d1eb --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_communication_network_traversal_client_enums.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class RouteType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The routing methodology to where the ICE server will be located from the client. + """ + + ANY = "any" + NEAREST = "nearest" diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models.py index fed3c7405e7a..bcdf46396908 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models.py @@ -103,18 +103,23 @@ class CommunicationIceServer(msrest.serialization.Model): :vartype username: str :ivar credential: Required. Credential for the server. :vartype credential: str + :ivar route_type: Required. The routing methodology to where the ICE server will be located + from the client. Possible values include: "any", "nearest". + :vartype route_type: str or ~azure.communication.networktraversal.models.RouteType """ _validation = { 'urls': {'required': True}, 'username': {'required': True}, 'credential': {'required': True}, + 'route_type': {'required': True}, } _attribute_map = { 'urls': {'key': 'urls', 'type': '[str]'}, 'username': {'key': 'username', 'type': 'str'}, 'credential': {'key': 'credential', 'type': 'str'}, + 'route_type': {'key': 'routeType', 'type': 'str'}, } def __init__( @@ -128,11 +133,15 @@ def __init__( :paramtype username: str :keyword credential: Required. Credential for the server. :paramtype credential: str + :keyword route_type: Required. The routing methodology to where the ICE server will be located + from the client. Possible values include: "any", "nearest". + :paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType """ super(CommunicationIceServer, self).__init__(**kwargs) self.urls = kwargs['urls'] self.username = kwargs['username'] self.credential = kwargs['credential'] + self.route_type = kwargs['route_type'] class CommunicationRelayConfiguration(msrest.serialization.Model): @@ -181,10 +190,14 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model): :ivar id: An existing ACS identity. :vartype id: str + :ivar route_type: The routing methodology to where the ICE server will be located from the + client. Possible values include: "any", "nearest". + :vartype route_type: str or ~azure.communication.networktraversal.models.RouteType """ _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, + 'route_type': {'key': 'routeType', 'type': 'str'}, } def __init__( @@ -194,6 +207,10 @@ def __init__( """ :keyword id: An existing ACS identity. :paramtype id: str + :keyword route_type: The routing methodology to where the ICE server will be located from the + client. Possible values include: "any", "nearest". + :paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType """ super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs) self.id = kwargs.get('id', None) + self.route_type = kwargs.get('route_type', None) diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models_py3.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models_py3.py index 75c2169ac8ec..d6fde2dcabd2 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models_py3.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models_py3.py @@ -7,11 +7,13 @@ # -------------------------------------------------------------------------- import datetime -from typing import List, Optional +from typing import List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization +from ._communication_network_traversal_client_enums import * + class CommunicationError(msrest.serialization.Model): """The Communication Services error. @@ -111,18 +113,23 @@ class CommunicationIceServer(msrest.serialization.Model): :vartype username: str :ivar credential: Required. Credential for the server. :vartype credential: str + :ivar route_type: Required. The routing methodology to where the ICE server will be located + from the client. Possible values include: "any", "nearest". + :vartype route_type: str or ~azure.communication.networktraversal.models.RouteType """ _validation = { 'urls': {'required': True}, 'username': {'required': True}, 'credential': {'required': True}, + 'route_type': {'required': True}, } _attribute_map = { 'urls': {'key': 'urls', 'type': '[str]'}, 'username': {'key': 'username', 'type': 'str'}, 'credential': {'key': 'credential', 'type': 'str'}, + 'route_type': {'key': 'routeType', 'type': 'str'}, } def __init__( @@ -131,6 +138,7 @@ def __init__( urls: List[str], username: str, credential: str, + route_type: Union[str, "RouteType"], **kwargs ): """ @@ -140,11 +148,15 @@ def __init__( :paramtype username: str :keyword credential: Required. Credential for the server. :paramtype credential: str + :keyword route_type: Required. The routing methodology to where the ICE server will be located + from the client. Possible values include: "any", "nearest". + :paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType """ super(CommunicationIceServer, self).__init__(**kwargs) self.urls = urls self.username = username self.credential = credential + self.route_type = route_type class CommunicationRelayConfiguration(msrest.serialization.Model): @@ -196,21 +208,30 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model): :ivar id: An existing ACS identity. :vartype id: str + :ivar route_type: The routing methodology to where the ICE server will be located from the + client. Possible values include: "any", "nearest". + :vartype route_type: str or ~azure.communication.networktraversal.models.RouteType """ _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, + 'route_type': {'key': 'routeType', 'type': 'str'}, } def __init__( self, *, id: Optional[str] = None, + route_type: Optional[Union[str, "RouteType"]] = None, **kwargs ): """ :keyword id: An existing ACS identity. :paramtype id: str + :keyword route_type: The routing methodology to where the ICE server will be located from the + client. Possible values include: "any", "nearest". + :paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType """ super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs) self.id = id + self.route_type = route_type diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/operations/_communication_network_traversal_operations.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/operations/_communication_network_traversal_operations.py index 1f20e8968ecf..036ca8a53b1d 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/operations/_communication_network_traversal_operations.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/operations/_communication_network_traversal_operations.py @@ -21,21 +21,21 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False # fmt: off def build_issue_relay_configuration_request( **kwargs # type: Any ): # type: (...) -> HttpRequest + api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-06-21-preview" accept = "application/json" # Construct URL url = kwargs.pop("template_url", '/networktraversal/:issueRelayConfiguration') @@ -85,6 +85,7 @@ def __init__(self, client, config, serializer, deserializer): def issue_relay_configuration( self, id=None, # type: Optional[str] + route_type=None, # type: Optional[Union[str, "_models.RouteType"]] **kwargs # type: Any ): # type: (...) -> "_models.CommunicationRelayConfiguration" @@ -94,6 +95,12 @@ def issue_relay_configuration( :param id: An existing ACS identity. :type id: str + :param route_type: The routing methodology to where the ICE server will be located from the + client. + :type route_type: str or ~azure.communication.networktraversal.models.RouteType + :keyword api_version: Api Version. The default value is "2021-10-08-preview". Note that + overriding this default value may result in unsupported behavior. + :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response :return: CommunicationRelayConfiguration, or the result of cls(response) :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration @@ -105,15 +112,17 @@ def issue_relay_configuration( } error_map.update(kwargs.pop('error_map', {})) + api_version = kwargs.pop('api_version', "2021-10-08-preview") # type: str content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - _body = _models.CommunicationRelayConfigurationRequest(id=id) + _body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type) if _body is not None: json = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') else: json = None request = build_issue_relay_configuration_request( + api_version=api_version, content_type=content_type, json=json, template_url=self.issue_relay_configuration.metadata['url'], @@ -124,7 +133,7 @@ def issue_relay_configuration( } request.url = self._client.format_url(request.url, **path_format_arguments) - pipeline_response = self._client.send_request(request, stream=False, _return_pipeline_response=True, **kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/__init__.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/__init__.py index 60e51a69334d..93345989ad8f 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/__init__.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/__init__.py @@ -5,7 +5,9 @@ # -------------------------------------------------------------------------- from ._communication_relay_client_async import CommunicationRelayClient +from .._generated.models import RouteType __all__ = [ - 'CommunicationRelayClient' + 'CommunicationRelayClient', + 'RouteType' ] diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/_communication_relay_client_async.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/_communication_relay_client_async.py index f04ea0c60c23..38b6c3d05e3d 100644 --- a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/_communication_relay_client_async.py +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/aio/_communication_relay_client_async.py @@ -84,18 +84,23 @@ def from_connection_string( async def get_relay_configuration( self, user: 'CommunicationUserIdentifier' = None, + route_type: 'CommunicationRelayConfigurationRequestRouteType' = None, **kwargs # type: Any ) -> 'CommunicationRelayConfiguration': """get a Communication Relay configuration. - :param: CommunicationUserIdentifier user: A user from which we will get an id + :param user: Azure Communication User + :type user: ~azure.communication.identity.CommunicationUserIdentifier + :param route_type: Azure Communication Route Type + :type route_type: ~azure.communication.networktraversal.RouteType :return: CommunicationRelayConfiguration - :rtype: ~azure.communication.networktraversal.CommunicationRelayConfiguration + :rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration """ if user is None: return await self._network_traversal_service_client.communication_network_traversal. \ - issue_relay_configuration(None, **kwargs) + issue_relay_configuration(None, route_type, **kwargs) return await self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( user.properties['id'], + route_type, **kwargs) async def __aenter__(self) -> "CommunicationRelayClient": diff --git a/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py b/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py index e0a658cbd187..96589bd48dd4 100644 --- a/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py +++ b/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py @@ -58,26 +58,6 @@ def get_relay_config(self): print("Icer server:") print(iceServer) - def get_relay_config_no_identity(self): - from azure.communication.networktraversal import ( - CommunicationRelayClient - ) - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity import DefaultAzureCredential - endpoint, _ = parse_connection_str(self.connection_string) - relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential()) - else: - relay_client = CommunicationRelayClient.from_connection_string(self.connection_string) - - print("Getting relay configuration") - relay_configuration = relay_client.get_relay_configuration() - - for iceServer in relay_configuration.ice_servers: - print("Icer server:") - print(iceServer) - if __name__ == '__main__': sample = CommunicationRelayClientSamples() sample.get_relay_config() - sample.get_relay_config_no_identity() diff --git a/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples_async.py b/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples_async.py index 5d3932338adf..7eb8c56d6950 100644 --- a/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples_async.py +++ b/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples_async.py @@ -57,28 +57,9 @@ async def get_relay_config(self): print("Icer server:") print(iceServer) - async def get_relay_config_no_identity(self): - from azure.communication.networktraversal.aio import CommunicationRelayClient - - if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None: - from azure.identity.aio import DefaultAzureCredential - endpoint, _ = parse_connection_str(self.connection_string) - relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential()) - else: - relay_client = CommunicationRelayClient.from_connection_string(self.connection_string) - - async with relay_client: - print("Getting relay configuration") - relay_configuration = await relay_client.get_relay_configuration() - - for iceServer in relay_configuration.ice_servers: - print("Icer server:") - print(iceServer) - async def main(): sample = CommunicationRelayClientSamples() await sample.get_relay_config() - await sample.get_relay_config_no_identity() if __name__ == '__main__': loop = asyncio.get_event_loop() diff --git a/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md b/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md index 4b4fb6c76e35..df98393216d6 100644 --- a/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md @@ -16,8 +16,8 @@ autorest ./SWAGGER.md ### Settings ``` yaml -tag: package-2021-06-21-preview -require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4c8162b0a1f7bbd46e9aedc0e19bbe181e549c4c/specification/communication/data-plane/NetworkTraversal/readme.md +tag: package-2021-10-08-preview +require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/f2e08ab373eb0e96b54920e89f9fc96d683355ca/specification/communication/data-plane/NetworkTraversal/readme.md output-folder: ../azure/communication/networktraversal/_generated/ namespace: azure.communication.networktraversal license-header: MICROSOFT_MIT_NO_VERSION diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration.yaml index 10e71f3b7d7e..0542e670ccba 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration.yaml +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration.yaml @@ -13,36 +13,36 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:08 GMT + - Tue, 16 Nov 2021 23:06:39 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview response: body: string: '{"identity": {"id": "sanitized"}}' headers: api-supported-versions: - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview + 2021-10-31-preview, 2021-11-01 + content-length: + - '101' content-type: - application/json; charset=utf-8 date: - - Fri, 01 Oct 2021 23:03:07 GMT + - Tue, 16 Nov 2021 23:06:39 GMT ms-cv: - - FV1I5QAfBk69A3bUGCU3xg.0 + - U9b65h5ASkKa+KIPCvUxWQ.0 request-context: - appId= strict-transport-security: - max-age=2592000 - transfer-encoding: - - chunked x-cache: - CONFIG_NOCACHE x-processing-time: - - 179ms + - 41ms status: code: 201 message: Created @@ -60,37 +60,39 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:08 GMT + - Tue, 16 Nov 2021 23:06:39 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview response: body: - string: '{"expiresOn": "2021-10-01T23:03:08.8008369+00:00", "iceServers": [{"urls": - ["turn.skype.com", "turn:world.relay.skype.com:3478"], "username": "sanitized", - "credential": "sanitized"}]}' + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}, {"routeType": "nearest", + "urls": ["stun:13.107.17.41:3478", "turn:13.107.17.41:3478"], "username": + "BQAANvHfttoB19zQystmgxt0S2mLYX7tGAxJeabzv9sAAAAMARCsgNlqhd5IsZldo6P6NifItsKK7e2LnRB0Ih7ljEfqyuKo124=", + "credential": "jCELLqJ7zq/h3iDdbwz9KEikIt0="}], "expiresOn": "2021-11-16T23:06:40.0024453+00:00"}' headers: api-supported-versions: - - 2021-02-22-preview1, 2021-06-21-preview + - 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: + - '560' content-type: - application/json; charset=utf-8 date: - - Fri, 01 Oct 2021 23:03:08 GMT + - Tue, 16 Nov 2021 23:06:39 GMT ms-cv: - - T1Tb9K+y6E6pLXFgnCjmmg.0 + - qEuVYpr70Ei+7tA9v36ydg.0 request-context: - appId= strict-transport-security: - max-age=2592000 - transfer-encoding: - - chunked x-cache: - CONFIG_NOCACHE x-processing-time: - - 128ms + - 40ms status: code: 200 message: OK diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_any.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_any.yaml new file mode 100644 index 000000000000..e1e54788462c --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_any.yaml @@ -0,0 +1,96 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:40 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview + response: + body: + string: '{"identity": {"id": "sanitized"}}' + headers: + api-supported-versions: + - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, + 2021-10-31-preview, 2021-11-01 + content-length: + - '101' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 16 Nov 2021 23:06:39 GMT + ms-cv: + - rmh6d+6tBkiqtYEPdBND/Q.0 + request-context: + - appId= + strict-transport-security: + - max-age=2592000 + x-cache: + - CONFIG_NOCACHE + x-processing-time: + - 43ms + status: + code: 201 + message: Created +- request: + body: '{"id": "sanitized", "routeType": "any"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '109' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:40 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview + response: + body: + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}], "expiresOn": "2021-11-16T23:06:40.4127712+00:00"}' + headers: + api-supported-versions: + - 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: + - '319' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 16 Nov 2021 23:06:39 GMT + ms-cv: + - fuapfk2WNE2Qo3K+cXomnw.0 + request-context: + - appId= + strict-transport-security: + - max-age=2592000 + x-cache: + - CONFIG_NOCACHE + x-processing-time: + - 39ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_nearest.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_nearest.yaml new file mode 100644 index 000000000000..7e7d43bfe279 --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_with_route_type_nearest.yaml @@ -0,0 +1,97 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:40 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview + response: + body: + string: '{"identity": {"id": "sanitized"}}' + headers: + api-supported-versions: + - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, + 2021-10-31-preview, 2021-11-01 + content-length: + - '101' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 16 Nov 2021 23:06:39 GMT + ms-cv: + - AWedRcBNFEiUrHbsxosGJg.0 + request-context: + - appId= + strict-transport-security: + - max-age=2592000 + x-cache: + - CONFIG_NOCACHE + x-processing-time: + - 25ms + status: + code: 201 + message: Created +- request: + body: '{"id": "sanitized", "routeType": "nearest"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '113' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:40 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview + response: + body: + string: '{"iceServers": [{"routeType": "nearest", "urls": ["turn.skype.com", + "turn:13.107.17.41:3478"], "username": "sanitized", "credential": "sanitized"}], + "expiresOn": "2021-11-16T23:06:41.0641698+00:00"}' + headers: + api-supported-versions: + - 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: + - '305' + content-type: + - application/json; charset=utf-8 + date: + - Tue, 16 Nov 2021 23:06:40 GMT + ms-cv: + - gb3giHJ1ak+dJlNIiwKx6A.0 + request-context: + - appId= + strict-transport-security: + - max-age=2592000 + x-cache: + - CONFIG_NOCACHE + x-processing-time: + - 303ms + status: + code: 200 + message: OK +version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_without_identity.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_without_identity.yaml index 7a1fa30695d5..1641e2c2fedb 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_without_identity.yaml +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_without_identity.yaml @@ -13,37 +13,39 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:08 GMT + - Tue, 16 Nov 2021 23:06:41 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview response: body: - string: '{"expiresOn": "2021-10-01T23:03:09.2274327+00:00", "iceServers": [{"urls": - ["turn.skype.com", "turn:world.relay.skype.com:3478"], "username": "sanitized", - "credential": "sanitized"}]}' + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}, {"routeType": "nearest", + "urls": ["stun:13.107.17.41:3478", "turn:13.107.17.41:3478"], "username": + "BQAANvKq+koB19zQBweakrFDOv2ryC7xNWF/jV9BJoAAAAAMARCsgNlqhd5IsZldo6P6NifIAa6byOgmmQCuGcIq36sfDTfL6Cc=", + "credential": "pF5SPr5F7X6ZwmMOn8cGEKl50YM="}], "expiresOn": "2021-11-16T23:06:41.3447718+00:00"}' headers: api-supported-versions: - - 2021-02-22-preview1, 2021-06-21-preview + - 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: + - '560' content-type: - application/json; charset=utf-8 date: - - Fri, 01 Oct 2021 23:03:08 GMT + - Tue, 16 Nov 2021 23:06:40 GMT ms-cv: - - c1XdV0vrhEOnOWF2LrDjGQ.0 + - nsDeFbsDmUi6XnHX4QvoSA.0 request-context: - appId= strict-transport-security: - max-age=2592000 - transfer-encoding: - - chunked x-cache: - CONFIG_NOCACHE x-processing-time: - - 311ms + - 159ms status: code: 200 message: OK diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration.yaml index 0902b75be361..0418c0a2d400 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration.yaml +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration.yaml @@ -9,31 +9,31 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:09 GMT + - Tue, 16 Nov 2021 23:06:41 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview response: body: string: '{"identity": {"id": "sanitized"}}' headers: api-supported-versions: 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, - 2021-03-31-preview1, 2021-10-31-preview + 2021-03-31-preview1, 2021-10-31-preview, 2021-11-01 + content-length: '101' content-type: application/json; charset=utf-8 - date: Fri, 01 Oct 2021 23:03:09 GMT - ms-cv: hEHBfG5MIkqgUk3m0Wdarw.0 + date: Tue, 16 Nov 2021 23:06:40 GMT + ms-cv: 4ptSJ2AmVE+PjMCylDY7Aw.0 request-context: appId= strict-transport-security: max-age=2592000 - transfer-encoding: chunked x-cache: CONFIG_NOCACHE - x-processing-time: 145ms + x-processing-time: 21ms status: code: 201 message: Created - url: https://smstestapp.communication.azure.com/identities?api-version=2021-03-07 + url: https://smstestapp.communication.azure.com/identities?api-version=2021-10-31-preview - request: body: '{"id": "sanitized"}' headers: @@ -44,30 +44,32 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:09 GMT + - Tue, 16 Nov 2021 23:06:41 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview response: body: - string: '{"expiresOn": "2021-10-01T23:03:10.0042344+00:00", "iceServers": [{"urls": - ["turn.skype.com", "turn:world.relay.skype.com:3478"], "username": "sanitized", - "credential": "sanitized"}]}' + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}, {"routeType": "nearest", + "urls": ["stun:13.107.17.41:3478", "turn:13.107.17.41:3478"], "username": + "BQAANvLEk3sB19zQDFB99XfvREaYUjaW+99mXybbmD8AAAAMARCsgNlqhd5IsZldo6P6NifI+iWmJVl8G6EL9UYo+n1+3Vjdkrg=", + "credential": "HHySJRALhMrETWsv/DWRtfjHZ4E="}], "expiresOn": "2021-11-16T23:06:41.5125461+00:00"}' headers: - api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview + api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: '560' content-type: application/json; charset=utf-8 - date: Fri, 01 Oct 2021 23:03:09 GMT - ms-cv: pDiu+i86Fk+DMv1bFRw7qA.0 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: cxYKkXL150+Dhco9akfN/Q.0 request-context: appId= strict-transport-security: max-age=2592000 - transfer-encoding: chunked x-cache: CONFIG_NOCACHE - x-processing-time: 118ms + x-processing-time: 21ms status: code: 200 message: OK - url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_any.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_any.yaml new file mode 100644 index 000000000000..bf3b88185d66 --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_any.yaml @@ -0,0 +1,72 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:41 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview + response: + body: + string: '{"identity": {"id": "sanitized"}}' + headers: + api-supported-versions: 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, + 2021-03-31-preview1, 2021-10-31-preview, 2021-11-01 + content-length: '101' + content-type: application/json; charset=utf-8 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: +m4qlverWU2x1qiBYz7jkw.0 + request-context: appId= + strict-transport-security: max-age=2592000 + x-cache: CONFIG_NOCACHE + x-processing-time: 24ms + status: + code: 201 + message: Created + url: https://smstestapp.communication.azure.com/identities?api-version=2021-10-31-preview +- request: + body: '{"id": "sanitized", "routeType": "any"}' + headers: + Accept: + - application/json + Content-Length: + - '109' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:41 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview + response: + body: + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}], "expiresOn": "2021-11-16T23:06:41.9304572+00:00"}' + headers: + api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: '319' + content-type: application/json; charset=utf-8 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: KRB1BWGVHk24ApJNUrmViw.0 + request-context: appId= + strict-transport-security: max-age=2592000 + x-cache: CONFIG_NOCACHE + x-processing-time: 280ms + status: + code: 200 + message: OK + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview +version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_nearest.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_nearest.yaml new file mode 100644 index 000000000000..383a0fa3ee52 --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_with_route_type_nearest.yaml @@ -0,0 +1,73 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-identity/1.1.0b2 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:41 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/identities?api-version=2021-10-31-preview + response: + body: + string: '{"identity": {"id": "sanitized"}}' + headers: + api-supported-versions: 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, + 2021-03-31-preview1, 2021-10-31-preview, 2021-11-01 + content-length: '101' + content-type: application/json; charset=utf-8 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: /N9YbA1Auk6fyACeMfet1A.0 + request-context: appId= + strict-transport-security: max-age=2592000 + x-cache: CONFIG_NOCACHE + x-processing-time: 25ms + status: + code: 201 + message: Created + url: https://smstestapp.communication.azure.com/identities?api-version=2021-10-31-preview +- request: + body: '{"id": "sanitized", "routeType": "nearest"}' + headers: + Accept: + - application/json + Content-Length: + - '113' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) + x-ms-date: + - Tue, 16 Nov 2021 23:06:42 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview + response: + body: + string: '{"iceServers": [{"routeType": "nearest", "urls": ["turn.skype.com", + "turn:13.107.17.41:3478"], "username": "sanitized", "credential": "sanitized"}], + "expiresOn": "2021-11-16T23:06:42.1186447+00:00"}' + headers: + api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: '305' + content-type: application/json; charset=utf-8 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: 7KtJ3h8LDkCGRWOukVG7eQ.0 + request-context: appId= + strict-transport-security: max-age=2592000 + x-cache: CONFIG_NOCACHE + x-processing-time: 23ms + status: + code: 200 + message: OK + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview +version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_without_identity.yaml b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_without_identity.yaml index 93ea5a5eea47..424d46daa5ac 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_without_identity.yaml +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_without_identity.yaml @@ -9,30 +9,32 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22494-SP0) x-ms-date: - - Fri, 01 Oct 2021 23:03:10 GMT + - Tue, 16 Nov 2021 23:06:42 GMT x-ms-return-client-request-id: - 'true' method: POST - uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview response: body: - string: '{"expiresOn": "2021-10-01T23:03:10.2349126+00:00", "iceServers": [{"urls": - ["turn.skype.com", "turn:world.relay.skype.com:3478"], "username": "sanitized", - "credential": "sanitized"}]}' + string: '{"iceServers": [{"routeType": "any", "urls": ["turn.skype.com", "turn:world.relay.skype.com:3478"], + "username": "sanitized", "credential": "sanitized"}, {"routeType": "nearest", + "urls": ["stun:13.107.17.41:3478", "turn:13.107.17.41:3478"], "username": + "BQAANvMy40gB19zQSlEkRVh1/NNKh1DiLyF8/XLlsvAAAAAMARCsgNlqhd5IsZldo6P6NifIJL2J21avFzCaenmOaE4FLkbOnpI=", + "credential": "3kkYslXJ8YfdkE2umnl6QSrEGXk="}], "expiresOn": "2021-11-16T23:06:42.230697+00:00"}' headers: - api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview + api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview, 2021-10-08-preview + content-length: '559' content-type: application/json; charset=utf-8 - date: Fri, 01 Oct 2021 23:03:09 GMT - ms-cv: roYDP9+E6EKToiocQJpVlg.0 + date: Tue, 16 Nov 2021 23:06:41 GMT + ms-cv: bLTqTS2HfEGkVtY9HQA9+w.0 request-context: appId= strict-transport-security: max-age=2592000 - transfer-encoding: chunked x-cache: CONFIG_NOCACHE - x-processing-time: 117ms + x-processing-time: 21ms status: code: 200 message: OK - url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-10-08-preview version: 1 diff --git a/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client.py b/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client.py index 53f5a0921257..5067cb4b53b7 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client.py +++ b/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client.py @@ -6,6 +6,7 @@ # -------------------------------------------------------------------------- from azure.core.credentials import AccessToken from azure.communication.identity import CommunicationIdentityClient +from azure.communication.networktraversal import RouteType from azure.communication.identity._api_versions import ApiVersion from azure.communication.networktraversal import CommunicationRelayClient from _shared.helper import URIIdentityReplacer @@ -36,7 +37,6 @@ def setUp(self): def test_get_relay_configuration(self, communication_livetest_dynamic_connection_string): identity_client = CommunicationIdentityClient.from_connection_string( communication_livetest_dynamic_connection_string, - api_version=ApiVersion.V2021_03_07, http_logging_policy=get_http_logging_policy() ) user = identity_client.create_user() @@ -49,7 +49,8 @@ def test_get_relay_configuration(self, communication_livetest_dynamic_connection print('Getting relay config:\n') config = relay_client.get_relay_configuration(user) - print('Ice Servers: \n') + print(config.ice_servers) + for iceServer in config.ice_servers: assert iceServer.username is not None print('Username: ' + iceServer.username) @@ -58,11 +59,15 @@ def test_get_relay_configuration(self, communication_livetest_dynamic_connection print('Credential: ' + iceServer.credential) assert iceServer.urls is not None + for url in iceServer.urls: print('Url: ' + url) + + print(iceServer.route_type) + assert iceServer.route_type is not None assert config is not None - + @CommunicationPreparer() def test_get_relay_configuration_without_identity(self, communication_livetest_dynamic_connection_string): @@ -87,4 +92,67 @@ def test_get_relay_configuration_without_identity(self, communication_livetest_d print('Url: ' + url) assert config is not None - \ No newline at end of file + + @CommunicationPreparer() + def test_get_relay_configuration_with_route_type_nearest(self, communication_livetest_dynamic_connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + user = identity_client.create_user() + + relay_client = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + print('Getting relay config with route type nearest:\n') + config = relay_client.get_relay_configuration(user, RouteType.NEAREST) + + for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url: ' + url) + + print(iceServer.route_type) + assert iceServer.route_type == RouteType.NEAREST + + assert config is not None + + @CommunicationPreparer() + def test_get_relay_configuration_with_route_type_any(self, communication_livetest_dynamic_connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + user = identity_client.create_user() + + relay_client = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + print('Getting relay config with route type nearest:\n') + config = relay_client.get_relay_configuration(user, RouteType.ANY) + + for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url: ' + url) + + print(iceServer.route_type) + assert iceServer.route_type == RouteType.ANY + + assert config is not None \ No newline at end of file diff --git a/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client_async.py b/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client_async.py index 6e133a1cc73f..bf2180635d45 100644 --- a/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client_async.py +++ b/sdk/communication/azure-communication-networktraversal/tests/test_communication_relay_client_async.py @@ -6,6 +6,7 @@ # -------------------------------------------------------------------------- from azure.core.credentials import AccessToken from azure.communication.identity.aio import CommunicationIdentityClient +from azure.communication.networktraversal import RouteType from azure.communication.identity._api_versions import ApiVersion from azure.communication.networktraversal.aio import CommunicationRelayClient from _shared.helper import URIIdentityReplacer @@ -36,7 +37,6 @@ def setUp(self): async def test_get_relay_configuration(self, communication_livetest_dynamic_connection_string): identity_client = CommunicationIdentityClient.from_connection_string( communication_livetest_dynamic_connection_string, - api_version=ApiVersion.V2021_03_07, http_logging_policy=get_http_logging_policy() ) @@ -52,7 +52,6 @@ async def test_get_relay_configuration(self, communication_livetest_dynamic_conn print('Getting relay config:\n') config = await networkTraversalClient.get_relay_configuration(user) - print('Ice Servers Async:\n') for iceServer in config.ice_servers: assert iceServer.username is not None print('Username: ' + iceServer.username) @@ -64,8 +63,10 @@ async def test_get_relay_configuration(self, communication_livetest_dynamic_conn for url in iceServer.urls: print('Url:' + url) - assert config is not None + assert iceServer.route_type is not None + assert config is not None + @CommunicationPreparer() async def test_get_relay_configuration_without_identity(self, communication_livetest_dynamic_connection_string): @@ -91,4 +92,74 @@ async def test_get_relay_configuration_without_identity(self, communication_live print('Url:' + url) assert config is not None + + @CommunicationPreparer() + async def test_get_relay_configuration_with_route_type_nearest(self, communication_livetest_dynamic_connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + async with identity_client: + user = await identity_client.create_user() + + networkTraversalClient = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + async with networkTraversalClient: + print('Getting relay config with nearest type:\n') + config = await networkTraversalClient.get_relay_configuration(user, RouteType.NEAREST) + + print('Ice Servers Async:\n') + for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url:' + url) + + assert iceServer.route_type == RouteType.NEAREST + + assert config is not None + + @CommunicationPreparer() + async def test_get_relay_configuration_with_route_type_any(self, communication_livetest_dynamic_connection_string): + identity_client = CommunicationIdentityClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + async with identity_client: + user = await identity_client.create_user() + + networkTraversalClient = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + async with networkTraversalClient: + print('Getting relay config with nearest type:\n') + config = await networkTraversalClient.get_relay_configuration(user, RouteType.ANY) + + print('Ice Servers Async:\n') + for iceServer in config.ice_servers: + assert iceServer.username is not None + print('Username: ' + iceServer.username) + + assert iceServer.credential is not None + print('Credential: ' + iceServer.credential) + + assert iceServer.urls is not None + for url in iceServer.urls: + print('Url:' + url) + + assert iceServer.route_type == RouteType.ANY + + assert config is not None \ No newline at end of file