mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2026-03-13 03:57:30 +01:00
Upgrade dependencies. Prepare 1.5.0 release
Entire-Checkpoint: 37abb99fe6a7
This commit is contained in:
25
internal/api/api.go
Normal file
25
internal/api/api.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved. This file is part of cc-metric-store.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package api provides the REST API for cc-metric-store.
|
||||
//
|
||||
// @title cc-metric-store REST API
|
||||
// @version 1.0.0
|
||||
// @description API for cc-metric-store
|
||||
//
|
||||
// @contact.name ClusterCockpit Project
|
||||
// @contact.url https://clustercockpit.org
|
||||
// @contact.email support@clustercockpit.org
|
||||
//
|
||||
// @license.name MIT License
|
||||
// @license.url https://opensource.org/licenses/MIT
|
||||
//
|
||||
// @host localhost:8082
|
||||
// @basePath /api/
|
||||
//
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
// @name X-Auth-Token
|
||||
package api
|
||||
@@ -1,8 +1,3 @@
|
||||
// Copyright (C) NHR@FAU, University Erlangen-Nuremberg.
|
||||
// All rights reserved. This file is part of cc-metric-store.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package api Code generated by swaggo/swag. DO NOT EDIT
|
||||
package api
|
||||
|
||||
@@ -30,11 +25,6 @@ const docTemplate = `{
|
||||
"paths": {
|
||||
"/debug/": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "This endpoint allows the users to print the content of",
|
||||
"produces": [
|
||||
"application/json"
|
||||
@@ -82,16 +72,16 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/api.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/free/": {
|
||||
"post": {
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
},
|
||||
"/free/": {
|
||||
"post": {
|
||||
"description": "This endpoint allows the users to free the Buffers from the",
|
||||
"produces": [
|
||||
"application/json"
|
||||
@@ -138,16 +128,16 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/api.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/healthcheck/": {
|
||||
"get": {
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
},
|
||||
"/healthcheck/": {
|
||||
"get": {
|
||||
"description": "This endpoint allows the users to check if a node is healthy",
|
||||
"produces": [
|
||||
"application/json"
|
||||
@@ -195,16 +185,16 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/api.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/query/": {
|
||||
"get": {
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
},
|
||||
"/query/": {
|
||||
"get": {
|
||||
"description": "This endpoint allows the users to retrieve data from the",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -223,7 +213,7 @@ const docTemplate = `{
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.ApiQueryRequest"
|
||||
"$ref": "#/definitions/api.APIQueryRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -231,7 +221,7 @@ const docTemplate = `{
|
||||
"200": {
|
||||
"description": "API query response object",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.ApiQueryResponse"
|
||||
"$ref": "#/definitions/api.APIQueryResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -258,16 +248,16 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/api.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/write/": {
|
||||
"post": {
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
},
|
||||
"/write/": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"text/plain"
|
||||
],
|
||||
@@ -313,12 +303,17 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/api.ErrorResponse"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"api.ApiMetricData": {
|
||||
"api.APIMetricData": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"avg": {
|
||||
@@ -350,7 +345,7 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.ApiQuery": {
|
||||
"api.APIQuery": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"aggreg": {
|
||||
@@ -388,7 +383,7 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.ApiQueryRequest": {
|
||||
"api.APIQueryRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"cluster": {
|
||||
@@ -406,7 +401,7 @@ const docTemplate = `{
|
||||
"queries": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ApiQuery"
|
||||
"$ref": "#/definitions/api.APIQuery"
|
||||
}
|
||||
},
|
||||
"to": {
|
||||
@@ -423,13 +418,13 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.ApiQueryResponse": {
|
||||
"api.APIQueryResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"queries": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ApiQuery"
|
||||
"$ref": "#/definitions/api.APIQuery"
|
||||
}
|
||||
},
|
||||
"results": {
|
||||
@@ -437,7 +432,7 @@ const docTemplate = `{
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ApiMetricData"
|
||||
"$ref": "#/definitions/api.APIMetricData"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ func handleError(err error, statusCode int, rw http.ResponseWriter) {
|
||||
|
||||
type APIMetricData struct {
|
||||
Error *string `json:"error,omitempty"`
|
||||
Data schema.FloatArray `json:"data,omitempty"`
|
||||
Data schema.FloatArray `json:"data,omitempty" swaggertype:"array,number"`
|
||||
From int64 `json:"from"`
|
||||
To int64 `json:"to"`
|
||||
Resolution int64 `json:"resolution"`
|
||||
Avg schema.Float `json:"avg"`
|
||||
Min schema.Float `json:"min"`
|
||||
Max schema.Float `json:"max"`
|
||||
Avg schema.Float `json:"avg" swaggertype:"number"`
|
||||
Min schema.Float `json:"min" swaggertype:"number"`
|
||||
Max schema.Float `json:"max" swaggertype:"number"`
|
||||
}
|
||||
|
||||
// TODO: Optimize this, just like the stats endpoint!
|
||||
@@ -141,7 +141,7 @@ type APIQuery struct {
|
||||
Resolution int64 `json:"resolution"`
|
||||
TypeIds []string `json:"type-ids,omitempty"`
|
||||
SubTypeIds []string `json:"subtype-ids,omitempty"`
|
||||
ScaleFactor schema.Float `json:"scale-by,omitempty"`
|
||||
ScaleFactor schema.Float `json:"scale-by,omitempty" swaggertype:"number"`
|
||||
Aggregate bool `json:"aggreg"`
|
||||
}
|
||||
|
||||
@@ -153,12 +153,12 @@ type APIQuery struct {
|
||||
// specified interval requested by the user
|
||||
// @accept json
|
||||
// @produce json
|
||||
// @param request body api.ApiQueryRequest true "API query payload object"
|
||||
// @success 200 {object} api.ApiQueryResponse "API query response object"
|
||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
||||
// @param request body APIQueryRequest true "API query payload object"
|
||||
// @success 200 {object} APIQueryResponse "API query response object"
|
||||
// @failure 400 {object} ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} ErrorResponse "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /query/ [get]
|
||||
func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
||||
@@ -298,10 +298,10 @@ func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
||||
// @produce json
|
||||
// @param to query string false "up to timestamp"
|
||||
// @success 200 {string} string "ok"
|
||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
||||
// @failure 400 {object} ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} ErrorResponse "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /free/ [post]
|
||||
func freeMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
@@ -350,10 +350,10 @@ func freeMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
// @produce json
|
||||
// @param cluster query string false "If the lines in the body do not have a cluster tag, use this value instead."
|
||||
// @success 200 {string} string "ok"
|
||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
||||
// @failure 400 {object} ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} ErrorResponse "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /write/ [post]
|
||||
func writeMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
@@ -383,10 +383,10 @@ func writeMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
// @produce json
|
||||
// @param selector query string false "Selector"
|
||||
// @success 200 {string} string "Debug dump"
|
||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
||||
// @failure 400 {object} ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} ErrorResponse "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /debug/ [post]
|
||||
func debugMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
@@ -411,10 +411,10 @@ func debugMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
// @produce json
|
||||
// @param selector query string false "Selector"
|
||||
// @success 200 {string} string "Debug dump"
|
||||
// @failure 400 {object} api.ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} api.ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} api.ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} api.ErrorResponse "Internal Server Error"
|
||||
// @failure 400 {object} ErrorResponse "Bad Request"
|
||||
// @failure 401 {object} ErrorResponse "Unauthorized"
|
||||
// @failure 403 {object} ErrorResponse "Forbidden"
|
||||
// @failure 500 {object} ErrorResponse "Internal Server Error"
|
||||
// @security ApiKeyAuth
|
||||
// @router /healthcheck/ [get]
|
||||
func metricsHealth(rw http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user