mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 01:41:31 +00:00
Prettier 2.0 (#393)
This commit is contained in:
@@ -1,98 +1,98 @@
|
||||
import { ArmApiVersions } from "../Common/Constants";
|
||||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import {
|
||||
NotebookWorkspace,
|
||||
NotebookWorkspaceConnectionInfo,
|
||||
NotebookWorkspaceFeedResponse
|
||||
} from "../Contracts/DataModels";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||
|
||||
export class NotebookWorkspaceManager {
|
||||
private resourceProviderClientFactory: IResourceProviderClientFactory<any>;
|
||||
|
||||
constructor() {
|
||||
this.resourceProviderClientFactory = new ResourceProviderClientFactory();
|
||||
}
|
||||
|
||||
public async getNotebookWorkspacesAsync(cosmosdbResourceId: string): Promise<NotebookWorkspace[]> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces`;
|
||||
try {
|
||||
const response = (await this.rpClient(uri).getAsync(
|
||||
uri,
|
||||
ArmApiVersions.documentDB
|
||||
)) as NotebookWorkspaceFeedResponse;
|
||||
return response && response.value;
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookWorkspacesAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getNotebookWorkspaceAsync(
|
||||
cosmosdbResourceId: string,
|
||||
notebookWorkspaceId: string
|
||||
): Promise<NotebookWorkspace> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
return (await this.rpClient(uri).getAsync(uri, ArmApiVersions.documentDB)) as NotebookWorkspace;
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async createNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
await this.rpClient(uri).putAsync(uri, ArmApiVersions.documentDB, { name: notebookWorkspaceId });
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/createNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
await this.rpClient(uri).deleteAsync(uri, ArmApiVersions.documentDB);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/deleteNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getNotebookConnectionInfoAsync(
|
||||
cosmosdbResourceId: string,
|
||||
notebookWorkspaceId: string
|
||||
): Promise<NotebookWorkspaceConnectionInfo> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}/listConnectionInfo`;
|
||||
try {
|
||||
return await this.rpClient<NotebookWorkspaceConnectionInfo>(uri).postAsync(
|
||||
uri,
|
||||
ArmApiVersions.documentDB,
|
||||
undefined
|
||||
);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookConnectionInfoAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async startNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}/start`;
|
||||
try {
|
||||
return await this.rpClient(uri).postAsync(uri, ArmApiVersions.documentDB, undefined, {
|
||||
skipResourceValidation: true
|
||||
});
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/startNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private rpClient<TResource>(uri: string): IResourceProviderClient<TResource> {
|
||||
return this.resourceProviderClientFactory.getOrCreate(uri);
|
||||
}
|
||||
}
|
||||
import { ArmApiVersions } from "../Common/Constants";
|
||||
import { IResourceProviderClient, IResourceProviderClientFactory } from "../ResourceProvider/IResourceProviderClient";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import {
|
||||
NotebookWorkspace,
|
||||
NotebookWorkspaceConnectionInfo,
|
||||
NotebookWorkspaceFeedResponse,
|
||||
} from "../Contracts/DataModels";
|
||||
import { ResourceProviderClientFactory } from "../ResourceProvider/ResourceProviderClientFactory";
|
||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
||||
|
||||
export class NotebookWorkspaceManager {
|
||||
private resourceProviderClientFactory: IResourceProviderClientFactory<any>;
|
||||
|
||||
constructor() {
|
||||
this.resourceProviderClientFactory = new ResourceProviderClientFactory();
|
||||
}
|
||||
|
||||
public async getNotebookWorkspacesAsync(cosmosdbResourceId: string): Promise<NotebookWorkspace[]> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces`;
|
||||
try {
|
||||
const response = (await this.rpClient(uri).getAsync(
|
||||
uri,
|
||||
ArmApiVersions.documentDB
|
||||
)) as NotebookWorkspaceFeedResponse;
|
||||
return response && response.value;
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookWorkspacesAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getNotebookWorkspaceAsync(
|
||||
cosmosdbResourceId: string,
|
||||
notebookWorkspaceId: string
|
||||
): Promise<NotebookWorkspace> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
return (await this.rpClient(uri).getAsync(uri, ArmApiVersions.documentDB)) as NotebookWorkspace;
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async createNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
await this.rpClient(uri).putAsync(uri, ArmApiVersions.documentDB, { name: notebookWorkspaceId });
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/createNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async deleteNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}`;
|
||||
try {
|
||||
await this.rpClient(uri).deleteAsync(uri, ArmApiVersions.documentDB);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/deleteNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async getNotebookConnectionInfoAsync(
|
||||
cosmosdbResourceId: string,
|
||||
notebookWorkspaceId: string
|
||||
): Promise<NotebookWorkspaceConnectionInfo> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}/listConnectionInfo`;
|
||||
try {
|
||||
return await this.rpClient<NotebookWorkspaceConnectionInfo>(uri).postAsync(
|
||||
uri,
|
||||
ArmApiVersions.documentDB,
|
||||
undefined
|
||||
);
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/getNotebookConnectionInfoAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
public async startNotebookWorkspaceAsync(cosmosdbResourceId: string, notebookWorkspaceId: string): Promise<void> {
|
||||
const uri = `${cosmosdbResourceId}/notebookWorkspaces/${notebookWorkspaceId}/start`;
|
||||
try {
|
||||
return await this.rpClient(uri).postAsync(uri, ArmApiVersions.documentDB, undefined, {
|
||||
skipResourceValidation: true,
|
||||
});
|
||||
} catch (error) {
|
||||
Logger.logError(getErrorMessage(error), "NotebookWorkspaceManager/startNotebookWorkspaceAsync");
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private rpClient<TResource>(uri: string): IResourceProviderClient<TResource> {
|
||||
return this.resourceProviderClientFactory.getOrCreate(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
import { IResourceProviderClient } from "../ResourceProvider/IResourceProviderClient";
|
||||
import { NotebookWorkspace } from "../Contracts/DataModels";
|
||||
|
||||
export class NotebookWorkspaceSettingsProviderClient implements IResourceProviderClient<string> {
|
||||
public async deleteAsync(url: string, apiVersion: string): Promise<void> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async postAsync(url: string, body: any, apiVersion: string): Promise<any> {
|
||||
return Promise.resolve({
|
||||
notebookServerEndpoint: "http://localhost:8888",
|
||||
username: "",
|
||||
password: ""
|
||||
});
|
||||
}
|
||||
|
||||
public async getAsync(url: string, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async putAsync(url: string, body: any, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async patchAsync(url: string, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
}
|
||||
|
||||
export class NotebookWorkspaceResourceProviderClient implements IResourceProviderClient<NotebookWorkspace> {
|
||||
public async deleteAsync(url: string, apiVersion: string): Promise<void> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async postAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async getAsync(url: string, apiVersion: string): Promise<NotebookWorkspace | NotebookWorkspace[]> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async putAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async patchAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
}
|
||||
import { IResourceProviderClient } from "../ResourceProvider/IResourceProviderClient";
|
||||
import { NotebookWorkspace } from "../Contracts/DataModels";
|
||||
|
||||
export class NotebookWorkspaceSettingsProviderClient implements IResourceProviderClient<string> {
|
||||
public async deleteAsync(url: string, apiVersion: string): Promise<void> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async postAsync(url: string, body: any, apiVersion: string): Promise<any> {
|
||||
return Promise.resolve({
|
||||
notebookServerEndpoint: "http://localhost:8888",
|
||||
username: "",
|
||||
password: "",
|
||||
});
|
||||
}
|
||||
|
||||
public async getAsync(url: string, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async putAsync(url: string, body: any, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async patchAsync(url: string, apiVersion: string): Promise<string> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
}
|
||||
|
||||
export class NotebookWorkspaceResourceProviderClient implements IResourceProviderClient<NotebookWorkspace> {
|
||||
public async deleteAsync(url: string, apiVersion: string): Promise<void> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async postAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async getAsync(url: string, apiVersion: string): Promise<NotebookWorkspace | NotebookWorkspace[]> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async putAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
|
||||
public async patchAsync(url: string, body: any, apiVersion: string): Promise<NotebookWorkspace> {
|
||||
throw new Error("Not yet implemented");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user