Skip to content
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] -Administration- changing some createReservation from public to private #17576

Merged
merged 3 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sdk/communication/azure-communication-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Acquired phone numbers can come with many capabilities, depending on the country
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-administration</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```

Expand Down Expand Up @@ -242,7 +242,7 @@ for (String areaCode

### Configure Phone Number

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L338-L338 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L306-L306 -->
```java
phoneNumberClient.configureNumber(phoneNumber, pstnConfiguration);
```
Expand All @@ -253,7 +253,7 @@ The Phone Number Client supports a variety of long running operations that allow

### Create Search

<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L345-L369 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L313-L337 -->
```java
String phonePlanId = "PHONE_PLAN_ID";

Expand Down Expand Up @@ -283,7 +283,7 @@ for (String phoneNumber: result.getPhoneNumbers()) {
```

### Purchase Search
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L376-L382 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L344-L350 -->
```java
Duration duration = Duration.ofSeconds(1);
String phoneNumberReservationId = "RESERVATION_ID_TO_PURCHASE";
Expand All @@ -295,7 +295,7 @@ res.waitForCompletion();
```

### Release Phone Numbers
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L389-L399 -->
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L357-L367 -->
```java
Duration duration = Duration.ofSeconds(1);
PhoneNumber phoneNumber = new PhoneNumber("PHONE_NUMBER_TO_RELEASE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,8 +640,7 @@ Mono<Response<PhoneNumberReservation>> getReservationByIdWithResponse(String res
* @param reservationOptions A {@link CreateReservationOptions} with the reservation options
* @return A {@link Mono} containing a {@link CreateReservationResponse} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<CreateReservationResponse> createReservation(CreateReservationOptions reservationOptions) {
private Mono<CreateReservationResponse> createReservation(CreateReservationOptions reservationOptions) {
return createReservationWithResponse(reservationOptions).flatMap(FluxUtil::toMono);
}

Expand All @@ -652,8 +651,7 @@ public Mono<CreateReservationResponse> createReservation(CreateReservationOption
* @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue()} value returns
* a {@link CreateReservationResponse} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<CreateReservationResponse>> createReservationWithResponse(
private Mono<Response<CreateReservationResponse>> createReservationWithResponse(
CreateReservationOptions reservationOptions) {
return createReservationWithResponse(reservationOptions, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.azure.communication.administration.models.AcquiredPhoneNumber;
import com.azure.communication.administration.models.AreaCodes;
import com.azure.communication.administration.models.CreateReservationOptions;
import com.azure.communication.administration.models.CreateReservationResponse;
import com.azure.communication.administration.models.LocationOptionsQuery;
import com.azure.communication.administration.models.LocationOptionsResponse;
import com.azure.communication.administration.models.NumberConfigurationResponse;
Expand Down Expand Up @@ -411,31 +410,6 @@ public Response<PhoneNumberReservation> getReservationByIdWithResponse(String re
return phoneNumberAsyncClient.getReservationByIdWithResponse(reservationId, context).block();
}

/**
* Create a phone number reservation.
*
* @param reservationOptions A {@link CreateReservationOptions} with the reservation options
* @return A {@link CreateReservationResponse} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public CreateReservationResponse createReservation(CreateReservationOptions reservationOptions) {
return phoneNumberAsyncClient.createReservation(reservationOptions).block();
}

/**
* Create a phone number reservation.
*
* @param reservationOptions A {@link CreateReservationOptions} with the reservation options
* @param context A {@link Context} representing the request context.
* @return A {@link Response} whose {@link Response#getValue()} value returns
* a {@link CreateReservationResponse} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CreateReservationResponse> createReservationWithResponse(
CreateReservationOptions reservationOptions, Context context) {
return phoneNumberAsyncClient.createReservationWithResponse(reservationOptions, context).block();
}

/**
* Gets the list of all reservations
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.azure.communication.administration.models.AcquiredPhoneNumber;
import com.azure.communication.administration.models.AreaCodes;
import com.azure.communication.administration.models.CreateReservationOptions;
import com.azure.communication.administration.models.CreateReservationResponse;
import com.azure.communication.administration.models.LocationOptions;
import com.azure.communication.administration.models.LocationOptionsDetails;
import com.azure.communication.administration.models.LocationOptionsQuery;
Expand All @@ -27,6 +26,7 @@
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.polling.SyncPoller;


public class ReadmeSamples {
/**
* Sample code for creating a sync Communication Identity Client.
Expand Down Expand Up @@ -294,38 +294,6 @@ public AreaCodes getAreaCodes() {
return areaCodes;
}

/**
* Sample code to create a phone number reservation
*
* @return PhoneNumberReservation for the phone plan
*/
public PhoneNumberReservation createPhoneNumberReservation() {
String phonePlanId = "PHONE_PLAN_ID";

List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(phonePlanId);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode("AREA_CODE_FOR_RESERVATION")
.setDescription("DESCRIPTION_FOR_RESERVATION")
.setDisplayName("NAME_FOR_RESERVATION")
.setPhonePlanIds(phonePlanIds)
.setQuantity(2);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();
CreateReservationResponse createReservationResponse = phoneNumberClient.createReservation(createReservationOptions);

System.out.println("ReservationId: " + createReservationResponse.getReservationId());
PhoneNumberReservation phoneNumberReservation = phoneNumberClient.getReservationById(createReservationResponse.getReservationId());

for (String phoneNumber
: phoneNumberReservation.getPhoneNumbers()) {
System.out.println("Phone Number: " + phoneNumber);
}

return phoneNumberReservation;
}

/**
* Sample code to configure a phone number
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,29 +273,6 @@ public void getCapabilitiesUpdateWithResponse(HttpClient httpClient) {
.verifyComplete();
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createReservation(HttpClient httpClient) {
List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(PHONE_PLAN_ID);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode(AREA_CODE_FOR_SEARCH)
.setDescription("testreservation20200014")
.setDisplayName("testreservation20200014")
.setPhonePlanIds(phonePlanIds)
.setQuantity(1);

Mono<CreateReservationResponse> mono = this.getClient(httpClient).createReservation(createReservationOptions);

StepVerifier.create(mono)
.assertNext(item -> {
assertNotNull(item.getReservationId());
})
.verifyComplete();
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createReservationWithResponse(HttpClient httpClient) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.azure.communication.administration.models.AcquiredPhoneNumber;
import com.azure.communication.administration.models.AreaCodes;
import com.azure.communication.administration.models.Capability;
import com.azure.communication.administration.models.CreateReservationOptions;
import com.azure.communication.administration.models.CreateReservationResponse;
import com.azure.communication.administration.models.LocationOptionsQuery;
import com.azure.communication.administration.models.LocationOptionsResponse;
import com.azure.communication.administration.models.NumberConfigurationResponse;
Expand Down Expand Up @@ -196,46 +194,6 @@ public void getCapabilitiesUpdateWithResponse(HttpClient httpClient) {
assertNotNull(response.getValue().getCapabilitiesUpdateId());
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createReservation(HttpClient httpClient) {
List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(PHONE_PLAN_ID);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode(AREA_CODE_FOR_SEARCH)
.setDescription("318362fa-2b19-4062-92af-fa0673914f30")
.setDisplayName("318362fa-2b19-4062-92af-fa0673914f30")
.setPhonePlanIds(phonePlanIds)
.setQuantity(1);

CreateReservationResponse createReservationResponse = this.getClient(httpClient).createReservation(createReservationOptions);

assertNotNull(createReservationResponse.getReservationId());
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createReservationWithResponse(HttpClient httpClient) {
List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(PHONE_PLAN_ID);

CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode(AREA_CODE_FOR_SEARCH)
.setDescription("318362fa-2b19-4062-92af-fa0673914f30")
.setDisplayName("318362fa-2b19-4062-92af-fa0673914f30")
.setPhonePlanIds(phonePlanIds)
.setQuantity(1);

Response<CreateReservationResponse> response =
this.getClient(httpClient).createReservationWithResponse(createReservationOptions, Context.NONE);

assertEquals(201, response.getStatusCode());
assertNotNull(response.getValue().getReservationId());
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void getReservationById(HttpClient httpClient) {
Expand Down