From 701772ebd51f2ca17450525143ec866125500abc Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 19 Jul 2023 10:15:05 +0200 Subject: [PATCH] Setup api --- packages/frontend-core/src/api/index.js | 2 ++ packages/frontend-core/src/api/viewsV2.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 packages/frontend-core/src/api/viewsV2.js diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js index 5bffb82f4d..aefc3522a7 100644 --- a/packages/frontend-core/src/api/index.js +++ b/packages/frontend-core/src/api/index.js @@ -23,6 +23,7 @@ import { buildTemplateEndpoints } from "./templates" import { buildUserEndpoints } from "./user" import { buildSelfEndpoints } from "./self" import { buildViewEndpoints } from "./views" +import { buildViewV2Endpoints } from "./viewsV2" import { buildLicensingEndpoints } from "./licensing" import { buildGroupsEndpoints } from "./groups" import { buildPluginEndpoints } from "./plugins" @@ -279,5 +280,6 @@ export const createAPIClient = config => { ...buildEventEndpoints(API), ...buildAuditLogsEndpoints(API), ...buildLogsEndpoints(API), + viewV2: buildViewV2Endpoints(API), } } diff --git a/packages/frontend-core/src/api/viewsV2.js b/packages/frontend-core/src/api/viewsV2.js new file mode 100644 index 0000000000..bcea4194c3 --- /dev/null +++ b/packages/frontend-core/src/api/viewsV2.js @@ -0,0 +1,16 @@ +export const buildViewV2Endpoints = API => ({ + /** + * Fetches all rows in a view + * @param id the id of the view + */ + get: async id => { + return await API.get({ url: `/api/v2/views/${id}` }) + }, + /** + * Get a view information + * @param id the id of the view + */ + fetch: async id => { + return await API.get({ url: `/api/v2/views/${id}/search` }) + }, +})