Add GraphQL support for updating alert integrations
What does this MR do?
Issues: #255515 (closed), #245332 (closed)
This MR adds two new mutations for managing alerting integrations - update & reset_token mutations for both Prometheus integrations and HTTP integrations.
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'
- Failure to update the integration: 200 OK, but errors includes message related to what might have gone wrong
Sample mutation info for httpIntegrationUpdate
Sample Mutation:
mutation updateHttp($input: HttpIntegrationUpdateInput!) {
httpIntegrationUpdate(input: $input) {
integration {
active
apiUrl
url
name
token
id
}
errors
}
}
Sample Input:
{
"input": {
"id": "gid://gitlab/AlertManagement::HttpIntegration/120040",
"active": false,
"name": "Name modified via API"
}
}
Sample Response:
{
"data": {
"httpIntegrationUpdate": {
"integration": {
"active": false,
"apiUrl": null,
"url": "http://192.168.1.152:3000/Commit451/lab-coat/alerts/notify/name-modified-via-api/d9b54ccf55d99506.json",
"name": "Name modified via API",
"token": "c652b80195e57c5cbb71fcdbc9a79da9",
"id": "gid://gitlab/AlertManagement::HttpIntegration/120040"
},
"errors": []
}
}
}
Sample mutation info for prometheusIntegrationUpdate
Sample Mutation:
mutation updateProm($input: PrometheusIntegrationUpdateInput!) {
prometheusIntegrationUpdate(input: $input) {
integration {
active
apiUrl
url
name
token
id
}
errors
}
}
Sample Input:
{
"input": {
"id": "gid://gitlab/PrometheusService/29",
"active": false,
"apiUrl": "https://was-modified-via-api.com"
}
}
Sample Response:
{
"data": {
"prometheusIntegrationUpdate": {
"integration": {
"active": false,
"apiUrl": "https://was-modified-via-api.com",
"url": "http://192.168.1.152:3000/Commit451/lab-coat/prometheus/alerts/notify.json",
"name": "Prometheus",
"token": "e0528fe9ba1dd096307d8320d4f13186",
"id": "gid://gitlab/PrometheusService/29"
},
"errors": []
}
}
}
Sample mutation info for httpIntegrationResetToken
Sample Mutation:
mutation resetTokenHttp($input: HttpIntegrationResetTokenInput!) {
httpIntegrationResetToken(input: $input) {
integration {
active
apiUrl
url
token
id
name
}
errors
}
}
Sample Input:
{
"input": {
"id": "gid://gitlab/AlertManagement::HttpIntegration/120040"
}
}
Sample Response:
{
"data": {
"httpIntegrationResetToken": {
"integration": {
"active": false,
"apiUrl": null,
"url": "http://192.168.1.152:3000/Commit451/lab-coat/alerts/notify/name-modified-via-api/d9b54ccf55d99506.json",
"token": "d25ab41ddd9f1677a24fc806ae184e2d",
"id": "gid://gitlab/AlertManagement::HttpIntegration/120040",
"name": "Name modified via API"
},
"errors": []
}
}
}
Sample mutation info for prometheusIntegrationResetToken
Sample Mutation:
mutation resetTokenProm($input: PrometheusIntegrationResetTokenInput!) {
prometheusIntegrationResetToken(input: $input) {
integration {
active
apiUrl
url
token
id
name
}
errors
}
}
Sample Input:
{
"input": {
"id": "gid://gitlab/PrometheusService/29"
}
}
Sample Response:
{
"data": {
"prometheusIntegrationResetToken": {
"integration": {
"active": false,
"apiUrl": "https://was-modified-via-api.com",
"url": "http://192.168.1.152:3000/Commit451/lab-coat/prometheus/alerts/notify.json",
"token": "f3f6805462e54170394f9acd839a5b2e",
"id": "gid://gitlab/PrometheusService/29",
"name": "Prometheus"
},
"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 flag
- [-] 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