Skip to content

Commit

Permalink
[Communication] -Administration- Renaming the model from PhoneNumberS…
Browse files Browse the repository at this point in the history
…earch to PhoneNumberReservation (#17253)

* Renaming from PhoneNumberSearch to PhoneNumberReservation

* Renaming from PhoneNumberSearch to PhoneNumberReservation

* Renaming from PhoneNumberSearch to PhoneNumberReservation

* upadating readme samples

* Renaming the model CreateSearchReponse and CreateSearchOptions

* Fixing tests

* Fixing tests

* fixing typo un reservations
  • Loading branch information
paolamvhz authored Nov 13, 2020
1 parent 65b9871 commit 5262e66
Show file tree
Hide file tree
Showing 53 changed files with 1,832 additions and 1,214 deletions.
26 changes: 13 additions & 13 deletions sdk/communication/azure-communication-administration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,23 @@ String phonePlanId = "PHONE_PLAN_ID";
List<String> phonePlanIds = new ArrayList<>();
phonePlanIds.add(phonePlanId);

CreateSearchOptions createSearchOptions = new CreateSearchOptions();
createSearchOptions
.setAreaCode("AREA_CODE_FOR_SEARCH")
.setDescription("DESCRIPTION_FOR_SEARCH")
.setDisplayName("NAME_FOR_SEARCH")
CreateReservationOptions createReservationOptions = new CreateReservationOptions();
createReservationOptions
.setAreaCode("AREA_CODE_FOR_RESERVATION")
.setDescription("DESCRIPTION_FOR_RESERVATION")
.setDisplayName("NAME_FOR_RESERVATION")
.setPhonePlanIds(phonePlanIds)
.setQuantity(2);

Duration duration = Duration.ofSeconds(1);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberSearch, PhoneNumberSearch> res =
phoneNumberClient.beginCreateSearch(createSearchOptions, duration);
SyncPoller<PhoneNumberReservation, PhoneNumberReservation> res =
phoneNumberClient.beginCreateReservation(createReservationOptions, duration);
res.waitForCompletion();
PhoneNumberSearch result = res.getFinalResult();
PhoneNumberReservation result = res.getFinalResult();

System.out.println("Search Id: " + result.getSearchId());
System.out.println("Reservation Id: " + result.getReservationId());
for (String phoneNumber: result.getPhoneNumbers()) {
System.out.println("Phone Number: " + phoneNumber);
}
Expand All @@ -286,11 +286,11 @@ for (String phoneNumber: result.getPhoneNumbers()) {
<!-- embedme ./src/samples/java/com/azure/communication/administration/ReadmeSamples.java#L376-L382 -->
```java
Duration duration = Duration.ofSeconds(1);
String phoneNumberSearchId = "SEARCH_ID_TO_PURCHASE";
String phoneNumberReservationId = "RESERVATION_ID_TO_PURCHASE";
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<Void, Void> res =
phoneNumberClient.beginPurchaseSearch(phoneNumberSearchId, duration);
SyncPoller<Void, Void> res =
phoneNumberClient.beginPurchaseReservation(phoneNumberReservationId, duration);
res.waitForCompletion();
```

Expand All @@ -303,7 +303,7 @@ List<PhoneNumber> phoneNumbers = new ArrayList<>();
phoneNumbers.add(phoneNumber);
PhoneNumberClient phoneNumberClient = createPhoneNumberClient();

SyncPoller<PhoneNumberRelease, PhoneNumberRelease> res =
SyncPoller<PhoneNumberRelease, PhoneNumberRelease> res =
phoneNumberClient.beginReleasePhoneNumbers(phoneNumbers, duration);
res.waitForCompletion();
PhoneNumberRelease result = res.getFinalResult();
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import com.azure.communication.administration.models.AcquiredPhoneNumber;
import com.azure.communication.administration.models.AreaCodes;
import com.azure.communication.administration.models.CreateSearchOptions;
import com.azure.communication.administration.models.CreateSearchResponse;
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 All @@ -17,7 +17,7 @@
import com.azure.communication.administration.models.PhonePlanGroup;
import com.azure.communication.administration.models.PstnConfiguration;
import com.azure.communication.administration.models.UpdateNumberCapabilitiesResponse;
import com.azure.communication.administration.models.PhoneNumberSearch;
import com.azure.communication.administration.models.PhoneNumberReservation;
import com.azure.communication.administration.models.UpdatePhoneNumberCapabilitiesResponse;
import com.azure.communication.common.PhoneNumber;
import com.azure.core.annotation.ReturnType;
Expand Down Expand Up @@ -388,134 +388,135 @@ public PagedIterable<PhoneNumberEntity> listAllReleases(Context context) {
}

/**
* Gets a search by ID.
* Gets a reservation by ID.
*
* @param searchId ID of the search
* @return A {@link PhoneNumberSearch} representing the search.
* @param reservationId ID of the reservation
* @return A {@link PhoneNumberReservation} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public PhoneNumberSearch getSearchById(String searchId) {
return phoneNumberAsyncClient.getSearchById(searchId).block();
public PhoneNumberReservation getReservationById(String reservationId) {
return phoneNumberAsyncClient.getReservationById(reservationId).block();
}

/**
* Gets a search by ID.
* Gets a reservation by ID.
*
* @param searchId ID of the search
* @param reservationId ID of the reservation
* @param context A {@link Context} representing the request context.
* @return A {@link Response} whose {@link Response#getValue()} value returns
* a {@link PhoneNumberSearch} representing the search.
* a {@link PhoneNumberReservation} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<PhoneNumberSearch> getSearchByIdWithResponse(String searchId, Context context) {
return phoneNumberAsyncClient.getSearchByIdWithResponse(searchId, context).block();
public Response<PhoneNumberReservation> getReservationByIdWithResponse(String reservationId, Context context) {
return phoneNumberAsyncClient.getReservationByIdWithResponse(reservationId, context).block();
}

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

/**
* Create a phone number search.
* Create a phone number reservation.
*
* @param searchOptions A {@link CreateSearchOptions} with the search options
* @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 CreateSearchResponse} representing the search.
* a {@link CreateReservationResponse} representing the reservation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<CreateSearchResponse> createSearchWithResponse(CreateSearchOptions searchOptions, Context context) {
return phoneNumberAsyncClient.createSearchWithResponse(searchOptions, context).block();
public Response<CreateReservationResponse> createReservationWithResponse(
CreateReservationOptions reservationOptions, Context context) {
return phoneNumberAsyncClient.createReservationWithResponse(reservationOptions, context).block();
}

/**
* Gets the list of all searches
* Gets the list of all reservations
*
* @return A {@link PagedIterable} of {@link PhoneNumberEntity} instances representing searches.
* @return A {@link PagedIterable} of {@link PhoneNumberEntity} instances representing reservations.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PhoneNumberEntity> listAllSearches() {
return new PagedIterable<>(phoneNumberAsyncClient.listAllSearches());
public PagedIterable<PhoneNumberEntity> listAllReservations() {
return new PagedIterable<>(phoneNumberAsyncClient.listAllReservations());
}

/**
* Gets the list of all searches
* Gets the list of all reservationes
*
* @param context A {@link Context} representing the request context.
* @return A {@link PagedIterable} of {@link PhoneNumberEntity} instances representing searches.
* @return A {@link PagedIterable} of {@link PhoneNumberEntity} instances representing reservations.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<PhoneNumberEntity> listAllSearches(Context context) {
return new PagedIterable<>(phoneNumberAsyncClient.listAllSearches(context));
public PagedIterable<PhoneNumberEntity> listAllReservations(Context context) {
return new PagedIterable<>(phoneNumberAsyncClient.listAllReservations(context));
}

/**
* Cancels the search. This means existing numbers in the search will be made available.
* Cancels the reservation. This means existing numbers in the reservation will be made available.
*
* @param searchId ID of the search
* @param reservationId ID of the reservation
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void cancelSearch(String searchId) {
phoneNumberAsyncClient.cancelSearch(searchId).block();
public void cancelReservation(String reservationId) {
phoneNumberAsyncClient.cancelReservation(reservationId).block();
}

/**
* Cancels the search. This means existing numbers in the search will be made available.
* Cancels the reservation. This means existing numbers in the reservation will be made available.
*
* @param searchId ID of the search
* @param reservationId ID of the reservation
* @param context A {@link Context} representing the request context.
* @return A {@link Response} for the operation
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> cancelSearchWithResponse(String searchId, Context context) {
return phoneNumberAsyncClient.cancelSearchWithResponse(searchId, context).block();
public Response<Void> cancelReservationWithResponse(String reservationId, Context context) {
return phoneNumberAsyncClient.cancelReservationWithResponse(reservationId, context).block();
}

/**
* Initiates a search and returns a {@link PhoneNumberSearch} usable by other functions
* Initiates a reservation and returns a {@link PhoneNumberReservation} usable by other functions
* This function returns a Long Running Operation poller.
*
* @param options A {@link CreateSearchOptions} with the search options
* @param pollInterval The time our long running operation will keep on polling
*
* @param options A {@link CreateReservationOptions} with the reservation options
* @param pollInterval The time our long running operation will keep on polling
* until it gets a result from the server
* @return A {@link SyncPoller} object with the search result
* @return A {@link SyncPoller} object with the reservation result
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public SyncPoller<PhoneNumberSearch, PhoneNumberSearch> beginCreateSearch(
CreateSearchOptions options, Duration pollInterval) {
return phoneNumberAsyncClient.beginCreateSearch(options, pollInterval).getSyncPoller();
public SyncPoller<PhoneNumberReservation, PhoneNumberReservation> beginCreateReservation(
CreateReservationOptions options, Duration pollInterval) {
return phoneNumberAsyncClient.beginCreateReservation(options, pollInterval).getSyncPoller();
}

/**
* Initiates a purchase process and polls until a terminal state is reached
* This function returns a Long Running Operation poller
*
* @param searchId ID of the search
* @param pollInterval The time our long running operation will keep on polling
*
* @param reservationId ID of the reservation
* @param pollInterval The time our long running operation will keep on polling
* until it gets a result from the server
* @return A {@link SyncPoller} object with the search result
* @return A {@link SyncPoller} object with the reservation result
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public SyncPoller<Void, Void> beginPurchaseSearch(
String searchId, Duration pollInterval) {
return phoneNumberAsyncClient.beginPurchaseSearch(searchId, pollInterval).getSyncPoller();
public SyncPoller<Void, Void> beginPurchaseReservation(
String reservationId, Duration pollInterval) {
return phoneNumberAsyncClient.beginPurchaseReservation(reservationId, pollInterval).getSyncPoller();
}

/**
* Releases the given phone numbers.
* This function returns a Long Running Operation poller
*
*
* @param phoneNumbers A list of {@link PhoneNumber} with the desired numbers to release
* @param pollInterval The time our long running operation will keep on polling
* @param pollInterval The time our long running operation will keep on polling
* until it gets a result from the server
* @return A {@link SyncPoller} object with the search result
* @return A {@link SyncPoller} object with the reservation result
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public SyncPoller<PhoneNumberRelease, PhoneNumberRelease> beginReleasePhoneNumbers(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.communication.administration;

import com.azure.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Collection;

/** Defines values for ReservationStatus. */
public final class ReservationStatus extends ExpandableStringEnum<ReservationStatus> {
/** Static value Pending for ReservationStatus. */
public static final ReservationStatus PENDING = fromString("Pending");

/** Static value InProgress for ReservationStatus. */
public static final ReservationStatus IN_PROGRESS = fromString("InProgress");

/** Static value Reserved for ReservationStatus. */
public static final ReservationStatus RESERVED = fromString("Reserved");

/** Static value Expired for ReservationStatus. */
public static final ReservationStatus EXPIRED = fromString("Expired");

/** Static value Expiring for ReservationStatus. */
public static final ReservationStatus EXPIRING = fromString("Expiring");

/** Static value Completing for ReservationStatus. */
public static final ReservationStatus COMPLETING = fromString("Completing");

/** Static value Refreshing for ReservationStatus. */
public static final ReservationStatus REFRESHING = fromString("Refreshing");

/** Static value Success for ReservationStatus. */
public static final ReservationStatus SUCCESS = fromString("Success");

/** Static value Manual for ReservationStatus. */
public static final ReservationStatus MANUAL = fromString("Manual");

/** Static value Cancelled for ReservationStatus. */
public static final ReservationStatus CANCELLED = fromString("Cancelled");

/** Static value Cancelling for ReservationStatus. */
public static final ReservationStatus CANCELLING = fromString("Cancelling");

/** Static value Error for ReservationStatus. */
public static final ReservationStatus ERROR = fromString("Error");

/** Static value PurchasePending for ReservationStatus. */
public static final ReservationStatus PURCHASE_PENDING = fromString("PurchasePending");

/**
* Creates or finds a ReservationStatus from its string representation.
*
* @param name a name to look for.
* @return the corresponding ReservationStatus.
*/
@JsonCreator
public static ReservationStatus fromString(String name) {
return fromString(name, ReservationStatus.class);
}

/** @return known ReservationStatus values. */
public static Collection<ReservationStatus> values() {
return values(ReservationStatus.class);
}
}
Loading

0 comments on commit 5262e66

Please sign in to comment.