Skip to content

Commit e5063d1

Browse files
authored
Add new ttl parameter to getRelayConfiguration (Azure#23568)
* Add ttl as parameter to GetRelayConfiguration * Fix build errors * Use correct version convention * Fix build errors * Fix build * Only validate the TTL in live tests
1 parent deb8ac9 commit e5063d1

27 files changed

+453
-224
lines changed

sdk/communication/azure-communication-networktraversal/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Release History
22

3+
## 1.1.0b1 (2022-03-18)
4+
5+
### Features Added
6+
7+
- Adding optional parameter to GetRelayConfiguration to choose credential Time-To-Live in seconds of max 48 hours.
8+
The default value will be used if given value exceeds it.
9+
10+
### Breaking Changes
11+
12+
- Making User, RouteType and Ttl part of the options parameter
13+
- getRelayConfiguration can be called without parameters or passing the GetRelayConfigurationOptions parameter
14+
315
## 1.0.0 (2022-02-04) (Deprecated)
416

517
### Breaking Changes

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_communication_relay_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def get_relay_configuration(
8989
*,
9090
user=None, # type: CommunicationUserIdentifier
9191
route_type=None, # type: Optional[Union[str, "RouteType"]]
92+
ttl=172800, # type: Optional[int]
9293
**kwargs # type: Any
9394
):
9495
# type: (...) -> CommunicationRelayConfiguration
@@ -102,8 +103,9 @@ def get_relay_configuration(
102103
"""
103104
if user is None:
104105
return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration(
105-
None, route_type, **kwargs)
106+
route_type=route_type, ttl=ttl, **kwargs)
106107
return self._network_traversal_service_client.communication_network_traversal.issue_relay_configuration(
107-
user.properties['id'],
108-
route_type,
108+
id=user.properties['id'],
109+
route_type=route_type,
110+
ttl=ttl,
109111
**kwargs)

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_communication_network_traversal_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from copy import deepcopy
1010
from typing import TYPE_CHECKING
1111

12-
from azure.core import PipelineClient
1312
from msrest import Deserializer, Serializer
1413

14+
from azure.core import PipelineClient
15+
1516
from . import models
1617
from ._configuration import CommunicationNetworkTraversalClientConfiguration
1718
from .operations import CommunicationNetworkTraversalOperations
@@ -31,8 +32,8 @@ class CommunicationNetworkTraversalClient(object):
3132
:param endpoint: The communication resource, for example
3233
https://my-resource.communication.azure.com.
3334
:type endpoint: str
34-
:keyword api_version: Api Version. The default value is "2022-02-01". Note that overriding this
35-
default value may result in unsupported behavior.
35+
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
36+
this default value may result in unsupported behavior.
3637
:paramtype api_version: str
3738
"""
3839

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/_configuration.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,17 @@
1717

1818
VERSION = "unknown"
1919

20-
class CommunicationNetworkTraversalClientConfiguration(Configuration):
20+
class CommunicationNetworkTraversalClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
2121
"""Configuration for CommunicationNetworkTraversalClient.
2222
2323
Note that all parameters used to create this instance are saved as instance
2424
attributes.
2525
26-
:param endpoint: The communication resource, for example https://my-resource.communication.azure.com.
26+
:param endpoint: The communication resource, for example
27+
https://my-resource.communication.azure.com.
2728
:type endpoint: str
28-
:keyword api_version: Api Version. The default value is "2022-02-01". Note that overriding this default value may result in unsupported behavior.
29+
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
30+
this default value may result in unsupported behavior.
2931
:paramtype api_version: str
3032
"""
3133

@@ -36,7 +38,7 @@ def __init__(
3638
):
3739
# type: (...) -> None
3840
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)
39-
api_version = kwargs.pop('api_version', "2022-02-01") # type: str
41+
api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str
4042

4143
if endpoint is None:
4244
raise ValueError("Parameter 'endpoint' must not be None.")

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_communication_network_traversal_client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
from copy import deepcopy
1010
from typing import Any, Awaitable
1111

12+
from msrest import Deserializer, Serializer
13+
1214
from azure.core import AsyncPipelineClient
1315
from azure.core.rest import AsyncHttpResponse, HttpRequest
14-
from msrest import Deserializer, Serializer
1516

1617
from .. import models
1718
from ._configuration import CommunicationNetworkTraversalClientConfiguration
@@ -26,8 +27,8 @@ class CommunicationNetworkTraversalClient:
2627
:param endpoint: The communication resource, for example
2728
https://my-resource.communication.azure.com.
2829
:type endpoint: str
29-
:keyword api_version: Api Version. The default value is "2022-02-01". Note that overriding this
30-
default value may result in unsupported behavior.
30+
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
31+
this default value may result in unsupported behavior.
3132
:paramtype api_version: str
3233
"""
3334

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/_configuration.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414
VERSION = "unknown"
1515

16-
class CommunicationNetworkTraversalClientConfiguration(Configuration):
16+
class CommunicationNetworkTraversalClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
1717
"""Configuration for CommunicationNetworkTraversalClient.
1818
1919
Note that all parameters used to create this instance are saved as instance
2020
attributes.
2121
22-
:param endpoint: The communication resource, for example https://my-resource.communication.azure.com.
22+
:param endpoint: The communication resource, for example
23+
https://my-resource.communication.azure.com.
2324
:type endpoint: str
24-
:keyword api_version: Api Version. The default value is "2022-02-01". Note that overriding this default value may result in unsupported behavior.
25+
:keyword api_version: Api Version. Default value is "2022-03-01-preview". Note that overriding
26+
this default value may result in unsupported behavior.
2527
:paramtype api_version: str
2628
"""
2729

@@ -31,7 +33,7 @@ def __init__(
3133
**kwargs: Any
3234
) -> None:
3335
super(CommunicationNetworkTraversalClientConfiguration, self).__init__(**kwargs)
34-
api_version = kwargs.pop('api_version', "2022-02-01") # type: str
36+
api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str
3537

3638
if endpoint is None:
3739
raise ValueError("Parameter 'endpoint' must not be None.")

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/aio/operations/_communication_network_traversal_operations.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
# pylint: disable=too-many-lines
12
# coding=utf-8
23
# --------------------------------------------------------------------------
34
# Copyright (c) Microsoft Corporation. All rights reserved.
45
# Licensed under the MIT License. See License.txt in the project root for license information.
56
# Code generated by Microsoft (R) AutoRest Code Generator.
67
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
78
# --------------------------------------------------------------------------
8-
import functools
9-
from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union
10-
import warnings
9+
from typing import Any, Callable, Dict, Optional, TypeVar, Union
1110

1211
from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
1312
from azure.core.pipeline import PipelineResponse
@@ -22,32 +21,31 @@
2221
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
2322

2423
class CommunicationNetworkTraversalOperations:
25-
"""CommunicationNetworkTraversalOperations async operations.
26-
27-
You should not instantiate this class directly. Instead, you should create a Client instance that
28-
instantiates it for you and attaches it as an attribute.
24+
"""
25+
.. warning::
26+
**DO NOT** instantiate this class directly.
2927
30-
:ivar models: Alias to model classes used in this operation group.
31-
:type models: ~azure.communication.networktraversal.models
32-
:param client: Client for service requests.
33-
:param config: Configuration of service client.
34-
:param serializer: An object model serializer.
35-
:param deserializer: An object model deserializer.
28+
Instead, you should access the following operations through
29+
:class:`~azure.communication.networktraversal.aio.CommunicationNetworkTraversalClient`'s
30+
:attr:`communication_network_traversal` attribute.
3631
"""
3732

3833
models = _models
3934

40-
def __init__(self, client, config, serializer, deserializer) -> None:
41-
self._client = client
42-
self._serialize = serializer
43-
self._deserialize = deserializer
44-
self._config = config
35+
def __init__(self, *args, **kwargs) -> None:
36+
args = list(args)
37+
self._client = args.pop(0) if args else kwargs.pop("client")
38+
self._config = args.pop(0) if args else kwargs.pop("config")
39+
self._serialize = args.pop(0) if args else kwargs.pop("serializer")
40+
self._deserialize = args.pop(0) if args else kwargs.pop("deserializer")
41+
4542

4643
@distributed_trace_async
4744
async def issue_relay_configuration(
4845
self,
4946
id: Optional[str] = None,
5047
route_type: Optional[Union[str, "_models.RouteType"]] = None,
48+
ttl: Optional[int] = 172800,
5149
**kwargs: Any
5250
) -> "_models.CommunicationRelayConfiguration":
5351
"""Issue a configuration for an STUN/TURN server.
@@ -56,14 +54,14 @@ async def issue_relay_configuration(
5654
5755
:param id: An identity to be associated with telemetry for data relayed using the returned
5856
credentials. Must be an existing ACS user identity. If not provided, the telemetry will not
59-
contain an associated identity value.
57+
contain an associated identity value. Default value is None.
6058
:type id: str
6159
:param route_type: Filter the routing methodology returned. If not provided, will return all
62-
route types in separate ICE servers.
60+
route types in separate ICE servers. Default value is None.
6361
:type route_type: str or ~azure.communication.networktraversal.models.RouteType
64-
:keyword api_version: Api Version. The default value is "2022-02-01". Note that overriding this
65-
default value may result in unsupported behavior.
66-
:paramtype api_version: str
62+
:param ttl: The credential Time-To-Live (TTL), in seconds. The default value will be used if
63+
given value exceeds it. Default value is 172800.
64+
:type ttl: int
6765
:keyword callable cls: A custom type or function that will be passed the direct response
6866
:return: CommunicationRelayConfiguration, or the result of cls(response)
6967
:rtype: ~azure.communication.networktraversal.models.CommunicationRelayConfiguration
@@ -75,10 +73,10 @@ async def issue_relay_configuration(
7573
}
7674
error_map.update(kwargs.pop('error_map', {}))
7775

78-
api_version = kwargs.pop('api_version', "2022-02-01") # type: str
76+
api_version = kwargs.pop('api_version', "2022-03-01-preview") # type: str
7977
content_type = kwargs.pop('content_type', "application/json") # type: Optional[str]
8078

81-
_body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type)
79+
_body = _models.CommunicationRelayConfigurationRequest(id=id, route_type=route_type, ttl=ttl)
8280
if _body is not None:
8381
_json = self._serialize.body(_body, 'CommunicationRelayConfigurationRequest')
8482
else:
@@ -96,7 +94,11 @@ async def issue_relay_configuration(
9694
}
9795
request.url = self._client.format_url(request.url, **path_format_arguments)
9896

99-
pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
97+
pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access
98+
request,
99+
stream=False,
100+
**kwargs
101+
)
100102
response = pipeline_response.http_response
101103

102104
if response.status_code not in [200]:
@@ -111,5 +113,5 @@ async def issue_relay_configuration(
111113

112114
return deserialized
113115

114-
issue_relay_configuration.metadata = {'url': '/networkTraversal/:issueRelayConfiguration'} # type: ignore
116+
issue_relay_configuration.metadata = {'url': "/networkTraversal/:issueRelayConfiguration"} # type: ignore
115117

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,19 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model):
199199
:ivar route_type: Filter the routing methodology returned. If not provided, will return all
200200
route types in separate ICE servers. Possible values include: "any", "nearest".
201201
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
202+
:ivar ttl: The credential Time-To-Live (TTL), in seconds. The default value will be used if
203+
given value exceeds it.
204+
:vartype ttl: int
202205
"""
203206

207+
_validation = {
208+
'ttl': {'maximum': 172800, 'minimum': 0},
209+
}
210+
204211
_attribute_map = {
205212
'id': {'key': 'id', 'type': 'str'},
206213
'route_type': {'key': 'routeType', 'type': 'str'},
214+
'ttl': {'key': 'ttl', 'type': 'int'},
207215
}
208216

209217
def __init__(
@@ -218,7 +226,11 @@ def __init__(
218226
:keyword route_type: Filter the routing methodology returned. If not provided, will return all
219227
route types in separate ICE servers. Possible values include: "any", "nearest".
220228
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
229+
:keyword ttl: The credential Time-To-Live (TTL), in seconds. The default value will be used if
230+
given value exceeds it.
231+
:paramtype ttl: int
221232
"""
222233
super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs)
223234
self.id = kwargs.get('id', None)
224235
self.route_type = kwargs.get('route_type', None)
236+
self.ttl = kwargs.get('ttl', 172800)

sdk/communication/azure-communication-networktraversal/azure/communication/networktraversal/_generated/models/_models_py3.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,27 @@ class CommunicationRelayConfigurationRequest(msrest.serialization.Model):
217217
:ivar route_type: Filter the routing methodology returned. If not provided, will return all
218218
route types in separate ICE servers. Possible values include: "any", "nearest".
219219
:vartype route_type: str or ~azure.communication.networktraversal.models.RouteType
220+
:ivar ttl: The credential Time-To-Live (TTL), in seconds. The default value will be used if
221+
given value exceeds it.
222+
:vartype ttl: int
220223
"""
221224

225+
_validation = {
226+
'ttl': {'maximum': 172800, 'minimum': 0},
227+
}
228+
222229
_attribute_map = {
223230
'id': {'key': 'id', 'type': 'str'},
224231
'route_type': {'key': 'routeType', 'type': 'str'},
232+
'ttl': {'key': 'ttl', 'type': 'int'},
225233
}
226234

227235
def __init__(
228236
self,
229237
*,
230238
id: Optional[str] = None,
231239
route_type: Optional[Union[str, "RouteType"]] = None,
240+
ttl: Optional[int] = 172800,
232241
**kwargs
233242
):
234243
"""
@@ -239,7 +248,11 @@ def __init__(
239248
:keyword route_type: Filter the routing methodology returned. If not provided, will return all
240249
route types in separate ICE servers. Possible values include: "any", "nearest".
241250
:paramtype route_type: str or ~azure.communication.networktraversal.models.RouteType
251+
:keyword ttl: The credential Time-To-Live (TTL), in seconds. The default value will be used if
252+
given value exceeds it.
253+
:paramtype ttl: int
242254
"""
243255
super(CommunicationRelayConfigurationRequest, self).__init__(**kwargs)
244256
self.id = id
245257
self.route_type = route_type
258+
self.ttl = ttl

0 commit comments

Comments
 (0)