Alerting: Update OnCall integration url (#93407)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Michael Derynck
2024-10-02 16:13:55 +02:00
committed by GitHub
co-authored by Gilles De Mey
parent a1556fded2
commit 97f480386f
2 changed files with 10 additions and 10 deletions
@@ -38,13 +38,13 @@ export interface OnCallConfigChecks {
is_integration_chatops_connected: boolean;
}
const getProxyApiUrl = (path: string) => `/api/plugin-proxy/${SupportedPlugin.OnCall}${path}`;
const getProxyApiUrl = (path: string) => `/api/plugins/${SupportedPlugin.OnCall}/resources${path}`;
export const onCallApi = alertingApi.injectEndpoints({
endpoints: (build) => ({
grafanaOnCallIntegrations: build.query<OnCallIntegrationDTO[], void>({
query: () => ({
url: getProxyApiUrl('/api/internal/v1/alert_receive_channels/'),
url: getProxyApiUrl('/alert_receive_channels/'),
// legacy_grafana_alerting is necessary for OnCall.
// We do NOT need to differentiate between these two on our side
params: {
@@ -64,14 +64,14 @@ export const onCallApi = alertingApi.injectEndpoints({
}),
validateIntegrationName: build.query<boolean, string>({
query: (name) => ({
url: getProxyApiUrl('/api/internal/v1/alert_receive_channels/validate_name/'),
url: getProxyApiUrl('/alert_receive_channels/validate_name/'),
params: { verbal_name: name },
showErrorAlert: false,
}),
}),
createIntegration: build.mutation<NewOnCallIntegrationDTO, CreateIntegrationDTO>({
query: (integration) => ({
url: getProxyApiUrl('/api/internal/v1/alert_receive_channels/'),
url: getProxyApiUrl('/alert_receive_channels/'),
data: integration,
method: 'POST',
showErrorAlert: true,
@@ -80,13 +80,13 @@ export const onCallApi = alertingApi.injectEndpoints({
}),
features: build.query<OnCallFeature[], void>({
query: () => ({
url: getProxyApiUrl('/api/internal/v1/features/'),
url: getProxyApiUrl('/features/'),
showErrorAlert: false,
}),
}),
onCallConfigChecks: build.query<OnCallConfigChecks, void>({
query: () => ({
url: getProxyApiUrl('/api/internal/v1/organization/config-checks/'),
url: getProxyApiUrl('/organization/config-checks/'),
showErrorAlert: false,
}),
}),
@@ -2,22 +2,22 @@ import { HttpResponse, http } from 'msw';
import { ONCALL_INTEGRATION_V2_FEATURE, OnCallIntegrationDTO } from 'app/features/alerting/unified/api/onCallApi';
const BASE_URL = `/api/plugin-proxy/grafana-oncall-app`;
const BASE_URL = `/api/plugins/grafana-oncall-app/resources`;
export const getOnCallIntegrationsHandler = (receiveChannels: OnCallIntegrationDTO[] = []) =>
http.get(`${BASE_URL}/api/internal/v1/alert_receive_channels`, () => {
http.get(`${BASE_URL}/alert_receive_channels`, () => {
return HttpResponse.json(receiveChannels);
});
export const getFeaturesHandler = (features = [ONCALL_INTEGRATION_V2_FEATURE]) =>
http.get(`${BASE_URL}/api/internal/v1/features`, () => {
http.get(`${BASE_URL}/features`, () => {
return HttpResponse.json(features);
});
const validateIntegrationNameHandler = (
invalidNames: string[] = ['grafana-integration', 'alertmanager-integration']
) => {
return http.get(`${BASE_URL}/api/internal/v1/alert_receive_channels/validate_name`, ({ request }) => {
return http.get(`${BASE_URL}/alert_receive_channels/validate_name`, ({ request }) => {
const url = new URL(request.url);
const isValid = !invalidNames.includes(url.searchParams.get('verbal_name') ?? '');
return HttpResponse.json(isValid, {