Skip to content

Commit e1cd0f1

Browse files
authored
Jiriburant/ga version of sip routing (Azure#29217)
* Regenerated the SDKs. * Updated siprouting to GA version. * Added ability to skip tests. * Split SipTrunkRoute public interface and api side. * Fixing lint issues. * Updated SipTrunkRoute model to match the previous one. * Recording new tests. * Reverting changes on skipping the sip routing tests. * Updated CHANGELOG.md * Fixing PR comments. * Fixing comment from apiview. get_trunk throws on not found instead of returning None.
1 parent f317ab3 commit e1cd0f1

File tree

68 files changed

+3800
-5537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3800
-5537
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features Added
66
- API version `2022-12-01` is now the default for Phone Numbers clients.
7+
- Added support for SIP routing API version `2023-03-01`, releasing SIP routing functionality from public preview to GA.
8+
- Added environment variable `AZURE_TEST_DOMAIN` for SIP routing tests to support domain verification.
79

810
### Breaking Changes
911

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77

88
from ._sip_routing_client import SipRoutingClient
9-
from ._generated.models import SipTrunkRoute
10-
from ._models import SipTrunk
9+
from ._models import SipTrunk, SipTrunkRoute
1110

1211
__all__ = [
1312
'SipRoutingClient',

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/__init__.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from ._sip_routing_service import SIPRoutingService
10-
__all__ = ['SIPRoutingService']
9+
from ._client import SIPRoutingService
1110

12-
# `._patch.py` is used for handwritten extensions to the generated code
13-
# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
14-
from ._patch import patch_sdk
15-
patch_sdk()
11+
try:
12+
from ._patch import __all__ as _patch_all
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
except ImportError:
15+
_patch_all = []
16+
from ._patch import patch_sdk as _patch_sdk
17+
18+
__all__ = [
19+
"SIPRoutingService",
20+
]
21+
__all__.extend([p for p in _patch_all if p not in __all__])
22+
23+
_patch_sdk()
Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,54 @@
77
# --------------------------------------------------------------------------
88

99
from copy import deepcopy
10-
from typing import TYPE_CHECKING
11-
12-
from msrest import Deserializer, Serializer
10+
from typing import Any
1311

1412
from azure.core import PipelineClient
13+
from azure.core.rest import HttpRequest, HttpResponse
1514

16-
from . import models
15+
from . import models as _models
1716
from ._configuration import SIPRoutingServiceConfiguration
18-
from .operations import SIPRoutingServiceOperationsMixin
19-
20-
if TYPE_CHECKING:
21-
# pylint: disable=unused-import,ungrouped-imports
22-
from typing import Any
17+
from ._serialization import Deserializer, Serializer
18+
from .operations import SipRoutingOperations
2319

24-
from azure.core.rest import HttpRequest, HttpResponse
2520

26-
class SIPRoutingService(SIPRoutingServiceOperationsMixin):
21+
class SIPRoutingService: # pylint: disable=client-accepts-api-version-keyword
2722
"""SipRouting Service.
2823
24+
:ivar sip_routing: SipRoutingOperations operations
25+
:vartype sip_routing:
26+
azure.communication.phonenumbers.siprouting.operations.SipRoutingOperations
2927
:param endpoint: The communication resource, for example
30-
https://resourcename.communication.azure.com.
28+
https://resourcename.communication.azure.com. Required.
3129
:type endpoint: str
32-
:keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding
33-
this default value may result in unsupported behavior.
30+
:keyword api_version: Api Version. Default value is "2023-03-01". Note that overriding this
31+
default value may result in unsupported behavior.
3432
:paramtype api_version: str
3533
"""
3634

37-
def __init__(
38-
self,
39-
endpoint, # type: str
40-
**kwargs # type: Any
41-
):
42-
# type: (...) -> None
43-
_base_url = '{endpoint}'
35+
def __init__( # pylint: disable=missing-client-constructor-parameter-credential
36+
self, endpoint: str, **kwargs: Any
37+
) -> None:
38+
_endpoint = "{endpoint}"
4439
self._config = SIPRoutingServiceConfiguration(endpoint=endpoint, **kwargs)
45-
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)
40+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
4641

47-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
42+
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
4843
self._serialize = Serializer(client_models)
4944
self._deserialize = Deserializer(client_models)
5045
self._serialize.client_side_validation = False
46+
self.sip_routing = SipRoutingOperations(self._client, self._config, self._serialize, self._deserialize)
5147

52-
53-
def _send_request(
54-
self,
55-
request, # type: HttpRequest
56-
**kwargs # type: Any
57-
):
58-
# type: (...) -> HttpResponse
48+
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
5949
"""Runs the network request through the client's chained policies.
6050
6151
>>> from azure.core.rest import HttpRequest
6252
>>> request = HttpRequest("GET", "https://www.example.org/")
6353
<HttpRequest [GET], url: 'https://www.example.org/'>
64-
>>> response = client._send_request(request)
54+
>>> response = client.send_request(request)
6555
<HttpResponse: 200 OK>
6656
67-
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
57+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
6858
6959
:param request: The network request you want to make. Required.
7060
:type request: ~azure.core.rest.HttpRequest
@@ -75,21 +65,18 @@ def _send_request(
7565

7666
request_copy = deepcopy(request)
7767
path_format_arguments = {
78-
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
68+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
7969
}
8070

8171
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
8272
return self._client.send_request(request_copy, **kwargs)
8373

84-
def close(self):
85-
# type: () -> None
74+
def close(self) -> None:
8675
self._client.close()
8776

88-
def __enter__(self):
89-
# type: () -> SIPRoutingService
77+
def __enter__(self) -> "SIPRoutingService":
9078
self._client.__enter__()
9179
return self
9280

93-
def __exit__(self, *exc_details):
94-
# type: (Any) -> None
81+
def __exit__(self, *exc_details: Any) -> None:
9582
self._client.__exit__(*exc_details)

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_configuration.py

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,53 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
from typing import TYPE_CHECKING
9+
import sys
10+
from typing import Any
1011

1112
from azure.core.configuration import Configuration
1213
from azure.core.pipeline import policies
1314

14-
if TYPE_CHECKING:
15-
# pylint: disable=unused-import,ungrouped-imports
16-
from typing import Any
15+
if sys.version_info >= (3, 8):
16+
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
17+
else:
18+
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
1719

1820
VERSION = "unknown"
1921

22+
2023
class SIPRoutingServiceConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
2124
"""Configuration for SIPRoutingService.
2225
2326
Note that all parameters used to create this instance are saved as instance
2427
attributes.
2528
2629
:param endpoint: The communication resource, for example
27-
https://resourcename.communication.azure.com.
30+
https://resourcename.communication.azure.com. Required.
2831
:type endpoint: str
29-
:keyword api_version: Api Version. Default value is "2021-05-01-preview". Note that overriding
30-
this default value may result in unsupported behavior.
32+
:keyword api_version: Api Version. Default value is "2023-03-01". Note that overriding this
33+
default value may result in unsupported behavior.
3134
:paramtype api_version: str
3235
"""
3336

34-
def __init__(
35-
self,
36-
endpoint, # type: str
37-
**kwargs # type: Any
38-
):
39-
# type: (...) -> None
37+
def __init__(self, endpoint: str, **kwargs: Any) -> None:
4038
super(SIPRoutingServiceConfiguration, self).__init__(**kwargs)
41-
api_version = kwargs.pop('api_version', "2021-05-01-preview") # type: str
39+
api_version: Literal["2023-03-01"] = kwargs.pop("api_version", "2023-03-01")
4240

4341
if endpoint is None:
4442
raise ValueError("Parameter 'endpoint' must not be None.")
4543

4644
self.endpoint = endpoint
4745
self.api_version = api_version
48-
kwargs.setdefault('sdk_moniker', 'siproutingservice/{}'.format(VERSION))
46+
kwargs.setdefault("sdk_moniker", "siproutingservice/{}".format(VERSION))
4947
self._configure(**kwargs)
5048

51-
def _configure(
52-
self,
53-
**kwargs # type: Any
54-
):
55-
# type: (...) -> None
56-
self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs)
57-
self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs)
58-
self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs)
59-
self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs)
60-
self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs)
61-
self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs)
62-
self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs)
63-
self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs)
64-
self.authentication_policy = kwargs.get('authentication_policy')
49+
def _configure(self, **kwargs: Any) -> None:
50+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
51+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
52+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
53+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
54+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
55+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
56+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
57+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
58+
self.authentication_policy = kwargs.get("authentication_policy")

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/siprouting/_generated/_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
# This file is used for handwritten extensions to the generated code. Example:
2929
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
3030
def patch_sdk():
31-
pass
31+
pass

0 commit comments

Comments
 (0)