Skip to content

Create and delete apis for group event type filters

Hitesh Raghuvanshi requested to merge 436611-create-event-group-filter into master

What does this MR do and why?

Added create and delete graphql apis for creating and deleting event type filters to a group level external audit event streaming destination.

This is part of our refactoring epic &12339, so we have reused some of the existing classes for creation and deletion.

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. You need to have a group with Ultimate license.
  2. Open graphql-explorer and run following graphql queries and mutations.
  3. Create a group level external audit event destination by running following mutation. Here I am using a group named twitter but you can change that.
mutation groupAuditEventStreamingDestinationsCreate {
  groupAuditEventStreamingDestinationsCreate(input: {
    name: "testdest4",
    category: "http",
    groupPath: "twitter",
    secretToken: "asfergrbtr",
    config: {
      url: "https://www.example.com"
    }
  }) {
    errors
    externalAuditEventDestination {
      id
      name
      config
      category
      eventTypeFilters
    }
  }
}
  1. Now add an event type filter to the destination created in step 3 by running following mutation:
mutation auditEventsGroupDestinationEventsAdd {
    auditEventsGroupDestinationEventsAdd(input: {
        destinationId: "gid://gitlab/AuditEvents::Group::ExternalStreamingDestination/2",
        eventTypeFilters: ["event_type_filters_created"]}){
        errors
        eventTypeFilters
    }
}
  1. You can list down all information of the destinations belonging to the group by, it should list the filter added:
query groupDestinations {
  group(fullPath: "twitter") {
    id
    name
    externalAuditEventStreamingDestinations {
      nodes {
        id
        name
        category
        config
        eventTypeFilters
      }
    }
  }
}
  1. For deleting the filter, run following mutation:
mutation auditEventsGroupDestinationEventsDelete {
    auditEventsGroupDestinationEventsDelete(input: {
    destinationId: "gid://gitlab/AuditEvents::Group::ExternalStreamingDestination/2",
    eventTypeFilters: ["event_type_filters_created"]
  }){
    errors
  }
}
  1. Check if the filter is removed by running query in step 5.

Related to #436611

Edited by Hitesh Raghuvanshi

Merge request reports