Skip to content

Extend creating HTTP Integration mutation with custom mapping attributes

What does this MR do?

Implements #294235 (closed)

Add payload_example and payload_attribute_mapping arguments to the create HTTP integration GraphQL mutation.

The feature is available with the GitLab Premium license.

Currently hidden behind multiple_http_integrations_custom_mapping feature flag.

Enable feature flag

Feature.enable(:multiple_http_integrations_custom_mapping)

GraphQL

Mutation

mutation createHttp($input: HttpIntegrationCreateInput!) {
  httpIntegrationCreate(input: $input) {
    integration {
      active
      apiUrl
      url
      token
      name
      id
    }
    errors
  }
}

Query variables

{
  "input": {
    "projectPath": "<PROJECT-PATH>",
    "name": "Testing the custom mapping",
    "active": true,
    "payloadExample": "{\"alert\":{\"name\":\"Example\",\"desc\":\"An alert example\"},\"started_at\":\"2021-01-06T04:09:16Z\"}",
    "payloadAttributeMappings": [
      { "fieldName": "TITLE", "path": ["alert", "name"], "type": "STRING", "label": "Alert title" },
      { "fieldName": "START_TIME", "path": ["started_at"], "type": "DATETIME" }
    ]
  }
}

Created HTTP Integration

The GraphQL query doesn't return payloadExample and payloadAttributeMapping yet. It is going to be done in #295186 (closed)

Now we can check the output from the rails c

> pp AlertManagement::HttpIntegration.last

=> #<AlertManagement::HttpIntegration:0x00007ffac4b830c8
 id: 5,
 created_at: Wed, 13 Jan 2021 12:11:25 UTC +00:00,
 updated_at: Wed, 13 Jan 2021 12:11:25 UTC +00:00,
 project_id: 20,
 active: true,
 encrypted_token: "[FILTERED]",
 encrypted_token_iv: "jOW9C7zJFEYP9xZ7\n",
 endpoint_identifier: "e1d5ca222b3e0fd2",
 name: "Testing the custom mapping",
 payload_example: {"alert"=>{"desc"=>"An alert example", "name"=>"Example"}, "started_at"=>"2021-01-13T04:09:16Z"},
 payload_attribute_mapping: {"title"=>"[FILTERED]", "start_time"=>{"path"=>["started_at"], "type"=>"datetime", "label"=>nil}},
 token: nil>

Screenshots

Screenshot_2021-01-13_at_13.11.35

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen

Merge request reports