Skip to content

Commit 69d88e0

Browse files
[Communication] - Phone Numbers - Add browse API methods (Azure#25355)
* Add browse API methods * Export new models to public API, fix errors Due to changes in the latest version of autorest, some generated method signatures had changed. * Fix docstring for new API methods * Cleanup docstrings, update min azure-core version * Override locked dependency for phone-numbers * Fix linter issues * Setup autorest with new v2 api * Rename AreaCodeResult to AreaCodeItem * Add locality and administrative division to search and add acepted_language to constructor * Rafactor list_area_codes to have just 1 function for tollFree and geographic * Replace two_letter_iso_country_name with country_code * Add optional arguments to kwargs * Add changes to phone_number_clients_async * Replace phone_number_assignment_type with assignment_type * Replace get_routes with list_routes * Replace get_trunks with list_trunks * Add area codes tests * Add countries tests * Add localities and offerings tests * Test changes in administrative division * Replace swagger * Update tests to include first locality * Replace docstrings for area codes method * Fix docstring comments * Refactor area_codes function to receive phone number type * Remove unecessary comments * Add aad tests to browse api * Update recordings * Update recordings * Update sync recordings * Update sip recordings * Update sip recordings duplicates * Rename localities tests * Update localities recordings * Update localities recordings * Remove unused recordings * Fix linting * Fix failling error from merge * Fix lint and recover errased test cases * Fix identation * Remove whitespace * Remove extra whitespace Co-authored-by: Sofia Robles Sandoval <sofiar@microsoft.com>
1 parent 0e54d68 commit 69d88e0

File tree

118 files changed

+18818
-4007
lines changed

Some content is hidden

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

118 files changed

+18818
-4007
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ poller = self.phone_number_client.begin_update_phone_number_capabilities(
189189
Get the list of currently configured trunks or routes.
190190

191191
```python
192-
trunks = sip_routing_client.get_trunks()
192+
trunks = sip_routing_client.list_trunks()
193193
for trunk in trunks:
194194
print(trunk.fqdn)
195195
print(trunk.sip_signaling_port)
196-
routes = sip_routing_client.get_routes()
196+
routes = sip_routing_client.list_routes()
197197
for route in routes:
198198
print(route.name)
199199
print(route.description)

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
PhoneNumberAssignmentType,
1616
PhoneNumberCapabilityType,
1717
PhoneNumberType,
18+
PhoneNumberAreaCode,
19+
PhoneNumberAdministrativeDivision,
20+
PhoneNumberCountry,
21+
PhoneNumberLocality,
22+
PhoneNumberOffering,
1823
)
1924

2025
__all__ = [
@@ -26,5 +31,10 @@
2631
'PhoneNumberAssignmentType',
2732
'PhoneNumberCapabilityType',
2833
'PhoneNumberType',
34+
'PhoneNumberAreaCode',
35+
'PhoneNumberAdministrativeDivision',
36+
'PhoneNumberCountry',
37+
'PhoneNumberLocality',
38+
'PhoneNumberOffering',
2939
'PhoneNumbersClient'
3040
]

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

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

9-
from ._phone_numbers_client import PhoneNumbersClient
9+
from ._client import PhoneNumbersClient
1010

1111
try:
1212
from ._patch import __all__ as _patch_all
13-
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
13+
from ._patch import * # pylint: disable=unused-wildcard-import
1414
except ImportError:
1515
_patch_all = []
1616
from ._patch import patch_sdk as _patch_sdk
1717

18-
__all__ = ["PhoneNumbersClient"]
18+
__all__ = [
19+
"PhoneNumbersClient",
20+
]
1921
__all__.extend([p for p in _patch_all if p not in __all__])
2022

2123
_patch_sdk()

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_phone_numbers_client.py renamed to sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/_client.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from azure.core import PipelineClient
1313
from azure.core.rest import HttpRequest, HttpResponse
1414

15-
from . import models
15+
from . import models as _models
1616
from ._configuration import PhoneNumbersClientConfiguration
1717
from ._serialization import Deserializer, Serializer
1818
from .operations import PhoneNumbersOperations
@@ -27,8 +27,8 @@ class PhoneNumbersClient: # pylint: disable=client-accepts-api-version-keyword
2727
:param endpoint: The communication resource, for example
2828
https://resourcename.communication.azure.com. Required.
2929
:type endpoint: str
30-
:keyword api_version: Api Version. Default value is "2022-01-11-preview2". Note that overriding
31-
this default value may result in unsupported behavior.
30+
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
31+
default value may result in unsupported behavior.
3232
:paramtype api_version: str
3333
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
3434
Retry-After header is present.
@@ -41,19 +41,20 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
4141
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
4242
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
4343

44-
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
44+
client_models = {k: v for k, v in _models._models.__dict__.items() if isinstance(v, type)}
45+
client_models.update({k: v for k, v in _models.__dict__.items() if isinstance(v, type)})
4546
self._serialize = Serializer(client_models)
4647
self._deserialize = Deserializer(client_models)
4748
self._serialize.client_side_validation = False
4849
self.phone_numbers = PhoneNumbersOperations(self._client, self._config, self._serialize, self._deserialize)
4950

50-
def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
51+
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
5152
"""Runs the network request through the client's chained policies.
5253
5354
>>> from azure.core.rest import HttpRequest
5455
>>> request = HttpRequest("GET", "https://www.example.org/")
5556
<HttpRequest [GET], url: 'https://www.example.org/'>
56-
>>> response = client._send_request(request)
57+
>>> response = client.send_request(request)
5758
<HttpResponse: 200 OK>
5859
5960
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
@@ -73,15 +74,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
7374
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
7475
return self._client.send_request(request_copy, **kwargs)
7576

76-
def close(self):
77-
# type: () -> None
77+
def close(self) -> None:
7878
self._client.close()
7979

80-
def __enter__(self):
81-
# type: () -> PhoneNumbersClient
80+
def __enter__(self) -> "PhoneNumbersClient":
8281
self._client.__enter__()
8382
return self
8483

85-
def __exit__(self, *exc_details):
86-
# type: (Any) -> None
84+
def __exit__(self, *exc_details) -> None:
8785
self._client.__exit__(*exc_details)

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

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

9+
import sys
910
from typing import Any
1011

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

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+
1420
VERSION = "unknown"
1521

1622

@@ -23,14 +29,14 @@ class PhoneNumbersClientConfiguration(Configuration): # pylint: disable=too-man
2329
:param endpoint: The communication resource, for example
2430
https://resourcename.communication.azure.com. Required.
2531
:type endpoint: str
26-
:keyword api_version: Api Version. Default value is "2022-01-11-preview2". Note that overriding
27-
this default value may result in unsupported behavior.
32+
:keyword api_version: Api Version. Default value is "2022-12-01". Note that overriding this
33+
default value may result in unsupported behavior.
2834
:paramtype api_version: str
2935
"""
3036

3137
def __init__(self, endpoint: str, **kwargs: Any) -> None:
3238
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
33-
api_version = kwargs.pop("api_version", "2022-01-11-preview2") # type: str
39+
api_version: Literal["2022-12-01"] = kwargs.pop("api_version", "2022-12-01")
3440

3541
if endpoint is None:
3642
raise ValueError("Parameter 'endpoint' must not be None.")
@@ -40,10 +46,7 @@ def __init__(self, endpoint: str, **kwargs: Any) -> None:
4046
kwargs.setdefault("sdk_moniker", "phonenumbersclient/{}".format(VERSION))
4147
self._configure(**kwargs)
4248

43-
def _configure(
44-
self, **kwargs # type: Any
45-
):
46-
# type: (...) -> None
49+
def _configure(self, **kwargs: Any) -> None:
4750
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
4851
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
4952
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
1-
# coding=utf-8
2-
# --------------------------------------------------------------------------
3-
#
4-
# Copyright (c) Microsoft Corporation. All rights reserved.
5-
#
6-
# The MIT License (MIT)
7-
#
8-
# Permission is hereby granted, free of charge, to any person obtaining a copy
9-
# of this software and associated documentation files (the ""Software""), to
10-
# deal in the Software without restriction, including without limitation the
11-
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12-
# sell copies of the Software, and to permit persons to whom the Software is
13-
# furnished to do so, subject to the following conditions:
14-
#
15-
# The above copyright notice and this permission notice shall be included in
16-
# all copies or substantial portions of the Software.
17-
#
18-
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23-
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24-
# IN THE SOFTWARE.
25-
#
26-
# --------------------------------------------------------------------------
1+
# ------------------------------------
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
# ------------------------------------
5+
"""Customize generated code here.
6+
7+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
8+
"""
9+
from typing import List
10+
11+
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level
12+
2713

28-
# This file is used for handwritten extensions to the generated code. Example:
29-
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
3014
def patch_sdk():
31-
pass
15+
"""Do not remove from this file.
16+
17+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
18+
you can't accomplish using the techniques described in
19+
https://aka.ms/azsdk/python/dpcodegen/python/customize
20+
"""

0 commit comments

Comments
 (0)