Skip to content

Azure Communication Service - Phone Number Administration SDK#15497

Merged
waynemo merged 6 commits intoAzure:feature/communication/phonenumberfrom
waynemo:phonenumberadmin
Sep 25, 2020
Merged

Azure Communication Service - Phone Number Administration SDK#15497
waynemo merged 6 commits intoAzure:feature/communication/phonenumberfrom
waynemo:phonenumberadmin

Conversation

@waynemo
Copy link
Contributor

@waynemo waynemo commented Sep 22, 2020

This PR adds the initial Phone Number Administration SDK. It includes the following:

  • AutoRest Generated Client Code
  • Convenience Layer Sync + Async Clients and Builder
  • Unit Tests for Convenience Layer Builder
  • Playback Tests for Convenience Layer Sync + Async Clients

To be completed in separate PRs:

  • Exception handling / Null Checks
  • Java Doc Code Snippets
  • Long Running Operations
  • README updates

@waynemo waynemo marked this pull request as ready for review September 23, 2020 03:52
@waynemo waynemo requested a review from srnagar September 23, 2020 03:54
* @return A {@link Mono} containing a {@link AreaCodes} representing area codes.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<AreaCodes> getAllAreaCodes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure that none of these methods throw exception. Exception should be returned through Mono.error or Flux.error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can update the error handling in a separate PR.

import java.util.stream.Collectors;

/**
* Asynchronous client for Communication service phone number operations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, our javadocs should also include codesnippets on how to instantiate the client at the class level and how to use the APIs for each of the public methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this in a separate PR.

public Mono<UpdateNumberCapabilitiesResponse> updateCapabilities(
Map<PhoneNumber, NumberUpdateCapabilities> phoneNumberCapabilitiesUpdate) {
Map<String, NumberUpdateCapabilities> capabilitiesMap = new HashMap<>();
for (Map.Entry<PhoneNumber, NumberUpdateCapabilities> entry : phoneNumberCapabilitiesUpdate.entrySet()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add null checks before using user-input (phoneNumberCapabilitiesUpdate) and provide helpful error message. Do the same for other methods too.

Objects.requireNonNull(phoneNumberCapabilitiesUpdate, "'phoneNumberCapabilitiesUpdate' cannot be null");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can update the error handling in a separate PR.

private final PhoneNumberAdminClientImpl phoneNumberAdminClient;

PhoneNumberAsyncClient(PhoneNumberAdminClientImpl phoneNumberAdminClient) {
this.phoneNumberAdminClient = phoneNumberAdminClient;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like all APIs in this class only uses phoneNumberAdminClient.getAdministrations(). So, it might be simpler to have the Administrations type as instance variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Will update.

* @return The updated {@link PhoneNumberClientBuilder} object.
*/
public PhoneNumberClientBuilder pipeline(HttpPipeline pipeline) {
this.pipeline = Objects.requireNonNull(pipeline, "'pipeline' cannot be null.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be null in scenarios where the user initially set the pipeline but then decided to clear it out. These validations can be postponed until the build method is called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be addressed in separate PR.

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

@Execution(value = ExecutionMode.SAME_THREAD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed for mocking in the unit tests. If the tests are run in parallel, the mocks will have conflicts.

@waynemo waynemo merged commit 7a5fa95 into Azure:feature/communication/phonenumber Sep 25, 2020
ankitarorabit pushed a commit to ankitarorabit/azure-sdk-for-java that referenced this pull request Oct 1, 2020
…15497)

* Add Phone Number functionality to azure-communication-administration

* Update checkstyle suppressions
RezaJooyandeh pushed a commit that referenced this pull request Oct 2, 2020
* Azure Communication Service - Phone Number Administration SDK (#15497)

* Add Phone Number functionality to azure-communication-administration

* Update checkstyle suppressions

* Azure Communication Services - Refactor PhoneNumberAsyncClient to Wrap Exceptions (#15794)

* Catch exceptions and return error Mono/PagedFlux

* Refactor PhoneNumberAsyncClient method overloads to consolidate logic

* Azure Communication Service - Update Phone Number Admin Null Checks (#15811)

* Add null checks for required method arguments

* Remove setter null check to allow clearing of httpPipeline

* Updating azure-communication-administration README with a few samples (#15816)

* Updating javadoc with a few samples

* resolve comments

* Fixing spot check errors

* fix typo

* Add Env Var check to skip PhoneNumber integration tests (#15855)

* Samples and Readme update for Administration package (#15853)

* More samples and readme changes

* PR comments

* build failure

* fix indentation

* azure-communication-administration - Regenerate Code for Updated Swagger (#15861)

* Update swagger and regenerate code

* Fix tests after code regeneration

* Fix the param name

* updating the sample code

Co-authored-by: waynemo <wamo@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants