Backend: Basic Implementation of annotations CRUD
Summary
As a part of the annotations feature, we need to define an annotations model in the backend.
The backend should support creating, reading, updating and deleting an annotation record. These operations need not expose an API yet. There is another issue for that.
Technical details
Note: As for ~12.10 panels don't have a unique Id. https://gitlab.com/gitlab-org/gitlab/-/issues/210286
issue handles how panel Id will be implemented.
Create
Annotation can be associated to a panel with a panel Id or dashboard Id. Create method should accept the attributes listed in the table below
Read
Similar to create, annotations should be fetched by panel or dashboard Id.
Crazy Idea: I wonder if passing time range can be more efficient for the backend.
Update
Annotations description and tags should be editable.
Delete
Annotations should be deletable based on panel/dashboard Id.
Annotation model
Below are all the fields that annotation supports. This excerpt is from #205091 (comment 302202307)
Field | Type | Description |
---|---|---|
Id (required) | Integer | Unique Id for an annotations object |
From (required) | Datetime | If the annotation is a plot band, this is where the annotations begin from. If annotations is a plotline, this is where the annotations line exists |
To (optional) | Datetime | If annotation is a plot band, this is where the annotations ends. If annotations is a plotline, this value is null |
Dashboard_id (required) | String | The dashboard an annotation belongs to |
Panel_id (optional) | String | The panel to which annotation belongs to. If panel Id exists then dashboard Id is expected to be defined as well. (Mainly for performance reasons) |
Tags (optional) | Array | Needs further investigation. |
Description (required) | String | Text describing given annotation |
Environment_id(required) | Integer | Foreign key to environments table. It identifies environment entry owning annotations. We need to add this to scope annotations to right accounts / usersPresence is mutually exclusive with_cluster_id_ |
Cluster_id (required) | Integer | Foreign key to cluster table. It identifies environment entry owning annotations. We need to add this to scope annotations to right accounts / usersPresence is mutually exclusive with_environment_id_ |
Refer to #205091 (comment 302202307) for more information about the rationale.