Skip to content

Added active param to create streaming headers API

Hitesh Raghuvanshi requested to merge 367509-activate-headers-apis into master

What does this MR do and why?

  1. Added active param to audit event streaming headers create API.
  2. The param is by default true so that the change will be consistent with the existing functionality.
  3. This param is true will activate the header to be streamed else it will be deactivated and will not be used while streaming audit event to the custom http streaming destination.

How to set up and validate locally

For Instance level streaming headers:

  1. Create a new instance level http audit event streaming destination by following steps in https://docs.gitlab.com/ee/administration/audit_event_streaming/#add-a-new-http-destination-1.
  2. Create a new header for this destination by running the following mutation in https://gitlab.localdev:3000/-/graphql-explorer.
mutation auditEventsStreamingInstanceHeadersCreate {
  auditEventsStreamingInstanceHeadersCreate(input:
    {
      destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id>",
      key: "foo",
      value: "bar",
      active: false
    }) {
    errors
    header {
      id
      key
      value
      active
    }
  }
}
  1. Also try to create a header without passing active, by default its value is true.
  2. List all the headers for the destinations by running following query, the value of active param should be as provided at time of creation.
query instanceExternalAuditEventDestinations {
  instanceExternalAuditEventDestinations {
    nodes {
      id
      name
      destinationUrl
      verificationToken
      headers {
        nodes {
          id
          key
          value
          active
        }
      }
      eventTypeFilters
    }
  }
}

Group level streaming headers

  1. Create a new http streaming destination for a group by following steps in https://docs.gitlab.com/ee/administration/audit_event_streaming/graphql_api.html#add-a-new-streaming-destination.
  2. List all streaming destinations for the group by running https://docs.gitlab.com/ee/administration/audit_event_streaming/graphql_api.html#list-streaming-destinations in graphql explorer.
  3. Then create a new header for the destination by running following mutation
mutation auditEventsStreamingHeadersCreate {
  auditEventsStreamingHeadersCreate(input: { destinationId: "gid://gitlab/AuditEvents::ExternalAuditEventDestination/33", 
    key: "foo", 
    value: "bar",
    active: false
  }) {
    errors
    header {
      id
      key
      value
      active
    }
  }
}
  1. Also create a header without passing active param, default value for it is true.
  2. List down all the headers for the destinations for group by following step 2 and the active param should match with the provided ones.

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 #367509 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports