Skip to content

Commit

Permalink
serviceconnector: Add "Create connection" and "Delete connection" act…
Browse files Browse the repository at this point in the history
…ivity children (#1577)

* Add create and delete activity children

* small change
  • Loading branch information
motm32 authored Sep 1, 2023
1 parent a31911d commit 9ee913c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
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

0 comments on commit 9ee913c

Please sign in to comment.