Skip to content

Extend updating HTTP Integration mutation with custom mapping attributes

What does this MR do?

Implements #294236 (closed) (similar to !50860 (merged))

Add payload_example and payload_attribute_mapping arguments to the update 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: HttpIntegrationUpdateInput!) {
  httpIntegrationUpdate(input: $input) {
    integration {
      active
      apiUrl
      url
      token
      name
      id
    }
    errors
  }
}

Query variables

{
  "input": {
    "id": "gid://gitlab/AlertManagement::HttpIntegration/<INTEGRATION-ID>",
    "name": "Testing the custom mapping",
    "active": true,
    "payloadExample": "{\"alert\":{\"name\":\"New Example\",\"desc\":\"An alert example\"},\"started_at\":\"2021-01-18T04:09:16Z\"}",
    "payloadAttributeMappings": [
      { "fieldName": "TITLE", "path": ["alert", "name"], "type": "STRING", "label": "Alert title" }
    ]
  }
}

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

Before

> pp AlertManagement::HttpIntegration.last

#<AlertManagement::HttpIntegration:0x00007fcbe46cca98
 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: "123\n",
 endpoint_identifier: "abc123",
 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>

After

> pp AlertManagement::HttpIntegration.last

#<AlertManagement::HttpIntegration:0x00007fcbe2e514f0
 id: 5,
 created_at: Wed, 13 Jan 2021 12:11:25 UTC +00:00,
 updated_at: Mon, 18 Jan 2021 14:57:14 UTC +00:00,
 project_id: 20,
 active: true,
 encrypted_token: "[FILTERED]",
 encrypted_token_iv: "123\n",
 endpoint_identifier: "aaa123",
 name: "Testing the custom mapping",
 payload_example:
  {"alert"=>{"desc"=>"An alert example", "name"=>"New Example"},
   "started_at"=>"2021-01-18T04:09:16Z"},
 payload_attribute_mapping: {"title"=>"[FILTERED]"},
 token: nil>

Screenshots

Screenshot_2021-01-18_at_15.57.21

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 Vitali Tatarintev

Merge request reports

Loading