Skip to content

Sofiar/cherrypicker #45095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
1127697
Generate new models for api-version 2025-04-01
sofiar-msft Apr 3, 2025
e0bbdb6
Create public facing methods fro cherry picker
sofiar-msft Apr 3, 2025
6c2f6a9
Add cherry picker tests
sofiar-msft Apr 9, 2025
6b2d1d9
Add DNR tests
sofiar-msft Apr 9, 2025
c19766f
Add missing params on doc comments
sofiar-msft Apr 10, 2025
21faa55
Add DNR tests for traditional search
sofiar-msft Apr 10, 2025
68ca33e
Fix linting problems
sofiar-msft Apr 10, 2025
ca4458d
Fix linting issues
sofiar-msft Apr 10, 2025
bc0b065
Rename ReservationStatus to PhoneNUmberReservationStatus
sofiar-msft Apr 10, 2025
5f508a6
Add custom PhoneNumbersReservation
sofiar-msft Apr 11, 2025
a6967c7
Format clients
sofiar-msft Apr 11, 2025
92b69d1
Fix warnings
sofiar-msft Apr 11, 2025
fe632d6
Fix spacing on doc, and naming
sofiar-msft Apr 11, 2025
7c276e0
Fix naming
sofiar-msft Apr 11, 2025
4ee6a0f
Update recordings
sofiar-msft Apr 14, 2025
0a8ec69
Add countryCode to PhoneNumbersBrowseRequest
sofiar-msft Apr 22, 2025
ad1dff8
Split createOrUpdate reservation into two methods
sofiar-msft Apr 22, 2025
c5662f7
Reuse PhoneNumberCost
sofiar-msft Apr 22, 2025
b268d68
Join create and update
sofiar-msft Apr 23, 2025
c2cb718
Update tests to use new createOrUpdate reservation method
sofiar-msft Apr 23, 2025
0ef9574
Update tests to use new createOrUpdate reservation method
sofiar-msft Apr 23, 2025
91cbd86
Remove all unused imports
sofiar-msft Apr 23, 2025
7e7bbb0
Add missing params on doc comments
sofiar-msft Apr 23, 2025
e0a309a
Update readme to add remove-empty-child-schemas flag
sofiar-msft Apr 23, 2025
cbf46d1
Make browse return an AvailablePhoneNumber list
sofiar-msft Apr 24, 2025
31ce9ed
Remove browseresult model
sofiar-msft Apr 24, 2025
c3de5ed
Make browseresult model internal
sofiar-msft Apr 24, 2025
e38b8dc
Replace browseCapabilitiesRequest with regular request
sofiar-msft Apr 24, 2025
7c4358c
Replace PhoneNumberCapabilitiesRequest to PhoneNumberCapabilities
sofiar-msft Apr 24, 2025
2a08eaa
Use createOrUpdateClientOptions
sofiar-msft Apr 24, 2025
639a60b
Add missing comments for CreateOrUpdateReservationOptions
sofiar-msft Apr 24, 2025
a00e35e
Add missing comments for CreateOrUpdateReservationOptions
sofiar-msft Apr 24, 2025
cca8f0b
Remove unused models from public
sofiar-msft Apr 24, 2025
85242cf
Fix comments from CreateOrUpdateReservationOptions
sofiar-msft Apr 24, 2025
778cb21
Fix mappers
sofiar-msft Apr 25, 2025
2789fac
Replace UUID for string
sofiar-msft Apr 29, 2025
4de991a
Fix recordings
sofiar-msft Apr 30, 2025
39d2634
Fix linting issues
sofiar-msft Apr 30, 2025
17c3dd4
Replace Listo for PhoneNumbersBrowseResult
sofiar-msft Apr 30, 2025
471a3a3
Add missing WithResponse methods
sofiar-msft Apr 30, 2025
325b7bb
Add missing comment on deleteReservationWithResponse
sofiar-msft Apr 30, 2025
9ea1091
Rename AvailablePhoneNumberStatus to PhoneNumberAvailabilityStatus
sofiar-msft Apr 30, 2025
5c2a345
Rename BrowseRequest to BrowsePhoneNumbersOptions
sofiar-msft Apr 30, 2025
41b6536
Add fields as readonly
sofiar-msft May 6, 2025
b707412
Add directive to replace PhoneNumberCapabilitiesRequest
sofiar-msft May 6, 2025
7ec7ee3
Replace AvailablePhoneNumberError with ResponseError
sofiar-msft May 6, 2025
a737756
Remove unused imports
sofiar-msft May 6, 2025
8cc5b34
Remove unused models
sofiar-msft May 7, 2025
937cfac
Make setPhoneNumbers private
sofiar-msft May 7, 2025
7f953a3
Add accesshelper to PhoneNumbersReservation customization
sofiar-msft May 7, 2025
3a3f6ea
Add required fields to constructor
sofiar-msft May 7, 2025
7c40387
Add custom PhoneNumberSearchResultError
sofiar-msft May 7, 2025
511e2b1
Remove params from CreateOrUpdateReservationOptions constructor
sofiar-msft May 7, 2025
866ed7e
Fix linting on AccssHelper
sofiar-msft May 7, 2025
177bfa4
Make phoneNUmbers readonly on phoneNumbersBrowseResult
sofiar-msft May 7, 2025
14bfa87
Exclude PhoneNumbersReservationAccessHelper
sofiar-msft May 7, 2025
5dc9f33
Remove unused setter on CreateOrUpdateReservationOptions
sofiar-msft May 8, 2025
bce5cf0
Update changelog and README
sofiar-msft May 8, 2025
f35e4b1
Add samples
sofiar-msft May 8, 2025
9a176d1
Fix version on changelog
sofiar-msft May 8, 2025
86eff93
Remove unused imports from samples
sofiar-msft May 8, 2025
3b57f6e
Remove unecessary required com.azure.core
sofiar-msft May 14, 2025
31dd9f3
Rename params to match type
sofiar-msft May 14, 2025
232f67d
Replace UUID for string on missing function
sofiar-msft May 14, 2025
5fd8ae3
Remove setter for country code and number type from BrowseOptions
sofiar-msft May 14, 2025
e4421ad
Replace getId from UUID to String
sofiar-msft May 14, 2025
2709f37
Replace request with reservationOptions on missin method
sofiar-msft May 14, 2025
564188f
Format createOrUpdateReservationWithResponse
sofiar-msft May 14, 2025
bdd3dd5
Fix linting
sofiar-msft May 14, 2025
6b0d56e
Update sdk/communication/azure-communication-phonenumbers/README.md
sofiar-msft May 15, 2025
82bd7a7
Solve PR comments for refactoring createOrUpdateReservation
sofiar-msft May 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

