Skip to content
Snippets Groups Projects
Commit 545f89c0 authored by Vitali Tatarintev's avatar Vitali Tatarintev
Browse files

Add payloadAlertFields to HttpIntegration response

Now a `alertManagementHttpIntegrations` GraphQL query returns
`payloadAlertFields` calculated from the persisted `payload_example`.
parent 8155ccf4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -634,6 +634,11 @@ type AlertManagementHttpIntegration implements AlertManagementIntegration {
"""
name: String
 
"""
Extract alert fields from payload example for custom mapping.
"""
payloadAlertFields: [AlertManagementPayloadAlertField!]
"""
The custom mapping of GitLab alert attributes to fields from the payload_example.
"""
Loading
Loading
Loading
Loading
@@ -1578,6 +1578,28 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "payloadAlertFields",
"description": "Extract alert fields from payload example for custom mapping.",
"args": [
],
"type": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "AlertManagementPayloadAlertField",
"ofType": null
}
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "payloadAttributeMappings",
"description": "The custom mapping of GitLab alert attributes to fields from the payload_example.",
Loading
Loading
@@ -274,6 +274,7 @@ An endpoint and credentials used to accept alerts for a project.
| `apiUrl` | String | URL at which Prometheus metrics can be queried to populate the metrics dashboard. |
| `id` | ID! | ID of the integration. |
| `name` | String | Name of the integration. |
| `payloadAlertFields` | AlertManagementPayloadAlertField! => Array | Extract alert fields from payload example for custom mapping. |
| `payloadAttributeMappings` | AlertManagementPayloadAlertMappingField! => Array | The custom mapping of GitLab alert attributes to fields from the payload_example. |
| `payloadExample` | JsonString | The example of an alert payload. |
| `token` | String | Token used to authenticate alert notification requests. |
Loading
Loading
Loading
Loading
@@ -15,6 +15,11 @@ module HttpIntegrationType
null: true,
description: 'The custom mapping of GitLab alert attributes to fields from the payload_example.',
resolver: ::Resolvers::AlertManagement::PayloadAlertMappingFieldResolver
field :payload_alert_fields, [::Types::AlertManagement::PayloadAlertFieldType],
null: true,
description: 'Extract alert fields from payload example for custom mapping.',
resolver: ::Resolvers::AlertManagement::PersistedPayloadAlertFieldResolver
end
end
end
Loading
Loading
Loading
Loading
@@ -8,8 +8,6 @@ class PayloadAlertMappingFieldResolver < BaseResolver
alias_method :integration, :object
 
def resolve
return [] unless integration.is_a?(::AlertManagement::HttpIntegration)
integration.payload_attribute_mapping.map do |field_name, mapping|
::AlertManagement::AlertPayloadField.new(
project: integration.project,
Loading
Loading
# frozen_string_literal: true
module Resolvers
module AlertManagement
class PersistedPayloadAlertFieldResolver < BaseResolver
type ::Types::AlertManagement::PayloadAlertFieldType, null: true
alias_method :integration, :object
def resolve
Gitlab::AlertManagement::AlertPayloadFieldExtractor
.new(integration.project)
.extract(integration.payload_example)
end
end
end
end
Loading
Loading
@@ -18,6 +18,7 @@
api_url
payload_example
payload_attribute_mappings
payload_alert_fields
]
 
expect(described_class).to have_graphql_fields(*expected_fields)
Loading
Loading
Loading
Loading
@@ -107,6 +107,18 @@
'path' => %w(alert desc),
'type' => 'STRING'
}
],
'payloadAlertFields' => [
{
'label' => 'Name',
'path' => %w(alert name),
'type' => 'STRING'
},
{
'label' => 'Desc',
'path' => %w(alert desc),
'type' => 'STRING'
}
]
},
{
Loading
Loading
@@ -118,7 +130,8 @@
'url' => inactive_http_integration.url,
'apiUrl' => nil,
'payloadExample' => "{}",
'payloadAttributeMappings' => []
'payloadAttributeMappings' => [],
'payloadAlertFields' => []
}
)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment