mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Resolve Lint errors in NotebookConfigurationUtils.ts (#490)
This commit is contained in:
parent
9253ab1876
commit
184910ee6c
@ -258,7 +258,6 @@ src/TokenProviders/PortalTokenProvider.ts
|
|||||||
src/TokenProviders/TokenProviderFactory.ts
|
src/TokenProviders/TokenProviderFactory.ts
|
||||||
src/Utils/DatabaseAccountUtils.test.ts
|
src/Utils/DatabaseAccountUtils.test.ts
|
||||||
src/Utils/DatabaseAccountUtils.ts
|
src/Utils/DatabaseAccountUtils.ts
|
||||||
src/Utils/NotebookConfigurationUtils.ts
|
|
||||||
src/Utils/PricingUtils.test.ts
|
src/Utils/PricingUtils.test.ts
|
||||||
src/Utils/QueryUtils.test.ts
|
src/Utils/QueryUtils.test.ts
|
||||||
src/Utils/QueryUtils.ts
|
src/Utils/QueryUtils.ts
|
||||||
|
@ -24,7 +24,7 @@ import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBa
|
|||||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||||
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
import { NotebookComponentAdapter } from "../Notebook/NotebookComponent/NotebookComponentAdapter";
|
||||||
import { NotebookConfigurationUtils } from "../../Utils/NotebookConfigurationUtils";
|
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
|
||||||
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
import { KernelSpecsDisplay, NotebookClientV2 } from "../Notebook/NotebookClientV2";
|
||||||
import { configContext } from "../../ConfigContext";
|
import { configContext } from "../../ConfigContext";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
|
@ -8,15 +8,46 @@ interface KernelConnectionMetadata {
|
|||||||
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
|
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NotebookConfigurationUtils {
|
export const _configureServiceEndpoints = async (kernelMetadata: KernelConnectionMetadata): Promise<void> => {
|
||||||
private constructor() {}
|
if (!kernelMetadata) {
|
||||||
|
// should never get into this state
|
||||||
|
Logger.logWarning("kernel metadata is null or undefined", "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public static async configureServiceEndpoints(
|
const notebookConnectionInfo = kernelMetadata.notebookConnectionInfo;
|
||||||
|
const configurationEndpoints = kernelMetadata.configurationEndpoints;
|
||||||
|
if (notebookConnectionInfo && configurationEndpoints) {
|
||||||
|
try {
|
||||||
|
const headers: HeadersInit = { "Content-Type": "application/json" };
|
||||||
|
if (notebookConnectionInfo.authToken) {
|
||||||
|
headers["Authorization"] = `token ${notebookConnectionInfo.authToken}`;
|
||||||
|
}
|
||||||
|
const response = await fetch(`${notebookConnectionInfo.notebookServerEndpoint}/api/configureEndpoints`, {
|
||||||
|
method: "POST",
|
||||||
|
headers,
|
||||||
|
body: JSON.stringify(configurationEndpoints),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const responseMessage = await response.json();
|
||||||
|
Logger.logError(
|
||||||
|
getErrorMessage(responseMessage),
|
||||||
|
"NotebookConfigurationUtils/configureServiceEndpoints",
|
||||||
|
response.status
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Logger.logError(getErrorMessage(error), "NotebookConfigurationUtils/configureServiceEndpoints");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const configureServiceEndpoints = async (
|
||||||
notebookPath: string,
|
notebookPath: string,
|
||||||
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo,
|
notebookConnectionInfo: DataModels.NotebookWorkspaceConnectionInfo,
|
||||||
kernelName: string,
|
kernelName: string,
|
||||||
clusterConnectionInfo: DataModels.SparkClusterConnectionInfo
|
clusterConnectionInfo: DataModels.SparkClusterConnectionInfo
|
||||||
): Promise<void> {
|
): Promise<void> => {
|
||||||
if (!notebookPath || !notebookConnectionInfo || !kernelName) {
|
if (!notebookPath || !notebookConnectionInfo || !kernelName) {
|
||||||
Logger.logError(
|
Logger.logError(
|
||||||
"Invalid or missing notebook connection info/path",
|
"Invalid or missing notebook connection info/path",
|
||||||
@ -53,40 +84,5 @@ export class NotebookConfigurationUtils {
|
|||||||
name: kernelName,
|
name: kernelName,
|
||||||
};
|
};
|
||||||
|
|
||||||
return await NotebookConfigurationUtils._configureServiceEndpoints(kernelMetadata);
|
return await _configureServiceEndpoints(kernelMetadata);
|
||||||
}
|
};
|
||||||
|
|
||||||
private static async _configureServiceEndpoints(kernelMetadata: KernelConnectionMetadata): Promise<void> {
|
|
||||||
if (!kernelMetadata) {
|
|
||||||
// should never get into this state
|
|
||||||
Logger.logWarning("kernel metadata is null or undefined", "NotebookConfigurationUtils/configureServiceEndpoints");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const notebookConnectionInfo = kernelMetadata.notebookConnectionInfo;
|
|
||||||
const configurationEndpoints = kernelMetadata.configurationEndpoints;
|
|
||||||
if (notebookConnectionInfo && configurationEndpoints) {
|
|
||||||
try {
|
|
||||||
const headers: any = { "Content-Type": "application/json" };
|
|
||||||
if (notebookConnectionInfo.authToken) {
|
|
||||||
headers["Authorization"] = `token ${notebookConnectionInfo.authToken}`;
|
|
||||||
}
|
|
||||||
const response = await fetch(`${notebookConnectionInfo.notebookServerEndpoint}/api/configureEndpoints`, {
|
|
||||||
method: "POST",
|
|
||||||
headers,
|
|
||||||
body: JSON.stringify(configurationEndpoints),
|
|
||||||
});
|
|
||||||
if (!response.ok) {
|
|
||||||
const responseMessage = await response.json();
|
|
||||||
Logger.logError(
|
|
||||||
getErrorMessage(responseMessage),
|
|
||||||
"NotebookConfigurationUtils/configureServiceEndpoints",
|
|
||||||
response.status
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
Logger.logError(getErrorMessage(error), "NotebookConfigurationUtils/configureServiceEndpoints");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user