### Features Added

- Adds support for the Browse Available Phone Numbers and Reservations APIs
- 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.
- Adds support for automated purchases of phone numbers from countries requiring a Do Not Resell agreement.
- For more information, refer to: https://learn.microsoft.com/azure/communication-services/concepts/numbers/sub-eligibility-number-capability
- API version `2025-04-01` is the default.

### Breaking Changes

### Bugs Fixed
Expand Down
79 changes: 65 additions & 14 deletions sdk/communication/azure-communication-phonenumbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ Purchased phone numbers can come with many capabilities, depending on the countr

[Source code][source] | [Package (Maven)][package] | [API reference documentation][api_documentation]
| [Product documentation][product_docs]

## Getting started

### Prerequisites

- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
- [Java Development Kit (JDK)](https://learn.microsoft.com/java/azure/jdk/?view=azure-java-stable) version 8 or above.
- [Apache Maven](https://maven.apache.org/download.cgi).
- A deployed Communication Services resource. You can use the [Azure Portal](https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://learn.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up.
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
- [Java Development Kit (JDK)](https://learn.microsoft.com/java/azure/jdk/?view=azure-java-stable) version 8 or above.
- [Apache Maven](https://maven.apache.org/download.cgi).
- A deployed Communication Services resource. You can use the [Azure Portal](https://learn.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://learn.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up.

### Include the package

#### Include the BOM file

Please include the azure-sdk-bom to your project to take dependency on the General Availability (GA) version of the library. In the following snippet, replace the {bom_version_to_target} placeholder with the version number.
Expand All @@ -34,6 +36,7 @@ To learn more about the BOM, see the [AZURE SDK BOM README](https://github.com/A
</dependencies>
</dependencyManagement>
```

and then include the direct dependency in the dependencies section without the version tag.

```xml
Expand All @@ -46,11 +49,12 @@ and then include the direct dependency in the dependencies section without the v
```

#### Include direct dependency

If you want to take dependency on a particular version of the library that is not present in the BOM,
add the direct dependency to your project as follows.

[//]: # "{x-version-update-start;com.azure:azure-communication-phonenumbers;current}"

[//]: # ({x-version-update-start;com.azure:azure-communication-phonenumbers;current})
```xml
<dependency>
<groupId>com.azure</groupId>
Expand All @@ -70,6 +74,7 @@ The `direct routing` feature enables connecting your existing telephony infrastr
The configuration is managed using the `SipRoutingClient`, which provides methods for setting up SIP trunks and voice routing rules, in order to properly handle calls for your telephony subnet.

### Initializing Client

Clients can be initialized using the Azure Active Directory Authentication.

```java readme-sample-createPhoneNumberClientWithAAD
Expand Down Expand Up @@ -131,6 +136,7 @@ SipRoutingClient sipRoutingClient = new SipRoutingClientBuilder()
.httpClient(httpClient)
.buildClient();
```

Alternatively, you can provide the entire connection string using the connectionString() function of the client instead of providing the endpoint and access key.

### Phone numbers client
Expand All @@ -145,6 +151,14 @@ Phone numbers can be searched through the search creation API by providing an ar

Phone numbers can also be released using the release API.

#### Browsing and reserving phone numbers

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.

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.

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.

### SIP routing client

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.
Expand All @@ -157,6 +171,7 @@ Once a route is matched, the call is routed to the first trunk in the route's tr
### PhoneNumbersClient

#### Get Purchased Phone Number

Gets the specified purchased phone number.

```java readme-sample-getPurchasedPhoneNumber
Expand All @@ -166,6 +181,7 @@ System.out.println("Phone Number Country Code: " + phoneNumber.getCountryCode())
```

#### Get All Purchased Phone Numbers

Lists all the purchased phone numbers.

```java readme-sample-listPhoneNumbers
Expand All @@ -175,11 +191,36 @@ System.out.println("Phone Number Value: " + phoneNumber.getPhoneNumber());
System.out.println("Phone Number Country Code: " + phoneNumber.getCountryCode());
```

### Browse and reserve available phone numbers

Use the Browse and Reservations API to reserve a phone number

```java readme-sample-browseAndReservePhoneNumbers
PhoneNumbersClient phoneNumberClient = createPhoneNumberClient();
String reservationId = UUID.randomUUID().toString();

BrowsePhoneNumbersOptions browseRequest = new BrowsePhoneNumbersOptions("US", PhoneNumberType.TOLL_FREE)
.setAssignmentType(PhoneNumberAssignmentType.APPLICATION)
.setCapabilities(new PhoneNumberCapabilities().setCalling(PhoneNumberCapabilityType.INBOUND_OUTBOUND)
.setSms(PhoneNumberCapabilityType.INBOUND_OUTBOUND));

PhoneNumbersBrowseResult result = phoneNumberClient.browseAvailableNumbers(browseRequest);

List<AvailablePhoneNumber> numbersToAdd = new ArrayList<>();

numbersToAdd.add(result.getPhoneNumbers().get(0));

PhoneNumbersReservation reservationResponse = phoneNumberClient.createOrUpdateReservation(
new CreateOrUpdateReservationOptions(reservationId).setPhoneNumbersToAdd(numbersToAdd));
System.out.println("Reservation ID: " + reservationResponse.getId());
```

### Long Running Operations

The Phone Number Client supports a variety of long-running operations that allow indefinite polling time to the functions listed down below.

#### Search for Available Phone Numbers

Search for available phone numbers by providing the area code, assignment type, phone number capabilities, phone number type, and quantity. The result of the search can then be used to purchase the numbers. Note that for the toll-free phone number type, providing the area code is optional.

```java readme-sample-searchAvailablePhoneNumbers
Expand All @@ -204,6 +245,7 @@ if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED == response.getStatus()) {
```

#### Purchase Phone Numbers

The result of searching for phone numbers is a `PhoneNumberSearchResult`. This can be used to get the numbers' details and purchase numbers by passing in the `searchId` to the purchase number API.

```java readme-sample-purchasePhoneNumbers
Expand All @@ -212,7 +254,18 @@ PollResponse<PhoneNumberOperation> purchaseResponse =
System.out.println("Purchase phone numbers is complete: " + purchaseResponse.getStatus());
```

#### Purchase Phone Number Reservation

Begin the purchas of a reservation

```java readme-sample-purchaseReservation
PollResponse<PhoneNumberOperation> purchaseResponse =
phoneNumberClient.beginReservationPurchase(reservationId, Context.NONE).waitForCompletion();
System.out.println("Purchase reservation is complete: " + purchaseResponse.getStatus());
```

#### Release Phone Number

Releases a purchased phone number.

```java readme-sample-releasePhoneNumber
Expand All @@ -222,11 +275,13 @@ System.out.println("Release phone number is complete: " + releaseResponse.getSta
```

#### Updating Phone Number Capabilities

Updates Phone Number Capabilities for Calling and SMS to one of:
- `PhoneNumberCapabilityValue.NONE`
- `PhoneNumberCapabilityValue.INBOUND`
- `PhoneNumberCapabilityValue.OUTBOUND`
- `PhoneNumberCapabilityValue.INBOUND_OUTBOUND`

- `PhoneNumberCapabilityValue.NONE`
- `PhoneNumberCapabilityValue.INBOUND`
- `PhoneNumberCapabilityValue.OUTBOUND`
- `PhoneNumberCapabilityValue.INBOUND_OUTBOUND`

```java readme-sample-updatePhoneNumberCapabilities
PhoneNumberCapabilities capabilities = new PhoneNumberCapabilities();
Expand Down Expand Up @@ -311,7 +366,6 @@ When you submit a pull request, a CLA-bot will automatically determine whether y

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or comments.


## Troubleshooting

In progress.
Expand All @@ -321,6 +375,7 @@ In progress.
Check out other client libraries for Azure communication service

<!-- LINKS -->

[cla]: https://cla.microsoft.com
[coc]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
Expand All @@ -329,7 +384,3 @@ Check out other client libraries for Azure communication service
[package]: https://central.sonatype.com/artifact/com.azure/azure-communication-phonenumbers
[api_documentation]: https://aka.ms/java-docs
[source]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/communication/azure-communication-phonenumbers/src




Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/communication/azure-communication-phonenumbers",
"Tag": "java/communication/azure-communication-phonenumbers_2dd73df054"
"Tag": "java/communication/azure-communication-phonenumbers_ac7d2e0f8b"
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@
<Class name="com.azure.communication.phonenumbers.siprouting.models.SipTrunkRoute" />
</Or>
</Match>
<Match>
<Bug pattern="EI_EXPOSE_STATIC_REP2" />
<Or>
<Class name="com.azure.communication.phonenumbers.implementation.accesshelpers.PhoneNumbersReservationAccessHelper" />
</Or>
</Match>
</FindBugsFilter>
Loading
Loading