Skip to content

Commit c3f69eb

Browse files
[Communication] - PhoneNumberClient - Adding LRO for purchasing phone (Azure#15803)
* Implement long running operatins * Update readme with long running opertions * Address review issues and rename search to reservation - WIP * move operations to Model namespace use lock reorange operation classes * remove unused terminalStatuses initialization * use ReservationStatus type for PhoneNumberReservationPurchaseOperation * use ReservationStatus type for PhoneNumberReservationPurchaseOperation - update readmy * Merge branch 'master' into pavel/feature/communication/lro * Merge branch 'master' into pavel/feature/communication/lro * addressing PR feedback * LRO - removed HasSucceeded and Error properties from operation * LRO - removed HasSucceeded and Error properties from operation * Administratin LRO addressing PR feedback
1 parent ea54d9c commit c3f69eb

24 files changed

+1087
-316
lines changed

sdk/communication/Azure.Communication.Administration/README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ Phone plans come in two types; Geographic and Toll-Free. Geographic phone plans
101101

102102
All geographic phone plans within the same country are grouped into a phone plan group with a Geographic phone number type. All Toll-Free phone plans within the same country are grouped into a phone plan group.
103103

104-
### Searching and acquiring numbers
104+
### Reserving and acquiring numbers
105105

106-
Phone numbers search can be performed through the search creation API by providing a phone plan id, an area code and quantity of phone numbers. The provided quantity of phone numbers will be reserved for ten minutes. This search of phone numbers can either be cancelled or purchased. If the search is cancelled, then the phone numbers will become available to others. If the search is purchased, then the phone numbers are acquired for the Azure resources.
106+
Phone numbers reservation can be performed through the reservation creation API by providing a phone plan id, an area code and quantity of phone numbers. The provided quantity of phone numbers will be reserved for ten minutes. This reservation of phone numbers can either be cancelled or purchased. If the reservation is cancelled, then the phone numbers will become available to others. If the reservation is purchased, then the phone numbers are acquired for the Azure resources.
107107

108108
### Configuring / Assigning numbers
109109

@@ -190,19 +190,34 @@ foreach (var secondaryAreaCode in areaCodes.SecondaryAreaCodes)
190190
}
191191
```
192192

193-
### Create search
193+
### Create reservation
194194

195195
```C#
196-
var searchOptions = new CreateSearchOptions(displayName, description, plans, areaCode) { Quantity = 1 };
197-
var createSearchResponse = client.CreateSearch(searchOptions);
196+
var reservationOptions = new CreateReservationOptions(displayName, description, plans, areaCode) { Quantity = 1 };
197+
var reservationOperation = await client.StartReservationAsync(reservationOptions).ConfigureAwait(false);
198+
var reservationResponse = await reservationOperation.WaitForCompletionAsync().ConfigureAwait(false);
198199

199-
Console.WriteLine($"Search result: SearchId: {createSearchResponse.Value.SearchId}");
200+
Console.WriteLine($"ReservationId: {reservationResponse.Value.ReservationId}, Status {reservationResponse.Value.Status}");
200201
```
201202

202-
### Purchase search
203+
### Purchase reservation
203204

204205
```C#
205-
client.PurchaseSearch(searchId);
206+
var reservationPurchaseOperation = await client.StartPurchaseReservationAsync(reservationId).ConfigureAwait(false);
207+
await reservationPurchaseOperation.WaitForCompletionAsync().ConfigureAwait(false);
208+
209+
// Ensure purchase has completed successfuly
210+
try
211+
{
212+
var reservationStatus = reservationPurchaseOperation.Value;
213+
// ...
214+
}
215+
catch (Exception ex)
216+
{
217+
Console.WriteLine("Purchase failed");
218+
Console.WriteLine(ex.Message);
219+
}
220+
206221
```
207222

208223
### Configure phone number
@@ -213,6 +228,15 @@ var phoneNumber = new PhoneNumber("<phone_number>");
213228
client.ConfigureNumber(pstnConfiguration, phoneNumber);
214229
```
215230

231+
### Release phone numbers
232+
233+
```C#
234+
var releasePhoneNumberOperation = await client.StartReleasePhoneNumbersAsync(numbers).ConfigureAwait(false);
235+
await releasePhoneNumberOperation.WaitForCompletionAsync().ConfigureAwait(false);
236+
237+
Console.WriteLine($"ReleaseId: {releasePhoneNumberOperation.Value.ReleaseId}, Status: {releasePhoneNumberOperation.Value.Status}");
238+
```
239+
216240
## Next steps
217241
[Read more about Communication user access tokens][user_access_token]
218242

sdk/communication/Azure.Communication.Administration/api/Azure.Communication.Administration.netstandard2.0.cs

Lines changed: 78 additions & 48 deletions
Large diffs are not rendered by default.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateSearchOptions.Serialization.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateReservationOptions.Serialization.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateSearchOptions.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateReservationOptions.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateSearchResponse.Serialization.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateReservationResponse.Serialization.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateReservationResponse.cs

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/CreateSearchResponse.cs

Lines changed: 0 additions & 31 deletions
This file was deleted.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/ReleaseResponse.Serialization.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/PhoneNumberReleaseResponse.Serialization.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/ReleaseResponse.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/PhoneNumberReleaseResponse.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/Azure.Communication.Administration/src/Generated/Models/PhoneNumberSearch.Serialization.cs renamed to sdk/communication/Azure.Communication.Administration/src/Generated/Models/PhoneNumberReservation.Serialization.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)