Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serviceconnector: Add "Create connection" and "Delete connection" activity children #1577

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions serviceconnector/src/createLinker/ICreateLinkerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*--------------------------------------------------------------------------------------------*/
import { AuthInfoBase, KnownClientType, LinkerResource } from "@azure/arm-servicelinker";
import { IStorageAccountWizardContext } from "@microsoft/vscode-azext-azureutils";
import { ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { ExecuteActivityContext, ISubscriptionActionContext } from "@microsoft/vscode-azext-utils";
import { TargetServiceType } from "../../constants";
import { DatabaseAccountJsonResponse } from "./CosmosDBAccountListStep";
import { KeyVaultAccountJsonResponse } from "./KeyVaultListStep";

export interface ICreateLinkerContext extends ISubscriptionActionContext, IStorageAccountWizardContext {
export interface ICreateLinkerContext extends ISubscriptionActionContext, IStorageAccountWizardContext, ExecuteActivityContext {
//Source resource
sourceResourceUri?: string;
/** This is only assigned when the source resource is a container app to indicate which container is being connected */
Expand Down
12 changes: 11 additions & 1 deletion serviceconnector/src/createLinker/LinkerCreateStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardExecuteStep, nonNullValue } from "@microsoft/vscode-azext-utils";
import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, nonNullValue, randomUtils } from "@microsoft/vscode-azext-utils";
import * as vscode from 'vscode';
import { TargetServiceTypeName } from "../../constants";
import { createLinkerClient } from "../linkerClient";
Expand All @@ -26,6 +26,16 @@ export class LinkerCreateStep extends AzureWizardExecuteStep<ICreateLinkerContex
};

await client.linker.beginCreateOrUpdate(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName), context.linker);
const config = await client.linker.listConfigurations(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName));

context.activityChildren = [];
for (const item of nonNullProp(config, 'configurations')) {
context.activityChildren.push(new GenericTreeItem(undefined, {
contextValue: `createResult-` + randomUtils.getRandomHexString(3),
label: `Added application setting: ${nonNullProp(item, 'name')}`,

}));
}
}

public shouldExecute(context: ICreateLinkerContext): boolean {
Expand Down
13 changes: 12 additions & 1 deletion serviceconnector/src/deleteLinker/DeleteLinkerStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardExecuteStep, nonNullValue } from "@microsoft/vscode-azext-utils";
import { AzureWizardExecuteStep, GenericTreeItem, nonNullProp, nonNullValue, randomUtils } from "@microsoft/vscode-azext-utils";
import { createLinkerClient } from "../linkerClient";
import { IPickLinkerContext } from "./IPickLinkerContext";

Expand All @@ -12,6 +12,17 @@ export class DeleteLinkerStep extends AzureWizardExecuteStep<IPickLinkerContext>

public async execute(context: IPickLinkerContext): Promise<void> {
const client = await createLinkerClient(context.credentials);
const config = await client.linker.listConfigurations(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName));

context.activityChildren = [];
for (const item of nonNullProp(config, 'configurations')) {
context.activityChildren.push(new GenericTreeItem(undefined, {
contextValue: `createResult-` + randomUtils.getRandomHexString(3),
label: `Deleted application setting: ${nonNullProp(item, 'name')}`,

}));
}

await client.linker.beginDeleteAndWait(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName));
}

Expand Down