Skip to content

Commit c4edaae

Browse files
whisper6284Adrian Tangsofiar-msftdanielortega-msft
authored
Azure Communication Services Phone Numbers SDK With Browsing Capabilities (#29962)
* Update CODEOWNERS for Communication Phone Numbers * New model objects and methods for browse APIs. * . * Update API version * . * Generate autorest client with 2022-12-01 api version * Replace AreaCodeResult with AreaCodeItem * Replace CountryCode with twoLetterIsoCountryName * Add default to optional params * Rename area codes function to rearrange alphabetically * Add locality and administrative division to the search options * Remove accept language from constructor * Add live tests * Replace swagger file and update areaCodes tests * Update Azure.Communication.PhoneNumbers.Tests.csproj Revert unwanted changes * Update recordings * Update recordings after merge * Run generate code * Update recordings with new generated code * Solving building errors * Update recordings test agent * Update Purcharse and Release records * Fix generate code issue * Update Location in recordings * Fix purchase and release test * Update snipets * Update snipets readme * Update Azure.ResourceManager.MachineLearning.netstandard2.0.cs Remove unwanted changes * Delete Azure.Storage.Blobs.Batch.net6.0.cs * Delete Azure.Storage.Blobs.ChangeFeed.net6.0.cs * Delete Azure.Storage.Blobs.net6.0.cs * Delete Azure.Storage.Common.net6.0.cs * Delete Azure.Storage.Files.DataLake.net6.0.cs * Delete Azure.Storage.Files.Shares.net6.0.cs * Delete Azure.Storage.Queues.net6.0.cs * Remove test code from sample snippets * Remove whitespace Co-authored-by: Adrian Tang <adtang@microsoft.com> Co-authored-by: Sofia Robles Sandoval <sofiar@microsoft.com> Co-authored-by: Daniel Ortega <danielortega@microsoft.com>
1 parent 462961f commit c4edaae

File tree

79 files changed

+17550
-20932
lines changed

Some content is hidden

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

79 files changed

+17550
-20932
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ var client = new PhoneNumbersClient(connectionString);
125125
Phone numbers need to be searched before they can be purchased. Search is a long running operation that can be started by `StartSearchAvailablePhoneNumbers` function that returns an `SearchAvailablePhoneNumbersOperation` object. `SearchAvailablePhoneNumbersOperation` can be used to update status of the operation and to check for completeness.
126126

127127
```C# Snippet:SearchPhoneNumbersAsync
128-
var capabilities = new PhoneNumberCapabilities(calling:PhoneNumberCapabilityType.None, sms:PhoneNumberCapabilityType.Outbound);
128+
var capabilities = new PhoneNumberCapabilities(calling: PhoneNumberCapabilityType.None, sms: PhoneNumberCapabilityType.Outbound);
129129

130130
var searchOperation = await client.StartSearchAvailablePhoneNumbersAsync(countryCode, PhoneNumberType.TollFree, PhoneNumberAssignmentType.Application, capabilities);
131131
await searchOperation.WaitForCompletionAsync();
@@ -161,6 +161,7 @@ If you no longer need a phone number you can release it.
161161
var purchasedPhoneNumber = "<purchased_phone_number>";
162162
var releaseOperation = await client.StartReleasePhoneNumberAsync(purchasedPhoneNumber);
163163
await releaseOperation.WaitForCompletionResponseAsync();
164+
await WaitForCompletionResponseAsync(releaseOperation);
164165
```
165166

166167
### SipRoutingClient

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ namespace Azure.Communication.PhoneNumbers
1717
public static bool operator !=(Azure.Communication.PhoneNumbers.BillingFrequency left, Azure.Communication.PhoneNumbers.BillingFrequency right) { throw null; }
1818
public override string ToString() { throw null; }
1919
}
20+
public partial class PhoneNumberAdministrativeDivision
21+
{
22+
internal PhoneNumberAdministrativeDivision() { }
23+
public string AbbreviatedName { get { throw null; } }
24+
public string LocalizedName { get { throw null; } }
25+
}
26+
public partial class PhoneNumberAreaCode
27+
{
28+
internal PhoneNumberAreaCode() { }
29+
public string AreaCode { get { throw null; } }
30+
}
2031
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
2132
public readonly partial struct PhoneNumberAssignmentType : System.IEquatable<Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType>
2233
{
@@ -68,13 +79,43 @@ internal PhoneNumberCost() { }
6879
public Azure.Communication.PhoneNumbers.BillingFrequency BillingFrequency { get { throw null; } }
6980
public string IsoCurrencySymbol { get { throw null; } }
7081
}
82+
public partial class PhoneNumberCountry
83+
{
84+
internal PhoneNumberCountry() { }
85+
public string CountryCode { get { throw null; } }
86+
public string LocalizedName { get { throw null; } }
87+
}
88+
public partial class PhoneNumberLocality
89+
{
90+
internal PhoneNumberLocality() { }
91+
public Azure.Communication.PhoneNumbers.PhoneNumberAdministrativeDivision AdministrativeDivision { get { throw null; } }
92+
public string LocalizedName { get { throw null; } }
93+
}
94+
public partial class PhoneNumberOffering
95+
{
96+
internal PhoneNumberOffering() { }
97+
public Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType? AssignmentType { get { throw null; } }
98+
public Azure.Communication.PhoneNumbers.PhoneNumberCapabilities AvailableCapabilities { get { throw null; } }
99+
public Azure.Communication.PhoneNumbers.PhoneNumberCost Cost { get { throw null; } }
100+
public Azure.Communication.PhoneNumbers.PhoneNumberType? PhoneNumberType { get { throw null; } }
101+
}
71102
public partial class PhoneNumbersClient
72103
{
73104
protected PhoneNumbersClient() { }
74105
public PhoneNumbersClient(string connectionString) { }
75106
public PhoneNumbersClient(string connectionString, Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions options) { }
76107
public PhoneNumbersClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions options = null) { }
77108
public PhoneNumbersClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions options = null) { }
109+
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PhoneNumberAreaCode> GetAvailableAreaCodesGeographic(string twoLetterIsoCountryName, Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType phoneNumberAssignmentType, string locality, string administrativeDivision = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
110+
public virtual Azure.AsyncPageable<Azure.Communication.PhoneNumbers.PhoneNumberAreaCode> GetAvailableAreaCodesGeographicAsync(string twoLetterIsoCountryName, Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType phoneNumberAssignmentType, string locality, string administrativeDivision = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
111+
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PhoneNumberAreaCode> GetAvailableAreaCodesTollFree(string twoLetterIsoCountryName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
112+
public virtual Azure.AsyncPageable<Azure.Communication.PhoneNumbers.PhoneNumberAreaCode> GetAvailableAreaCodesTollFreeAsync(string twoLetterIsoCountryName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
113+
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PhoneNumberCountry> GetAvailableCountries(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
114+
public virtual Azure.AsyncPageable<Azure.Communication.PhoneNumbers.PhoneNumberCountry> GetAvailableCountriesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
115+
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PhoneNumberLocality> GetAvailableLocalities(string twoLetterIsoCountryName, string administrativeDivision = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
116+
public virtual Azure.AsyncPageable<Azure.Communication.PhoneNumbers.PhoneNumberLocality> GetAvailableLocalitiesAsync(string twoLetterIsoCountryName, string administrativeDivision = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
117+
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PhoneNumberOffering> GetAvailableOfferings(string twoLetterIsoCountryName, Azure.Communication.PhoneNumbers.PhoneNumberType? phoneNumberType = default(Azure.Communication.PhoneNumbers.PhoneNumberType?), Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType? phoneNumberAssignmentType = default(Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
118+
public virtual Azure.AsyncPageable<Azure.Communication.PhoneNumbers.PhoneNumberOffering> GetAvailableOfferingsAsync(string twoLetterIsoCountryName, Azure.Communication.PhoneNumbers.PhoneNumberType? phoneNumberType = default(Azure.Communication.PhoneNumbers.PhoneNumberType?), Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType? phoneNumberAssignmentType = default(Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType?), System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
78119
public virtual Azure.Response<Azure.Communication.PhoneNumbers.PurchasedPhoneNumber> GetPurchasedPhoneNumber(string phoneNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
79120
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.PhoneNumbers.PurchasedPhoneNumber>> GetPurchasedPhoneNumberAsync(string phoneNumber, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
80121
public virtual Azure.Pageable<Azure.Communication.PhoneNumbers.PurchasedPhoneNumber> GetPurchasedPhoneNumbers(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
@@ -90,17 +131,21 @@ public PhoneNumbersClient(System.Uri endpoint, Azure.Core.TokenCredential tokenC
90131
}
91132
public partial class PhoneNumbersClientOptions : Azure.Core.ClientOptions
92133
{
93-
public PhoneNumbersClientOptions(Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions.ServiceVersion version = Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions.ServiceVersion.V2022_01_11_Preview_2) { }
134+
public PhoneNumbersClientOptions(Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions.ServiceVersion version = Azure.Communication.PhoneNumbers.PhoneNumbersClientOptions.ServiceVersion.V2022_12_01) { }
135+
public string? AcceptedLanguage { get { throw null; } set { } }
94136
public enum ServiceVersion
95137
{
96138
V2021_03_07 = 1,
97139
V2022_01_11_Preview_2 = 2,
140+
V2022_12_01 = 3,
98141
}
99142
}
100143
public partial class PhoneNumberSearchOptions
101144
{
102145
public PhoneNumberSearchOptions() { }
146+
public string AdministrativeDivision { get { throw null; } set { } }
103147
public string AreaCode { get { throw null; } set { } }
148+
public string Locality { get { throw null; } set { } }
104149
public int? Quantity { get { throw null; } set { } }
105150
}
106151
public partial class PhoneNumberSearchResult
@@ -116,9 +161,14 @@ internal PhoneNumberSearchResult() { }
116161
}
117162
public static partial class PhoneNumbersModelFactory
118163
{
164+
public static Azure.Communication.PhoneNumbers.PhoneNumberAdministrativeDivision PhoneNumberAdministrativeDivision(string localizedName = null, string abbreviatedName = null) { throw null; }
165+
public static Azure.Communication.PhoneNumbers.PhoneNumberAreaCode PhoneNumberAreaCode(string areaCode = null) { throw null; }
119166
public static Azure.Communication.PhoneNumbers.PhoneNumberCost PhoneNumberCost(double amount = 0, string isoCurrencySymbol = null, Azure.Communication.PhoneNumbers.BillingFrequency billingFrequency = default(Azure.Communication.PhoneNumbers.BillingFrequency)) { throw null; }
120167
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
121168
public static Azure.Communication.PhoneNumbers.PhoneNumberCost PhoneNumberCost(double amount, string currencyCode, string billingFrequency) { throw null; }
169+
public static Azure.Communication.PhoneNumbers.PhoneNumberCountry PhoneNumberCountry(string localizedName = null, string countryCode = null) { throw null; }
170+
public static Azure.Communication.PhoneNumbers.PhoneNumberLocality PhoneNumberLocality(string localizedName = null, Azure.Communication.PhoneNumbers.PhoneNumberAdministrativeDivision administrativeDivision = null) { throw null; }
171+
public static Azure.Communication.PhoneNumbers.PhoneNumberOffering PhoneNumberOffering(Azure.Communication.PhoneNumbers.PhoneNumberType? phoneNumberType = default(Azure.Communication.PhoneNumbers.PhoneNumberType?), Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType? assignmentType = default(Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType?), Azure.Communication.PhoneNumbers.PhoneNumberCapabilities availableCapabilities = null, Azure.Communication.PhoneNumbers.PhoneNumberCost cost = null) { throw null; }
122172
public static Azure.Communication.PhoneNumbers.PhoneNumberSearchResult PhoneNumberSearchResult(string searchId, System.Collections.Generic.IEnumerable<string> phoneNumbers, Azure.Communication.PhoneNumbers.PhoneNumberType phoneNumberType, Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType assignmentType, Azure.Communication.PhoneNumbers.PhoneNumberCapabilities capabilities, Azure.Communication.PhoneNumbers.PhoneNumberCost cost, System.DateTimeOffset searchExpiresOn) { throw null; }
123173
public static Azure.Communication.PhoneNumbers.PurchasedPhoneNumber PurchasedPhoneNumber(string id, string phoneNumber, string countryCode, Azure.Communication.PhoneNumbers.PhoneNumberType phoneNumberType, Azure.Communication.PhoneNumbers.PhoneNumberCapabilities capabilities, Azure.Communication.PhoneNumbers.PhoneNumberAssignmentType assignmentType, System.DateTimeOffset purchaseDate, Azure.Communication.PhoneNumbers.PhoneNumberCost cost) { throw null; }
124174
}

sdk/communication/Azure.Communication.PhoneNumbers/samples/Sample_PhoneNumbersClient.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ var client = new PhoneNumbersClient(connectionString);
2020
Phone numbers need to be searched before they can be purchased. Search is a long running operation that can be started by `StartSearchAvailablePhoneNumbers` function that returns an `SearchAvailablePhoneNumbersOperation` object. `SearchAvailablePhoneNumbersOperation` can be used to update status of the operation and to check for completeness.
2121

2222
```C# Snippet:SearchPhoneNumbers
23-
var capabilities = new PhoneNumberCapabilities(calling:PhoneNumberCapabilityType.None, sms:PhoneNumberCapabilityType.Outbound);
23+
var capabilities = new PhoneNumberCapabilities(calling: PhoneNumberCapabilityType.None, sms: PhoneNumberCapabilityType.Outbound);
2424

2525
var searchOperation = client.StartSearchAvailablePhoneNumbers(countryCode, PhoneNumberType.TollFree, PhoneNumberAssignmentType.Application, capabilities);
2626

2727
while (!searchOperation.HasCompleted)
2828
{
2929
Thread.Sleep(2000);
30+
SleepIfNotInPlaybackMode();
3031
searchOperation.UpdateStatus();
3132
}
3233
```
@@ -37,10 +38,10 @@ Phone numbers can be acquired through purchasing a reservation.
3738

3839
```C# Snippet:StartPurchaseSearch
3940
var purchaseOperation = client.StartPurchasePhoneNumbers(searchOperation.Value.SearchId);
40-
4141
while (!purchaseOperation.HasCompleted)
4242
{
4343
Thread.Sleep(2000);
44+
SleepIfNotInPlaybackMode();
4445
purchaseOperation.UpdateStatus();
4546
}
4647
```
@@ -63,11 +64,12 @@ foreach (var phoneNumber in purchasedPhoneNumbers)
6364
Phone number's capabilities can be updated by started by `StartUpdateCapabilities` function.
6465

6566
```C# Snippet:UpdateCapabilitiesNumbers
66-
var updateCapabilitiesOperation = client.StartUpdateCapabilities(purchasedPhoneNumber, calling:PhoneNumberCapabilityType.Outbound, sms:PhoneNumberCapabilityType.InboundOutbound);
67+
var updateCapabilitiesOperation = client.StartUpdateCapabilities(purchasedPhoneNumber, calling: PhoneNumberCapabilityType.Outbound, sms: PhoneNumberCapabilityType.InboundOutbound);
6768

6869
while (!updateCapabilitiesOperation.HasCompleted)
6970
{
7071
Thread.Sleep(2000);
72+
SleepIfNotInPlaybackMode();
7173
updateCapabilitiesOperation.UpdateStatus();
7274
}
7375
```
@@ -83,6 +85,7 @@ var releaseOperation = client.StartReleasePhoneNumber(purchasedPhoneNumber);
8385
while (!releaseOperation.HasCompleted)
8486
{
8587
Thread.Sleep(2000);
88+
SleepIfNotInPlaybackMode();
8689
releaseOperation.UpdateStatus();
8790
}
8891
```

sdk/communication/Azure.Communication.PhoneNumbers/samples/Sample_PhoneNumbersClientAsync.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var client = new PhoneNumbersClient(connectionString);
2020
Phone numbers need to be searched before they can be purchased. Search is a long running operation that can be started by `StartSearchAvailablePhoneNumbers` function that returns an `SearchAvailablePhoneNumbersOperation` object. `SearchAvailablePhoneNumbersOperation` can be used to update status of the operation and to check for completeness.
2121

2222
```C# Snippet:SearchPhoneNumbersAsync
23-
var capabilities = new PhoneNumberCapabilities(calling:PhoneNumberCapabilityType.None, sms:PhoneNumberCapabilityType.Outbound);
23+
var capabilities = new PhoneNumberCapabilities(calling: PhoneNumberCapabilityType.None, sms: PhoneNumberCapabilityType.Outbound);
2424

2525
var searchOperation = await client.StartSearchAvailablePhoneNumbersAsync(countryCode, PhoneNumberType.TollFree, PhoneNumberAssignmentType.Application, capabilities);
2626
await searchOperation.WaitForCompletionAsync();
@@ -66,4 +66,5 @@ If you no longer need a phone number you can release it.
6666
var purchasedPhoneNumber = "<purchased_phone_number>";
6767
var releaseOperation = await client.StartReleasePhoneNumberAsync(purchasedPhoneNumber);
6868
await releaseOperation.WaitForCompletionResponseAsync();
69+
await WaitForCompletionResponseAsync(releaseOperation);
6970
```

0 commit comments

Comments
 (0)