Skip to content

Commit 8d881ea

Browse files
committed
Merge branch 'release/azure-communication-phone-numbers-1.3.1-beta.1' of https://github.com/Azure/azure-sdk-for-python into release/azure-communication-phone-numbers-1.3.0b1
2 parents 725be62 + cdbc068 commit 8d881ea

35 files changed

+3502
-309
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Release History
22

3+
4+
## 1.3.0b1 (Unreleased)
5+
6+
### Features Added
7+
- Adds support for the Browse Available Phone Numbers and Reservations APIs.
8+
- This adds an alternate way to search and purchase phone numbers that allows customers to select which phone numbers they want to reserve and purchase.
9+
- Adds support for automated purchases of phone numbers from countries requiring a Do Not Resell agreement.
10+
- For more information, refer to: https://learn.microsoft.com/azure/communication-services/concepts/numbers/sub-eligibility-number-capability
11+
- API version `2025-04-01` is the default.
12+
13+
### Breaking Changes
14+
15+
### Bugs Fixed
16+
17+
### Other Changes
18+
319
## 1.2.0 (2025-02-11)
420

521
### Features Added

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ Phone numbers can be searched through the search creation API by providing an ar
8585

8686
Phone numbers can also be released using the release API.
8787

88+
#### Browsing and reserving phone numbers
89+
90+
The Browse and Reservations APIs provide an alternate way to acquire phone numbers via a shopping-cart-like experience. This is achieved by splitting the search operation, which finds and reserves numbers using a single LRO, into two separate synchronous steps, Browse and Reservation.
91+
92+
The browse operation retrieves a random sample of phone numbers that are available for purchase for a given country, with optional filtering criteria to narrow down results. The returned phone numbers are not reserved for any customer.
93+
94+
Reservations represent a collection of phone numbers that are locked by a specific customer and are awaiting purchase. They have an expiration time of 15 minutes after the last modification or 2 hours from creation time. A reservation can include numbers from different countries, in contrast with the Search operation. Customers can Create, Retrieve, Modify (by adding and removing numbers), Delete, and Purchase reservations. Purchasing a reservation is an LRO.
95+
8896
### SIP routing client
8997

9098
Direct routing feature allows connecting customer-provided telephony infrastructure to Azure Communication Resources. In order to setup routing configuration properly, customer needs to supply the SIP trunk configuration and SIP routing rules for calls. SIP routing client provides the necessary interface for setting this configuration.
@@ -116,6 +124,33 @@ print(result.country_code)
116124
print(result.phone_number)
117125
```
118126

127+
#### Broswing and Reserving Available Phone Numbers
128+
129+
Use the Browse and Reservations API to reserve a phone number
130+
131+
```python
132+
import uuid
133+
134+
browse_result = await phone_numbers_client.browse_available_phone_numbers(
135+
country_code="US",
136+
phone_number_type="tollFree"
137+
)
138+
number_to_reserve = browse_result.phone_numbers[0]
139+
140+
# The reservation ID needs to be a valid UUID.
141+
reservation_id = str(uuid.uuid4())
142+
reservation = await phone_numbers_client.create_or_update_reservation(
143+
reservation_id=reservation_id,
144+
numbers_to_add=[number_to_reserve]
145+
)
146+
147+
numbers_with_error = [n for n in reservation.phone_numbers.values() if n.status == "error"]
148+
if any(numbers_with_error):
149+
print("Errors occurred during reservation")
150+
else:
151+
print("Reservation operation completed without errors.")
152+
```
153+
119154
### Long Running Operations
120155

121156
The Phone Number Client supports a variety of long running operations that allow indefinite polling time to the functions listed down below.
@@ -182,6 +217,32 @@ poller = phone_numbers_client.begin_update_phone_number_capabilities(
182217
)
183218
```
184219

