Commit cfcd67b8 authored by Sean Arnold's avatar Sean Arnold

Add documentation, remove unused code

parent 829f9695
......@@ -11,6 +11,36 @@ This is the documentation of Alert Management Alerts API.
NOTE:
This API is limited to metric images. For more API endpoints please refer to the [GraphQL API](graphql/reference/index.md#alertmanagementalert).
## Upload metric image
```plaintext
POST /projects/:id/alert_management_alerts/:alert_iid/metric_images
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|--------------------------------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `alert_iid` | integer | yes | The internal ID of a project's alert |
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --form 'file=@/path/to/file.png' \
--form 'url=http://example.com' --form 'url_text=Example website' "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images"
```
Example response:
```json
{
"id": 17,
"created_at": "2020-11-12T20:07:58.156Z",
"filename": "sample_2054",
"file_path": "/uploads/-/system/alert_metric_image/file/17/sample_2054.png",
"url": "example.com/metric",
"url_text": "An example metric"
}
```
## List metric images
```plaintext
......@@ -48,3 +78,34 @@ Example response:
}
]
```
## Update metric image
```plaintext
PUT /projects/:id/alert_management_alerts/:alert_iid/metric_image/:image_id
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|--------------------------------------|
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `alert_iid` | integer | yes | The internal ID of a project's alert |
| `image_id` | integer | yes | The ID of the image |
| `url` | string | no | The URL to view more metric information |
| `url_text` | string | no | A description of the image or URL |
```shell
curl --header "PRIVATE-TOKEN: <your_access_token>" --request PUT --form 'url=http://example.com' --form 'url_text=Example website' "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images/1"
```
Example response:
```json
{
"id": 23,
"created_at": "2020-11-13T00:06:18.084Z",
"filename": "file.png",
"file_path": "/uploads/-/system/alert_metric_image/file/23/file.png",
"url": "http://example.com",
"url_text": "Example website"
}
```
......@@ -3,13 +3,12 @@
module AlertManagement
module MetricImages
class UploadService < BaseService
attr_reader :alert, :project, :file, :url, :url_text, :metric
attr_reader :alert, :file, :url, :url_text, :metric
def initialize(alert, current_user, params = {})
super
@alert = alert
@project = alert&.project
@file = params.fetch(:file)
@url = params.fetch(:url, nil)
@url_text = params.fetch(:url_text, nil)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment