-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Communication] - Phone Numbers - Address API View comments #19325
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,15 +6,19 @@ | |||||
import com.azure.communication.phonenumbers.implementation.PhoneNumbersImpl; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumbersPurchasePhoneNumbersResponse; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumberPurchaseRequest; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumberSearchRequest; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumbersSearchAvailablePhoneNumbersResponse; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumbersReleasePhoneNumberResponse; | ||||||
import com.azure.communication.phonenumbers.implementation.models.PhoneNumbersUpdateCapabilitiesResponse; | ||||||
import com.azure.communication.phonenumbers.models.AcquiredPhoneNumber; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberAssignmentType; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberCapabilities; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberCapabilitiesRequest; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberOperation; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberOperationStatus; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberSearchRequest; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberSearchOptions; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberSearchResult; | ||||||
import com.azure.communication.phonenumbers.models.PhoneNumberType; | ||||||
import com.azure.core.annotation.ReturnType; | ||||||
import com.azure.core.annotation.ServiceClient; | ||||||
import com.azure.core.annotation.ServiceMethod; | ||||||
|
@@ -98,22 +102,42 @@ public PagedFlux<AcquiredPhoneNumber> listPhoneNumbers() { | |||||
* Starts the search for available phone numbers to purchase. | ||||||
* | ||||||
* @param countryCode The ISO 3166-2 country code. | ||||||
* @param searchRequest {@link PhoneNumberSearchRequest} specifying the search request | ||||||
* until it gets a result from the server | ||||||
* @param phoneNumberType {@link PhoneNumberType} The phone number type | ||||||
* @param assignmentType {@link PhoneNumberAssignmentType} The phone assignment type | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Nit: let's be consistent with full stops at the end. |
||||||
* @param capabilities {@link PhoneNumberCapabilities} The phone number's capabilities | ||||||
* @param searchOptions The phone number search options | ||||||
* @return A {@link PollerFlux} object with the reservation result | ||||||
* @throws NullPointerException if {@code countryCode} or {@code searchRequest} is null. | ||||||
*/ | ||||||
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) | ||||||
public PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers( | ||||||
String countryCode, PhoneNumberSearchRequest searchRequest) { | ||||||
return beginSearchAvailablePhoneNumbers(countryCode, searchRequest, null); | ||||||
String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, | ||||||
PhoneNumberCapabilities capabilities, PhoneNumberSearchOptions searchOptions) { | ||||||
return beginSearchAvailablePhoneNumbers(countryCode, phoneNumberType, assignmentType, capabilities, searchOptions, null); | ||||||
} | ||||||
|
||||||
PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> beginSearchAvailablePhoneNumbers( | ||||||
String countryCode, PhoneNumberSearchRequest searchRequest, Context context) { | ||||||
String countryCode, PhoneNumberType phoneNumberType, PhoneNumberAssignmentType assignmentType, | ||||||
PhoneNumberCapabilities capabilities, PhoneNumberSearchOptions searchOptions, Context context) { | ||||||
try { | ||||||
Objects.requireNonNull(countryCode, "'countryCode' cannot be null."); | ||||||
Objects.requireNonNull(searchRequest, "'searchRequest' cannot be null."); | ||||||
Objects.requireNonNull(phoneNumberType, "'phoneNumberType' cannot be null."); | ||||||
Objects.requireNonNull(assignmentType, "'assignmentType' cannot be null."); | ||||||
Objects.requireNonNull(capabilities, "'capabilities' cannot be null."); | ||||||
|
||||||
String areaCode = null; | ||||||
Integer quantity = null; | ||||||
if (searchOptions != null) { | ||||||
areaCode = searchOptions.getAreaCode(); | ||||||
quantity = searchOptions.getQuantity(); | ||||||
} | ||||||
PhoneNumberSearchRequest searchRequest = new PhoneNumberSearchRequest(); | ||||||
searchRequest | ||||||
.setPhoneNumberType(phoneNumberType) | ||||||
.setAssignmentType(assignmentType) | ||||||
.setCapabilities(capabilities) | ||||||
.setAreaCode(areaCode) | ||||||
.setQuantity(quantity); | ||||||
|
||||||
return new PollerFlux<>(defaultPollInterval, | ||||||
searchAvailableNumbersInitOperation(countryCode, searchRequest, context), | ||||||
|
@@ -145,7 +169,7 @@ PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> beginSearchAvailablePh | |||||
|
||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PollResponse<PhoneNumberOperation>>> | ||||||
pollOperation() { | ||||||
return (pollingContext) -> { | ||||||
return (pollingContext) -> { | ||||||
return client.getOperationAsync(pollingContext.getData("operationId")) | ||||||
.flatMap(operation -> { | ||||||
if (operation.getStatus().toString().equalsIgnoreCase(PhoneNumberOperationStatus.SUCCEEDED.toString())) { | ||||||
|
@@ -179,7 +203,7 @@ PollerFlux<PhoneNumberOperation, PhoneNumberSearchResult> beginSearchAvailablePh | |||||
return Mono.empty(); | ||||||
}; | ||||||
} | ||||||
|
||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberSearchResult>> | ||||||
searchAvailableNumbersFetchFinalResultOperation() { | ||||||
return (pollingContext) -> { | ||||||
|
@@ -212,7 +236,7 @@ PollerFlux<PhoneNumberOperation, Void> beginPurchasePhoneNumbers(String searchId | |||||
} | ||||||
} | ||||||
|
||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
purchaseNumbersInitOperation(String searchId, Context context) { | ||||||
return (pollingContext) -> { | ||||||
return withContext(contextValue -> { | ||||||
|
@@ -231,7 +255,7 @@ PollerFlux<PhoneNumberOperation, Void> beginPurchasePhoneNumbers(String searchId | |||||
/** | ||||||
* Begins release of an acquired phone number. | ||||||
* | ||||||
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the | ||||||
* This function returns a Long Running Operation poller that allows you to wait indefinitely until the | ||||||
* operation is complete. | ||||||
* @param phoneNumber The phone number id in E.164 format. The leading plus can be either + or encoded | ||||||
* as %2B. | ||||||
|
@@ -256,7 +280,7 @@ PollerFlux<PhoneNumberOperation, Void> beginReleasePhoneNumber(String phoneNumbe | |||||
} | ||||||
} | ||||||
|
||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
releaseNumberInitOperation(String phoneNumber, Context context) { | ||||||
return (pollingContext) -> { | ||||||
return withContext(contextValue -> { | ||||||
|
@@ -281,12 +305,12 @@ PollerFlux<PhoneNumberOperation, Void> beginReleasePhoneNumber(String phoneNumbe | |||||
* @throws NullPointerException if {@code phoneNumber} or {@code capabilitiesUpdateRequest} is null. | ||||||
*/ | ||||||
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) | ||||||
public PollerFlux<PhoneNumberOperation, AcquiredPhoneNumber> | ||||||
public PollerFlux<PhoneNumberOperation, AcquiredPhoneNumber> | ||||||
beginUpdatePhoneNumberCapabilities(String phoneNumber, PhoneNumberCapabilitiesRequest capabilitiesUpdateRequest) { | ||||||
return beginUpdatePhoneNumberCapabilities(phoneNumber, capabilitiesUpdateRequest, null); | ||||||
} | ||||||
|
||||||
PollerFlux<PhoneNumberOperation, AcquiredPhoneNumber> | ||||||
PollerFlux<PhoneNumberOperation, AcquiredPhoneNumber> | ||||||
beginUpdatePhoneNumberCapabilities(String phoneNumber, PhoneNumberCapabilitiesRequest capabilitiesUpdateRequest, Context context) { | ||||||
try { | ||||||
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null."); | ||||||
|
@@ -302,7 +326,7 @@ PollerFlux<PhoneNumberOperation, Void> beginReleasePhoneNumber(String phoneNumbe | |||||
} | ||||||
} | ||||||
|
||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
private Function<PollingContext<PhoneNumberOperation>, Mono<PhoneNumberOperation>> | ||||||
updateNumberCapabilitiesInitOperation(String phoneNumber, PhoneNumberCapabilitiesRequest capabilitiesUpdateRequest, Context context) { | ||||||
return (pollingContext) -> { | ||||||
return withContext(contextValue -> { | ||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
clientOptions
have applicationId which should get intoUserAgent
here.azure-sdk-for-java/sdk/communication/azure-communication-identity/src/main/java/com/azure/communication/identity/CommunicationIdentityClientBuilder.java
Line 272 in ea3f1d4
This is an old PR shows how UserAgent should be populated with
applicationId
https://github.com/Azure/azure-sdk-for-java/pull/16428/files#diff-57d5c797a106560d37148554ddcceb69f85c68f35b2a257823fbcc69b24a28aaR171
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. Addressed