220+
#### Purchase Reservation
221+
222+
Given an existing and active reservation, purchase the phone numbers in that reservation.
223+
224+
```python
225+
reservation_id = "<reservation id>"
226+
poller = phone_numbers_client.begin_purchase_reservation(
227+
reservation_id,
228+
polling = True
229+
)
230+
```
231+
232+
After the LRO finishes processing, the status of each individual number can be validated by retrieving the reservation.
233+
234+
```python
235+
reservation_id = "<reservation id>"
236+
reservation = phone_numbers_client.get_reservation(reservation_id)
237+
238+
numbers_with_error = [
239+
n for n in reservation.phone_numbers.values() if n.status == "error"]
240+
if any(numbers_with_error):
241+
print("Errors occurred during purchase")
242+
else:
243+
print("Reservation purchase completed without errors.")
244+
```
245+
185246
### SipRoutingClient
186247

187248
#### Retrieve SIP trunks and routes

sdk/communication/azure-communication-phonenumbers/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/communication/azure-communication-phonenumbers",
5-
"Tag": "python/communication/azure-communication-phonenumbers_a45b7bec94"
5+
"Tag": "python/communication/azure-communication-phonenumbers_db3a0ba22d"
66
}

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
OperatorInformationOptions,
2424
OperatorInformation,
2525
OperatorInformationResult,
26+
PhoneNumbersBrowseResult,
27+
AvailablePhoneNumber,
28+
PhoneNumbersReservation,
29+
CommunicationError
30+
)
31+
32+
from ._generated.models._enums import (
33+
ReservationStatus,
34+
PhoneNumberAvailabilityStatus,
35+
PhoneNumberSearchResultError
2636
)
2737

2838
__all__ = [
@@ -42,5 +52,12 @@
4252
'OperatorInformationOptions',
4353
'OperatorInformation',
4454
'OperatorInformationResult',
45-
'PhoneNumbersClient'
55+
'PhoneNumbersClient',
56+
'PhoneNumbersReservation',
57+
'PhoneNumbersBrowseResult',
58+
'AvailablePhoneNumber',
59+
'CommunicationError',
60+
'ReservationStatus',
61+
'PhoneNumberAvailabilityStatus',
62+
'PhoneNumberSearchResultError',
4663
]

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1313
V2023_05_01_PREVIEW = "2023-05-01-preview"
1414
V2024_03_01_PREVIEW = "2024-03-01-preview"
1515
V2025_02_11 = "2025-02-11"
16+
V2025_04_01 = "2025-04-01"
1617

1718

18-
DEFAULT_VERSION = ApiVersion.V2025_02_11
19+
DEFAULT_VERSION = ApiVersion.V2025_04_01

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from . import models as _models
1818
from ._configuration import PhoneNumbersClientConfiguration
19-
from ._serialization import Deserializer, Serializer
19+
from ._utils.serialization import Deserializer, Serializer
2020
from .operations import PhoneNumbersOperations
2121

2222

@@ -29,7 +29,7 @@ class PhoneNumbersClient:
2929
:param endpoint: The communication resource, for example
3030
https://resourcename.communication.azure.com. Required.
3131
:type endpoint: str
32-
:keyword api_version: Api Version. Default value is "2025-02-11". Note that overriding this
32+
:keyword api_version: Api Version. Default value is "2025-04-01". Note that overriding this
3333
default value may result in unsupported behavior.
3434
:paramtype api_version: str
3535
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
@@ -41,6 +41,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
4141
) -> None:
4242
_endpoint = "{endpoint}"
4343
self._config = PhoneNumbersClientConfiguration(endpoint=endpoint, **kwargs)
44+
4445
_policies = kwargs.pop("policies", None)
4546
if _policies is None:
4647
_policies = [

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ class PhoneNumbersClientConfiguration: # pylint: disable=too-many-instance-attr
2222
:param endpoint: The communication resource, for example
2323
https://resourcename.communication.azure.com. Required.
2424
:type endpoint: str
25-
:keyword api_version: Api Version. Default value is "2025-02-11". Note that overriding this
25+
:keyword api_version: Api Version. Default value is "2025-04-01". Note that overriding this
2626
default value may result in unsupported behavior.
2727
:paramtype api_version: str
2828
"""
2929

3030
def __init__(self, endpoint: str, **kwargs: Any) -> None:
31-
api_version: str = kwargs.pop("api_version", "2025-02-11")
31+
api_version: str = kwargs.pop("api_version", "2025-04-01")
3232

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License.
44
# ------------------------------------
55

6+
67
"""Customize generated code here.
78
89
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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+
# --------------------------------------------------------------------------

0 commit comments

Comments
 (0)