mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Add silences RTK Query API
This commit is contained in:
parent
6f875188b7
commit
8f27ec2521
65
public/app/features/alerting/unified/api/alertSilencesApi.ts
Normal file
65
public/app/features/alerting/unified/api/alertSilencesApi.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import { Silence, SilenceCreatePayload } from 'app/plugins/datasource/alertmanager/types';
|
||||
|
||||
import { alertingApi } from './alertingApi';
|
||||
|
||||
export const alertSilencesApi = alertingApi.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
getSilences: build.query<
|
||||
Silence[],
|
||||
{
|
||||
datasourceUid: string;
|
||||
}
|
||||
>({
|
||||
query: ({ datasourceUid }) => ({
|
||||
url: `/api/alertmanager/${datasourceUid}/api/v2/silences`,
|
||||
}),
|
||||
providesTags: ['AlertSilences'],
|
||||
}),
|
||||
|
||||
getSilence: build.query<
|
||||
Silence,
|
||||
{
|
||||
datasourceUid: string;
|
||||
id: string;
|
||||
}
|
||||
>({
|
||||
query: ({ datasourceUid, id }) => ({
|
||||
url: `/api/alertmanager/${datasourceUid}/api/v2/silence/${id}`,
|
||||
}),
|
||||
providesTags: ['AlertSilences'],
|
||||
}),
|
||||
|
||||
createSilence: build.mutation<
|
||||
{
|
||||
silenceId: string;
|
||||
},
|
||||
{
|
||||
datasourceUid: string;
|
||||
payload: SilenceCreatePayload;
|
||||
}
|
||||
>({
|
||||
query: ({ datasourceUid, payload }) => ({
|
||||
url: `/api/alertmanager/${datasourceUid}/api/v2/silences`,
|
||||
method: 'POST',
|
||||
data: payload,
|
||||
}),
|
||||
invalidatesTags: ['AlertSilences'],
|
||||
}),
|
||||
|
||||
expireSilence: build.mutation<
|
||||
{
|
||||
message: string;
|
||||
},
|
||||
{
|
||||
datasourceUid: string;
|
||||
silenceId: string;
|
||||
}
|
||||
>({
|
||||
query: ({ datasourceUid, silenceId }) => ({
|
||||
url: `/api/alertmanager/${datasourceUid}/api/v2/silence/${silenceId}`,
|
||||
method: 'DELETE',
|
||||
}),
|
||||
invalidatesTags: ['AlertSilences'],
|
||||
}),
|
||||
}),
|
||||
});
|
@ -40,6 +40,7 @@ export const alertingApi = createApi({
|
||||
'DataSourceSettings',
|
||||
'GrafanaLabels',
|
||||
'CombinedAlertRule',
|
||||
'AlertSilences',
|
||||
],
|
||||
endpoints: () => ({}),
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user