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 6 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,9 @@
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);
const requestBody = { mongodb_explain: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},
};
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
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
const requestBody = { mysql_show_create_table: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},

getMysqlTableStatus(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLShowTableStatus', body);
const requestBody = { mysql_show_table_status: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},

getMysqlIndex(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLShowIndex', body);
const requestBody = { mysql_show_index: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},

getTraditionalExplainJSONMysql(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLExplainJSON', body);
const requestBody = { mysql_explain_traditional_json: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},

getTraditionalExplainMysql(body) {
return apiRequestManagement.post<any, any>('/Actions/StartMySQLExplain', body);
const requestBody = { mysql_explain_json: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
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);
const requestBody = { postgres_show_index: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},
getShowCreateTablePostgreSQL(body) {
return apiRequestManagement.post<any, any>('/Actions/StartPostgreSQLShowCreateTable', body);
const requestBody = { postgres_show_create_table: body };

return apiRequestActions.post<any, any>(':startServiceAction', requestBody);
},
};
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' });
6 changes: 3 additions & 3 deletions pmm-app/src/shared/core/Settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ 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);
},
};

const toModel = (response: SettingsPayload): Settings => ({
updatesDisabled: response.updates_disabled,
updatesEnabled: response.updates_enabled,
});
2 changes: 1 addition & 1 deletion pmm-app/src/shared/core/__mocks__/Settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Settings } from '../types';

export const SettingsService = {
async getSettings(): Promise<Settings> {
return Promise.resolve({ updatesDisabled: false });
return Promise.resolve({ updatesEnabled: true });
},
};
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
4 changes: 2 additions & 2 deletions pmm-app/src/shared/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ export enum Databases {
}

export interface Settings {
updatesDisabled?: boolean;
updatesEnabled?: boolean;
}

export interface SettingsAPIResponse {
settings: SettingsPayload;
}

export interface SettingsPayload {
updates_disabled: boolean;
updates_enabled: boolean;
}

export interface PaginatedPayload {
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