Skip to content

Create and delete apis for instance event type filters

Hitesh Raghuvanshi requested to merge 436614-create-instance-event-filters into master

What does this MR do and why?

Added create and delete graphql apis for creating and deleting event type filters to an instance 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 GitLab instance with Ultimate license and its admin access.
  2. Open graphql-explorer and run following graphql queries and mutations.
  3. Create an instance level external audit event destination by running following mutation.
mutation instanceAuditEventStreamingDestinationsCreate {
  instanceAuditEventStreamingDestinationsCreate(input: {
    name: "testdest7",
    category: "http",
    secretToken: "random_secret_token",
    config: {
      url: "https://www.example.com"
    }
  }) {
    errors
    externalAuditEventDestination {
      id
      name
      config
      category
    }
  }
}
  1. Now add an event type filter to the destination created in step 3 by running following mutation:
mutation auditEventsInstanceDestinationEventsAdd {
    auditEventsInstanceDestinationEventsAdd(input: {
        destinationId: "gid://gitlab/AuditEvents::Instance::ExternalStreamingDestination/3",
        eventTypeFilters: ["event_type_filters_created", "event_type_filters_deleted"]}){
        errors
        eventTypeFilters
    }
}
  1. You can list down all information of the destinations belonging to the group by, it should list the filter added:
query auditEventsInstanceStreamingDestinations {
  auditEventsInstanceStreamingDestinations {
    nodes {
      id
      name
      category
      config
      eventTypeFilters
    }
  }
}
  1. For deleting the filter, run following mutation:
mutation auditEventsInstanceDestinationEventsDelete {
    auditEventsInstanceDestinationEventsDelete(input: {
    destinationId: "gid://gitlab/AuditEvents::Instance::ExternalStreamingDestination/3",
    eventTypeFilters: ["event_type_filters_created"]
  }){
    errors
  }
}
  1. Check if the filter is removed by running query in step 5.

Related to #436614 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading