mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 07:57:13 +08:00
Allow to select a specific log history entry by its create date
This commit is contained in:
41
docs/docs.go
41
docs/docs.go
@@ -1641,6 +1641,47 @@ const docTemplate = `{
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.ProcessReport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/process/{id}/report/{at}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Get the logs and the log history of a process.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"v16.?.?"
|
||||
],
|
||||
"summary": "Get the logs of a process",
|
||||
"operationId": "process-3-get-report-at",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Process ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
|
@@ -1634,6 +1634,47 @@
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.ProcessReport"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/process/{id}/report/{at}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Get the logs and the log history of a process.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"v16.?.?"
|
||||
],
|
||||
"summary": "Get the logs of a process",
|
||||
"operationId": "process-3-get-report-at",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Process ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
|
@@ -2994,6 +2994,32 @@ paths:
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/api.ProcessReport'
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/api.Error'
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Get the logs of a process
|
||||
tags:
|
||||
- v16.7.2
|
||||
/api/v3/process/{id}/report/{at}:
|
||||
get:
|
||||
description: Get the logs and the log history of a process.
|
||||
operationId: process-3-get-report-at
|
||||
parameters:
|
||||
- description: Process ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
@@ -3011,7 +3037,7 @@ paths:
|
||||
- ApiKeyAuth: []
|
||||
summary: Get the logs of a process
|
||||
tags:
|
||||
- v16.7.2
|
||||
- v16.?.?
|
||||
/api/v3/process/{id}/state:
|
||||
get:
|
||||
description: Get the state and progress data of a process.
|
||||
|
@@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/datarhei/core/v16/http/api"
|
||||
@@ -320,7 +321,6 @@ func (h *RestreamHandler) GetState(c echo.Context) error {
|
||||
// @Param id path string true "Process ID"
|
||||
// @Success 200 {object} api.ProcessReport
|
||||
// @Failure 404 {object} api.Error
|
||||
// @Failure 400 {object} api.Error
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v3/process/{id}/report [get]
|
||||
func (h *RestreamHandler) GetReport(c echo.Context) error {
|
||||
@@ -337,6 +337,42 @@ func (h *RestreamHandler) GetReport(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, report)
|
||||
}
|
||||
|
||||
// GetReport return the current log and the log history of a process
|
||||
// @Summary Get the logs of a process
|
||||
// @Description Get the logs and the log history of a process.
|
||||
// @Tags v16.?.?
|
||||
// @ID process-3-get-report-at
|
||||
// @Produce json
|
||||
// @Param id path string true "Process ID"
|
||||
// @Success 200 {object} api.ProcessReport
|
||||
// @Failure 404 {object} api.Error
|
||||
// @Failure 400 {object} api.Error
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v3/process/{id}/report/{at} [get]
|
||||
func (h *RestreamHandler) GetReportAt(c echo.Context) error {
|
||||
id := util.PathParam(c, "id")
|
||||
at, err := strconv.ParseInt(util.PathParam(c, "at"), 10, 64)
|
||||
if err != nil {
|
||||
return api.Err(http.StatusBadRequest, "Invalid process report date", "%s", err)
|
||||
}
|
||||
|
||||
l, err := h.restream.GetProcessLog(id)
|
||||
if err != nil {
|
||||
return api.Err(http.StatusNotFound, "Unknown process ID", "%s", err)
|
||||
}
|
||||
|
||||
report := api.ProcessReport{}
|
||||
report.Unmarshal(l)
|
||||
|
||||
for _, r := range report.History {
|
||||
if r.CreatedAt == at {
|
||||
return c.JSON(http.StatusOK, r)
|
||||
}
|
||||
}
|
||||
|
||||
return api.Err(http.StatusNotFound, "Unknown process report date")
|
||||
}
|
||||
|
||||
// Probe probes a process
|
||||
// @Summary Probe a process
|
||||
// @Description Probe an existing process to get a detailed stream information on the inputs.
|
||||
|
@@ -555,6 +555,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) {
|
||||
v3.GET("/process/:id/config", s.v3handler.restream.GetConfig)
|
||||
v3.GET("/process/:id/state", s.v3handler.restream.GetState)
|
||||
v3.GET("/process/:id/report", s.v3handler.restream.GetReport)
|
||||
v3.GET("/process/:id/report/:at", s.v3handler.restream.GetReportAt)
|
||||
v3.GET("/process/:id/probe", s.v3handler.restream.Probe)
|
||||
|
||||
v3.GET("/process/:id/metadata", s.v3handler.restream.GetProcessMetadata)
|
||||
|
Reference in New Issue
Block a user