Skip to content
Next Next commit
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
  • Loading branch information
ericasp16 authored Jan 29, 2024
commit 8e2997a0617d9ad3ab35de464487bb55c9c270aa
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Release History

## 1.1.1 (Unreleased)
## 1.2.0 (2024-03-01)

### Features Added
- Add support for number lookup
- Format only can be returned for no cost
- Additional number details can be returned for a cost

### Breaking Changes

### Bugs Fixed
## 1.2.0b1 (2023-08-04)

### Other Changes
### Features Added
- Number Lookup API public preview
- API version `2023-05-01-preview` is the default

## 1.1.0 (2023-03-28)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
PhoneNumberCountry,
PhoneNumberLocality,
PhoneNumberOffering,
OperatorInformationResult,
)

__all__ = [
Expand All @@ -36,5 +37,6 @@
'PhoneNumberCountry',
'PhoneNumberLocality',
'PhoneNumberOffering',
'OperatorInformationResult',
'PhoneNumbersClient'
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
V2022_01_11_PREVIEW2 = "2022-01-11-preview2"
V2022_12_01 = "2022-12-01"
V2023_05_01_PREVIEW = "2023-05-01-preview"
V2024_03_01 = "2024-03-01"


DEFAULT_VERSION = ApiVersion.V2022_12_01
DEFAULT_VERSION = ApiVersion.V2024_03_01
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Any

from azure.core import PipelineClient
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from . import models as _models
Expand All @@ -27,7 +28,7 @@ class PhoneNumbersClient: # pylint: disable=client-accepts-api-version-keyword
:param endpoint: The communication resource, for example
https://resourcename.communication.azure.com. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Expand All @@ -39,7 +40,24 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
) -> None:
_endpoint = "{endpoint}"
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)

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

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.

>>> from azure.core.rest import HttpRequest
Expand All @@ -72,7 +90,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
self._client.close()
Expand All @@ -81,5 +99,5 @@ def __enter__(self) -> "PhoneNumbersClient":
self._client.__enter__()
return self

def __exit__(self, *exc_details) -> None:
def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

import sys
from typing import Any

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

if sys.version_info >= (3, 8):
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
else:
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports

VERSION = "unknown"


class PhoneNumbersClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
class PhoneNumbersClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
"""Configuration for PhoneNumbersClient.

Note that all parameters used to create this instance are saved as instance
Expand All @@ -29,21 +22,21 @@ class PhoneNumbersClientConfiguration(Configuration): # pylint: disable=too-man
:param endpoint: The communication resource, for example
https://resourcename.communication.azure.com. Required.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
:keyword api_version: Api Version. Default value is "2024-03-01". Note that overriding this
default value may result in unsupported behavior.
:paramtype api_version: str
"""

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

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

self.endpoint = endpoint
self.api_version = api_version
kwargs.setdefault("sdk_moniker", "phonenumbersclient/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _configure(self, **kwargs: Any) -> None:
Expand All @@ -52,7 +45,7 @@ def _configure(self, **kwargs: Any) -> None:
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
Loading