62886dbba8
Remove Job * removejob * rmjob * sync * cleanup * precommit * startslow * startslow * startslow * openapi * clean * test * scripts * littlecleanercmds * mermaid
710 lines
26 KiB
Go
710 lines
26 KiB
Go
// Package queryservice provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version 2.4.1 DO NOT EDIT.
|
|
package queryservice
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/oapi-codegen/runtime"
|
|
openapi_types "github.com/oapi-codegen/runtime/types"
|
|
)
|
|
|
|
// Defines values for ClientStatus.
|
|
const (
|
|
INSYNC ClientStatus = "IN_SYNC"
|
|
NOTSYNCED ClientStatus = "NOT_SYNCED"
|
|
NOTSYNCING ClientStatus = "NOT_SYNCING"
|
|
)
|
|
|
|
// Defines values for ExportStatus.
|
|
const (
|
|
Completed ExportStatus = "completed"
|
|
Failed ExportStatus = "failed"
|
|
InProgress ExportStatus = "in_progress"
|
|
)
|
|
|
|
// Defines values for FieldFilterCondition.
|
|
const (
|
|
ClosedInterval FieldFilterCondition = "closed_interval"
|
|
Exclude FieldFilterCondition = "exclude"
|
|
GreaterThan FieldFilterCondition = "greater_than"
|
|
Include FieldFilterCondition = "include"
|
|
LeftClosedInterval FieldFilterCondition = "left_closed_interval"
|
|
LessThan FieldFilterCondition = "less_than"
|
|
OpenInterval FieldFilterCondition = "open_interval"
|
|
RightClosedInterval FieldFilterCondition = "right_closed_interval"
|
|
)
|
|
|
|
// Defines values for QueryType.
|
|
const (
|
|
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
|
JSONEXTRACTOR QueryType = "JSON_EXTRACTOR"
|
|
)
|
|
|
|
// ClientCreate defines model for ClientCreate.
|
|
type ClientCreate struct {
|
|
// Name The client name
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// ClientStatus Specifies the status of a client.
|
|
type ClientStatus string
|
|
|
|
// ClientStatusBody defines model for ClientStatusBody.
|
|
type ClientStatusBody struct {
|
|
// ClientId The client id
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
|
|
// Status Specifies the status of a client.
|
|
Status ClientStatus `json:"status"`
|
|
}
|
|
|
|
// ClientUpdate defines model for ClientUpdate.
|
|
type ClientUpdate struct {
|
|
// CanSync If the client is allowing active syncs
|
|
CanSync *bool `json:"can_sync,omitempty"`
|
|
|
|
// Name The client name
|
|
Name *string `json:"name,omitempty"`
|
|
}
|
|
|
|
// Collector Collector model.
|
|
type Collector struct {
|
|
// ActiveVersion The active version of the collector.
|
|
ActiveVersion int32 `json:"active_version"`
|
|
|
|
// ClientId The ID of the associated client.
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
|
|
// Fields The fields in the collector.
|
|
Fields []CollectorField `json:"fields"`
|
|
|
|
// LatestVersion The latest version of the collector.
|
|
LatestVersion int32 `json:"latest_version"`
|
|
|
|
// MinimumCleanerVersion The minimum version for the document cleaner.
|
|
MinimumCleanerVersion int32 `json:"minimum_cleaner_version"`
|
|
|
|
// MinimumTextVersion The minimum version for the text parser.
|
|
MinimumTextVersion int32 `json:"minimum_text_version"`
|
|
}
|
|
|
|
// CollectorField The field properties for the collector.
|
|
type CollectorField struct {
|
|
// Name The output field name.
|
|
Name string `json:"name"`
|
|
|
|
// QueryId The query id that will populate the result.
|
|
QueryId openapi_types.UUID `json:"query_id"`
|
|
}
|
|
|
|
// CollectorUpdate Payload for updating a Collector.
|
|
type CollectorUpdate struct {
|
|
// ActiveVersion The active version of the collector.
|
|
ActiveVersion *int32 `json:"active_version,omitempty"`
|
|
|
|
// Fields The fields in the collector.
|
|
Fields *[]CollectorField `json:"fields,omitempty"`
|
|
|
|
// MinimumCleanerVersion The minimum version for the document cleaner.
|
|
MinimumCleanerVersion *int32 `json:"minimum_cleaner_version,omitempty"`
|
|
|
|
// MinimumTextVersion The minimum version for the text parser.
|
|
MinimumTextVersion *int32 `json:"minimum_text_version,omitempty"`
|
|
}
|
|
|
|
// DocClient defines model for DocClient.
|
|
type DocClient struct {
|
|
// CanSync If the client is allowing active syncs
|
|
CanSync bool `json:"can_sync"`
|
|
|
|
// Id The client id
|
|
Id openapi_types.UUID `json:"id"`
|
|
|
|
// Name The client name
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// Document defines model for Document.
|
|
type Document struct {
|
|
// Bucket The bucket containing the document
|
|
Bucket string `json:"bucket"`
|
|
|
|
// Id The document id
|
|
Id openapi_types.UUID `json:"id"`
|
|
|
|
// Key The path to the document
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
// ExportDetails Payload for export trigger response.
|
|
type ExportDetails struct {
|
|
// ClientId The client id relative to the export.
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
|
|
// OutputLocation The location in which the export zip file will be found.
|
|
OutputLocation *string `json:"output_location,omitempty"`
|
|
|
|
// Status The possible export states.
|
|
Status ExportStatus `json:"status"`
|
|
}
|
|
|
|
// ExportStatus The possible export states.
|
|
type ExportStatus string
|
|
|
|
// ExportTrigger Payload for triggering an export.
|
|
type ExportTrigger struct {
|
|
// FieldFilters Filter the scope based on field output values.
|
|
FieldFilters *[]FieldFilter `json:"field_filters,omitempty"`
|
|
|
|
// IngestionFilters Filter the scope based on ingestion parameters.
|
|
IngestionFilters *struct {
|
|
// EndDate The last date of ingestion.
|
|
EndDate *string `json:"end_date,omitempty"`
|
|
|
|
// StartDate This first date of ingestion.
|
|
StartDate *string `json:"start_date,omitempty"`
|
|
} `json:"ingestion_filters,omitempty"`
|
|
}
|
|
|
|
// FieldFilter Filtering a column
|
|
type FieldFilter struct {
|
|
// Condition The possible field filtering conditions.
|
|
Condition FieldFilterCondition `json:"condition"`
|
|
|
|
// FieldName The name of the field in question.
|
|
FieldName string `json:"field_name"`
|
|
|
|
// Values The values useful to the filter.
|
|
Values []string `json:"values"`
|
|
}
|
|
|
|
// FieldFilterCondition The possible field filtering conditions.
|
|
type FieldFilterCondition string
|
|
|
|
// IdMessage defines model for IdMessage.
|
|
type IdMessage struct {
|
|
// Id Unique identifier for entity.
|
|
Id openapi_types.UUID `json:"id"`
|
|
}
|
|
|
|
// ListDocuments The documents in the client.
|
|
type ListDocuments = []Document
|
|
|
|
// ListQueries defines model for ListQueries.
|
|
type ListQueries struct {
|
|
// Queries List of queries.
|
|
Queries []Query `json:"queries"`
|
|
}
|
|
|
|
// Query defines model for Query.
|
|
type Query struct {
|
|
// ActiveVersion The active version of the query.
|
|
ActiveVersion int32 `json:"active_version"`
|
|
|
|
// Config Configuration for the query.
|
|
Config *string `json:"config,omitempty"`
|
|
|
|
// Id Unique identifier for the query.
|
|
Id openapi_types.UUID `json:"id"`
|
|
|
|
// LatestVersion The latest version of the query.
|
|
LatestVersion int32 `json:"latest_version"`
|
|
|
|
// RequiredQueries List of required query IDs.
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
|
|
|
// Type Specifies the type of the query.
|
|
Type QueryType `json:"type"`
|
|
}
|
|
|
|
// QueryCreate defines model for QueryCreate.
|
|
type QueryCreate struct {
|
|
// Config Configuration for the new query.
|
|
Config *string `json:"config,omitempty"`
|
|
|
|
// RequiredQueries List of required query IDs.
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
|
|
|
// Type Specifies the type of the query.
|
|
Type QueryType `json:"type"`
|
|
}
|
|
|
|
// QueryTestRequest defines model for QueryTestRequest.
|
|
type QueryTestRequest struct {
|
|
// DocumentId ID of the document to test against.
|
|
DocumentId openapi_types.UUID `json:"document_id"`
|
|
|
|
// QueryVersion Version of the query to use for testing.
|
|
QueryVersion int32 `json:"query_version"`
|
|
}
|
|
|
|
// QueryTestResponse defines model for QueryTestResponse.
|
|
type QueryTestResponse struct {
|
|
// Value Result of the query test.
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
// QueryType Specifies the type of the query.
|
|
type QueryType string
|
|
|
|
// QueryUpdate defines model for QueryUpdate.
|
|
type QueryUpdate struct {
|
|
// ActiveVersion Updated active version.
|
|
ActiveVersion *int32 `json:"active_version,omitempty"`
|
|
|
|
// Config Updated configuration for the query.
|
|
Config *string `json:"config,omitempty"`
|
|
|
|
// RequiredQueries Updated list of required query IDs.
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
|
}
|
|
|
|
// CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType.
|
|
type CreateClientJSONRequestBody = ClientCreate
|
|
|
|
// UpdateClientJSONRequestBody defines body for UpdateClient for application/json ContentType.
|
|
type UpdateClientJSONRequestBody = ClientUpdate
|
|
|
|
// UpdateCollectorByClientIdJSONRequestBody defines body for UpdateCollectorByClientId for application/json ContentType.
|
|
type UpdateCollectorByClientIdJSONRequestBody = CollectorUpdate
|
|
|
|
// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType.
|
|
type TriggerExportJSONRequestBody = ExportTrigger
|
|
|
|
// CreateQueryJSONRequestBody defines body for CreateQuery for application/json ContentType.
|
|
type CreateQueryJSONRequestBody = QueryCreate
|
|
|
|
// UpdateQueryJSONRequestBody defines body for UpdateQuery for application/json ContentType.
|
|
type UpdateQueryJSONRequestBody = QueryUpdate
|
|
|
|
// TestQueryJSONRequestBody defines body for TestQuery for application/json ContentType.
|
|
type TestQueryJSONRequestBody = QueryTestRequest
|
|
|
|
// ServerInterface represents all server handlers.
|
|
type ServerInterface interface {
|
|
// Create a new client
|
|
// (POST /client)
|
|
CreateClient(ctx echo.Context) error
|
|
// Get a client by ID
|
|
// (GET /client/{id})
|
|
GetClient(ctx echo.Context, id openapi_types.UUID) error
|
|
// Update a client
|
|
// (PATCH /client/{id})
|
|
UpdateClient(ctx echo.Context, id openapi_types.UUID) error
|
|
// Get a collector by client ID
|
|
// (GET /client/{id}/collector)
|
|
GetCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error
|
|
// Update a collector
|
|
// (PATCH /client/{id}/collector)
|
|
UpdateCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error
|
|
// List the documents for a client
|
|
// (GET /client/{id}/documents)
|
|
ListDocumentsByClientId(ctx echo.Context, id openapi_types.UUID) error
|
|
// Check export state.
|
|
// (GET /client/{id}/export)
|
|
ExportState(ctx echo.Context, id openapi_types.UUID) error
|
|
// Trigger an export
|
|
// (POST /client/{id}/export)
|
|
TriggerExport(ctx echo.Context, id openapi_types.UUID) error
|
|
// Get client sync status
|
|
// (GET /client/{id}/status)
|
|
GetStatusByClientId(ctx echo.Context, id openapi_types.UUID) error
|
|
// List queries
|
|
// (GET /query)
|
|
ListQueries(ctx echo.Context) error
|
|
// Create a new query
|
|
// (POST /query)
|
|
CreateQuery(ctx echo.Context) error
|
|
// Get a query by ID
|
|
// (GET /query/{id})
|
|
GetQuery(ctx echo.Context, id openapi_types.UUID) error
|
|
// Update a query
|
|
// (PATCH /query/{id})
|
|
UpdateQuery(ctx echo.Context, id openapi_types.UUID) error
|
|
// Test a query
|
|
// (POST /query/{id}/test)
|
|
TestQuery(ctx echo.Context, id openapi_types.UUID) error
|
|
}
|
|
|
|
// ServerInterfaceWrapper converts echo contexts to parameters.
|
|
type ServerInterfaceWrapper struct {
|
|
Handler ServerInterface
|
|
}
|
|
|
|
// CreateClient converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) CreateClient(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.CreateClient(ctx)
|
|
return err
|
|
}
|
|
|
|
// GetClient converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetClient(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetClient(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// UpdateClient converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) UpdateClient(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.UpdateClient(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetCollectorByClientId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetCollectorByClientId(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetCollectorByClientId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// UpdateCollectorByClientId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) UpdateCollectorByClientId(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.UpdateCollectorByClientId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// ListDocumentsByClientId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ListDocumentsByClientId(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.ListDocumentsByClientId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// ExportState converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.ExportState(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// TriggerExport converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.TriggerExport(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetStatusByClientId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetStatusByClientId(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetStatusByClientId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// ListQueries converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ListQueries(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.ListQueries(ctx)
|
|
return err
|
|
}
|
|
|
|
// CreateQuery converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) CreateQuery(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.CreateQuery(ctx)
|
|
return err
|
|
}
|
|
|
|
// GetQuery converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetQuery(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetQuery(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// UpdateQuery converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) UpdateQuery(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.UpdateQuery(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// TestQuery converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) TestQuery(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id openapi_types.UUID
|
|
|
|
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
|
|
if err != nil {
|
|
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
|
|
}
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.TestQuery(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// This is a simple interface which specifies echo.Route addition functions which
|
|
// are present on both echo.Echo and echo.Group, since we want to allow using
|
|
// either of them for path registration
|
|
type EchoRouter interface {
|
|
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
|
|
}
|
|
|
|
// RegisterHandlers adds each server route to the EchoRouter.
|
|
func RegisterHandlers(router EchoRouter, si ServerInterface) {
|
|
RegisterHandlersWithBaseURL(router, si, "")
|
|
}
|
|
|
|
// Registers handlers, and prepends BaseURL to the paths, so that the paths
|
|
// can be served under a prefix.
|
|
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
|
|
|
|
wrapper := ServerInterfaceWrapper{
|
|
Handler: si,
|
|
}
|
|
|
|
router.POST(baseURL+"/client", wrapper.CreateClient)
|
|
router.GET(baseURL+"/client/:id", wrapper.GetClient)
|
|
router.PATCH(baseURL+"/client/:id", wrapper.UpdateClient)
|
|
router.GET(baseURL+"/client/:id/collector", wrapper.GetCollectorByClientId)
|
|
router.PATCH(baseURL+"/client/:id/collector", wrapper.UpdateCollectorByClientId)
|
|
router.GET(baseURL+"/client/:id/documents", wrapper.ListDocumentsByClientId)
|
|
router.GET(baseURL+"/client/:id/export", wrapper.ExportState)
|
|
router.POST(baseURL+"/client/:id/export", wrapper.TriggerExport)
|
|
router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId)
|
|
router.GET(baseURL+"/query", wrapper.ListQueries)
|
|
router.POST(baseURL+"/query", wrapper.CreateQuery)
|
|
router.GET(baseURL+"/query/:id", wrapper.GetQuery)
|
|
router.PATCH(baseURL+"/query/:id", wrapper.UpdateQuery)
|
|
router.POST(baseURL+"/query/:id/test", wrapper.TestQuery)
|
|
|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auTiZ8pl7pO4Jl7TA/esC1ODdFzRIPJubq7v1T69Uzx4membdY9eWcp",
|
|
"KF27wTZDpX/NExrjP/rGWgndHrfVs0fsK/tIzv9nvJe+KLJGuhjs/TTAiCbz6ycgucvmdoIoc+7+pact",
|
|
"r9c/t9orlUHps8OkOjjtj5VT8/eDyEgemloz+u/eX1Uf24nuQdiZPSA3cYB9kSLNSZhNgUwGSS5ZMk5W",
|
|
"WmdqPBrhjA79F5tDItajzbvEoMVz26d3W/hbua9PIUVa+JJPlWitl427QU8yRZOnSmm/8dOXWNkOCrQa",
|
|
"zYq+tMpSyVOq+aAvFXfJqVCpX3J297v/BgAA//8NIKB+FzgAAA==",
|
|
}
|
|
|
|
// GetSwagger returns the content of the embedded swagger specification file
|
|
// or error if failed to decode
|
|
func decodeSpec() ([]byte, error) {
|
|
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error base64 decoding spec: %w", err)
|
|
}
|
|
zr, err := gzip.NewReader(bytes.NewReader(zipped))
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error decompressing spec: %w", err)
|
|
}
|
|
var buf bytes.Buffer
|
|
_, err = buf.ReadFrom(zr)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error decompressing spec: %w", err)
|
|
}
|
|
|
|
return buf.Bytes(), nil
|
|
}
|
|
|
|
var rawSpec = decodeSpecCached()
|
|
|
|
// a naive cached of a decoded swagger spec
|
|
func decodeSpecCached() func() ([]byte, error) {
|
|
data, err := decodeSpec()
|
|
return func() ([]byte, error) {
|
|
return data, err
|
|
}
|
|
}
|
|
|
|
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
|
|
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
|
|
res := make(map[string]func() ([]byte, error))
|
|
if len(pathToFile) > 0 {
|
|
res[pathToFile] = rawSpec
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
// GetSwagger returns the Swagger specification corresponding to the generated code
|
|
// in this file. The external references of Swagger specification are resolved.
|
|
// The logic of resolving external references is tightly connected to "import-mapping" feature.
|
|
// Externally referenced files must be embedded in the corresponding golang packages.
|
|
// Urls can be supported but this task was out of the scope.
|
|
func GetSwagger() (swagger *openapi3.T, err error) {
|
|
resolvePath := PathToRawSpec("")
|
|
|
|
loader := openapi3.NewLoader()
|
|
loader.IsExternalRefsAllowed = true
|
|
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
|
|
pathToFile := url.String()
|
|
pathToFile = path.Clean(pathToFile)
|
|
getSpec, ok := resolvePath[pathToFile]
|
|
if !ok {
|
|
err1 := fmt.Errorf("path not found: %s", pathToFile)
|
|
return nil, err1
|
|
}
|
|
return getSpec()
|
|
}
|
|
var specData []byte
|
|
specData, err = rawSpec()
|
|
if err != nil {
|
|
return
|
|
}
|
|
swagger, err = loader.LoadFromData(specData)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|