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

PMM-12710: API breaking changes #1594

Merged
merged 14 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -14,7 +14,7 @@ const getExample = async ({
tables,
};

return apiRequestQAN.post<QueryExampleResponse, any>('/ObjectDetails/GetQueryExample', data);
return apiRequestQAN.post<QueryExampleResponse, any>('/query:getExample', data);
};

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getMetrics = async ({
totals,
};

return apiRequestQAN.post<any, any>('/ObjectDetails/GetMetrics', body);
return apiRequestQAN.post<any, any>(':getMetrics', body);
};

export const getHistogram = async ({
Expand All @@ -28,7 +28,7 @@ export const getHistogram = async ({
period_start_to: to,
};

return apiRequestQAN.post<HistogramResponse, HistogramRequest>('/ObjectDetails/GetHistogram', body);
return apiRequestQAN.post<HistogramResponse, HistogramRequest>(':getHistogram', body);
};

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const PlanService = {
};

return apiRequestQAN
.post<QueryPlanResponse, QueryPlanRequest>('/ObjectDetails/GetQueryPlan', body)
.get<QueryPlanResponse, QueryPlanRequest>(`/query/${body.queryid}/plan`)
.then(({ planid, query_plan }) => (
planid && query_plan ? { id: planid, plan: query_plan } : undefined
));
Expand Down
Original file line number Diff line number Diff line change
@@ -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<any, any>('/Actions/StartMongoDBExplain', body);
return apiRequestActions.post<any, any>(':startServiceAction', body);
},
matejkubinec marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<any, any>('/Actions/StartMySQLShowCreateTable', body);
matejkubinec marked this conversation as resolved.
Show resolved Hide resolved
},

getMysqlTableStatus(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLShowTableStatus', body);
},

getMysqlIndex(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLShowIndex', body);
},

getTraditionalExplainJSONMysql(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLExplainJSON', body);
},

getTraditionalExplainMysql(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLExplain', body);
getMySQLActions(body) {
return apiRequestActions.post<any, any>(':startServiceAction', body);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<any, any>('/Actions/StartPostgreSQLShowIndex', body);
},
getShowCreateTablePostgreSQL(body) {
return apiRequestManagement.post<any, any>('/Actions/StartPostgreSQLShowCreateTable', body);
getPostgreSQLActions(body) {
return apiRequestActions.post<any, any>(':startServiceAction', body);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const markCheckedLabels = (labels, paramLabels) => {

export default {
getQueryOverviewFiltersList: async (paramLabels, from, to, mainMetric) => {
const { labels } = await apiRequestQAN.post<any, any>('/Filters/Get', {
const { labels } = await apiRequestQAN.post<any, any>('/metrics:getFilters', {
labels: getLabelQueryParams(paramLabels),
main_metric_name: mainMetric,
period_start_from: from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export default {
search: body.dimensionSearchText,
};

return apiRequestQAN.post<any, any>('/GetReport', request);
return apiRequestQAN.post<any, any>('/metrics:getReport', request);
},
};
4 changes: 2 additions & 2 deletions pmm-app/src/shared/components/Actions/Actions.service.ts
Original file line number Diff line number Diff line change
@@ -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<ActionResponse> {
return apiRequestManagement.post<any, any>('/Actions/Get', body);
return apiRequestActions.get<any, any>(`/${body.action_id}`);
},
};
3 changes: 2 additions & 1 deletion pmm-app/src/shared/components/helpers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
4 changes: 2 additions & 2 deletions pmm-app/src/shared/core/Settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { API } from './constants';
import { Settings, SettingsAPIResponse, SettingsPayload } from './types';

export const SettingsService = {
async getSettings(disableNotifications = false): Promise<Settings> {
const { settings } = await apiRequest.post(API.SETTINGS, {}, disableNotifications) as SettingsAPIResponse;
async getSettings(): Promise<Settings> {
const { settings } = await apiRequest.get(API.SETTINGS) as SettingsAPIResponse;
matejkubinec marked this conversation as resolved.
Show resolved Hide resolved

return toModel(settings);
},
Expand Down
3 changes: 1 addition & 2 deletions pmm-app/src/shared/core/constants.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
9 changes: 3 additions & 6 deletions setup-page/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`, {
matejkubinec marked this conversation as resolved.
Show resolved Hide resolved
method: 'GET',
credentials: "include",
cache: "no-cache",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
instance_id: instanceId.trim(),
}),
}
});

if (!response.ok) {
Expand Down
Loading