From c1766d9fc2ecea6f08b05dc301018c0328bf4da1 Mon Sep 17 00:00:00 2001 From: Rares Mardare Date: Tue, 2 Apr 2024 15:43:55 +0300 Subject: [PATCH] Pass existing integration id to test_connection (#4131) # What this PR does Pass existing integration id to `test_connection` servicenow endpoint --- .../ServiceNowConfigDrawer/ServiceNowAuthSection.tsx | 2 +- .../alert_receive_channel.helpers.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx index b1566589..662d096b 100644 --- a/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx +++ b/grafana-plugin/src/containers/ServiceNowConfigDrawer/ServiceNowAuthSection.tsx @@ -53,7 +53,7 @@ export const ServiceNowAuthSection: React.FC = observer(() => { }; setIsAuthTestRunning(true); - const result = await AlertReceiveChannelHelper.testServiceNowAuthentication({ data }); + const result = await AlertReceiveChannelHelper.testServiceNowAuthentication({ id: currentIntegration?.id, data }); setAuthTestResult(result); setIsAuthTestRunning(false); } diff --git a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts index 4e131d03..e339446b 100644 --- a/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts +++ b/grafana-plugin/src/models/alert_receive_channel/alert_receive_channel.helpers.ts @@ -74,14 +74,20 @@ export class AlertReceiveChannelHelper { } static async testServiceNowAuthentication({ + id, data, }: { + id: ApiSchemas['AlertReceiveChannel']['id']; data: OmitReadonlyMembers; }) { try { - const result = await onCallApi({ skipErrorHandling: false }).POST('/alert_receive_channels/test_connection/', { + const endpoint = id + ? '/alert_receive_channels/{id}/test_connection/' + : '/alert_receive_channels/test_connection/'; + + const result = await onCallApi({ skipErrorHandling: false }).POST(endpoint, { body: data as ApiSchemas['AlertReceiveChannelUpdate'], - params: {}, + params: { path: { id } }, }); return result?.response.status === 200; } catch (ex) {