Skip to content

Adding create and delete apis for group level namespace filters

Hitesh Raghuvanshi requested to merge 436612-create-dele-apis into master

What does this MR do and why?

This MR is introducing create and delete apis for namespace filters for group level external audit event destinations. The namespace filters were recently introduced in !150092 (merged). It is a part of consolidation process mentioned in &12339.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Make sure you have group, let's say with name twitter with Ultimate license. Also, create subgroups and subprojects under it, here I have created a subgroup named sub4 for creating namespace filter.
  2. First create an external audit event destination for the group with Ultimate license by running following mutation in http://gitlab.localdev:3000/-/graphql-explorer.
mutation groupAuditEventStreamingDestinationsCreate {
  groupAuditEventStreamingDestinationsCreate(input: {
    name: "test_name",
    category: "http",
    groupPath: "twitter",
    secretToken: "token"
    config: {
      url: "https://www.example.com",
      headers: {
        key1: {
          value: "value1",
          active: true
        },
        key2: {
          value: "value2"
        },
        key3: {
          value: "value3",
          active: false
        }
      }
    }
  }) {
    errors
    externalAuditEventDestination {
      id
      name
      config
      category
      namespaceFilters {
        id
        namespace {
          id
          name
        }
      }
    }
  }
}
  1. Now create a namespace filter for the destination by running following mutation:
mutation auditEventsGroupDestinationNamespaceFilterCreate {
  auditEventsGroupDestinationNamespaceFilterCreate(input: {
    destinationId: "gid://gitlab/AuditEvents::Group::ExternalStreamingDestination/<id>",
    namespacePath: "twitter/sub4"
  }) {
    errors
    namespaceFilter {
      id
      namespace {
        id
        name
        fullName
      }
    }
  }
}
  1. For deleting the namespace filter you can run following mutation:
mutation auditEventsGroupDestinationNamespaceFilterDelete {
  auditEventsGroupDestinationNamespaceFilterDelete(input: {
    namespaceFilterId: "gid://gitlab/AuditEvents::Group::NamespaceFilter/<id>"
  }) {
    errors
  }
}
  1. You should not get errors in any of the above mutations.

Related to #436612 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports