Skip to content

Commit 956765d

Browse files
Updates API version for package azure-communication-phonenumber (Azure#22252)
* Updates azure-communication-phonenumbers api version * Upgrades the azure-core version to 1.20.0 to include the module azure.core.rest. * Points swagger to the definitive version of the API * Updatest azure-communication-phonenumbers CHANGELOG * Fixes azure-communication-phonenumbers Swagger to a specific sha * Adds depency changes to azure-communication-phonenumbers's CHANGELOG * Updates azure-communication-phonenumbers package version * Updates azure-communication-phonenumbers CHANGELOG to be more descriptive Co-authored-by: Lucas Santos <lucassantos@microsoft.com>
1 parent 0f96411 commit 956765d

File tree

41 files changed

+4332
-1141
lines changed

Some content is hidden

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

41 files changed

+4332
-1141
lines changed

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

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

3-
## 1.0.2 (Unreleased)
3+
## 1.1.0b1 (Unreleased)
44

5-
### Features Added
6-
7-
### Breaking Changes
5+
- Users can now purchase United Kingdom (GB) toll free and geographic phone numbers for PSTN Calling
6+
- Users can now purchase Denmark (DK) toll free and geographic phone numbers for PSTN Calling
87

9-
### Bugs Fixed
8+
### Features Added
9+
- Adds support for API verion `2022-01-11-preview2`
1010

1111
### Other Changes
12+
- Updates dependency `azure-core` to `1.20.0`
1213

1314
## 1.0.1 (2021-06-08)
1415
### Bug Fixes

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from ._phone_numbers_client import PhoneNumbersClient
1010
__all__ = ['PhoneNumbersClient']
1111

12-
try:
13-
from ._patch import patch_sdk # type: ignore
14-
patch_sdk()
15-
except ImportError:
16-
pass
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()

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class PhoneNumbersClientConfiguration(Configuration):
2525
2626
:param endpoint: The communication resource, for example https://resourcename.communication.azure.com.
2727
:type endpoint: str
28+
:keyword api_version: Api Version. The default value is "2022-01-11-preview2". Note that overriding this default value may result in unsupported behavior.
29+
:paramtype api_version: str
2830
"""
2931

3032
def __init__(
@@ -33,12 +35,14 @@ def __init__(
3335
**kwargs # type: Any
3436
):
3537
# type: (...) -> None
38+
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
39+
api_version = kwargs.pop('api_version', "2022-01-11-preview2") # type: str
40+
3641
if endpoint is None:
3742
raise ValueError("Parameter 'endpoint' must not be None.")
38-
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
3943

4044
self.endpoint = endpoint
41-
self.api_version = "2021-03-07"
45+
self.api_version = api_version
4246
kwargs.setdefault('sdk_moniker', 'phonenumbersclient/{}'.format(VERSION))
4347
self._configure(**kwargs)
4448

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
# --------------------------------------------------------------------------
27+
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
30+
def patch_sdk():
31+
pass

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

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

9+
from copy import deepcopy
910
from typing import TYPE_CHECKING
1011

1112
from azure.core import PipelineClient
1213
from msrest import Deserializer, Serializer
1314

15+
from . import models
16+
from ._configuration import PhoneNumbersClientConfiguration
17+
from .operations import PhoneNumbersOperations
18+
1419
if TYPE_CHECKING:
1520
# pylint: disable=unused-import,ungrouped-imports
1621
from typing import Any
1722

18-
from azure.core.pipeline.transport import HttpRequest, HttpResponse
19-
20-
from ._configuration import PhoneNumbersClientConfiguration
21-
from .operations import PhoneNumbersOperations
22-
from . import models
23-
23+
from azure.core.rest import HttpRequest, HttpResponse
2424

2525
class PhoneNumbersClient(object):
2626
"""The phone numbers client uses Azure Communication Services to purchase and manage phone numbers.
2727
2828
:ivar phone_numbers: PhoneNumbersOperations operations
2929
:vartype phone_numbers: azure.communication.phonenumbers.operations.PhoneNumbersOperations
30-
:param endpoint: The communication resource, for example https://resourcename.communication.azure.com.
30+
:param endpoint: The communication resource, for example
31+
https://resourcename.communication.azure.com.
3132
:type endpoint: str
32-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
33+
:keyword api_version: Api Version. The default value is "2022-01-11-preview2". Note that
34+
overriding this default value may result in unsupported behavior.
35+
:paramtype api_version: str
36+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
37+
Retry-After header is present.
3338
"""
3439

3540
def __init__(
@@ -38,35 +43,47 @@ def __init__(
3843
**kwargs # type: Any
3944
):
4045
# type: (...) -> None
41-
base_url = '{endpoint}'
42-
self._config = PhoneNumbersClientConfiguration(endpoint, **kwargs)
43-
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)
46+
_base_url = '{endpoint}'
47+
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
48+
self._client = PipelineClient(base_url=_base_url, config=self._config, **kwargs)
4449

4550
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4651
self._serialize = Serializer(client_models)
47-
self._serialize.client_side_validation = False
4852
self._deserialize = Deserializer(client_models)
53+
self._serialize.client_side_validation = False
54+
self.phone_numbers = PhoneNumbersOperations(self._client, self._config, self._serialize, self._deserialize)
4955

50-
self.phone_numbers = PhoneNumbersOperations(
51-
self._client, self._config, self._serialize, self._deserialize)
5256

53-
def _send_request(self, http_request, **kwargs):
54-
# type: (HttpRequest, Any) -> HttpResponse
57+
def _send_request(
58+
self,
59+
request, # type: HttpRequest
60+
**kwargs # type: Any
61+
):
62+
# type: (...) -> HttpResponse
5563
"""Runs the network request through the client's chained policies.
5664
57-
:param http_request: The network request you want to make. Required.
58-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
59-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
65+
>>> from azure.core.rest import HttpRequest
66+
>>> request = HttpRequest("GET", "https://www.example.org/")
67+
<HttpRequest [GET], url: 'https://www.example.org/'>
68+
>>> response = client._send_request(request)
69+
<HttpResponse: 200 OK>
70+
71+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
72+
73+
:param request: The network request you want to make. Required.
74+
:type request: ~azure.core.rest.HttpRequest
75+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
6076
:return: The response of your network call. Does not do error handling on your response.
61-
:rtype: ~azure.core.pipeline.transport.HttpResponse
77+
:rtype: ~azure.core.rest.HttpResponse
6278
"""
79+
80+
request_copy = deepcopy(request)
6381
path_format_arguments = {
64-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
82+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
6583
}
66-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
67-
stream = kwargs.pop("stream", True)
68-
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
69-
return pipeline_response.http_response
84+
85+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
86+
return self._client.send_request(request_copy, **kwargs)
7087

7188
def close(self):
7289
# type: () -> None
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# Code generated by Microsoft (R) AutoRest Code Generator.
5+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from azure.core.pipeline.transport import HttpRequest
9+
10+
def _convert_request(request, files=None):
11+
data = request.content if not files else None
12+
request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data)
13+
if files:
14+
request.set_formdata_body(files)
15+
return request
16+
17+
def _format_url_section(template, **kwargs):
18+
components = template.split("/")
19+
while components:
20+
try:
21+
return template.format(**kwargs)
22+
except KeyError as key:
23+
formatted_components = template.split("/")
24+
components = [
25+
c for c in formatted_components if "{}".format(key.args[0]) not in c
26+
]
27+
template = "/".join(components)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88

99
from ._phone_numbers_client import PhoneNumbersClient
1010
__all__ = ['PhoneNumbersClient']
11+
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()

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,23 @@ class PhoneNumbersClientConfiguration(Configuration):
2121
2222
:param endpoint: The communication resource, for example https://resourcename.communication.azure.com.
2323
:type endpoint: str
24+
:keyword api_version: Api Version. The default value is "2022-01-11-preview2". Note that overriding this default value may result in unsupported behavior.
25+
:paramtype api_version: str
2426
"""
2527

2628
def __init__(
2729
self,
2830
endpoint: str,
2931
**kwargs: Any
3032
) -> None:
33+
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
34+
api_version = kwargs.pop('api_version', "2022-01-11-preview2") # type: str
35+
3136
if endpoint is None:
3237
raise ValueError("Parameter 'endpoint' must not be None.")
33-
super(PhoneNumbersClientConfiguration, self).__init__(**kwargs)
3438

3539
self.endpoint = endpoint
36-
self.api_version = "2021-03-07"
40+
self.api_version = api_version
3741
kwargs.setdefault('sdk_moniker', 'phonenumbersclient/{}'.format(VERSION))
3842
self._configure(**kwargs)
3943

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
# --------------------------------------------------------------------------
27+
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
30+
def patch_sdk():
31+
pass

sdk/communication/azure-communication-phonenumbers/azure/communication/phonenumbers/_generated/aio/_phone_numbers_client.py

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

9-
from typing import Any
9+
from copy import deepcopy
10+
from typing import Any, Awaitable
1011

1112
from azure.core import AsyncPipelineClient
12-
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
13+
from azure.core.rest import AsyncHttpResponse, HttpRequest
1314
from msrest import Deserializer, Serializer
1415

16+
from .. import models
1517
from ._configuration import PhoneNumbersClientConfiguration
1618
from .operations import PhoneNumbersOperations
17-
from .. import models
18-
1919

20-
class PhoneNumbersClient(object):
20+
class PhoneNumbersClient:
2121
"""The phone numbers client uses Azure Communication Services to purchase and manage phone numbers.
2222
2323
:ivar phone_numbers: PhoneNumbersOperations operations
2424
:vartype phone_numbers: azure.communication.phonenumbers.aio.operations.PhoneNumbersOperations
25-
:param endpoint: The communication resource, for example https://resourcename.communication.azure.com.
25+
:param endpoint: The communication resource, for example
26+
https://resourcename.communication.azure.com.
2627
:type endpoint: str
27-
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.
28+
:keyword api_version: Api Version. The default value is "2022-01-11-preview2". Note that
29+
overriding this default value may result in unsupported behavior.
30+
:paramtype api_version: str
31+
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
32+
Retry-After header is present.
2833
"""
2934

3035
def __init__(
3136
self,
3237
endpoint: str,
3338
**kwargs: Any
3439
) -> None:
35-
base_url = '{endpoint}'
36-
self._config = PhoneNumbersClientConfiguration(endpoint, **kwargs)
37-
self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)
40+
_base_url = '{endpoint}'
41+
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
42+
self._client = AsyncPipelineClient(base_url=_base_url, config=self._config, **kwargs)
3843

