Moved notebooks to latest API version (#1320)
* Moved notebooks to latest API version * fixed lint errors
This commit is contained in:
parent
a4061a96b1
commit
a851f78b1c
|
@ -481,6 +481,10 @@ export interface IMaxUsersPerDbAccountExceeded extends IPhoenixError {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IPhoenixConnectionInfoResult {
|
export interface IPhoenixConnectionInfoResult {
|
||||||
|
readonly phoenixServiceInfo?: IPhoenixServiceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IPhoenixServiceInfo {
|
||||||
readonly authToken?: string;
|
readonly authToken?: string;
|
||||||
readonly phoenixServiceUrl?: string;
|
readonly phoenixServiceUrl?: string;
|
||||||
readonly forwardingId?: string;
|
readonly forwardingId?: string;
|
||||||
|
|
|
@ -16,12 +16,7 @@ import { getErrorMessage, getErrorStack, handleError } from "../Common/ErrorHand
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { QueriesClient } from "../Common/QueriesClient";
|
import { QueriesClient } from "../Common/QueriesClient";
|
||||||
import * as DataModels from "../Contracts/DataModels";
|
import * as DataModels from "../Contracts/DataModels";
|
||||||
import {
|
import { ContainerConnectionInfo, IPhoenixServiceInfo, IProvisionData, IResponse } from "../Contracts/DataModels";
|
||||||
ContainerConnectionInfo,
|
|
||||||
IPhoenixConnectionInfoResult,
|
|
||||||
IProvisionData,
|
|
||||||
IResponse,
|
|
||||||
} from "../Contracts/DataModels";
|
|
||||||
import * as ViewModels from "../Contracts/ViewModels";
|
import * as ViewModels from "../Contracts/ViewModels";
|
||||||
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
import { GitHubOAuthService } from "../GitHub/GitHubOAuthService";
|
||||||
import { useSidePanel } from "../hooks/useSidePanel";
|
import { useSidePanel } from "../hooks/useSidePanel";
|
||||||
|
@ -407,7 +402,7 @@ export default class Explorer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setNotebookInfo(
|
private async setNotebookInfo(
|
||||||
connectionInfo: IResponse<IPhoenixConnectionInfoResult>,
|
connectionInfo: IResponse<IPhoenixServiceInfo>,
|
||||||
connectionStatus: DataModels.ContainerConnectionInfo
|
connectionStatus: DataModels.ContainerConnectionInfo
|
||||||
) {
|
) {
|
||||||
const containerData = {
|
const containerData = {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { ConnectionStatusType, HttpHeaders, HttpStatusCodes, Notebook, PoolIdTyp
|
||||||
import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
|
import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
|
||||||
import * as Logger from "../../Common/Logger";
|
import * as Logger from "../../Common/Logger";
|
||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import { IPhoenixConnectionInfoResult, IProvisionData, IResponse } from "../../Contracts/DataModels";
|
import { IPhoenixServiceInfo, IProvisionData, IResponse } from "../../Contracts/DataModels";
|
||||||
import { userContext } from "../../UserContext";
|
import { userContext } from "../../UserContext";
|
||||||
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
import { getAuthorizationHeader } from "../../Utils/AuthorizationUtils";
|
||||||
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
|
||||||
|
@ -129,9 +129,9 @@ export class NotebookContainerClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resetWorkspace(): Promise<IResponse<IPhoenixConnectionInfoResult>> {
|
public async resetWorkspace(): Promise<IResponse<IPhoenixServiceInfo>> {
|
||||||
this.isResettingWorkspace = true;
|
this.isResettingWorkspace = true;
|
||||||
let response: IResponse<IPhoenixConnectionInfoResult>;
|
let response: IResponse<IPhoenixServiceInfo>;
|
||||||
try {
|
try {
|
||||||
response = await this._resetWorkspace();
|
response = await this._resetWorkspace();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -142,7 +142,7 @@ export class NotebookContainerClient {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _resetWorkspace(): Promise<IResponse<IPhoenixConnectionInfoResult>> {
|
private async _resetWorkspace(): Promise<IResponse<IPhoenixServiceInfo>> {
|
||||||
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
const notebookServerInfo = useNotebook.getState().notebookServerInfo;
|
||||||
if (!notebookServerInfo || !notebookServerInfo.notebookServerEndpoint) {
|
if (!notebookServerInfo || !notebookServerInfo.notebookServerEndpoint) {
|
||||||
const error = "No server endpoint detected";
|
const error = "No server endpoint detected";
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
IMaxAllocationTimeExceeded,
|
IMaxAllocationTimeExceeded,
|
||||||
IPhoenixConnectionInfoResult,
|
IPhoenixConnectionInfoResult,
|
||||||
IPhoenixError,
|
IPhoenixError,
|
||||||
|
IPhoenixServiceInfo,
|
||||||
IProvisionData,
|
IProvisionData,
|
||||||
IResponse,
|
IResponse,
|
||||||
PhoenixErrorType,
|
PhoenixErrorType,
|
||||||
|
@ -38,30 +39,38 @@ export class PhoenixClient {
|
||||||
minTimeout: Notebook.retryAttemptDelayMs,
|
minTimeout: Notebook.retryAttemptDelayMs,
|
||||||
};
|
};
|
||||||
|
|
||||||
public async allocateContainer(provisionData: IProvisionData): Promise<IResponse<IPhoenixConnectionInfoResult>> {
|
public async allocateContainer(provisionData: IProvisionData): Promise<IResponse<IPhoenixServiceInfo>> {
|
||||||
return this.executeContainerAssignmentOperation(provisionData, "allocate");
|
return this.executeContainerAssignmentOperation(provisionData, "allocate");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resetContainer(provisionData: IProvisionData): Promise<IResponse<IPhoenixConnectionInfoResult>> {
|
public async resetContainer(provisionData: IProvisionData): Promise<IResponse<IPhoenixServiceInfo>> {
|
||||||
return this.executeContainerAssignmentOperation(provisionData, "reset");
|
return this.executeContainerAssignmentOperation(provisionData, "reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async executeContainerAssignmentOperation(
|
private async executeContainerAssignmentOperation(
|
||||||
provisionData: IProvisionData,
|
provisionData: IProvisionData,
|
||||||
operation: string
|
operation: string
|
||||||
): Promise<IResponse<IPhoenixConnectionInfoResult>> {
|
): Promise<IResponse<IPhoenixServiceInfo>> {
|
||||||
let response;
|
let response;
|
||||||
try {
|
try {
|
||||||
response = await fetch(`${this.getPhoenixControlPlanePathPrefix()}/containerconnections`, {
|
response = await fetch(`${this.getPhoenixControlPlanePathPrefix()}/containerconnections/multicontainer`, {
|
||||||
method: operation === "allocate" ? "POST" : "PATCH",
|
method: operation === "allocate" ? "POST" : "PATCH",
|
||||||
headers: PhoenixClient.getHeaders(),
|
headers: PhoenixClient.getHeaders(),
|
||||||
body: JSON.stringify(provisionData),
|
body: JSON.stringify(provisionData),
|
||||||
});
|
});
|
||||||
const responseJson = await response?.json();
|
const responseJson = await response?.json();
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
|
const phoenixConnectionInfoResult = responseJson as IPhoenixConnectionInfoResult[];
|
||||||
|
if (
|
||||||
|
!phoenixConnectionInfoResult ||
|
||||||
|
phoenixConnectionInfoResult.length === 0 ||
|
||||||
|
!phoenixConnectionInfoResult[0]
|
||||||
|
) {
|
||||||
|
throw new Error("Received invalid phoenix connection response.");
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
status: response.status,
|
status: response.status,
|
||||||
data: responseJson,
|
data: phoenixConnectionInfoResult[0].phoenixServiceInfo,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const phoenixError = responseJson as IPhoenixError;
|
const phoenixError = responseJson as IPhoenixError;
|
||||||
|
|
Loading…
Reference in New Issue