Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update notebooks to use observability backend #129

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ export const generateInContextReport = async (
rest = {}
) => {
toggleReportingLoadingModal(true);
let baseUrl = location.pathname + location.hash + '?view=output_only';
let baseUrl =
location.pathname +
location.hash.replace(/\?view=(view_both|input_only|output_only)/, '') +
'?view=output_only';
// Add selected tenant info to url
try {
const tenant = await getTenantInfoIfExists();
Expand Down
37 changes: 21 additions & 16 deletions server/adaptors/notebooks/default_backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class DefaultBackend implements NotebookAdaptor {
indexNote = async function (
client: ILegacyScopedClusterClient,
body: any
): Promise<{ notebookId: string }> {
): Promise<{ objectId: string }> {
try {
const response = await client.callAsCurrentUser('observability.createNotebook', {
const response = await client.callAsCurrentUser('observability.createObject', {
body: {
notebook: body,
},
Expand All @@ -79,8 +79,8 @@ export class DefaultBackend implements NotebookAdaptor {
updateBody: Partial<DefaultNotebooks>
) {
try {
const response = await client.callAsCurrentUser('observability.updateNotebookById', {
notebookId: noteId,
const response = await client.callAsCurrentUser('observability.updateObjectById', {
objectId: noteId,
body: {
notebook: updateBody,
},
Expand All @@ -94,10 +94,13 @@ export class DefaultBackend implements NotebookAdaptor {
// fetched a notebook by Id
getNote = async function (client: ILegacyScopedClusterClient, noteId: string) {
try {
const response = await client.callAsCurrentUser('observability.getNotebookById', {
notebookId: noteId,
const response = await client.callAsCurrentUser('observability.getObjectById', {
objectId: noteId,
});
return response.notebookDetails;
if (response.observabilityObjectList.length === 0) {
throw 'notebook id not found'
}
return response.observabilityObjectList[0];
} catch (error) {
throw new Error('Get Doc Error:' + error);
}
Expand All @@ -106,10 +109,12 @@ export class DefaultBackend implements NotebookAdaptor {
// gets first `FETCH_SIZE` notebooks available
viewNotes = async function (client: ILegacyScopedClusterClient, _wreckOptions: optionsType) {
try {
const response = await client.callAsCurrentUser('observability.getNotebooks');
return response.notebookDetailsList.map((notebook) => ({
const response = await client.callAsCurrentUser('observability.getObject', {
objectType: 'notebook'
});
return response.observabilityObjectList.map((notebook) => ({
path: notebook.notebook.name,
id: notebook.id,
id: notebook.objectId,
dateCreated: notebook.notebook.dateCreated,
dateModified: notebook.notebook.dateModified,
}));
Expand Down Expand Up @@ -155,7 +160,7 @@ export class DefaultBackend implements NotebookAdaptor {
return {
status: 'OK',
message: opensearchClientResponse,
body: opensearchClientResponse.notebookId,
body: opensearchClientResponse.objectId,
};
} catch (error) {
throw new Error('Creating New Notebook Error:' + error);
Expand All @@ -177,7 +182,7 @@ export class DefaultBackend implements NotebookAdaptor {
const notebook = notebooks[i];
await this.indexNote(client, notebook.notebook).then((response) => {
newNotebooks.push({
id: response.notebookId,
id: response.objectId,
name: notebook.notebook.name,
dateModified: notebook.dateModified,
dateCreated: notebook.dateCreated,
Expand Down Expand Up @@ -228,7 +233,7 @@ export class DefaultBackend implements NotebookAdaptor {
const opensearchClientIndexResponse = await this.indexNote(client, cloneNotebook);
return {
status: 'OK',
body: { ...cloneNotebook, id: opensearchClientIndexResponse.notebookId },
body: { ...cloneNotebook, id: opensearchClientIndexResponse.objectId },
};
} catch (error) {
throw new Error('Cloning Notebook Error:' + error);
Expand All @@ -244,8 +249,8 @@ export class DefaultBackend implements NotebookAdaptor {
_wreckOptions: optionsType
) {
try {
const response = await client.callAsCurrentUser('observability.deleteNotebookById', {
notebookId: noteId,
const response = await client.callAsCurrentUser('observability.deleteObjectById', {
objectId: noteId,
});
return { status: 'OK', message: response };
} catch (error) {
Expand Down Expand Up @@ -286,7 +291,7 @@ export class DefaultBackend implements NotebookAdaptor {
return {
status: 'OK',
message: opensearchClientIndexResponse,
body: opensearchClientIndexResponse.notebookId,
body: opensearchClientIndexResponse.objectId,
};
} catch (error) {
throw new Error('Import Notebook Error:' + error);
Expand Down
2 changes: 1 addition & 1 deletion server/routes/notebooks/noteRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function registerNoteRoute(router: IRouter) {
wreckOptions
);
return response.ok({
body: addResponse.message.notebookId,
body: addResponse.message.objectId,
});
} catch (error) {
return response.custom({
Expand Down