mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Add analytical store schema POC (#164)
* add schema APIs to JunoClient * start implementing buildSchemaNode * finish getSchemaNodes * finish implementing addSchema * cleanup * make schema optional * handle undefined/null schema and fields. Also don't retry on gettting schema failures. * fix request schema and get schema endpoints * add feature flag * try to get most recent schema when refreshed or initialized. * add tests * cleanup * cleanup * cleanup * fix merge conflict typos * fix lint errors * fix tests and update snapshot Co-authored-by: REDMOND\gaausfel <gaausfel@microsoft.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { IGitHubResponse } from "../GitHub/GitHubClient";
|
||||
import { IGitHubOAuthToken } from "../GitHub/GitHubOAuthService";
|
||||
import { userContext } from "../UserContext";
|
||||
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
|
||||
import { number } from "prop-types";
|
||||
|
||||
export interface IJunoResponse<T> {
|
||||
status: number;
|
||||
@@ -427,6 +428,51 @@ export class JunoClient {
|
||||
};
|
||||
}
|
||||
|
||||
public async requestSchema(
|
||||
schemaRequest: DataModels.ISchemaRequest
|
||||
): Promise<IJunoResponse<DataModels.ISchemaRequest>> {
|
||||
const response = await window.fetch(`${this.getAnalyticsUrl()}/${schemaRequest.accountName}/schema/request`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(schemaRequest),
|
||||
headers: JunoClient.getHeaders()
|
||||
});
|
||||
|
||||
let data: DataModels.ISchemaRequest;
|
||||
if (response.status === HttpStatusCodes.OK) {
|
||||
data = await response.json();
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data
|
||||
};
|
||||
}
|
||||
|
||||
public async getSchema(
|
||||
accountName: string,
|
||||
databaseName: string,
|
||||
containerName: string
|
||||
): Promise<IJunoResponse<DataModels.ISchema>> {
|
||||
const response = await window.fetch(
|
||||
`${this.getAnalyticsUrl()}/${accountName}/schema/${databaseName}/${containerName}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: JunoClient.getHeaders()
|
||||
}
|
||||
);
|
||||
|
||||
let data: DataModels.ISchema;
|
||||
|
||||
if (response.status === HttpStatusCodes.OK) {
|
||||
data = await response.json();
|
||||
}
|
||||
|
||||
return {
|
||||
status: response.status,
|
||||
data
|
||||
};
|
||||
}
|
||||
|
||||
private async getNotebooks(input: RequestInfo, init?: RequestInit): Promise<IJunoResponse<IGalleryItem[]>> {
|
||||
const response = await window.fetch(input, init);
|
||||
|
||||
@@ -457,6 +503,10 @@ export class JunoClient {
|
||||
return `${this.getNotebooksUrl()}/${this.getAccount()}`;
|
||||
}
|
||||
|
||||
private getAnalyticsUrl(): string {
|
||||
return `${configContext.JUNO_ENDPOINT}/api/analytics`;
|
||||
}
|
||||
|
||||
private static getHeaders(): HeadersInit {
|
||||
const authorizationHeader = getAuthorizationHeader();
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user