diff --git a/sdk/communication/communication-administration/CHANGELOG.md b/sdk/communication/communication-administration/CHANGELOG.md index b8d57dbaa1d1..5cb4bf4b2ed5 100644 --- a/sdk/communication/communication-administration/CHANGELOG.md +++ b/sdk/communication/communication-administration/CHANGELOG.md @@ -4,6 +4,7 @@ ### Key bug fixes +- Fixed a bug where poller options were ignored for `beginReleasePhoneNumbers`, `beginReservePhoneNumbers` and `beginPurchaseReservation`. - Fixed paging for `listPhoneNumbers`, `listPhonePlanGroups`, `listPhonePlans`, `listReleases`, `listSearches`, `listSupportedCountries`. ## 1.0.0-beta.3 (2020-11-16) diff --git a/sdk/communication/communication-administration/src/phoneNumber/phoneNumberAdministrationClient.ts b/sdk/communication/communication-administration/src/phoneNumber/phoneNumberAdministrationClient.ts index 44714cf4a224..e5da8d9a9560 100644 --- a/sdk/communication/communication-administration/src/phoneNumber/phoneNumberAdministrationClient.ts +++ b/sdk/communication/communication-administration/src/phoneNumber/phoneNumberAdministrationClient.ts @@ -974,10 +974,13 @@ export class PhoneNumberAdministrationClient { phoneNumbers: string[], options: BeginReleasePhoneNumbersOptions = {} ): Promise, PhoneNumberRelease>> { + const { pollInterval, resumeFrom, ...requestOptions } = options; const poller = new ReleasePhoneNumbersPoller({ phoneNumbers, client: this.client, - requestOptions: options + pollInterval, + resumeFrom, + requestOptions }); await poller.poll(); @@ -1010,10 +1013,13 @@ export class PhoneNumberAdministrationClient { reservationRequest: CreateReservationRequest, options: BeginReservePhoneNumbersOptions = {} ): Promise, PhoneNumberReservation>> { + const { pollInterval, resumeFrom, ...requestOptions } = options; const poller = new ReservePhoneNumbersPoller({ reservationRequest, client: this.client, - requestOptions: options + pollInterval, + resumeFrom, + requestOptions }); await poller.poll(); @@ -1045,10 +1051,13 @@ export class PhoneNumberAdministrationClient { reservationId: string, options: BeginPurchaseReservationOptions = {} ): Promise, void>> { + const { pollInterval, resumeFrom, ...requestOptions } = options; const poller = new PurchaseReservationPoller({ reservationId, client: this.client, - requestOptions: options + pollInterval, + resumeFrom, + requestOptions }); await poller.poll(); diff --git a/sdk/communication/communication-administration/test/lro.purchase.spec.ts b/sdk/communication/communication-administration/test/lro.purchase.spec.ts index 92e25e66b6d9..acb6ebf14afc 100644 --- a/sdk/communication/communication-administration/test/lro.purchase.spec.ts +++ b/sdk/communication/communication-administration/test/lro.purchase.spec.ts @@ -9,7 +9,10 @@ import { PhoneNumberAdministrationClient, PhoneNumberReservation } from "../src"; -import { createRecordedPhoneNumberAdministrationClient } from "./utils/recordedClient"; +import { + createRecordedPhoneNumberAdministrationClient, + testPollerOptions +} from "./utils/recordedClient"; describe("PhoneNumber - LROs - Purchase Reservation [Playback/Live]", function() { let recorder: Recorder; @@ -90,7 +93,10 @@ describe("PhoneNumber - LROs - Purchase Reservation [Playback/Live]", function() areaCode, quantity: 1 }; - const reservePoller = await client.beginReservePhoneNumbers(reservationRequest); + const reservePoller = await client.beginReservePhoneNumbers( + reservationRequest, + testPollerOptions + ); assert.ok(reservePoller.getOperationState().isStarted); const reservation: PhoneNumberReservation = await reservePoller.pollUntilDone(); @@ -100,7 +106,7 @@ describe("PhoneNumber - LROs - Purchase Reservation [Playback/Live]", function() assert.equal(reservation.status, "Reserved"); assert.equal(reservation.phoneNumbers?.length, 1); - const purchasePoller = await client.beginPurchaseReservation(reservationId); + const purchasePoller = await client.beginPurchaseReservation(reservationId, testPollerOptions); assert.ok(purchasePoller.getOperationState().isStarted); await purchasePoller.pollUntilDone(); diff --git a/sdk/communication/communication-administration/test/lro.release.spec.ts b/sdk/communication/communication-administration/test/lro.release.spec.ts index 06edc35a46b6..63fa6e528749 100644 --- a/sdk/communication/communication-administration/test/lro.release.spec.ts +++ b/sdk/communication/communication-administration/test/lro.release.spec.ts @@ -4,7 +4,10 @@ import { isPlaybackMode, Recorder } from "@azure/test-utils-recorder"; import { assert } from "chai"; import { PhoneNumberAdministrationClient, PhoneNumberRelease } from "../src"; -import { createRecordedPhoneNumberAdministrationClient } from "./utils/recordedClient"; +import { + createRecordedPhoneNumberAdministrationClient, + testPollerOptions +} from "./utils/recordedClient"; describe("PhoneNumber - LROs - Release [Playback/Live]", function() { let recorder: Recorder; @@ -42,7 +45,7 @@ describe("PhoneNumber - LROs - Release [Playback/Live]", function() { this.skip(); } - const poller = await client.beginReleasePhoneNumbers([phoneNumberToRelease]); + const poller = await client.beginReleasePhoneNumbers([phoneNumberToRelease], testPollerOptions); assert.ok(poller.getOperationState().isStarted); const release: PhoneNumberRelease = await poller.pollUntilDone(); diff --git a/sdk/communication/communication-administration/test/lro.reserve.spec.ts b/sdk/communication/communication-administration/test/lro.reserve.spec.ts index e07d88fb56e9..a80b97c409d1 100644 --- a/sdk/communication/communication-administration/test/lro.reserve.spec.ts +++ b/sdk/communication/communication-administration/test/lro.reserve.spec.ts @@ -10,7 +10,10 @@ import { PhoneNumberAdministrationClient, PhoneNumberReservation } from "../src"; -import { createRecordedPhoneNumberAdministrationClient } from "./utils/recordedClient"; +import { + createRecordedPhoneNumberAdministrationClient, + testPollerOptions +} from "./utils/recordedClient"; describe("PhoneNumber - LROs - Phone Number Reservations [Playback/Live]", function() { let recorder: Recorder; @@ -93,7 +96,7 @@ describe("PhoneNumber - LROs - Phone Number Reservations [Playback/Live]", funct areaCode, quantity: 1 }; - poller = await client.beginReservePhoneNumbers(reservationRequest); + poller = await client.beginReservePhoneNumbers(reservationRequest, testPollerOptions); assert.ok(poller.getOperationState().isStarted); const reservation: PhoneNumberReservation = await poller.pollUntilDone(); diff --git a/sdk/communication/communication-administration/test/utils/recordedClient.ts b/sdk/communication/communication-administration/test/utils/recordedClient.ts index c7513fc85de3..a56d63fc7458 100644 --- a/sdk/communication/communication-administration/test/utils/recordedClient.ts +++ b/sdk/communication/communication-administration/test/utils/recordedClient.ts @@ -4,7 +4,13 @@ import { Context } from "mocha"; import * as dotenv from "dotenv"; -import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder"; +import { + env, + Recorder, + record, + RecorderEnvironmentSetup, + isPlaybackMode +} from "@azure/test-utils-recorder"; import { isNode } from "@azure/core-http"; import { CommunicationIdentityClient, PhoneNumberAdministrationClient } from "../../src"; @@ -78,3 +84,7 @@ export function createRecordedPhoneNumberAdministrationClient( includePhoneNumberLiveTests: env.INCLUDE_PHONENUMBER_LIVE_TESTS == "true" }; } + +export const testPollerOptions = { + pollInterval: isPlaybackMode() ? 0 : undefined +};