Add mutation method to update a rule

This commit is contained in:
Tom Ratcliffe authored and Tom Ratcliffe committed 2024-04-03 18:38:49 +01:00
1 parent cad8190a91
commit e5a6dff801
1 file changed
+16
@@ -81,6 +81,14 @@ export interface ModifyExportPayload {
source_tenants?: string[] | undefined;
}
export interface AlertRuleUpdated {
message: string;
/**
* UIDs of rules updated from this request
*/
updated: string[];
}
export const alertRuleApi = alertingApi.injectEndpoints({
endpoints: (build) => ({
preview: build.mutation<
@@ -255,5 +263,13 @@ export const alertRuleApi = alertingApi.injectEndpoints({
}),
keepUnusedDataFor: 0,
}),
updateRule: build.mutation<AlertRuleUpdated, { nameSpaceUID: string; payload: ModifyExportPayload }>({
query: ({ payload, nameSpaceUID }) => ({
url: `/api/ruler/grafana/api/v1/rules/${nameSpaceUID}/`,
data: payload,
method: 'POST',
}),
}),
}),
});