Skip to content

Commit 8e2997a

Browse files
authored
Number lookup ga (#33203)
GA implementation of the number lookup feature. This commit should cover the vast majority of the work needed, and is updated to incorporate feedback from the stewardship board. These changes are going into a branch to wait until we're ready to do our final bug bashing and eventually merging and shipping the feature. ---------- * Add number lookup to communication phonenumbers (#31053) * update swagger and regenerate using autorest * update internal operation tests * regenerate autorest, add and record tests * Update changelog * update tests to account for phone number sanitization, update test recordings * update autorest generation * updates based on review comments * udpate tests/recordings * fix linting error * fix lint errors and test for async * update test recordings * update changelog, minor fixes to tests, and update to the recordings * update version in changelog to beta version * update version * update changelog * update changelog * update generated files * update to GA verison for review * updated based on SDK review feedback
1 parent 7744050 commit 8e2997a

File tree

30 files changed

+1682
-559
lines changed

30 files changed

+1682
-559
lines changed

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

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

3-
## 1.1.1 (Unreleased)
3+
## 1.2.0 (2024-03-01)
44

55
### Features Added
6+
- Add support for number lookup
7+
- Format only can be returned for no cost
8+
- Additional number details can be returned for a cost
69

7-
### Breaking Changes
8-
9-
### Bugs Fixed
10+
## 1.2.0b1 (2023-08-04)
1011

11-
### Other Changes
12+
### Features Added
13+
- Number Lookup API public preview
14+
- API version `2023-05-01-preview` is the default
1215

1316
## 1.1.0 (2023-03-28)
1417

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
PhoneNumberCountry,
2121
PhoneNumberLocality,
2222
PhoneNumberOffering,
23+
OperatorInformationResult,
2324
)
2425

2526
__all__ = [
@@ -36,5 +37,6 @@
3637
'PhoneNumberCountry',
3738
'PhoneNumberLocality',
3839
'PhoneNumberOffering',
40+
'OperatorInformationResult',
3941
'PhoneNumbersClient'
4042
]

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_api_versions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1111
V2022_01_11_PREVIEW2 = "2022-01-11-preview2"
1212
V2022_12_01 = "2022-12-01"
13+
V2023_05_01_PREVIEW = "2023-05-01-preview"
14+
V2024_03_01 = "2024-03-01"
1315

1416

15-
DEFAULT_VERSION = ApiVersion.V2022_12_01
17+
DEFAULT_VERSION = ApiVersion.V2024_03_01

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_client.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any
1111

1212
from azure.core import PipelineClient
13+
from azure.core.pipeline import policies
1314
from azure.core.rest import HttpRequest, HttpResponse
1415

1516
from . import models as _models
@@ -27,7 +28,7 @@ class PhoneNumbersClient: # pylint: disable=client-accepts-api-version-keyword
2728
:param endpoint: The communication resource, for example
2829
https://resourcename.communication.azure.com. Required.
2930
:type endpoint: str
30-
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
31+
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
3132
default value may result in unsupported behavior.
3233
:paramtype api_version: str
3334
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -39,7 +40,24 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
3940
) -> None:
4041
_endpoint = "{endpoint}"
4142
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
42-
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
43+
_policies = kwargs.pop("policies", None)
44+
if _policies is None:
45+
_policies = [
46+
policies.RequestIdPolicy(**kwargs),
47+
self._config.headers_policy,
48+
self._config.user_agent_policy,
49+
self._config.proxy_policy,
50+
policies.ContentDecodePolicy(**kwargs),
51+
self._config.redirect_policy,
52+
self._config.retry_policy,
53+
self._config.authentication_policy,
54+
self._config.custom_hook_policy,
55+
self._config.logging_policy,
56+
policies.DistributedTracingPolicy(**kwargs),
57+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
58+
self._config.http_logging_policy,
59+
]
60+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
4361

4462
client_models = {k: v for k, v in _models._models.__dict__.items() if isinstance(v, type)}
4563
client_models.update({k: v for k, v in _models.__dict__.items() if isinstance(v, type)})
@@ -48,7 +66,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
4866
self._serialize.client_side_validation = False
4967
self.phone_numbers = PhoneNumbersOperations(self._client, self._config, self._serialize, self._deserialize)
5068

51-
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
69+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
5270
"""Runs the network request through the client's chained policies.
5371
5472
>>> from azure.core.rest import HttpRequest
@@ -72,7 +90,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
7290
}
7391

7492
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
75-
return self._client.send_request(request_copy, **kwargs)
93+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
7694

7795
def close(self) -> None:
7896
self._client.close()
@@ -81,5 +99,5 @@ def __enter__(self) -> "PhoneNumbersClient":
8199
self._client.__enter__()
82100
return self
83101

84-
def __exit__(self, *exc_details) -> None:
102+
def __exit__(self, *exc_details: Any) -> None:
85103
self._client.__exit__(*exc_details)

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

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

9-
import sys
109
from typing import Any
1110

12-
from azure.core.configuration import Configuration
1311
from azure.core.pipeline import policies
1412

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
19-
2013
VERSION = "unknown"
2114

2215

23-
class PhoneNumbersClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
16+
class PhoneNumbersClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2417
"""Configuration for PhoneNumbersClient.
2518
2619
Note that all parameters used to create this instance are saved as instance
@@ -29,21 +22,21 @@ class PhoneNumbersClientConfiguration(Configuration): # pylint: disable=too-man
2922
:param endpoint: The communication resource, for example
3023
https://resourcename.communication.azure.com. Required.
3124
:type endpoint: str
32-
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
25+
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
3326
default value may result in unsupported behavior.
3427
:paramtype api_version: str
3528
"""
3629

3730
def __init__(self, endpoint: str, **kwargs: Any) -> None:
38-
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
39-
api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01")
31+
api_version: str = kwargs.pop("api_version", "2024-03-01")
4032

4133
if endpoint is None:
4234
raise ValueError("Parameter 'endpoint' must not be None.")
4335

4436
self.endpoint = endpoint
4537
self.api_version = api_version
4638
kwargs.setdefault("sdk_moniker", "phonenumbersclient/{}".format(VERSION))
39+
self.polling_interval = kwargs.get("polling_interval", 30)
4740
self._configure(**kwargs)
4841

4942
def _configure(self, **kwargs: Any) -> None:
@@ -52,7 +45,7 @@ def _configure(self, **kwargs: Any) -> None:
5245
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5346
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5447
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)
5648
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
5749
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
50+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
5851
self.authentication_policy = kwargs.get("authentication_policy")

0 commit comments

Comments
 (0)