Class PhoneNumbersAsyncClient
java.lang.Object
com.azure.communication.phonenumbers.PhoneNumbersAsyncClient
Asynchronous client for Communication service phone number operations.
Instantiating an asynchronous Phone Numbers Client
PhoneNumbersAsyncClient phoneNumberAsyncClient = new PhoneNumbersClientBuilder() .endpoint(endpoint) .credential(keyCredential) .httpClient(httpClient) .buildAsyncClient();
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncom.azure.core.util.polling.PollerFlux<PhoneNumberOperation,
PurchasePhoneNumbersResult> beginPurchasePhoneNumbers
(String searchId) Starts the purchase of the phone number(s) in the search result associated with a given id.com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,
ReleasePhoneNumberResult> beginReleasePhoneNumber
(String phoneNumber) Begins release of a purchased phone number.com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,
PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers
(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities) Starts the search for available phone numbers to purchase.com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,
PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers
(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities, PhoneNumberSearchOptions searchOptions) Starts the search for available phone numbers to purchase.com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,
PurchasedPhoneNumber> beginUpdatePhoneNumberCapabilities
(String phoneNumber, PhoneNumberCapabilities capabilities) Update capabilities of a purchased phone number.getPurchasedPhoneNumber
(String phoneNumber) Gets information about a purchased phone number.Mono<com.azure.core.http.rest.Response<PurchasedPhoneNumber>>
getPurchasedPhoneNumberWithResponse
(String phoneNumber) Gets information about a purchased phone number with response.com.azure.core.http.rest.PagedFlux<PhoneNumberCountry>
Gets the list of the available countries with context.com.azure.core.http.rest.PagedFlux<com.azure.communication.phonenumbers.implementation.models.PhoneNumberAreaCode>
listAvailableGeographicAreaCodes
(String countryCode, PhoneNumberAssignmentType assignmentType, String locality, String administrativeDivision) Gets the list of the available Geographic area codes for a given country and locality.com.azure.core.http.rest.PagedFlux<PhoneNumberLocality>
listAvailableLocalities
(String countryCode, String administrativeDivision) Gets the list of the available localities.com.azure.core.http.rest.PagedFlux<PhoneNumberOffering>
listAvailableOfferings
(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType) Gets the list of the available phone number offerings for the given country.com.azure.core.http.rest.PagedFlux<com.azure.communication.phonenumbers.implementation.models.PhoneNumberAreaCode>
listAvailableTollFreeAreaCodes
(String countryCode, PhoneNumberAssignmentType assignmentType) Gets the list of the available Toll-Free area codes for a given country.com.azure.core.http.rest.PagedFlux<PurchasedPhoneNumber>
Gets the list of the purchased phone numbers.
-
Method Details
-
getPurchasedPhoneNumber
Gets information about a purchased phone number.Code Samples
PurchasedPhoneNumber phoneNumber = phoneNumberAsyncClient.getPurchasedPhoneNumber("+18001234567").block(); System.out.println("Phone Number Value: " + phoneNumber.getPhoneNumber()); System.out.println("Phone Number Country Code: " + phoneNumber.getCountryCode());
- Parameters:
phoneNumber
- The phone number id in E.164 format. The leading plus can be either + or encoded as %2B.- Returns:
PurchasedPhoneNumber
representing the purchased telephone number.- Throws:
NullPointerException
- ifphoneNumber
is null.
-
getPurchasedPhoneNumberWithResponse
public Mono<com.azure.core.http.rest.Response<PurchasedPhoneNumber>> getPurchasedPhoneNumberWithResponse(String phoneNumber) Gets information about a purchased phone number with response.Code Samples
Response<PurchasedPhoneNumber> response = phoneNumberAsyncClient .getPurchasedPhoneNumberWithResponse("+18001234567").block(); PurchasedPhoneNumber phoneNumber = response.getValue(); System.out.println("Phone Number Value: " + phoneNumber.getPhoneNumber()); System.out.println("Phone Number Country Code: " + phoneNumber.getCountryCode());
- Parameters:
phoneNumber
- The phone number id in E.164 format. The leading plus can be either + or encoded as %2B.- Returns:
PurchasedPhoneNumber
representing the purchased telephone number.- Throws:
NullPointerException
- ifphoneNumber
is null.
-
listPurchasedPhoneNumbers
Gets the list of the purchased phone numbers.Code Samples
PagedFlux<PurchasedPhoneNumber> phoneNumbers = phoneNumberAsyncClient.listPurchasedPhoneNumbers(); PurchasedPhoneNumber phoneNumber = phoneNumbers.blockFirst(); System.out.println("Phone Number Value: " + phoneNumber.getPhoneNumber()); System.out.println("Phone Number Country Code: " + phoneNumber.getCountryCode());
- Returns:
- A
PagedFlux
ofPurchasedPhoneNumber
instances representing a purchased telephone numbers.
-
beginSearchAvailablePhoneNumbers
public com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities) Starts the search for available phone numbers to purchase.Code Samples
PhoneNumberCapabilities capabilities = new PhoneNumberCapabilities() .setCalling(PhoneNumberCapabilityType.INBOUND) .setSms(PhoneNumberCapabilityType.INBOUND_OUTBOUND); PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> poller = phoneNumberAsyncClient .beginSearchAvailablePhoneNumbers("US", PhoneNumberType.TOLL_FREE, PhoneNumberAssignmentType.APPLICATION, capabilities); AsyncPollResponse<PhoneNumberOperation, PhoneNumberSearchResult> response = poller.blockFirst(); String searchId = ""; if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED == response.getStatus()) { PhoneNumberSearchResult searchResult = response.getFinalResult().block(); searchId = searchResult.getSearchId(); System.out.println("Searched phone numbers: " + searchResult.getPhoneNumbers()); System.out.println("Search expires by: " + searchResult.getSearchExpiresBy()); System.out.println("Phone number costs:" + searchResult.getCost().getAmount()); }
- Parameters:
countryCode
- The ISO 3166-2 country code.phoneNumberType
-PhoneNumberType
The phone number type.assignmentType
-PhoneNumberAssignmentType
The phone number assignment type.capabilities
-PhoneNumberCapabilities
The phone number capabilities.- Returns:
- A
PollerFlux
object with the reservation result. - Throws:
NullPointerException
- ifcountryCode
orsearchRequest
is null.
-
beginSearchAvailablePhoneNumbers
public com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, PhoneNumberCapabilities capabilities, PhoneNumberSearchOptions searchOptions) Starts the search for available phone numbers to purchase.Code Samples
PhoneNumberCapabilities capabilities = new PhoneNumberCapabilities() .setCalling(PhoneNumberCapabilityType.INBOUND) .setSms(PhoneNumberCapabilityType.INBOUND_OUTBOUND); PhoneNumberSearchOptions searchOptions = new PhoneNumberSearchOptions().setAreaCode("800").setQuantity(1); PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> poller = phoneNumberAsyncClient .beginSearchAvailablePhoneNumbers("US", PhoneNumberType.TOLL_FREE, PhoneNumberAssignmentType.APPLICATION, capabilities, searchOptions); AsyncPollResponse<PhoneNumberOperation, PhoneNumberSearchResult> response = poller.blockFirst(); if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED == response.getStatus()) { PhoneNumberSearchResult searchResult = response.getFinalResult().block(); String searchId = searchResult.getSearchId(); System.out.println("Searched phone numbers: " + searchResult.getPhoneNumbers()); System.out.println("Search expires by: " + searchResult.getSearchExpiresBy()); System.out.println("Phone number costs:" + searchResult.getCost().getAmount()); }
- Parameters:
countryCode
- The ISO 3166-2 country code.phoneNumberType
-PhoneNumberType
The phone number type.assignmentType
-PhoneNumberAssignmentType
The phone number assignment type.capabilities
-PhoneNumberCapabilities
The phone number capabilities.searchOptions
- The phone number search options.- Returns:
- A
PollerFlux
object with the reservation result. - Throws:
NullPointerException
- ifcountryCode
orsearchRequest
is null.RuntimeException
- if search operation fails.
-
beginPurchasePhoneNumbers
public com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,PurchasePhoneNumbersResult> beginPurchasePhoneNumbers(String searchId) Starts the purchase of the phone number(s) in the search result associated with a given id.Code Samples
AsyncPollResponse<PhoneNumberOperation, PurchasePhoneNumbersResult> purchaseResponse = phoneNumberAsyncClient .beginPurchasePhoneNumbers(searchId).blockFirst(); System.out.println("Purchase phone numbers is complete: " + purchaseResponse.getStatus());
- Parameters:
searchId
- ID of the search.- Returns:
- A
PollerFlux
object. - Throws:
NullPointerException
- ifsearchId
is null.RuntimeException
- if purchase operation fails.
-
beginReleasePhoneNumber
public com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,ReleasePhoneNumberResult> beginReleasePhoneNumber(String phoneNumber) Begins release of a purchased phone number. This function returns a Long Running Operation poller that allows you to wait indefinitely until the operation is complete.Code Samples
AsyncPollResponse<PhoneNumberOperation, ReleasePhoneNumberResult> releaseResponse = phoneNumberAsyncClient .beginReleasePhoneNumber("+18001234567").blockFirst(); System.out.println("Release phone number is complete: " + releaseResponse.getStatus());
- Parameters:
phoneNumber
- The phone number id in E.164 format. The leading plus can be either + or encoded as %2B.- Returns:
- A
PollerFlux
object. - Throws:
NullPointerException
- ifphoneNumber
is null.RuntimeException
- if release operation fails.
-
beginUpdatePhoneNumberCapabilities
public com.azure.core.util.polling.PollerFlux<PhoneNumberOperation,PurchasedPhoneNumber> beginUpdatePhoneNumberCapabilities(String phoneNumber, PhoneNumberCapabilities capabilities) Update capabilities of a purchased phone number.Code Samples
PhoneNumberCapabilities capabilities = new PhoneNumberCapabilities(); capabilities .setCalling(PhoneNumberCapabilityType.INBOUND) .setSms(PhoneNumberCapabilityType.INBOUND_OUTBOUND); PollerFlux<PhoneNumberOperation, PurchasedPhoneNumber> poller = phoneNumberAsyncClient .beginUpdatePhoneNumberCapabilities("+18001234567", capabilities); AsyncPollResponse<PhoneNumberOperation, PurchasedPhoneNumber> response = poller.blockFirst(); if (LongRunningOperationStatus.SUCCESSFULLY_COMPLETED == response.getStatus()) { PurchasedPhoneNumber phoneNumber = response.getFinalResult().block(); System.out.println("Phone Number Calling capabilities: " + phoneNumber.getCapabilities().getCalling()); System.out.println("Phone Number SMS capabilities: " + phoneNumber.getCapabilities().getSms()); }
- Parameters:
phoneNumber
- The phone number id in E.164 format. The leading plus can be either + or encoded as %2B.capabilities
- Update capabilities of a purchased phone number.- Returns:
- A
PollerFlux
object. - Throws:
NullPointerException
- ifphoneNumber
orcapabilities
is null.RuntimeException
- if update capabilities operation fails.
-
listAvailableCountries
Gets the list of the available countries with context.- Returns:
- A
PagedFlux
ofPhoneNumberCountry
instances representing purchased telephone numbers.
-
listAvailableLocalities
public com.azure.core.http.rest.PagedFlux<PhoneNumberLocality> listAvailableLocalities(String countryCode, String administrativeDivision) Gets the list of the available localities. I.e. cities, towns.- Parameters:
countryCode
- The ISO 3166-2 country code.administrativeDivision
- An optional parameter. The name or short name of the state/province within which to list the localities.- Returns:
- A
PagedFlux
ofPhoneNumberLocality
instances representing available localities with phone numbers.
-
listAvailableTollFreeAreaCodes
public com.azure.core.http.rest.PagedFlux<com.azure.communication.phonenumbers.implementation.models.PhoneNumberAreaCode> listAvailableTollFreeAreaCodes(String countryCode, PhoneNumberAssignmentType assignmentType) Gets the list of the available Toll-Free area codes for a given country.- Parameters:
countryCode
- The ISO 3166-2 country code.assignmentType
-PhoneNumberAssignmentType
The phone number assignment type.- Returns:
- A
PagedFlux
ofPhoneNumberAreaCode
instances representing available area codes.
-
listAvailableGeographicAreaCodes
public com.azure.core.http.rest.PagedFlux<com.azure.communication.phonenumbers.implementation.models.PhoneNumberAreaCode> listAvailableGeographicAreaCodes(String countryCode, PhoneNumberAssignmentType assignmentType, String locality, String administrativeDivision) Gets the list of the available Geographic area codes for a given country and locality.- Parameters:
countryCode
- The ISO 3166-2 country code.assignmentType
-PhoneNumberAssignmentType
The phone number assignment type.locality
- The name of the locality (e.g. city or town name) in which to fetch area codes.administrativeDivision
- An optional parameter. The name of the administrative division (e.g. state or province) of the locality.- Returns:
- A
PagedFlux
ofPhoneNumberAreaCode
instances representing purchased telephone numbers.
-
listAvailableOfferings
public com.azure.core.http.rest.PagedFlux<PhoneNumberOffering> listAvailableOfferings(String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType) Gets the list of the available phone number offerings for the given country.- Parameters:
countryCode
- The ISO 3166-2 country code.phoneNumberType
-PhoneNumberType
Optional parameter. Restrict the offerings to the phone number type.assignmentType
-PhoneNumberAssignmentType
Optional parameter. Restrict the offerings to the assignment type.- Returns:
- A
PagedFlux
ofPurchasedPhoneNumber
instances representing purchased telephone numbers.
-