azure-sdk-for-js/sdk/communication/communication-job-router-rest/samples-dev/RouterWorker_Update.ts

44 строки
1.1 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @summary router worker crud
*/
import JobRouter, {
AzureCommunicationRoutingServiceClient
} from "@azure-rest/communication-job-router";
import * as dotenv from "dotenv";
dotenv.config();
const connectionString = process.env["COMMUNICATION_CONNECTION_STRING"] || "";
// Update a router worker
async function updateRouterWorker(): Promise<void> {
// Create the Router Client
const routerClient: AzureCommunicationRoutingServiceClient =
JobRouter(connectionString);
const id = "router-worker-123";
const result = await routerClient.path("/routing/workers/{workerId}", id).patch({
contentType: "application/merge-patch+json",
body: {
capacity: 100,
queues: [
"MainQueue",
"SecondaryQueue"
],
labels: {},
channels: [{
channelId: "CustomChatChannel",
capacityCostPerJob: 10
}, {
channelId: "CustomVoiceChannel",
capacityCostPerJob: 100
}],
}
})
console.log("router worker: " + result);
}
updateRouterWorker().catch(console.error);