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 1605aeb609e1..c4eb0fc83c7b 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 @@ -85,7 +85,7 @@ def from_connection_string( @distributed_trace def get_relay_configuration( self, - user, # type: CommunicationUserIdentifier + user=None, # type: CommunicationUserIdentifier **kwargs # type: Any ): # type: (Any) -> CommunicationRelayConfiguration @@ -94,6 +94,9 @@ def get_relay_configuration( :return: CommunicationRelayConfiguration :rtype: ~azure.communication.networktraversal.CommunicationRelayConfiguration """ + if user is None: + return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( + None, **kwargs) return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( user.properties['id'], **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 23ab5f90b2a3..232315d13b62 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 @@ -6,28 +6,30 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.core import PipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import CommunicationNetworkTraversalClientConfiguration +from .operations import CommunicationNetworkTraversalOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import CommunicationNetworkTraversalClientConfiguration -from .operations import CommunicationNetworkTraversalOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class CommunicationNetworkTraversalClient(object): """Azure Communication Networking Service. :ivar communication_network_traversal: CommunicationNetworkTraversalOperations operations - :vartype communication_network_traversal: azure.communication.networktraversal.operations.CommunicationNetworkTraversalOperations - :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. + :vartype communication_network_traversal: + azure.communication.networktraversal.operations.CommunicationNetworkTraversalOperations + :param endpoint: The communication resource, for example + https://my-resource.communication.azure.com. :type endpoint: str """ @@ -37,35 +39,47 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None - base_url = '{endpoint}' + _base_url = '{endpoint}' self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **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)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.communication_network_traversal = CommunicationNetworkTraversalOperations(self._client, self._config, self._serialize, self._deserialize) - self.communication_network_traversal = CommunicationNetworkTraversalOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_vendor.py b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_vendor.py new file mode 100644 index 000000000000..9a223d15524c --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_vendor.py @@ -0,0 +1,15 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request 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 f9ded0d8d97f..cb1e98300c1d 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 @@ -6,23 +6,25 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any +from copy import deepcopy +from typing import Any, Awaitable from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models from ._configuration import CommunicationNetworkTraversalClientConfiguration from .operations import CommunicationNetworkTraversalOperations -from .. import models - -class CommunicationNetworkTraversalClient(object): +class CommunicationNetworkTraversalClient: """Azure Communication Networking Service. :ivar communication_network_traversal: CommunicationNetworkTraversalOperations operations - :vartype communication_network_traversal: azure.communication.networktraversal.aio.operations.CommunicationNetworkTraversalOperations - :param endpoint: The communication resource, for example https://my-resource.communication.azure.com. + :vartype communication_network_traversal: + azure.communication.networktraversal.aio.operations.CommunicationNetworkTraversalOperations + :param endpoint: The communication resource, for example + https://my-resource.communication.azure.com. :type endpoint: str """ @@ -31,34 +33,46 @@ def __init__( endpoint: str, **kwargs: Any ) -> None: - base_url = '{endpoint}' + _base_url = '{endpoint}' self._config = CommunicationNetworkTraversalClientConfiguration(endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **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)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.communication_network_traversal = CommunicationNetworkTraversalOperations(self._client, self._config, self._serialize, self._deserialize) - self.communication_network_traversal = CommunicationNetworkTraversalOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ + + request_copy = deepcopy(request) path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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 b147205b3bd0..c093ef0e412f 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 @@ -5,14 +5,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # 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 import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async 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]] @@ -39,9 +44,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def issue_relay_configuration( self, - id: str, + id: Optional[str] = None, **kwargs: Any ) -> "_models.CommunicationRelayConfiguration": """Issue a configuration for an STUN/TURN server for an existing identity. @@ -61,37 +67,31 @@ async def issue_relay_configuration( } error_map.update(kwargs.pop('error_map', {})) - _body = _models.CommunicationRelayConfigurationRequest(id=id) - api_version = "2021-06-21-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.issue_relay_configuration.metadata['url'] # type: ignore + _body = _models.CommunicationRelayConfigurationRequest(id=id) + if _body is not None: + json = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') + else: + json = None + + request = build_issue_relay_configuration_request( + content_type=content_type, + json=json, + template_url=self.issue_relay_configuration.metadata['url'], + ) + request = _convert_request(request) path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationRelayConfiguration', pipeline_response) @@ -100,4 +100,6 @@ async def issue_relay_configuration( return cls(pipeline_response, deserialized, {}) return deserialized + issue_relay_configuration.metadata = {'url': '/networktraversal/:issueRelayConfiguration'} # type: ignore + 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 73a3bc58e2c9..fed3c7405e7a 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 @@ -17,10 +17,10 @@ class CommunicationError(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. The error code. - :type code: str - :param message: Required. The error message. - :type message: str + :ivar code: Required. The error code. + :vartype code: str + :ivar message: Required. The error message. + :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: Further details about specific errors that led to this error. @@ -49,6 +49,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Required. The error code. + :paramtype code: str + :keyword message: Required. The error message. + :paramtype message: str + """ super(CommunicationError, self).__init__(**kwargs) self.code = kwargs['code'] self.message = kwargs['message'] @@ -62,8 +68,8 @@ class CommunicationErrorResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param error: Required. The Communication Services error. - :type error: ~azure.communication.networktraversal.models.CommunicationError + :ivar error: Required. The Communication Services error. + :vartype error: ~azure.communication.networktraversal.models.CommunicationError """ _validation = { @@ -78,6 +84,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: Required. The Communication Services error. + :paramtype error: ~azure.communication.networktraversal.models.CommunicationError + """ super(CommunicationErrorResponse, self).__init__(**kwargs) self.error = kwargs['error'] @@ -87,12 +97,12 @@ class CommunicationIceServer(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param urls: Required. List of STUN/TURN server URLs. - :type urls: list[str] - :param username: Required. User account name which uniquely identifies the credentials. - :type username: str - :param credential: Required. Credential for the server. - :type credential: str + :ivar urls: Required. List of STUN/TURN server URLs. + :vartype urls: list[str] + :ivar username: Required. User account name which uniquely identifies the credentials. + :vartype username: str + :ivar credential: Required. Credential for the server. + :vartype credential: str """ _validation = { @@ -111,6 +121,14 @@ def __init__( self, **kwargs ): + """ + :keyword urls: Required. List of STUN/TURN server URLs. + :paramtype urls: list[str] + :keyword username: Required. User account name which uniquely identifies the credentials. + :paramtype username: str + :keyword credential: Required. Credential for the server. + :paramtype credential: str + """ super(CommunicationIceServer, self).__init__(**kwargs) self.urls = kwargs['urls'] self.username = kwargs['username'] @@ -122,12 +140,12 @@ class CommunicationRelayConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param expires_on: Required. The date for which the username and credentials are not longer + :ivar expires_on: Required. The date for which the username and credentials are not longer valid. - :type expires_on: ~datetime.datetime - :param ice_servers: Required. An array representing the credentials and the STUN/TURN server + :vartype expires_on: ~datetime.datetime + :ivar ice_servers: Required. An array representing the credentials and the STUN/TURN server URLs for use in ICE negotiations. - :type ice_servers: list[~azure.communication.networktraversal.models.CommunicationIceServer] + :vartype ice_servers: list[~azure.communication.networktraversal.models.CommunicationIceServer] """ _validation = { @@ -144,6 +162,15 @@ def __init__( self, **kwargs ): + """ + :keyword expires_on: Required. The date for which the username and credentials are not longer + valid. + :paramtype expires_on: ~datetime.datetime + :keyword ice_servers: Required. An array representing the credentials and the STUN/TURN server + URLs for use in ICE negotiations. + :paramtype ice_servers: + list[~azure.communication.networktraversal.models.CommunicationIceServer] + """ super(CommunicationRelayConfiguration, self).__init__(**kwargs) self.expires_on = kwargs['expires_on'] self.ice_servers = kwargs['ice_servers'] @@ -152,16 +179,10 @@ def __init__( class CommunicationRelayConfigurationRequest(msrest.serialization.Model): """Request for a CommunicationRelayConfiguration. - All required parameters must be populated in order to send to Azure. - - :param id: Required. An existing ACS identity. - :type id: str + :ivar id: An existing ACS identity. + :vartype id: str """ - _validation = { - 'id': {'required': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, } @@ -170,5 +191,9 @@ def __init__( self, **kwargs ): + """ + :keyword id: An existing ACS identity. + :paramtype id: str + """ super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs) - self.id = kwargs['id'] + self.id = kwargs.get('id', 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 e8feb05df2f2..75c2169ac8ec 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,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import List +from typing import List, Optional from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -20,10 +20,10 @@ class CommunicationError(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. The error code. - :type code: str - :param message: Required. The error message. - :type message: str + :ivar code: Required. The error code. + :vartype code: str + :ivar message: Required. The error message. + :vartype message: str :ivar target: The error target. :vartype target: str :ivar details: Further details about specific errors that led to this error. @@ -55,6 +55,12 @@ def __init__( message: str, **kwargs ): + """ + :keyword code: Required. The error code. + :paramtype code: str + :keyword message: Required. The error message. + :paramtype message: str + """ super(CommunicationError, self).__init__(**kwargs) self.code = code self.message = message @@ -68,8 +74,8 @@ class CommunicationErrorResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param error: Required. The Communication Services error. - :type error: ~azure.communication.networktraversal.models.CommunicationError + :ivar error: Required. The Communication Services error. + :vartype error: ~azure.communication.networktraversal.models.CommunicationError """ _validation = { @@ -86,6 +92,10 @@ def __init__( error: "CommunicationError", **kwargs ): + """ + :keyword error: Required. The Communication Services error. + :paramtype error: ~azure.communication.networktraversal.models.CommunicationError + """ super(CommunicationErrorResponse, self).__init__(**kwargs) self.error = error @@ -95,12 +105,12 @@ class CommunicationIceServer(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param urls: Required. List of STUN/TURN server URLs. - :type urls: list[str] - :param username: Required. User account name which uniquely identifies the credentials. - :type username: str - :param credential: Required. Credential for the server. - :type credential: str + :ivar urls: Required. List of STUN/TURN server URLs. + :vartype urls: list[str] + :ivar username: Required. User account name which uniquely identifies the credentials. + :vartype username: str + :ivar credential: Required. Credential for the server. + :vartype credential: str """ _validation = { @@ -123,6 +133,14 @@ def __init__( credential: str, **kwargs ): + """ + :keyword urls: Required. List of STUN/TURN server URLs. + :paramtype urls: list[str] + :keyword username: Required. User account name which uniquely identifies the credentials. + :paramtype username: str + :keyword credential: Required. Credential for the server. + :paramtype credential: str + """ super(CommunicationIceServer, self).__init__(**kwargs) self.urls = urls self.username = username @@ -134,12 +152,12 @@ class CommunicationRelayConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param expires_on: Required. The date for which the username and credentials are not longer + :ivar expires_on: Required. The date for which the username and credentials are not longer valid. - :type expires_on: ~datetime.datetime - :param ice_servers: Required. An array representing the credentials and the STUN/TURN server + :vartype expires_on: ~datetime.datetime + :ivar ice_servers: Required. An array representing the credentials and the STUN/TURN server URLs for use in ICE negotiations. - :type ice_servers: list[~azure.communication.networktraversal.models.CommunicationIceServer] + :vartype ice_servers: list[~azure.communication.networktraversal.models.CommunicationIceServer] """ _validation = { @@ -159,6 +177,15 @@ def __init__( ice_servers: List["CommunicationIceServer"], **kwargs ): + """ + :keyword expires_on: Required. The date for which the username and credentials are not longer + valid. + :paramtype expires_on: ~datetime.datetime + :keyword ice_servers: Required. An array representing the credentials and the STUN/TURN server + URLs for use in ICE negotiations. + :paramtype ice_servers: + list[~azure.communication.networktraversal.models.CommunicationIceServer] + """ super(CommunicationRelayConfiguration, self).__init__(**kwargs) self.expires_on = expires_on self.ice_servers = ice_servers @@ -167,16 +194,10 @@ def __init__( class CommunicationRelayConfigurationRequest(msrest.serialization.Model): """Request for a CommunicationRelayConfiguration. - All required parameters must be populated in order to send to Azure. - - :param id: Required. An existing ACS identity. - :type id: str + :ivar id: An existing ACS identity. + :vartype id: str """ - _validation = { - 'id': {'required': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, } @@ -184,8 +205,12 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model): def __init__( self, *, - id: str, + id: Optional[str] = None, **kwargs ): + """ + :keyword id: An existing ACS identity. + :paramtype id: str + """ super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs) self.id = id 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 ce068eea96b6..1f20e8968ecf 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 @@ -5,14 +5,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -21,6 +26,39 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +# fmt: off + +def build_issue_relay_configuration_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + 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') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class CommunicationNetworkTraversalOperations(object): """CommunicationNetworkTraversalOperations operations. @@ -43,9 +81,10 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def issue_relay_configuration( self, - id, # type: str + id=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> "_models.CommunicationRelayConfiguration" @@ -66,37 +105,31 @@ def issue_relay_configuration( } error_map.update(kwargs.pop('error_map', {})) - _body = _models.CommunicationRelayConfigurationRequest(id=id) - api_version = "2021-06-21-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct URL - url = self.issue_relay_configuration.metadata['url'] # type: ignore + _body = _models.CommunicationRelayConfigurationRequest(id=id) + if _body is not None: + json = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') + else: + json = None + + request = build_issue_relay_configuration_request( + content_type=content_type, + json=json, + template_url=self.issue_relay_configuration.metadata['url'], + ) + request = _convert_request(request) path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + 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) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.CommunicationErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('CommunicationRelayConfiguration', pipeline_response) @@ -105,4 +138,6 @@ def issue_relay_configuration( return cls(pipeline_response, deserialized, {}) return deserialized + issue_relay_configuration.metadata = {'url': '/networktraversal/:issueRelayConfiguration'} # type: ignore + 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 3a3939eb7f2d..f04ea0c60c23 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 @@ -83,7 +83,7 @@ def from_connection_string( @distributed_trace_async async def get_relay_configuration( self, - user: 'CommunicationUserIdentifier', + user: 'CommunicationUserIdentifier' = None, **kwargs # type: Any ) -> 'CommunicationRelayConfiguration': """get a Communication Relay configuration. @@ -91,6 +91,9 @@ async def get_relay_configuration( :return: CommunicationRelayConfiguration :rtype: ~azure.communication.networktraversal.CommunicationRelayConfiguration """ + if user is None: + return await self._network_traversal_service_client.communication_network_traversal. \ + issue_relay_configuration(None, **kwargs) return await self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration( user.properties['id'], **kwargs) 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 96589bd48dd4..e0a658cbd187 100644 --- a/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py +++ b/sdk/communication/azure-communication-networktraversal/samples/network_traversal_samples.py @@ -58,6 +58,26 @@ 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 7eb8c56d6950..5d3932338adf 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,9 +57,28 @@ 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/setup.py b/sdk/communication/azure-communication-networktraversal/setup.py index 21d2a6670ad9..54bb8f601be2 100644 --- a/sdk/communication/azure-communication-networktraversal/setup.py +++ b/sdk/communication/azure-communication-networktraversal/setup.py @@ -63,7 +63,7 @@ ]), install_requires=[ 'msrest>=0.5.0', - 'azure-core<2.0.0,>=1.2.2' + 'azure-core<2.0.0,>=1.16.0' ], extras_require={ ":python_version<'3.0'": ['azure-communication-nspkg'], diff --git a/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md b/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md index a35f800d2ed7..4b4fb6c76e35 100644 --- a/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md +++ b/sdk/communication/azure-communication-networktraversal/swagger/SWAGGER.md @@ -17,7 +17,7 @@ autorest ./SWAGGER.md ### Settings ``` yaml tag: package-2021-06-21-preview -require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/86408a8777e623f5f41e260472ed831309b85086/specification/communication/data-plane/Turn/readme.md +require: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4c8162b0a1f7bbd46e9aedc0e19bbe181e549c4c/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 d85f4a21c227..10e71f3b7d7e 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,9 +13,9 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.21390-SP0) + - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.22454-SP0) x-ms-date: - - Sat, 17 Jul 2021 00:38:51 GMT + - Fri, 01 Oct 2021 23:03:08 GMT x-ms-return-client-request-id: - 'true' method: POST @@ -25,13 +25,14 @@ interactions: string: '{"identity": {"id": "sanitized"}}' headers: api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1 + - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, + 2021-10-31-preview content-type: - application/json; charset=utf-8 date: - - Sat, 17 Jul 2021 00:38:51 GMT + - Fri, 01 Oct 2021 23:03:07 GMT ms-cv: - - li8R230IT0W2BXH+OJvqUA.0 + - FV1I5QAfBk69A3bUGCU3xg.0 request-context: - appId= strict-transport-security: @@ -41,7 +42,7 @@ interactions: x-cache: - CONFIG_NOCACHE x-processing-time: - - 93ms + - 179ms status: code: 201 message: Created @@ -59,26 +60,27 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.21390-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) x-ms-date: - - Sat, 17 Jul 2021 00:38:52 GMT + - Fri, 01 Oct 2021 23:03:08 GMT x-ms-return-client-request-id: - 'true' method: POST uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview response: body: - string: '{"expiresOn": "2021-07-17T00:38:52.4840215+00:00", "iceServers": [{"urls": - ["turn.skype.com"], "username": "sanitized", "credential": "sanitized"}]}' + 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"}]}' headers: api-supported-versions: - 2021-02-22-preview1, 2021-06-21-preview content-type: - application/json; charset=utf-8 date: - - Sat, 17 Jul 2021 00:38:52 GMT + - Fri, 01 Oct 2021 23:03:08 GMT ms-cv: - - znyph9q/bECDayYlLuWYlw.0 + - T1Tb9K+y6E6pLXFgnCjmmg.0 request-context: - appId= strict-transport-security: @@ -88,7 +90,7 @@ interactions: x-cache: - CONFIG_NOCACHE x-processing-time: - - 223ms + - 128ms status: code: 200 message: OK 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 new file mode 100644 index 000000000000..7a1fa30695d5 --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client.test_get_relay_configuration_without_identity.yaml @@ -0,0 +1,50 @@ +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-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + x-ms-date: + - Fri, 01 Oct 2021 23:03:08 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-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"}]}' + headers: + api-supported-versions: + - 2021-02-22-preview1, 2021-06-21-preview + content-type: + - application/json; charset=utf-8 + date: + - Fri, 01 Oct 2021 23:03:08 GMT + ms-cv: + - c1XdV0vrhEOnOWF2LrDjGQ.0 + request-context: + - appId= + strict-transport-security: + - max-age=2592000 + transfer-encoding: + - chunked + x-cache: + - CONFIG_NOCACHE + x-processing-time: + - 311ms + status: + code: 200 + message: OK +version: 1 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 f049b6bb912c..0902b75be361 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,9 +9,9 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.21390-SP0) + - azsdk-python-communication-identity/1.0.1 Python/3.7.4 (Windows-10-10.0.22454-SP0) x-ms-date: - - Sat, 17 Jul 2021 00:38:52 GMT + - Fri, 01 Oct 2021 23:03:09 GMT x-ms-return-client-request-id: - 'true' method: POST @@ -21,19 +21,19 @@ interactions: string: '{"identity": {"id": "sanitized"}}' headers: api-supported-versions: 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, - 2021-03-31-preview1 + 2021-03-31-preview1, 2021-10-31-preview content-type: application/json; charset=utf-8 - date: Sat, 17 Jul 2021 00:38:52 GMT - ms-cv: Esxlip8LGUqHgpjD5vk7lA.0 + date: Fri, 01 Oct 2021 23:03:09 GMT + ms-cv: hEHBfG5MIkqgUk3m0Wdarw.0 request-context: appId= strict-transport-security: max-age=2592000 transfer-encoding: chunked x-cache: CONFIG_NOCACHE - x-processing-time: 90ms + x-processing-time: 145ms status: code: 201 message: Created - url: https://turn-python-test.communication.azure.com/identities?api-version=2021-03-07 + url: https://smstestapp.communication.azure.com/identities?api-version=2021-03-07 - request: body: '{"id": "sanitized"}' headers: @@ -44,29 +44,30 @@ interactions: Content-Type: - application/json User-Agent: - - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.21390-SP0) + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) x-ms-date: - - Sat, 17 Jul 2021 00:38:52 GMT + - Fri, 01 Oct 2021 23:03:09 GMT x-ms-return-client-request-id: - 'true' method: POST uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview response: body: - string: '{"expiresOn": "2021-07-17T00:38:53.1187977+00:00", "iceServers": [{"urls": - ["turn.skype.com"], "username": "sanitized", "credential": "sanitized"}]}' + 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"}]}' headers: api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview content-type: application/json; charset=utf-8 - date: Sat, 17 Jul 2021 00:38:52 GMT - ms-cv: 6onUtJzytUObrG0T35kMWw.0 + date: Fri, 01 Oct 2021 23:03:09 GMT + ms-cv: pDiu+i86Fk+DMv1bFRw7qA.0 request-context: appId= strict-transport-security: max-age=2592000 transfer-encoding: chunked x-cache: CONFIG_NOCACHE - x-processing-time: 157ms + x-processing-time: 118ms status: code: 200 message: OK - url: https://turn-python-test.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-preview + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-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 new file mode 100644 index 000000000000..93ea5a5eea47 --- /dev/null +++ b/sdk/communication/azure-communication-networktraversal/tests/recordings/test_communication_relay_client_async.test_get_relay_configuration_without_identity.yaml @@ -0,0 +1,38 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - application/json + Content-Length: + - '2' + Content-Type: + - application/json + User-Agent: + - azsdk-python-communication-networktraversal/1.0.0b1 Python/3.7.4 (Windows-10-10.0.22454-SP0) + x-ms-date: + - Fri, 01 Oct 2021 23:03:10 GMT + x-ms-return-client-request-id: + - 'true' + method: POST + uri: https://sanitized.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-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"}]}' + headers: + api-supported-versions: 2021-02-22-preview1, 2021-06-21-preview + content-type: application/json; charset=utf-8 + date: Fri, 01 Oct 2021 23:03:09 GMT + ms-cv: roYDP9+E6EKToiocQJpVlg.0 + request-context: appId= + strict-transport-security: max-age=2592000 + transfer-encoding: chunked + x-cache: CONFIG_NOCACHE + x-processing-time: 117ms + status: + code: 200 + message: OK + url: https://smstestapp.communication.azure.com/networktraversal/:issueRelayConfiguration?api-version=2021-06-21-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 85e51a96592a..70e8cad42fe8 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 @@ -60,4 +60,29 @@ def test_get_relay_configuration(self, communication_livetest_dynamic_connection print('Url: ' + url) assert config is not None + + @CommunicationPreparer() + def test_get_relay_configuration_without_identity(self, communication_livetest_dynamic_connection_string): + + relay_client = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + print('Getting relay config:\n') + config = relay_client.get_relay_configuration() + + print('Ice Servers: \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 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 7546cb7923b7..a4e09de008fa 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 @@ -63,4 +63,30 @@ async def test_get_relay_configuration(self, communication_livetest_dynamic_conn print('Url:' + url) assert config is not None + + @CommunicationPreparer() + async def test_get_relay_configuration_without_identity(self, communication_livetest_dynamic_connection_string): + + networkTraversalClient = CommunicationRelayClient.from_connection_string( + communication_livetest_dynamic_connection_string, + http_logging_policy=get_http_logging_policy() + ) + + async with networkTraversalClient: + print('Getting relay config:\n') + config = await networkTraversalClient.get_relay_configuration() + + 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 config is not None \ No newline at end of file diff --git a/shared_requirements.txt b/shared_requirements.txt index 3c9254069d21..8940dba5f457 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -207,7 +207,7 @@ opentelemetry-sdk<2.0.0,>=1.0.0 #override azure-communication-sms azure-core<2.0.0,>=1.11.0 #override azure-communication-phonenumbers azure-core<2.0.0,>=1.11.0 #override azure-communication-identity azure-core<2.0.0,>=1.11.0 -#override azure-communication-network-traversal azure-core<2.0.0,>=1.11.0 +#override azure-communication-networktraversal azure-core<2.0.0,>=1.16.0 #override azure-mgmt-communication azure-core<2.0.0,>=1.9.0 #override azure-ai-metricsadvisor azure-core<2.0.0,>=1.6.0 #override azure-ai-metricsadvisor msrest>=0.6.21