Skip to content

Added destroy api for namespace filters

Hitesh Raghuvanshi requested to merge 424177-delete-api-namespace-filters into master

What does this MR do and why?

This MR adds a destroy API for deleting namespace(subgroup and project) filters for group level custom http external audit event destinations.

Context

  1. To summarise what are custom http external audit event destinations, any audit event generated for the top level group to which this destination is associated will be streamed to this destination.
  2. This MR will help in deleting namespace filters for the destinations.

Query plan

SQL delete query

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/23722/commands/76163

DELETE FROM 
  "audit_events_streaming_http_group_namespace_filters" 
WHERE 
  "audit_events_streaming_http_group_namespace_filters"."id" = 45

Note: Please note that the table does not have any entry on production as it is a newly created table.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Create namespace filter(s) for a top-level group by following steps mentioned in !136047 (merged).
  2. Now open graphql explorer and run following query by replacing name of group with the one that you had for the top-level group:
query externalAuditEventDestinations {
  group(fullPath: "Twitter") {
    id
    externalAuditEventDestinations {
      nodes {
        destinationUrl
        verificationToken
        id
        name
        headers {
          nodes {
            key
            value
            id
            active
          }
        }
        eventTypeFilters
        namespaceFilter {
          id
          namespace {
            id
            name
            fullName
          }
          externalAuditEventDestination {
           id 
          }
        }
      }
    }
  }
}
  1. Now let's delete one of the namespace filter by running following mutation, replace the namespace filter id with the one you received in step 4 response:
mutation auditEventsStreamingHttpNamespaceFiltersDelete {
  auditEventsStreamingHttpNamespaceFiltersDelete(input: {
    namespaceFilterId: "gid://gitlab/AuditEvents::Streaming::HTTP::NamespaceFilter/5"
  }) {
    errors
  }
}
  1. On running the query in step 4, you will see that the namespace filter which was deleted in step 5 is not there.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #424177 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports