yats.git

commit 5afe7695f8c71bda069c2d8fd0e8cffc270d43b7

Author: Paolo Lulli <paolo@lulli.net>

Add endpoint for grafana-json

%!v(PANIC=String method: strings: negative Repeat count)


diff --git a/server/config/config.go b/server/config/config.go
index f355329e7975fb46c3bae7a500605f9167dace43..eb79fec7366c8746a75ae7184a2a46688b960c34 100644
--- a/server/config/config.go
+++ b/server/config/config.go
@@ -54,7 +54,8 @@ 	TlsKeyFile     string `json:"tlsKeyFile"`
 	TlsCertificate string `json:"tlsCertificate"`
 	TlsCA          string `json:"tlsCA"`
 
-	LogFile string `json:"logFile"`
+	LogFile       string `json:"logFile"`
+	GrafanaActive string `json:"grafanaActive"`
 }
 
 func GetConfig(fileName string) Configuration {




diff --git a/server/grafana/README.md b/server/grafana/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..89976d8485e045b3a8d77c583e78cdc15778d8f7
--- /dev/null
+++ b/server/grafana/README.md
@@ -0,0 +1,41 @@
+# Go API Server for openapi
+
+API definition for the Grafana plugin simpod json datasource https://github.com/simPod/grafana-json-datasource
+
+## Overview
+This server was generated by the [openapi-generator]
+(https://openapi-generator.tech) project.
+By using the [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate a server stub.
+-
+
+To see how to make this your own, look here:
+
+[README](https://openapi-generator.tech)
+
+- API version: 0.1
+- Build date: 2024-08-02T00:52:32.279604829+02:00[Europe/Stockholm]
+- Generator version: 7.7.0
+
+### Running the server
+
+To run the server, follow these simple steps:
+
+```
+go run main.go
+```
+
+To run the server in a docker container
+```
+docker build --network=host -t openapi .
+```
+
+Once the image is built, just run
+```
+docker run --rm -it openapi
+```
+
+### Known Issue
+
+Endpoints sharing a common path may result in issues. For example, `/v2/pet/findByTags` and `/v2/pet/:petId` will result in an issue with the Gin framework. For more information about this known limitation, please refer to [gin-gonic/gin#388](https://github.com/gin-gonic/gin/issues/388) for more information.
+
+A workaround is to manually update the path and handler. Please refer to [gin-gonic/gin/issues/205#issuecomment-296155497](https://github.com/gin-gonic/gin/issues/205#issuecomment-296155497) for more information.




diff --git a/server/grafana/api_ad_hoc_filters.go b/server/grafana/api_ad_hoc_filters.go
new file mode 100644
index 0000000000000000000000000000000000000000..f8e7c5cb3a3708686ce17b7fc7ac69c2a0e1c885
--- /dev/null
+++ b/server/grafana/api_ad_hoc_filters.go
@@ -0,0 +1,42 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+import (
+	"github.com/gin-gonic/gin"
+	"net/http"
+)
+
+type AdHocFiltersAPI struct {
+}
+
+// Post /tag-keys
+// Keys for ad hoc filters
+func (api *AdHocFiltersAPI) ApiEndpointsTagKeys(c *gin.Context) {
+	//EMPTY REQUEST {}
+	var response = []ApiEndpointsTagKeys200ResponseInner{}
+
+	c.JSON(200, response)
+	return
+}
+
+// Post /tag-values
+// Values for ad hoc filters
+func (api *AdHocFiltersAPI) ApiEndpointsTagValues(c *gin.Context) {
+	var request ApiEndpointsTagValuesRequest
+	err := c.ShouldBindJSON(&request)
+	if err != nil {
+		return
+	}
+
+	c.JSON(http.StatusBadRequest, gin.H{"status": "Not implemented"})
+	return
+}




diff --git a/server/grafana/api_health_check.go b/server/grafana/api_health_check.go
new file mode 100644
index 0000000000000000000000000000000000000000..2ef879bba7b0e02659fc073ae747b46da73775db
--- /dev/null
+++ b/server/grafana/api_health_check.go
@@ -0,0 +1,24 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+type HealthCheckAPI struct {
+}
+
+// Get /
+// Test connection
+func (api *HealthCheckAPI) ApiEndpointsDatasourceHealth(c *gin.Context) {
+	c.JSON(200, gin.H{"status": "OK"})
+}




diff --git a/server/grafana/api_variable.go b/server/grafana/api_variable.go
new file mode 100644
index 0000000000000000000000000000000000000000..bbe5bea0367c39f1f62de190899305008542dc36
--- /dev/null
+++ b/server/grafana/api_variable.go
@@ -0,0 +1,25 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+type VariableAPI struct {
+}
+
+// Post /variable
+// Variable
+func (api *VariableAPI) ApiEndpointsVariable(c *gin.Context) {
+	// Your handler implementation
+	c.JSON(200, gin.H{"status": "OK"})
+}




diff --git a/server/grafana/api_visualization.go b/server/grafana/api_visualization.go
new file mode 100644
index 0000000000000000000000000000000000000000..bad3928c36cced9700f14962a38083dfa67ea4c9
--- /dev/null
+++ b/server/grafana/api_visualization.go
@@ -0,0 +1,39 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+import (
+	"github.com/gin-gonic/gin"
+)
+
+type VisualizationAPI struct {
+}
+
+// Post /metric-payload-options
+// List the available payload options.
+func (api *VisualizationAPI) ApiEndpointsListMetricPayloadOptions(c *gin.Context) {
+	// Your handler implementation
+	c.JSON(200, gin.H{"status": "OK"})
+}
+
+// Post /metrics
+// List available metrics
+func (api *VisualizationAPI) ApiEndpointsListMetrics(c *gin.Context) {
+	// Your handler implementation
+	c.JSON(200, gin.H{"status": "OK"})
+}
+
+// Post /query
+// Query
+func (api *VisualizationAPI) ApiEndpointsQuery(c *gin.Context) {
+	// Your handler implementation
+	c.JSON(200, gin.H{"status": "OK"})
+}




diff --git a/server/grafana/model_api_endpoints_list_metric_payload_options_200_response_inner.go b/server/grafana/model_api_endpoints_list_metric_payload_options_200_response_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..3aa961b061a06cceb4cf454a8a00a12c580ae841
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metric_payload_options_200_response_inner.go
@@ -0,0 +1,20 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetricPayloadOptions200ResponseInner struct {
+
+	// The label of the option in the drop-down box. If the value is empty, use the value as the label.
+	Label string `json:"label,omitempty"`
+
+	// The value of the option in the drop-down box.
+	Value string `json:"value"`
+}




diff --git a/server/grafana/model_api_endpoints_list_metric_payload_options_request.go b/server/grafana/model_api_endpoints_list_metric_payload_options_request.go
new file mode 100644
index 0000000000000000000000000000000000000000..defd3a864352ddef2cc117279e23392eed85096c
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metric_payload_options_request.go
@@ -0,0 +1,23 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetricPayloadOptionsRequest struct {
+
+	// Current metric.
+	Metric string `json:"metric"`
+
+	// Current payload.
+	Payload map[string]interface{} `json:"payload"`
+
+	// The payload name of the option list needs to be obtained.
+	Name string `json:"name"`
+}




diff --git a/server/grafana/model_api_endpoints_list_metrics_200_response_inner.go b/server/grafana/model_api_endpoints_list_metrics_200_response_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..112a604c37421426acf1412039b0c13a64c43db1
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metrics_200_response_inner.go
@@ -0,0 +1,23 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetrics200ResponseInner struct {
+
+	// If the value is empty, use the value as the label
+	Label string `json:"label,omitempty"`
+
+	// The value of the option.
+	Value string `json:"value"`
+
+	// Configuration parameters of the payload.
+	Payloads []ApiEndpointsListMetrics200ResponseInnerPayloadsInner `json:"payloads"`
+}




diff --git a/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner.go b/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..42d4146eef19042c015d9e402ee348cb1f7684ad
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner.go
@@ -0,0 +1,35 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetrics200ResponseInnerPayloadsInner struct {
+
+	// The label of the payload. If the value is empty, use the name as the label.
+	Label string `json:"label,omitempty"`
+
+	// The name of the payload.
+	Name string `json:"name"`
+
+	// If the value is select, the UI of the payload is a radio box. If the value is multi-select, the UI of the payload is a multi selection box. if the value is input, the UI of the payload is an input box. if the value is textarea, the UI of the payload is a multiline input box. The default is input.
+	Type string `json:"type,omitempty"`
+
+	// Input box / selection box prompt information.
+	Placeholder string `json:"placeholder,omitempty"`
+
+	// Whether to overload the metrics API after modifying the value of the payload.
+	ReloadMetric bool `json:"reloadMetric,omitempty"`
+
+	// Set the input / selection box width to a multiple of 8px.
+	Width int32 `json:"width,omitempty"`
+
+	// If the payload type is select / multi-select, the list is the configuration of the option list.
+	Options []ApiEndpointsListMetrics200ResponseInnerPayloadsInnerOptionsInner `json:"options,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner_options_inner.go b/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner_options_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..a54b127a0065e8c8c3037dddade1c3df2d49fed3
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metrics_200_response_inner_payloads_inner_options_inner.go
@@ -0,0 +1,20 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetrics200ResponseInnerPayloadsInnerOptionsInner struct {
+
+	// The label of the payload select option.
+	Label string `json:"label,omitempty"`
+
+	// The label of the payload value.
+	Value string `json:"value"`
+}




diff --git a/server/grafana/model_api_endpoints_list_metrics_request.go b/server/grafana/model_api_endpoints_list_metrics_request.go
new file mode 100644
index 0000000000000000000000000000000000000000..4e193255f5b5478a4470146a90b9c5b501d1499a
--- /dev/null
+++ b/server/grafana/model_api_endpoints_list_metrics_request.go
@@ -0,0 +1,20 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsListMetricsRequest struct {
+
+	// The currently selected Metric option.
+	Metric string `json:"metric,omitempty"`
+
+	// The currently selected/entered payload options and values. Key is the name of the payload, and value is the value of the payload.
+	Payload map[string]interface{} `json:"payload,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_query_200_response_inner.go b/server/grafana/model_api_endpoints_query_200_response_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..cb39d5f72c197fae50589e89c52fc04a15522a50
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_200_response_inner.go
@@ -0,0 +1,23 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQuery200ResponseInner struct {
+	Target string `json:"target"`
+
+	Datapoints [][]float32 `json:"datapoints"`
+
+	Type string `json:"type"`
+
+	Columns []ApiEndpointsQuery200ResponseInnerAnyOf1ColumnsInner `json:"columns"`
+
+	Rows []ApiEndpointsQuery200ResponseInnerAnyOf1RowsInner `json:"rows"`
+}




diff --git a/server/grafana/model_api_endpoints_query_200_response_inner_any_of.go b/server/grafana/model_api_endpoints_query_200_response_inner_any_of.go
new file mode 100644
index 0000000000000000000000000000000000000000..35904f5424496ee80876bfc38a463970be7e8a08
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_200_response_inner_any_of.go
@@ -0,0 +1,18 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+// ApiEndpointsQuery200ResponseInnerAnyOf - timeseries case
+type ApiEndpointsQuery200ResponseInnerAnyOf struct {
+	Target string `json:"target"`
+
+	Datapoints [][]float32 `json:"datapoints"`
+}




diff --git a/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1.go b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1.go
new file mode 100644
index 0000000000000000000000000000000000000000..9441855d4cdb64fb97bad9d1c91cf03ed6ddaaf6
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1.go
@@ -0,0 +1,20 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+// ApiEndpointsQuery200ResponseInnerAnyOf1 - table case
+type ApiEndpointsQuery200ResponseInnerAnyOf1 struct {
+	Type string `json:"type"`
+
+	Columns []ApiEndpointsQuery200ResponseInnerAnyOf1ColumnsInner `json:"columns"`
+
+	Rows []ApiEndpointsQuery200ResponseInnerAnyOf1RowsInner `json:"rows"`
+}




diff --git a/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_columns_inner.go b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_columns_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..9526c12177783b5792cc34e4426f7854e705cff8
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_columns_inner.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQuery200ResponseInnerAnyOf1ColumnsInner struct {
+	Text string `json:"text"`
+
+	Type string `json:"type,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_rows_inner.go b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_rows_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..ac62d9c3164a6651d3e5402008b28d5130a53e86
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_200_response_inner_any_of_1_rows_inner.go
@@ -0,0 +1,14 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQuery200ResponseInnerAnyOf1RowsInner struct {
+}




diff --git a/server/grafana/model_api_endpoints_query_request.go b/server/grafana/model_api_endpoints_query_request.go
new file mode 100644
index 0000000000000000000000000000000000000000..29ea767527d45e5715d0b04deb2aa22c10c11ec6
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_request.go
@@ -0,0 +1,31 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQueryRequest struct {
+	PanelId ApiEndpointsQueryRequestPanelId `json:"panelId,omitempty"`
+
+	Range ApiEndpointsQueryRequestRange `json:"range,omitempty"`
+
+	RangeRaw RawTimeFrame `json:"rangeRaw,omitempty"`
+
+	Interval string `json:"interval,omitempty"`
+
+	IntervalMs float32 `json:"intervalMs,omitempty"`
+
+	MaxDataPoints float32 `json:"maxDataPoints,omitempty"`
+
+	Targets []ApiEndpointsQueryRequestTargetsInner `json:"targets,omitempty"`
+
+	ScopedVars map[string]interface{} `json:"scopedVars,omitempty"`
+
+	AdhocFilters []ApiEndpointsQueryRequestAdhocFiltersInner `json:"adhocFilters,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_query_request_adhoc_filters_inner.go b/server/grafana/model_api_endpoints_query_request_adhoc_filters_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..065e9fc286ac25394635ff472f5fe5d695b81ad3
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_request_adhoc_filters_inner.go
@@ -0,0 +1,19 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQueryRequestAdhocFiltersInner struct {
+	Key string `json:"key,omitempty"`
+
+	Operator string `json:"operator,omitempty"`
+
+	Value string `json:"value,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_query_request_panel_id.go b/server/grafana/model_api_endpoints_query_request_panel_id.go
new file mode 100644
index 0000000000000000000000000000000000000000..ebc7a038195c5daabcc55c797dda7a79115bf271
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_request_panel_id.go
@@ -0,0 +1,16 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+// "gopkg.in/validator.v2"
+
+type ApiEndpointsQueryRequestPanelId struct {
+}




diff --git a/server/grafana/model_api_endpoints_query_request_range.go b/server/grafana/model_api_endpoints_query_request_range.go
new file mode 100644
index 0000000000000000000000000000000000000000..dcf4b8fd4b1af5b05e2e16b97d18bdf2165d92db
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_request_range.go
@@ -0,0 +1,23 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+import (
+	"time"
+)
+
+type ApiEndpointsQueryRequestRange struct {
+	From time.Time `json:"from,omitempty"`
+
+	To time.Time `json:"to,omitempty"`
+
+	Raw RawTimeFrame `json:"raw,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_query_request_targets_inner.go b/server/grafana/model_api_endpoints_query_request_targets_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..7ada20e7863b502ffdc15d43da8350ceb1c41ed9
--- /dev/null
+++ b/server/grafana/model_api_endpoints_query_request_targets_inner.go
@@ -0,0 +1,20 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsQueryRequestTargetsInner struct {
+	Target string `json:"target"`
+
+	RefId string `json:"refId,omitempty"`
+
+	// arbitrary \"additional data\" the user can pass in
+	Payload map[string]interface{} `json:"payload,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_tag_keys_200_response_inner.go b/server/grafana/model_api_endpoints_tag_keys_200_response_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..56678306e58b4e546c0d4cf2606c6d300f45dcd4
--- /dev/null
+++ b/server/grafana/model_api_endpoints_tag_keys_200_response_inner.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsTagKeys200ResponseInner struct {
+	Type string `json:"type,omitempty"`
+
+	Text string `json:"text,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_tag_values_request.go b/server/grafana/model_api_endpoints_tag_values_request.go
new file mode 100644
index 0000000000000000000000000000000000000000..c45b9456a8a53098413e0e21cd11992a9aae915c
--- /dev/null
+++ b/server/grafana/model_api_endpoints_tag_values_request.go
@@ -0,0 +1,15 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsTagValuesRequest struct {
+	Key string `json:"key"`
+}




diff --git a/server/grafana/model_api_endpoints_variable_200_response.go b/server/grafana/model_api_endpoints_variable_200_response.go
new file mode 100644
index 0000000000000000000000000000000000000000..e3a699106f7d4da1a0bee3c290713573e5ba5863
--- /dev/null
+++ b/server/grafana/model_api_endpoints_variable_200_response.go
@@ -0,0 +1,15 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsVariable200Response struct {
+	Fields []DataframeFieldsInner `json:"fields"`
+}




diff --git a/server/grafana/model_api_endpoints_variable_200_response_one_of_inner.go b/server/grafana/model_api_endpoints_variable_200_response_one_of_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..921cd1a87a4b7b58baf5e937a9044f16dd183ea6
--- /dev/null
+++ b/server/grafana/model_api_endpoints_variable_200_response_one_of_inner.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsVariable200ResponseOneOfInner struct {
+	Text string `json:"__text,omitempty"`
+
+	Value string `json:"__value,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_variable_request.go b/server/grafana/model_api_endpoints_variable_request.go
new file mode 100644
index 0000000000000000000000000000000000000000..81c1618bd325eed04a7857e29dfd4f94d5212931
--- /dev/null
+++ b/server/grafana/model_api_endpoints_variable_request.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsVariableRequest struct {
+	Payload ApiEndpointsVariableRequestPayload `json:"payload,omitempty"`
+
+	Range ApiEndpointsQueryRequestRange `json:"range,omitempty"`
+}




diff --git a/server/grafana/model_api_endpoints_variable_request_payload.go b/server/grafana/model_api_endpoints_variable_request_payload.go
new file mode 100644
index 0000000000000000000000000000000000000000..d3beb92f70fcb8364e42f864be82a50d2b39d3e7
--- /dev/null
+++ b/server/grafana/model_api_endpoints_variable_request_payload.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type ApiEndpointsVariableRequestPayload struct {
+	Target string `json:"target"`
+
+	Variables map[string]interface{} `json:"variables,omitempty"`
+}




diff --git a/server/grafana/model_dataframe.go b/server/grafana/model_dataframe.go
new file mode 100644
index 0000000000000000000000000000000000000000..f3f46857d34f0ed3794afb07e40b19ceb016aafe
--- /dev/null
+++ b/server/grafana/model_dataframe.go
@@ -0,0 +1,15 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type Dataframe struct {
+	Fields []DataframeFieldsInner `json:"fields"`
+}




diff --git a/server/grafana/model_dataframe_fields_inner.go b/server/grafana/model_dataframe_fields_inner.go
new file mode 100644
index 0000000000000000000000000000000000000000..0670a33a102055d8cc8d51e69091b5aa88280975
--- /dev/null
+++ b/server/grafana/model_dataframe_fields_inner.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type DataframeFieldsInner struct {
+	Name string `json:"name"`
+
+	Values []interface{} `json:"values"`
+}




diff --git a/server/grafana/model_raw_time_frame.go b/server/grafana/model_raw_time_frame.go
new file mode 100644
index 0000000000000000000000000000000000000000..2f7797a88850ddc40b01965cc105f46d23ef5f90
--- /dev/null
+++ b/server/grafana/model_raw_time_frame.go
@@ -0,0 +1,17 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+
+package grafana
+
+type RawTimeFrame struct {
+	From string `json:"from,omitempty"`
+
+	To string `json:"to,omitempty"`
+}




diff --git a/server/grafana.go b/server/grafana.go
new file mode 100644
index 0000000000000000000000000000000000000000..6d399418a88ad8ab613c4364b5e169b7c5c16c28
--- /dev/null
+++ b/server/grafana.go
@@ -0,0 +1,33 @@
+/**
+ * Yats - yats
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Paolo Lulli <kevwe.com>
+ * @copyright Paolo Lulli 2024
+ */
+package main
+
+import (
+	"github.com/gin-gonic/gin"
+	"yats-server/grafana"
+)
+
+func enableGrafanaEndpoint(router *gin.Engine) {
+	adHocFiltersAPI := grafana.AdHocFiltersAPI{}
+	variableAPI := grafana.VariableAPI{}
+	visualizationAPI := grafana.VisualizationAPI{}
+	healthcheckApi := grafana.HealthCheckAPI{}
+
+	router.GET("/", healthcheckApi.ApiEndpointsDatasourceHealth)
+	//
+	router.POST("/tag-keys", adHocFiltersAPI.ApiEndpointsTagKeys)
+	router.POST("/tag-values", adHocFiltersAPI.ApiEndpointsTagValues)
+	//
+	router.POST("/variable", variableAPI.ApiEndpointsVariable)
+	//
+	router.POST("/metrics", visualizationAPI.ApiEndpointsListMetrics)
+	router.POST("/query", visualizationAPI.ApiEndpointsQuery)
+	router.POST("/metric-payload-options", visualizationAPI.ApiEndpointsListMetricPayloadOptions)
+}




diff --git a/server/service-rest.go b/server/service-rest.go
index e5dd75ce3689905199846e853b234ac5ba04071a..06a6fc9560a0768f3ea5720ea8934b994b2f4b81 100644
--- a/server/service-rest.go
+++ b/server/service-rest.go
@@ -41,6 +41,10 @@ 	router.POST("/position", rest.WritePosition(cfg))
 
 	enableSwaggerEndpoint(router)
 
+	if cfg.GrafanaActive == "true" {
+		enableGrafanaEndpoint(router)
+	}
+
 	if cfg.TlsActive == "true" {
 		router.RunTLS(address, cfg.TlsCertificate, cfg.TlsKeyFile)
 	} else {