From ceee2f6eab29b5d64718e84f5ba8ed0c882df0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cdorac-ext=E2=80=9D?= <103416234+doracretu3pillar@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:27:55 +0300 Subject: [PATCH 1/9] Action service, QAN service API changes --- .../pmm-qan/panel/components/Details/Details.service.ts | 2 +- .../panel/components/Details/Metrics/Metrics.service.ts | 4 ++-- .../panel/components/Details/Plan/Plan.service.ts | 2 +- .../pmm-qan/panel/components/Filters/Filters.service.ts | 2 +- .../panel/components/Overview/Overview.service.ts | 2 +- pmm-app/src/shared/components/Actions/Actions.service.ts | 2 +- setup-page/src/App.jsx | 9 +++------ 7 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts index 6bc68c17a9..c60d223164 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts @@ -14,7 +14,7 @@ const getExample = async ({ tables, }; - return apiRequestQAN.post('/ObjectDetails/GetQueryExample', data); + return apiRequestQAN.post('/v1/qan/query:getExample', data); }; export default { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts index 6ebbe8dcd1..f107983366 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts @@ -15,7 +15,7 @@ export const getMetrics = async ({ totals, }; - return apiRequestQAN.post('/ObjectDetails/GetMetrics', body); + return apiRequestQAN.post('/v1/qan:getMetrics', body); }; export const getHistogram = async ({ @@ -28,7 +28,7 @@ export const getHistogram = async ({ period_start_to: to, }; - return apiRequestQAN.post('/ObjectDetails/GetHistogram', body); + return apiRequestQAN.post('/v1/qan:getHistogram', body); }; export default { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts index 5f51b13d86..0504644c67 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts @@ -8,7 +8,7 @@ export const PlanService = { }; return apiRequestQAN - .post('/ObjectDetails/GetQueryPlan', body) + .get(`/v1/qan/query/${body.queryid}/plan`) .then(({ planid, query_plan }) => ( planid && query_plan ? { id: planid, plan: query_plan } : undefined )); diff --git a/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts b/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts index ca0ea0189f..24c9ce1fee 100644 --- a/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts @@ -29,7 +29,7 @@ export const markCheckedLabels = (labels, paramLabels) => { export default { getQueryOverviewFiltersList: async (paramLabels, from, to, mainMetric) => { - const { labels } = await apiRequestQAN.post('/Filters/Get', { + const { labels } = await apiRequestQAN.post('/v1/qan/metrics:getFilters', { labels: getLabelQueryParams(paramLabels), main_metric_name: mainMetric, period_start_from: from, diff --git a/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts b/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts index 504024e78f..a15734ccb1 100644 --- a/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts @@ -20,6 +20,6 @@ export default { search: body.dimensionSearchText, }; - return apiRequestQAN.post('/GetReport', request); + return apiRequestQAN.post('/v1/qan/metrics:getReport', request); }, }; diff --git a/pmm-app/src/shared/components/Actions/Actions.service.ts b/pmm-app/src/shared/components/Actions/Actions.service.ts index 73dacd4db8..700663ee27 100644 --- a/pmm-app/src/shared/components/Actions/Actions.service.ts +++ b/pmm-app/src/shared/components/Actions/Actions.service.ts @@ -3,6 +3,6 @@ import { ActionRequest, ActionResponse } from './Actions.types'; export const ActionsService = { getActionResult(body: ActionRequest): Promise { - return apiRequestManagement.post('/Actions/Get', body); + return apiRequestManagement.get(`/v1/actions/${body.action_id}`); }, }; diff --git a/setup-page/src/App.jsx b/setup-page/src/App.jsx index a48c4fd2f9..78f6f9e3a3 100644 --- a/setup-page/src/App.jsx +++ b/setup-page/src/App.jsx @@ -16,16 +16,13 @@ export function App() { setLoading(true); try { - const response = await fetch('/v1/AWSInstanceCheck', { - method: 'POST', + const response = await fetch(`/v1/server/AWSInstance?instance_id${instanceId.trim()}`, { + method: 'GET', credentials: "include", cache: "no-cache", headers: { "Content-Type": "application/json", - }, - body: JSON.stringify({ - instance_id: instanceId.trim(), - }), + } }); if (!response.ok) { From 46f7954758fa1b59cbcddd13c572ea687701be95 Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Mon, 13 May 2024 14:14:58 +0530 Subject: [PATCH 2/9] PMM-12710 Update actions endpoints --- .../components/Details/Details.service.ts | 2 +- .../Details/Metrics/Metrics.service.ts | 4 ++-- .../components/Details/Plan/Plan.service.ts | 2 +- .../database-models/mongodb/service.ts | 4 ++-- .../Details/database-models/mysql/mysql.ts | 10 ++++---- .../Details/database-models/mysql/service.ts | 24 ++++--------------- .../database-models/postgresql/postgresql.ts | 4 ++-- .../database-models/postgresql/service.ts | 9 +++---- .../components/Filters/Filters.service.ts | 2 +- .../components/Overview/Overview.service.ts | 2 +- .../components/Actions/Actions.service.ts | 4 ++-- pmm-app/src/shared/components/helpers/api.ts | 3 ++- 12 files changed, 26 insertions(+), 44 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts index c60d223164..1f981d5f59 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Details.service.ts @@ -14,7 +14,7 @@ const getExample = async ({ tables, }; - return apiRequestQAN.post('/v1/qan/query:getExample', data); + return apiRequestQAN.post('/query:getExample', data); }; export default { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts index f107983366..911bfc1f69 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts @@ -15,7 +15,7 @@ export const getMetrics = async ({ totals, }; - return apiRequestQAN.post('/v1/qan:getMetrics', body); + return apiRequestQAN.post(':getMetrics', body); }; export const getHistogram = async ({ @@ -28,7 +28,7 @@ export const getHistogram = async ({ period_start_to: to, }; - return apiRequestQAN.post('/v1/qan:getHistogram', body); + return apiRequestQAN.post(':getHistogram', body); }; export default { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts index 0504644c67..3ad61b3732 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Plan/Plan.service.ts @@ -8,7 +8,7 @@ export const PlanService = { }; return apiRequestQAN - .get(`/v1/qan/query/${body.queryid}/plan`) + .get(`/query/${body.queryid}/plan`) .then(({ planid, query_plan }) => ( planid && query_plan ? { id: planid, plan: query_plan } : undefined )); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts index 61d9218d6b..1b9ad0fee4 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts @@ -1,7 +1,7 @@ -import { apiRequestManagement } from 'shared/components/helpers/api'; +import { apiRequestActions } from 'shared/components/helpers/api'; export default { getTraditionalExplainJSONMongo(body) { - return apiRequestManagement.post('/Actions/StartMongoDBExplain', body); + return apiRequestActions.post(':startServiceAction', body); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts index 5e812a3329..c8543f8844 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts @@ -7,7 +7,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getShowCreateTableMySQL({ + const result = await MysqlDatabaseService.getMySQLActions({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -21,7 +21,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getMysqlIndex({ + const result = await MysqlDatabaseService.getMySQLActions({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -35,7 +35,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getMysqlTableStatus({ + const result = await MysqlDatabaseService.getMySQLActions({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -48,7 +48,7 @@ export const mysqlMethods = { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getTraditionalExplainJSONMysql(payload); + const result = await MysqlDatabaseService.getMySQLActions(payload); return result.action_id; } catch (e) { @@ -62,7 +62,7 @@ export const mysqlMethods = { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getTraditionalExplainMysql(payload); + const result = await MysqlDatabaseService.getMySQLActions(payload); return result.action_id; } catch (e) { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index 30e7284062..b535cdada4 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -1,23 +1,7 @@ -import { apiRequestManagement } from 'shared/components/helpers/api'; +import { apiRequestActions } from 'shared/components/helpers/api'; export default { - getShowCreateTableMySQL(body) { - return apiRequestManagement.post('/Actions/StartMySQLShowCreateTable', body); - }, - - getMysqlTableStatus(body) { - return apiRequestManagement.post('/Actions/StartMySQLShowTableStatus', body); - }, - - getMysqlIndex(body) { - return apiRequestManagement.post('/Actions/StartMySQLShowIndex', body); - }, - - getTraditionalExplainJSONMysql(body) { - return apiRequestManagement.post('/Actions/StartMySQLExplainJSON', body); - }, - - getTraditionalExplainMysql(body) { - return apiRequestManagement.post('/Actions/StartMySQLExplain', body); - }, + getMySQLActions(body) { + return apiRequestActions.post(':startServiceAction', body); + } }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts index 3d7494e80e..54ae68fbba 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts @@ -6,7 +6,7 @@ export const postgresqlMethods = { return null; } - const result = await PostgresqlDatabaseService.getShowCreateTablePostgreSQL({ + const result = await PostgresqlDatabaseService.getPostgreSQLActions({ table_name: tableName, service_id: example.service_id, database, @@ -19,7 +19,7 @@ export const postgresqlMethods = { return null; } - const result = await PostgresqlDatabaseService.getPostgreSQLIndex({ + const result = await PostgresqlDatabaseService.getPostgreSQLActions({ table_name: tableName, service_id: example.service_id, database, diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts index d65c0bce5e..7194324c96 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts @@ -1,10 +1,7 @@ -import { apiRequestManagement } from 'shared/components/helpers/api'; +import { apiRequestActions } from 'shared/components/helpers/api'; export default { - getPostgreSQLIndex(body) { - return apiRequestManagement.post('/Actions/StartPostgreSQLShowIndex', body); - }, - getShowCreateTablePostgreSQL(body) { - return apiRequestManagement.post('/Actions/StartPostgreSQLShowCreateTable', body); + getPostgreSQLActions(body) { + return apiRequestActions.post(':startServiceAction', body); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts b/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts index 24c9ce1fee..59f279393b 100644 --- a/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Filters/Filters.service.ts @@ -29,7 +29,7 @@ export const markCheckedLabels = (labels, paramLabels) => { export default { getQueryOverviewFiltersList: async (paramLabels, from, to, mainMetric) => { - const { labels } = await apiRequestQAN.post('/v1/qan/metrics:getFilters', { + const { labels } = await apiRequestQAN.post('/metrics:getFilters', { labels: getLabelQueryParams(paramLabels), main_metric_name: mainMetric, period_start_from: from, diff --git a/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts b/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts index a15734ccb1..56a8455938 100644 --- a/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Overview/Overview.service.ts @@ -20,6 +20,6 @@ export default { search: body.dimensionSearchText, }; - return apiRequestQAN.post('/v1/qan/metrics:getReport', request); + return apiRequestQAN.post('/metrics:getReport', request); }, }; diff --git a/pmm-app/src/shared/components/Actions/Actions.service.ts b/pmm-app/src/shared/components/Actions/Actions.service.ts index 700663ee27..8b0f54a101 100644 --- a/pmm-app/src/shared/components/Actions/Actions.service.ts +++ b/pmm-app/src/shared/components/Actions/Actions.service.ts @@ -1,8 +1,8 @@ -import { apiRequestManagement } from '../helpers/api'; +import { apiRequestActions } from '../helpers/api'; import { ActionRequest, ActionResponse } from './Actions.types'; export const ActionsService = { getActionResult(body: ActionRequest): Promise { - return apiRequestManagement.get(`/v1/actions/${body.action_id}`); + return apiRequestActions.get(`/${body.action_id}`); }, }; diff --git a/pmm-app/src/shared/components/helpers/api.ts b/pmm-app/src/shared/components/helpers/api.ts index eb1f9c3885..a14068debd 100644 --- a/pmm-app/src/shared/components/helpers/api.ts +++ b/pmm-app/src/shared/components/helpers/api.ts @@ -60,7 +60,8 @@ export class ApiRequest { } export const apiRequest = new ApiRequest({}); -export const apiRequestQAN = new ApiRequest({ baseURL: '/v0/qan' }); +export const apiRequestQAN = new ApiRequest({ baseURL: '/v1/qan' }); export const apiRequestManagement = new ApiRequest({ baseURL: '/v1/management' }); export const apiRequestInventory = new ApiRequest({ baseURL: '/v1/inventory' }); export const apiRequestSettings = new ApiRequest({ baseURL: '/v1/Settings' }); +export const apiRequestActions = new ApiRequest({ baseURL: '/v1/actions' }); From f94a83f7f84c0ae22fa20696bbb21f531b42ea85 Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Mon, 13 May 2024 14:51:23 +0530 Subject: [PATCH 3/9] PMM-12710 fix lint issue --- .../panel/components/Details/database-models/mysql/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index b535cdada4..dccc5a3586 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -3,5 +3,5 @@ import { apiRequestActions } from 'shared/components/helpers/api'; export default { getMySQLActions(body) { return apiRequestActions.post(':startServiceAction', body); - } + }, }; From 6b80ebcc9800ad1178a366a2211f3e569e9939fe Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Wed, 15 May 2024 13:21:14 +0530 Subject: [PATCH 4/9] PMM-12710 Update settings endpoint --- pmm-app/src/shared/core/Settings.service.ts | 4 ++-- pmm-app/src/shared/core/constants.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pmm-app/src/shared/core/Settings.service.ts b/pmm-app/src/shared/core/Settings.service.ts index cc279855e8..8ce968b9ca 100644 --- a/pmm-app/src/shared/core/Settings.service.ts +++ b/pmm-app/src/shared/core/Settings.service.ts @@ -3,8 +3,8 @@ import { API } from './constants'; import { Settings, SettingsAPIResponse, SettingsPayload } from './types'; export const SettingsService = { - async getSettings(disableNotifications = false): Promise { - const { settings } = await apiRequest.post(API.SETTINGS, {}, disableNotifications) as SettingsAPIResponse; + async getSettings(): Promise { + const { settings } = await apiRequest.get(API.SETTINGS) as SettingsAPIResponse; return toModel(settings); }, diff --git a/pmm-app/src/shared/core/constants.ts b/pmm-app/src/shared/core/constants.ts index 44f1491f77..db430ec958 100644 --- a/pmm-app/src/shared/core/constants.ts +++ b/pmm-app/src/shared/core/constants.ts @@ -1,8 +1,7 @@ import { Databases } from './types'; export const API = { - ALERTMANAGER: '/alertmanager/api/v2', - SETTINGS: '/v1/Settings/Get', + SETTINGS: '/v1/server/settings', }; export const DATABASE_LABELS = { From 3439d608efaf9b56bac1517454fd700fbe77d93f Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Thu, 23 May 2024 17:30:47 +0530 Subject: [PATCH 5/9] PMM-12710 Update api request body --- .../database-models/mongodb/service.ts | 4 ++- .../Details/database-models/mysql/mysql.ts | 10 +++---- .../Details/database-models/mysql/service.ts | 30 +++++++++++++++++-- .../database-models/postgresql/postgresql.ts | 4 +-- .../database-models/postgresql/service.ts | 11 +++++-- pmm-app/src/shared/core/Settings.service.ts | 2 +- .../shared/core/__mocks__/Settings.service.ts | 2 +- pmm-app/src/shared/core/types.ts | 4 +-- 8 files changed, 51 insertions(+), 16 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts index 1b9ad0fee4..e88e70f593 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts @@ -2,6 +2,8 @@ import { apiRequestActions } from 'shared/components/helpers/api'; export default { getTraditionalExplainJSONMongo(body) { - return apiRequestActions.post(':startServiceAction', body); + const requestBody = { mongodb_explain: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts index c8543f8844..5e812a3329 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts @@ -7,7 +7,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getMySQLActions({ + const result = await MysqlDatabaseService.getShowCreateTableMySQL({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -21,7 +21,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getMySQLActions({ + const result = await MysqlDatabaseService.getMysqlIndex({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -35,7 +35,7 @@ export const mysqlMethods = { return null; } - const result = await MysqlDatabaseService.getMySQLActions({ + const result = await MysqlDatabaseService.getMysqlTableStatus({ database: database || example.schema, table_name: tableName, service_id: example.service_id, @@ -48,7 +48,7 @@ export const mysqlMethods = { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getMySQLActions(payload); + const result = await MysqlDatabaseService.getTraditionalExplainJSONMysql(payload); return result.action_id; } catch (e) { @@ -62,7 +62,7 @@ export const mysqlMethods = { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getMySQLActions(payload); + const result = await MysqlDatabaseService.getTraditionalExplainMysql(payload); return result.action_id; } catch (e) { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index dccc5a3586..081cdd739f 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -1,7 +1,33 @@ import { apiRequestActions } from 'shared/components/helpers/api'; export default { - getMySQLActions(body) { - return apiRequestActions.post(':startServiceAction', body); + getShowCreateTableMySQL(body) { + const requestBody = { mysql_show_create_table: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); + }, + + getMysqlTableStatus(body) { + const requestBody = { mysql_show_table_status: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); + }, + + getMysqlIndex(body) { + const requestBody = { mysql_show_index: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); + }, + + getTraditionalExplainJSONMysql(body) { + const requestBody = { mysql_explain_traditional_json: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); + }, + + getTraditionalExplainMysql(body) { + const requestBody = { mysql_explain_json: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts index 54ae68fbba..3d7494e80e 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts @@ -6,7 +6,7 @@ export const postgresqlMethods = { return null; } - const result = await PostgresqlDatabaseService.getPostgreSQLActions({ + const result = await PostgresqlDatabaseService.getShowCreateTablePostgreSQL({ table_name: tableName, service_id: example.service_id, database, @@ -19,7 +19,7 @@ export const postgresqlMethods = { return null; } - const result = await PostgresqlDatabaseService.getPostgreSQLActions({ + const result = await PostgresqlDatabaseService.getPostgreSQLIndex({ table_name: tableName, service_id: example.service_id, database, diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts index 7194324c96..8b4d27c324 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts @@ -1,7 +1,14 @@ import { apiRequestActions } from 'shared/components/helpers/api'; export default { - getPostgreSQLActions(body) { - return apiRequestActions.post(':startServiceAction', body); + getPostgreSQLIndex(body) { + const requestBody = { postgres_show_index: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); + }, + getShowCreateTablePostgreSQL(body) { + const requestBody = { postgres_show_create_table: body }; + + return apiRequestActions.post(':startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/shared/core/Settings.service.ts b/pmm-app/src/shared/core/Settings.service.ts index 8ce968b9ca..e97570c7dc 100644 --- a/pmm-app/src/shared/core/Settings.service.ts +++ b/pmm-app/src/shared/core/Settings.service.ts @@ -11,5 +11,5 @@ export const SettingsService = { }; const toModel = (response: SettingsPayload): Settings => ({ - updatesDisabled: response.updates_disabled, + updatesEnabled: response.updates_enabled, }); diff --git a/pmm-app/src/shared/core/__mocks__/Settings.service.ts b/pmm-app/src/shared/core/__mocks__/Settings.service.ts index b2ae50393d..5d545c0f43 100644 --- a/pmm-app/src/shared/core/__mocks__/Settings.service.ts +++ b/pmm-app/src/shared/core/__mocks__/Settings.service.ts @@ -2,6 +2,6 @@ import { Settings } from '../types'; export const SettingsService = { async getSettings(): Promise { - return Promise.resolve({ updatesDisabled: false }); + return Promise.resolve({ updatesEnabled: true }); }, }; diff --git a/pmm-app/src/shared/core/types.ts b/pmm-app/src/shared/core/types.ts index c96009c23a..7d7ccbde08 100644 --- a/pmm-app/src/shared/core/types.ts +++ b/pmm-app/src/shared/core/types.ts @@ -7,7 +7,7 @@ export enum Databases { } export interface Settings { - updatesDisabled?: boolean; + updatesEnabled?: boolean; } export interface SettingsAPIResponse { @@ -15,7 +15,7 @@ export interface SettingsAPIResponse { } export interface SettingsPayload { - updates_disabled: boolean; + updates_enabled: boolean; } export interface PaginatedPayload { From 9ec6263a6a0077f5f9579e0c50751973aa94b1f5 Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Wed, 5 Jun 2024 16:31:50 +0530 Subject: [PATCH 6/9] PMM-12710 fix api paths --- .../components/Details/Metrics/Metrics.service.ts | 6 +++--- .../Details/database-models/mongodb/service.ts | 4 ++-- .../Details/database-models/mysql/service.ts | 12 ++++++------ .../Details/database-models/postgresql/service.ts | 6 +++--- .../src/shared/components/Actions/Actions.service.ts | 4 ++-- pmm-app/src/shared/components/helpers/api.ts | 1 - 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts index 911bfc1f69..7f1b6da853 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Metrics/Metrics.service.ts @@ -1,4 +1,4 @@ -import { apiRequestQAN } from 'shared/components/helpers/api'; +import { apiRequest } from 'shared/components/helpers/api'; import { getLabelQueryParams } from 'pmm-qan/panel/QueryAnalytics.tools'; import { HistogramRequest, HistogramResponse } from './Metrics.types'; @@ -15,7 +15,7 @@ export const getMetrics = async ({ totals, }; - return apiRequestQAN.post(':getMetrics', body); + return apiRequest.post('/v1/qan:getMetrics', body); }; export const getHistogram = async ({ @@ -28,7 +28,7 @@ export const getHistogram = async ({ period_start_to: to, }; - return apiRequestQAN.post(':getHistogram', body); + return apiRequest.post('/v1/qan:getHistogram', body); }; export default { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts index e88e70f593..e5ff2d592c 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/service.ts @@ -1,9 +1,9 @@ -import { apiRequestActions } from 'shared/components/helpers/api'; +import { apiRequest } from 'shared/components/helpers/api'; export default { getTraditionalExplainJSONMongo(body) { const requestBody = { mongodb_explain: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index 081cdd739f..d7787241ff 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -1,33 +1,33 @@ -import { apiRequestActions } from 'shared/components/helpers/api'; +import { apiRequest } from 'shared/components/helpers/api'; export default { getShowCreateTableMySQL(body) { const requestBody = { mysql_show_create_table: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, getMysqlTableStatus(body) { const requestBody = { mysql_show_table_status: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, getMysqlIndex(body) { const requestBody = { mysql_show_index: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, getTraditionalExplainJSONMysql(body) { const requestBody = { mysql_explain_traditional_json: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, getTraditionalExplainMysql(body) { const requestBody = { mysql_explain_json: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts index 8b4d27c324..43559f8201 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/service.ts @@ -1,14 +1,14 @@ -import { apiRequestActions } from 'shared/components/helpers/api'; +import { apiRequest } from 'shared/components/helpers/api'; export default { getPostgreSQLIndex(body) { const requestBody = { postgres_show_index: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, getShowCreateTablePostgreSQL(body) { const requestBody = { postgres_show_create_table: body }; - return apiRequestActions.post(':startServiceAction', requestBody); + return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, }; diff --git a/pmm-app/src/shared/components/Actions/Actions.service.ts b/pmm-app/src/shared/components/Actions/Actions.service.ts index 8b0f54a101..d6054df6e4 100644 --- a/pmm-app/src/shared/components/Actions/Actions.service.ts +++ b/pmm-app/src/shared/components/Actions/Actions.service.ts @@ -1,8 +1,8 @@ -import { apiRequestActions } from '../helpers/api'; +import { apiRequest } from '../helpers/api'; import { ActionRequest, ActionResponse } from './Actions.types'; export const ActionsService = { getActionResult(body: ActionRequest): Promise { - return apiRequestActions.get(`/${body.action_id}`); + return apiRequest.get(`/v1/actions/${body.action_id}`); }, }; diff --git a/pmm-app/src/shared/components/helpers/api.ts b/pmm-app/src/shared/components/helpers/api.ts index a14068debd..f4d7fafd4c 100644 --- a/pmm-app/src/shared/components/helpers/api.ts +++ b/pmm-app/src/shared/components/helpers/api.ts @@ -64,4 +64,3 @@ export const apiRequestQAN = new ApiRequest({ baseURL: '/v1/qan' }); export const apiRequestManagement = new ApiRequest({ baseURL: '/v1/management' }); export const apiRequestInventory = new ApiRequest({ baseURL: '/v1/inventory' }); export const apiRequestSettings = new ApiRequest({ baseURL: '/v1/Settings' }); -export const apiRequestActions = new ApiRequest({ baseURL: '/v1/actions' }); From 8a6858113f11225a1bc78ac660be0aae1af126ac Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Wed, 5 Jun 2024 18:47:24 +0530 Subject: [PATCH 7/9] PMM-12710 fix actions according to updated response --- .../Details/database-models/mongodb/mongodb.ts | 2 +- .../components/Details/database-models/mysql/mysql.ts | 10 +++++----- .../Details/database-models/postgresql/postgresql.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/mongodb.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/mongodb.ts index 5f4a62e483..e748aa4e4a 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/mongodb.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mongodb/mongodb.ts @@ -9,7 +9,7 @@ export const mongodbMethods = { query: example.example, }); - return result.action_id; + return result.mongodb_explain.action_id; } catch (e) { console.error(e); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts index 5e812a3329..de2f0d1335 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts @@ -13,7 +13,7 @@ export const mysqlMethods = { service_id: example.service_id, }); - return result.action_id; + return result.mysql_show_create_table.action_id; }, getIndexes: async ({ example, tableName, database }) => { @@ -27,7 +27,7 @@ export const mysqlMethods = { service_id: example.service_id, }); - return result.action_id; + return result.mysql_show_index.action_id; }, getStatuses: async ({ example, tableName, database }) => { @@ -41,7 +41,7 @@ export const mysqlMethods = { service_id: example.service_id, }); - return result.action_id; + return result.mysql_show_table_status.action_id; }, getExplainJSON: async ({ example, queryId, placeholders }) => { @@ -50,7 +50,7 @@ export const mysqlMethods = { const result = await MysqlDatabaseService.getTraditionalExplainJSONMysql(payload); - return result.action_id; + return result.mysql_explain_json.action_id; } catch (e) { console.error(e); @@ -64,7 +64,7 @@ export const mysqlMethods = { const result = await MysqlDatabaseService.getTraditionalExplainMysql(payload); - return result.action_id; + return result.mysql_explain_traditional_json.action_id; } catch (e) { console.error(e); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts index 3d7494e80e..c44a775176 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/postgresql/postgresql.ts @@ -12,7 +12,7 @@ export const postgresqlMethods = { database, }); - return result.action_id; + return result.postgresql_show_create_table.action_id; }, getIndexes: async ({ example, tableName, database }) => { if (!tableName) { @@ -25,6 +25,6 @@ export const postgresqlMethods = { database, }); - return result.action_id; + return result.postgresql_show_index.action_id; }, }; From 5eca0b06b4b1e1ce71e89a5e7b0e592fd752c018 Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Fri, 7 Jun 2024 18:44:24 +0530 Subject: [PATCH 8/9] PMM-12710 Update mysql api functions --- .../panel/components/Details/Explain/Explain.tools.ts | 4 ++-- .../components/Details/database-models/mysql/mysql.ts | 10 +++++----- .../Details/database-models/mysql/service.ts | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts b/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts index 0da80a4f70..4f38e27f31 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts @@ -80,8 +80,8 @@ export const fetchExplains = async ( }; const [classicResult, jsonResult] = await Promise.all([ - mysqlMethods.getExplainTraditional(payload).then(getActionResult), - mysqlMethods.getExplainJSON(payload).then(getActionResult), + mysqlMethods.getExplainMysql(payload).then(getActionResult), + mysqlMethods.getExplainJSONMysql(payload).then(getActionResult), ]); const jsonValue = parseExplain(jsonResult); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts index de2f0d1335..2011dea57d 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts @@ -44,11 +44,11 @@ export const mysqlMethods = { return result.mysql_show_table_status.action_id; }, - getExplainJSON: async ({ example, queryId, placeholders }) => { + getExplainJSONMysql: async ({ example, queryId, placeholders }) => { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getTraditionalExplainJSONMysql(payload); + const result = await MysqlDatabaseService.getExplainJSONMysql(payload); return result.mysql_explain_json.action_id; } catch (e) { @@ -58,13 +58,13 @@ export const mysqlMethods = { } }, - getExplainTraditional: async ({ example, queryId, placeholders }) => { + getExplainMysql: async ({ example, queryId, placeholders }) => { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getTraditionalExplainMysql(payload); + const result = await MysqlDatabaseService.getExplainMysql(payload); - return result.mysql_explain_traditional_json.action_id; + return result.mysql_explain.action_id; } catch (e) { console.error(e); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index d7787241ff..3ef079ebc0 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -19,14 +19,14 @@ export default { return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, - getTraditionalExplainJSONMysql(body) { - const requestBody = { mysql_explain_traditional_json: body }; + getExplainJSONMysql(body) { + const requestBody = { mysql_explain_json: body }; return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, - getTraditionalExplainMysql(body) { - const requestBody = { mysql_explain_json: body }; + getExplainMysql(body) { + const requestBody = { mysql_explain: body }; return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, From 96cc2af42330183d02c3baf2ec8da8b86a4d9e94 Mon Sep 17 00:00:00 2001 From: Yash Sartanpara Date: Mon, 10 Jun 2024 13:47:02 +0530 Subject: [PATCH 9/9] PMM-12710 Update method names --- .../panel/components/Details/Explain/Explain.tools.ts | 4 ++-- .../components/Details/database-models/mysql/mysql.ts | 8 ++++---- .../components/Details/database-models/mysql/service.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts b/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts index 4f38e27f31..24e2c4ae05 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/Explain/Explain.tools.ts @@ -80,8 +80,8 @@ export const fetchExplains = async ( }; const [classicResult, jsonResult] = await Promise.all([ - mysqlMethods.getExplainMysql(payload).then(getActionResult), - mysqlMethods.getExplainJSONMysql(payload).then(getActionResult), + mysqlMethods.getExplain(payload).then(getActionResult), + mysqlMethods.getExplainJSON(payload).then(getActionResult), ]); const jsonValue = parseExplain(jsonResult); diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts index 2011dea57d..315b50e0b5 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/mysql.ts @@ -44,11 +44,11 @@ export const mysqlMethods = { return result.mysql_show_table_status.action_id; }, - getExplainJSONMysql: async ({ example, queryId, placeholders }) => { + getExplainJSON: async ({ example, queryId, placeholders }) => { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getExplainJSONMysql(payload); + const result = await MysqlDatabaseService.getExplainJSON(payload); return result.mysql_explain_json.action_id; } catch (e) { @@ -58,11 +58,11 @@ export const mysqlMethods = { } }, - getExplainMysql: async ({ example, queryId, placeholders }) => { + getExplain: async ({ example, queryId, placeholders }) => { try { const payload = getExplainPayload(example, queryId, placeholders); - const result = await MysqlDatabaseService.getExplainMysql(payload); + const result = await MysqlDatabaseService.getExplain(payload); return result.mysql_explain.action_id; } catch (e) { diff --git a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts index 3ef079ebc0..13c0e8b491 100644 --- a/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts +++ b/pmm-app/src/pmm-qan/panel/components/Details/database-models/mysql/service.ts @@ -19,13 +19,13 @@ export default { return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, - getExplainJSONMysql(body) { + getExplainJSON(body) { const requestBody = { mysql_explain_json: body }; return apiRequest.post('/v1/actions:startServiceAction', requestBody); }, - getExplainMysql(body) { + getExplain(body) { const requestBody = { mysql_explain: body }; return apiRequest.post('/v1/actions:startServiceAction', requestBody);