3944
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
4045
self._serialize = Serializer(client_models)
41-
self._serialize.client_side_validation = False
4246
self._deserialize = Deserializer(client_models)
47+
self._serialize.client_side_validation = False
48+
self.phone_numbers = PhoneNumbersOperations(self._client, self._config, self._serialize, self._deserialize)
4349

44-
self.phone_numbers = PhoneNumbersOperations(
45-
self._client, self._config, self._serialize, self._deserialize)
4650

47-
async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse:
51+
def _send_request(
52+
self,
53+
request: HttpRequest,
54+
**kwargs: Any
55+
) -> Awaitable[AsyncHttpResponse]:
4856
"""Runs the network request through the client's chained policies.
4957
50-
:param http_request: The network request you want to make. Required.
51-
:type http_request: ~azure.core.pipeline.transport.HttpRequest
52-
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
58+
>>> from azure.core.rest import HttpRequest
59+
>>> request = HttpRequest("GET", "https://www.example.org/")
60+
<HttpRequest [GET], url: 'https://www.example.org/'>
61+
>>> response = await client._send_request(request)
62+
<AsyncHttpResponse: 200 OK>
63+
64+
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
65+
66+
:param request: The network request you want to make. Required.
67+
:type request: ~azure.core.rest.HttpRequest
68+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
5369
:return: The response of your network call. Does not do error handling on your response.
54-
:rtype: ~azure.core.pipeline.transport.AsyncHttpResponse
70+
:rtype: ~azure.core.rest.AsyncHttpResponse
5571
"""
72+
73+
request_copy = deepcopy(request)
5674
path_format_arguments = {
57-
'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
75+
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True),
5876
}
59-
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
60-
stream = kwargs.pop("stream", True)
61-
pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs)
62-
return pipeline_response.http_response
77+
78+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
79+
return self._client.send_request(request_copy, **kwargs)
6380

6481
async def close(self) -> None:
6582
await self._client.close()

0 commit comments

Comments
 (0)