diff --git a/api/main.go b/api/main.go index 8f9a411..72000b0 100644 --- a/api/main.go +++ b/api/main.go @@ -116,7 +116,8 @@ func (a *API) refreshHandler(c echo.Context) error { // @Summary Prometheus service discovery // @Description Return one nodes based on given hostname // @Produce application/json -// @Success 200 {array} []prometheusDiscovery "Node details" +// @Param service path string true "Name of the service like: systemd, pgsql, .." +// @Success 200 {array} []nodes.prometheusDiscovery "Node details" // @Failure 401 {object} Message "Forbidden access" // @Security Bearer // @Router /prometheus/{service} [get] diff --git a/docs/docs.go b/docs/docs.go index b1670d7..defdffa 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -145,6 +145,49 @@ const docTemplate = `{ } } } + }, + "/prometheus/{service}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Return one nodes based on given hostname", + "produces": [ + "application/json" + ], + "summary": "Prometheus service discovery", + "parameters": [ + { + "type": "string", + "description": "Name of the service like: systemd, pgsql, ..", + "name": "service", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Node details", + "schema": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/nodes.prometheusDiscovery" + } + } + } + }, + "401": { + "description": "Forbidden access", + "schema": { + "$ref": "#/definitions/api.Message" + } + } + } + } } }, "definitions": { @@ -181,6 +224,23 @@ const docTemplate = `{ "type": "integer" } } + }, + "nodes.prometheusDiscovery": { + "type": "object", + "properties": { + "Labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Targets": { + "type": "array", + "items": { + "type": "string" + } + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.json b/docs/swagger.json index e5dba6b..0731def 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -137,6 +137,49 @@ } } } + }, + "/prometheus/{service}": { + "get": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Return one nodes based on given hostname", + "produces": [ + "application/json" + ], + "summary": "Prometheus service discovery", + "parameters": [ + { + "type": "string", + "description": "Name of the service like: systemd, pgsql, ..", + "name": "service", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "Node details", + "schema": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/nodes.prometheusDiscovery" + } + } + } + }, + "401": { + "description": "Forbidden access", + "schema": { + "$ref": "#/definitions/api.Message" + } + } + } + } } }, "definitions": { @@ -173,6 +216,23 @@ "type": "integer" } } + }, + "nodes.prometheusDiscovery": { + "type": "object", + "properties": { + "Labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "Targets": { + "type": "array", + "items": { + "type": "string" + } + } + } } }, "securityDefinitions": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 69e6d8c..5f8ebd8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -22,6 +22,17 @@ definitions: last_update: type: integer type: object + nodes.prometheusDiscovery: + properties: + Labels: + additionalProperties: + type: string + type: object + Targets: + items: + type: string + type: array + type: object info: contact: {} description: API of Lobby 2 project that helps to discover and connect to other @@ -111,6 +122,33 @@ paths: security: - Bearer: [] summary: Refresh node + /prometheus/{service}: + get: + description: Return one nodes based on given hostname + parameters: + - description: 'Name of the service like: systemd, pgsql, ..' + in: path + name: service + required: true + type: string + produces: + - application/json + responses: + "200": + description: Node details + schema: + items: + items: + $ref: '#/definitions/nodes.prometheusDiscovery' + type: array + type: array + "401": + description: Forbidden access + schema: + $ref: '#/definitions/api.Message' + security: + - Bearer: [] + summary: Prometheus service discovery securityDefinitions: Bearer: in: header