forked from microsoft/vscode-azurefunctions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopySchedulerEndpoint.ts
More file actions
35 lines (28 loc) · 1.68 KB
/
copySchedulerEndpoint.ts
File metadata and controls
35 lines (28 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { type IActionContext } from "@microsoft/vscode-azext-utils";
import { type DurableTaskSchedulerClient } from "../../tree/durableTaskScheduler/DurableTaskSchedulerClient";
import { type DurableTaskSchedulerResourceModel } from "../../tree/durableTaskScheduler/DurableTaskSchedulerResourceModel";
import { localize } from "../../localize";
import { ext } from "../../extensionVariables";
import { env } from "vscode";
export function copySchedulerEndpointCommandFactory(schedulerClient: DurableTaskSchedulerClient) {
return async (_: IActionContext, scheduler: DurableTaskSchedulerResourceModel | undefined): Promise<void> => {
if (!scheduler) {
throw new Error(localize('noSchedulerSelectedErrorMessage', 'No scheduler was selected.'));
}
const schedulerJson = await schedulerClient.getScheduler(
scheduler.subscription,
scheduler.resourceGroup,
scheduler.name);
if (!schedulerJson) {
throw new Error(localize('schedulerNotFoundErrorMessage', 'Scheduler does not exist.'));
}
const { endpoint } = schedulerJson.properties;
await env.clipboard.writeText(endpoint);
ext.outputChannel.show();
ext.outputChannel.appendLog(localize('schedulerEndpointCopiedMessage', 'Endpoint copied to clipboard: {0}', endpoint));
}
}