Add GraphQL support for creating alert integrations
What does this MR do?
Issues: #255515 (closed), #255603 (closed)
This MR adds two new mutations for managing alerting integrations - creation mutations for both Prometheus integrations and HTTP integrations. This MR also includes a base class which will house common functionality with the follow-up mutations (update/reset_token/destroy).
Expected responses:
- User doesn't have permissions: 200 OK, but errors includes 'The resource that you are attempting to access does not exist or you don't have permission to perform this action'
- A new integration isn't allowed: 200 OK, but errors includes 'Multiple Prometheus integrations are not supported' || ''Multiple HTTP integrations are not supported for this project' (for <GitLab Premium)
- Failure to create the integration: 200 OK, but errors includes message related to what might have gone wrong
Sample mutation info for httpIntegrationCreate
Sample Mutation:
mutation createHttp($input: HttpIntegrationCreateInput!) {
httpIntegrationCreate(input: $input) {
integration {
active
apiUrl
url
token
name
id
}
errors
}
}
Sample Input:
{
"input": {
"projectPath": "Commit451/lab-coat",
"name": "Helloooo dear",
"active": true
}
}
Sample Response:
{
"data": {
"httpIntegrationCreate": {
"integration": {
"active": true,
"apiUrl": null,
"url": "http://192.168.1.152:3000/Commit451/lab-coat/alerts/notify/helloooo-dear/d9b54ccf55d99506.json",
"token": "c652b80195e57c5cbb71fcdbc9a79da9",
"name": "Helloooo dear",
"id": "gid://gitlab/AlertManagement::HttpIntegration/120040"
},
"errors": []
}
}
}
Sample mutation info for prometheusIntegrationCreate
Sample Mutation:
mutation createProm($input: PrometheusIntegrationCreateInput!) {
prometheusIntegrationCreate(input: $input) {
integration {
active
apiUrl
url
token
name
id
}
errors
}
}
Sample Input:
{
"input": {
"projectPath": "Commit451/lab-coat",
"active": true,
"apiUrl": "https://prometheus-is-da-bomb.com"
}
}
Sample Response:
{
"data": {
"prometheusIntegrationCreate": {
"integration": {
"active": true,
"apiUrl": "https://prometheus-is-da-bomb.com",
"url": "http://192.168.1.152:3000/Commit451/lab-coat/prometheus/alerts/notify.json",
"token": "e0528fe9ba1dd096307d8320d4f13186",
"name": "Prometheus",
"id": "gid://gitlab/PrometheusService/29"
},
"errors": []
}
}
}
Sibling MRs:
- Query: !45622 (merged)
- Create Mutation: !45842 (merged)
- Update/Reset token Mutations: !45844 (merged)
- Destroy Mutation: !45843 (merged) (HTTP integrations only)
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry - feature flagged
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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 Sarah Yasonik