Skip to content

Commit

Permalink
test api calls.
Browse files Browse the repository at this point in the history
Signed-off-by: Tatsat Mishra <[email protected]>
  • Loading branch information
Tatsat Mishra committed Aug 27, 2024
1 parent 621a991 commit 5c09a50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/commands/aksKaito/aksKaito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default async function aksKaito(_context: IActionContext, target: unknown
}

const clusterName = clusterNode.result.name;
const armId = clusterNode.result.armId;
const subscriptionId = clusterNode.result.subscriptionId;
const resourceGroupName = clusterNode.result.resourceGroupName;

Expand All @@ -38,6 +39,7 @@ export default async function aksKaito(_context: IActionContext, target: unknown
clusterName,
subscriptionId,
resourceGroupName,
armId,
sessionProvider.result,
);

Expand Down
26 changes: 23 additions & 3 deletions src/panels/KaitoPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { MessageHandler, MessageSink } from "../webview-contract/messaging";
import { InitialState, ToVsCodeMsgDef, ToWebViewMsgDef } from "../webview-contract/webviewDefinitions/kaito";
import { TelemetryDefinition } from "../webview-contract/webviewTypes";
import { BasePanel, PanelDataProvider } from "./BasePanel";
import { getFeatureClient } from "../commands/utils/arm";
import { getFeatureClient, getResourceManagementClient } from "../commands/utils/arm";
import { FeatureClient } from "@azure/arm-features";
import { longRunning } from "../commands/utils/host";
import { ResourceManagementClient } from "@azure/arm-resources";

export class KaitoPanel extends BasePanel<"kaito"> {
constructor(extensionUri: vscode.Uri) {
Expand All @@ -21,19 +22,22 @@ export class KaitoPanel extends BasePanel<"kaito"> {
export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
// private readonly containerServiceClient: ContainerServiceClient;
private readonly featureClient: FeatureClient;
// private readonly resourceManagementClient: ResourceManagementClient;
private readonly resourceManagementClient: ResourceManagementClient;
// private readonly containerServiceClient: ContainerServiceClient;

public constructor(
readonly clusterName: string,
readonly subscriptionId: string,
readonly resourceGroupName: string,
readonly armId: string,
readonly sessionProvider: ReadyAzureSessionProvider,
) {
this.clusterName = clusterName;
this.subscriptionId = subscriptionId;
this.resourceGroupName = resourceGroupName;
this.armId = armId;
this.featureClient = getFeatureClient(sessionProvider, this.subscriptionId);
// this.resourceManagementClient = getResourceManagementClient(sessionProvider, this.subscriptionId);
this.resourceManagementClient = getResourceManagementClient(sessionProvider, this.subscriptionId);
// this.containerServiceClient = getAksClient(sessionProvider, this.subscriptionId);
}
getTitle(): string {
Expand Down Expand Up @@ -120,6 +124,22 @@ export class KaitoPanelDataProvider implements PanelDataProvider<"kaito"> {
}

// Install kaito enablement
// Get current json
const currentJson = await longRunning(`Get current json.`, () => {
return this.resourceManagementClient.resources.getById(this.armId, "2023-08-01");
});
console.log(currentJson);

// Update json
if (currentJson.properties) {
currentJson.properties.aiToolchainOperatorProfile = { enabled: true };
}

const updateJson = await longRunning(`Update json.`, () => {
return this.resourceManagementClient.resources.beginCreateOrUpdateByIdAndWait(this.armId, "2023-08-01", currentJson);
});
console.log(updateJson);

// const kaitoEnablement = await longRunning(`Enable KAITO Feature.`, () =>
// this.resourceManagementClient.deployments.beginCreateOrUpdate(
// this.resourceGroupName,
Expand Down

0 comments on commit 5c09a50

Please sign in to comment.