Adding update instance headers API
What does this MR do and why?
Added GraphQL API for updating streaming headers for instance level external audit event destinations.
GraphQL API
mutation {
auditEventsStreamingInstanceHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/3", key: "new-key", value: "new-value" }) {
errors
header {
id
key
value
}
}
}
Query plan
Query - Click to expand
UPDATE
"instance_audit_events_streaming_headers"
SET
"updated_at" = '2023-06-12 12:58:24.503241',
"key" = 'new-key',
"value" = 'new-value'
WHERE
"instance_audit_events_streaming_headers"."id" = 40
https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19381/commands/64007
Note: Since this is an instance level API, there are no records on production.
How to set up and validate locally
- Enable the feature flag from rails console by running
Feature.enable(:ff_external_audit_events)
. - Open graphql-explorer console in browser by opening url http://127.0.0.1:3000/-/graphql-explorer.
- Run following mutation in the graphql explorer and note down the id, which would be something like
gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id>
from output.
mutation {
instanceExternalAuditEventDestinationCreate(input: { destinationUrl: "https://www.example.com"}) {
errors
instanceExternalAuditEventDestination {
destinationUrl
id
}
}
}
- Run the following graphql command in explorer for creating a header created for destination created in step 3, note down the id of header:
mutation {
auditEventsStreamingInstanceHeadersCreate(input:
{
key: "header1",
value: "header1value",
destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id>"
}) {
errors
header {
id
key
value
}
}
}
- Run following mutation for updating the header, it should return with a successful response:
mutation {
auditEventsStreamingInstanceHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/<id>", key: "new-key", value: "new-value" }) {
errors
header {
id
key
value
}
}
}
- You can also check the updated value in rails console by running
AuditEvents::Streaming::InstanceHeader.last.key
or simplyAuditEvents::Streaming::InstanceHeader.last
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #404560 (closed)
Edited by Hitesh Raghuvanshi