Skip to content

Commit

Permalink
Update notebooks to use observability backend (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuali925 authored Oct 8, 2021
1 parent afd0c78 commit 618d5b1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
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

0 comments on commit 618d5b1

Please sign in to comment.