Skip to content
Snippets Groups Projects

Adding update instance headers API

Merged Hitesh Raghuvanshi requested to merge 404560-gq-apis-update into master
All threads resolved!

What does this MR do and why?

Added GraphQL API for updating streaming headers for instance level external audit event destinations.

GraphQL API

mutation {
  auditEventsStreamingInstanceHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/3", key: "new-key", value: "new-value" }) {
    errors
    header {
      id
      key
      value
    }
  }
}

Query plan

Query - Click to expand
UPDATE 
  "instance_audit_events_streaming_headers" 
SET 
  "updated_at" = '2023-06-12 12:58:24.503241', 
  "key" = 'new-key', 
  "value" = 'new-value' 
WHERE 
  "instance_audit_events_streaming_headers"."id" = 40

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/19381/commands/64007

Note: Since this is an instance level API, there are no records on production.

How to set up and validate locally

  1. Enable the feature flag from rails console by running Feature.enable(:ff_external_audit_events).
  2. Open graphql-explorer console in browser by opening url http://127.0.0.1:3000/-/graphql-explorer.
  3. Run following mutation in the graphql explorer and note down the id, which would be something like gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id> from output.
mutation {
  instanceExternalAuditEventDestinationCreate(input: { destinationUrl: "https://www.example.com"}) {
    errors
    instanceExternalAuditEventDestination {
      destinationUrl
      id
    }
  }
}
  1. Run the following graphql command in explorer for creating a header created for destination created in step 3, note down the id of header:
mutation {
  auditEventsStreamingInstanceHeadersCreate(input: 
    { 
      key: "header1",
      value: "header1value",
      destinationId: "gid://gitlab/AuditEvents::InstanceExternalAuditEventDestination/<id>"
    }) {
    errors
    header {
      id
      key
      value
    }
  }
}
  1. Run following mutation for updating the header, it should return with a successful response:
mutation {
  auditEventsStreamingInstanceHeadersUpdate(input: { headerId: "gid://gitlab/AuditEvents::Streaming::InstanceHeader/<id>", key: "new-key", value: "new-value" }) {
    errors
    header {
      id
      key
      value
    }
  }
}
  1. You can also check the updated value in rails console by running AuditEvents::Streaming::InstanceHeader.last.key or simply AuditEvents::Streaming::InstanceHeader.last.

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

Edited by Hitesh Raghuvanshi

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Sylvester Chin
  • Sylvester Chin
  • Sylvester Chin removed review request for @schin1

    removed review request for @schin1

  • Hitesh Raghuvanshi requested review from @schin1

    requested review from @schin1

  • Sylvester Chin approved this merge request

    approved this merge request

  • :wave: @schin1, thanks for approving this merge request.

    This is the first time the merge request is approved. To ensure full test coverage, a new pipeline will be started shortly.

    For more info, please refer to the following links:

  • Sylvester Chin requested review from @abdwdd and @cam.x and removed review request for @schin1

    requested review from @abdwdd and @cam.x and removed review request for @schin1

  • Abdul Wadood removed review request for @abdwdd

    removed review request for @abdwdd

  • Hitesh Raghuvanshi added 132 commits

    added 132 commits

    Compare with previous version

  • Camellia X Yang approved this merge request

    approved this merge request

  • Camellia X Yang removed review request for @cam.x

    removed review request for @cam.x

  • Camellia X Yang unapproved this merge request

    unapproved this merge request

  • @hraghuvanshi I am a designer not a developer, I don't think I should review those backend changes. I remove myself from approval

  • Hitesh Raghuvanshi requested review from @mwoolf

    requested review from @mwoolf

  • requested review from @harsimarsandhu

  • Max Woolf removed review request for @mwoolf

    removed review request for @mwoolf

  • Max Woolf approved this merge request

    approved this merge request

  • Harsimar Sandhu approved this merge request

    approved this merge request

  • Harsimar Sandhu removed review request for @harsimarsandhu

    removed review request for @harsimarsandhu

  • Hitesh Raghuvanshi requested review from @mwoolf

    requested review from @mwoolf

  • Max Woolf resolved all threads

    resolved all threads

  • Max Woolf enabled an automatic merge when the pipeline for cd4ecf32 succeeds

    enabled an automatic merge when the pipeline for cd4ecf32 succeeds

  • merged

  • Max Woolf mentioned in commit b2480d2d

    mentioned in commit b2480d2d

  • Verified on staging-ref

    image

    image

  • Hitesh Raghuvanshi mentioned in merge request !123895 (merged)

    mentioned in merge request !123895 (merged)

  • Please register or sign in to reply
    Loading