diff --git a/sdk/communication/communication-administration/package.json b/sdk/communication/communication-administration/package.json index 52986fa385d5..32f2f3cb9a83 100644 --- a/sdk/communication/communication-administration/package.json +++ b/sdk/communication/communication-administration/package.json @@ -126,10 +126,5 @@ "sinon": "^9.0.2", "typescript": "4.1.2", "typedoc": "0.15.0" - }, - "//smokeTestConfiguration": { - "skip": [ - "releasePhoneNumbers.js" - ] } } diff --git a/sdk/communication/communication-administration/samples/javascript/README.md b/sdk/communication/communication-administration/samples/javascript/README.md index 2317c29ec71c..3d8dc152534f 100644 --- a/sdk/communication/communication-administration/samples/javascript/README.md +++ b/sdk/communication/communication-administration/samples/javascript/README.md @@ -16,7 +16,7 @@ These sample programs show how to use the JavaScript client libraries for Azure | [issueToken.js][issuetoken] | uses the CommunicationIdentityClient to create a user and issue a token for this user | | [revokeTokens.js][revoketokens] | uses the CommunicationIdentityClient to create a user, issue tokens for this user, and revoke these tokens | | [purchasePhoneNumber.js][purchasephonenumber] | uses the PhoneNumberAdministrationClient to purchase a phone number | -| [releasePhoneNumbers.js][releasephonenumbers] | uses the PhoneNumberAdministrationClient to release all phone numbers that match certain criteria | +| [releasePhoneNumbers.js][releasephonenumbers] | uses the PhoneNumberAdministrationClient to release phone numbers | ## Prerequisites diff --git a/sdk/communication/communication-administration/samples/javascript/releasePhoneNumbers.js b/sdk/communication/communication-administration/samples/javascript/releasePhoneNumbers.js index c76d6aa07a6d..6d72c6c28c1f 100644 --- a/sdk/communication/communication-administration/samples/javascript/releasePhoneNumbers.js +++ b/sdk/communication/communication-administration/samples/javascript/releasePhoneNumbers.js @@ -3,7 +3,7 @@ /** * Demonstrates how to us the PhoneNumberAdministrationClient - * to release phone numbers that have been acquired. + * to release phone numbers. */ const { PhoneNumberAdministrationClient } = require("@azure/communication-administration"); @@ -22,44 +22,16 @@ async function main() { // create an instance of PhoneNumberAdministrationClient const phoneNumberClient = new PhoneNumberAdministrationClient(connectionString); - console.log("Getting acquired phone numbers."); + // Release a phone numbers + const releasePoller = await phoneNumberClient.beginReleasePhoneNumbers([ + "+14125550100", + "+14125550101" + ]); + console.log("Releasing phone numbers..."); - // get the list of acquired phone numbers - const phoneNumbers = await phoneNumberClient.listPhoneNumbers(); - const phoneNumbersToRelease = []; + await releasePoller.pollUntilDone(); - console.log("Searching for phone numbers to release."); - - // get toll free phone numbers with the sms outbound (A2P) capability as their only capability - // we will release these - for await (const acquired of phoneNumbers) { - if ( - acquired.acquiredCapabilities.length === 4 && - acquired.acquiredCapabilities.includes("Azure") && - acquired.acquiredCapabilities.includes("ThirdPartyAppAssignment") && - acquired.acquiredCapabilities.includes("TollFree") && - acquired.acquiredCapabilities.includes("OutboundA2PSms") - ) { - phoneNumbersToRelease.push(acquired.phoneNumber); - break; - } - } - - console.log(`Found ${phoneNumbersToRelease.length} phone number(s) to release.`); - - if (phoneNumbersToRelease.length) { - // create release poller - const releasePoller = await phoneNumberClient.beginReleasePhoneNumbers(phoneNumbersToRelease); - - console.log("Releasing phone numbers."); - - // poll until phone numbers are released. - await releasePoller.pollUntilDone(); - - console.log("Phone numbers released successfully."); - } else { - throw new Error("Did not find any phone numbers to release."); - } + console.log("Release succeeded."); } main().catch((error) => { diff --git a/sdk/communication/communication-administration/samples/typescript/README.md b/sdk/communication/communication-administration/samples/typescript/README.md index 164a83f1acab..e4acfe67bc9a 100644 --- a/sdk/communication/communication-administration/samples/typescript/README.md +++ b/sdk/communication/communication-administration/samples/typescript/README.md @@ -16,7 +16,7 @@ These sample programs show how to use the TypeScript client libraries for Azure | [issueToken.ts][issuetoken] | uses the CommunicationIdentityClient to create a user and issue a token for this user | | [revokeTokens.ts][revoketokens] | uses the CommunicationIdentityClient to create a user, issue tokens for this user, and revoke these tokens | | [purchasePhoneNumber.ts][purchasephonenumber] | uses the PhoneNumberAdministrationClient to purchase a phone number | -| [releasePhoneNumbers.ts][releasephonenumbers] | uses the PhoneNumberAdministrationClient to release all phone numbers that match certain criteria | +| [releasePhoneNumbers.ts][releasephonenumbers] | uses the PhoneNumberAdministrationClient to release phone numbers. | ## Prerequisites diff --git a/sdk/communication/communication-administration/samples/typescript/src/releasePhoneNumbers.ts b/sdk/communication/communication-administration/samples/typescript/src/releasePhoneNumbers.ts index b1a5f19a3689..acb17b40e5dd 100644 --- a/sdk/communication/communication-administration/samples/typescript/src/releasePhoneNumbers.ts +++ b/sdk/communication/communication-administration/samples/typescript/src/releasePhoneNumbers.ts @@ -3,7 +3,7 @@ /** * Demonstrates how to us the PhoneNumberAdministrationClient - * to release phone numbers that have been acquired. + * to release phone numbers. */ import { PhoneNumberAdministrationClient } from "@azure/communication-administration"; @@ -22,43 +22,16 @@ export const main = async () => { // create an instance of PhoneNumberAdministrationClient const phoneNumberClient = new PhoneNumberAdministrationClient(connectionString); - console.log("Getting acquired phone numbers."); + // Release a phone numbers + const releasePoller = await phoneNumberClient.beginReleasePhoneNumbers([ + "+14125550100", + "+14125550101" + ]); + console.log("Releasing phone numbers..."); - // get the list of acquired phone numbers - const phoneNumbers = await phoneNumberClient.listPhoneNumbers(); - const phoneNumbersToRelease: string[] = []; + await releasePoller.pollUntilDone(); - console.log("Searching for phone numbers to release."); - - // get toll free phone numbers with the sms outbound (A2P) capability as their only capability - // we will release these - for await (const acquired of phoneNumbers) { - if ( - acquired.acquiredCapabilities.length === 4 && - acquired.acquiredCapabilities.includes("Azure") && - acquired.acquiredCapabilities.includes("ThirdPartyAppAssignment") && - acquired.acquiredCapabilities.includes("TollFree") && - acquired.acquiredCapabilities.includes("OutboundA2PSms") - ) { - phoneNumbersToRelease.push(acquired.phoneNumber); - } - } - - console.log(`Found ${phoneNumbersToRelease.length} phone number(s) to release.`); - - if (phoneNumbersToRelease.length) { - // create release poller - const releasePoller = await phoneNumberClient.beginReleasePhoneNumbers(phoneNumbersToRelease); - - console.log("Releasing phone numbers."); - - // poll until phone numbers are released. - await releasePoller.pollUntilDone(); - - console.log("Phone numbers released successfully."); - } else { - throw new Error("Did not find any phone numbers to release."); - } + console.log("Release succeeded."); }; main().catch((error) => {