6648cdf1cb
Client External ID * normalizeexternalid * cleanopenapi * cleanopenapi * changingpublic * noprecommit * testing * precommit * processtest * nodb * tests * tests
764 lines
27 KiB
Go
764 lines
27 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"
|
|
)
|
|
|
|
// ClientCanSync If the client is allowing active syncs
|
|
type ClientCanSync = bool
|
|
|
|
// ClientCreate The properties for creation.
|
|
type ClientCreate struct {
|
|
// Id The client external id
|
|
Id ClientID `json:"id"`
|
|
|
|
// Name The client name
|
|
Name ClientName `json:"name"`
|
|
}
|
|
|
|
// ClientID The client external id
|
|
type ClientID = string
|
|
|
|
// ClientIDBody The client id.
|
|
type ClientIDBody struct {
|
|
// Id The client external id
|
|
Id ClientID `json:"id"`
|
|
}
|
|
|
|
// ClientName The client name
|
|
type ClientName = string
|
|
|
|
// ClientStatus Specifies the status of a client.
|
|
type ClientStatus string
|
|
|
|
// ClientStatusBody A client status information object.
|
|
type ClientStatusBody struct {
|
|
// Status Specifies the status of a client.
|
|
Status ClientStatus `json:"status"`
|
|
}
|
|
|
|
// ClientUID The client internal unique id
|
|
type ClientUID = openapi_types.UUID
|
|
|
|
// ClientUpdate The properties that may be updated.
|
|
type ClientUpdate struct {
|
|
// CanSync If the client is allowing active syncs
|
|
CanSync *ClientCanSync `json:"can_sync,omitempty"`
|
|
|
|
// Name The client name
|
|
Name *ClientName `json:"name,omitempty"`
|
|
}
|
|
|
|
// CodeVersion The desired code version.
|
|
type CodeVersion = int32
|
|
|
|
// Collector Collector model.
|
|
type Collector struct {
|
|
// ActiveVersion The desired version.
|
|
ActiveVersion Version `json:"active_version"`
|
|
|
|
// ClientId The client external id
|
|
ClientId ClientID `json:"client_id"`
|
|
|
|
// Fields The fields in the collector.
|
|
Fields CollectorFields `json:"fields"`
|
|
|
|
// LatestVersion The desired version.
|
|
LatestVersion Version `json:"latest_version"`
|
|
|
|
// MinimumCleanerVersion The desired code version.
|
|
MinimumCleanerVersion CodeVersion `json:"minimum_cleaner_version"`
|
|
|
|
// MinimumTextVersion The desired code version.
|
|
MinimumTextVersion CodeVersion `json:"minimum_text_version"`
|
|
}
|
|
|
|
// CollectorField The field properties for the collector.
|
|
type CollectorField struct {
|
|
// Name The output field name.
|
|
Name CollectorFieldName `json:"name"`
|
|
|
|
// QueryId The query id.
|
|
QueryId QueryID `json:"query_id"`
|
|
}
|
|
|
|
// CollectorFieldName The output field name.
|
|
type CollectorFieldName = string
|
|
|
|
// CollectorFields The fields in the collector.
|
|
type CollectorFields = []CollectorField
|
|
|
|
// CollectorSet Payload for updating a Collector.
|
|
type CollectorSet struct {
|
|
// ActiveVersion The desired version.
|
|
ActiveVersion *Version `json:"active_version,omitempty"`
|
|
|
|
// Fields The fields in the collector.
|
|
Fields *CollectorFields `json:"fields,omitempty"`
|
|
|
|
// MinimumCleanerVersion The desired code version.
|
|
MinimumCleanerVersion *CodeVersion `json:"minimum_cleaner_version,omitempty"`
|
|
|
|
// MinimumTextVersion The desired code version.
|
|
MinimumTextVersion *CodeVersion `json:"minimum_text_version,omitempty"`
|
|
}
|
|
|
|
// DocClient The properties of a client.
|
|
type DocClient struct {
|
|
// CanSync If the client is allowing active syncs
|
|
CanSync ClientCanSync `json:"can_sync"`
|
|
|
|
// Id The client external id
|
|
Id ClientID `json:"id"`
|
|
|
|
// Name The client name
|
|
Name ClientName `json:"name"`
|
|
|
|
// Uid The client internal unique id
|
|
Uid ClientUID `json:"uid"`
|
|
}
|
|
|
|
// Document The document properties.
|
|
type Document struct {
|
|
// Bucket The bucket containing the document
|
|
Bucket string `json:"bucket"`
|
|
|
|
// Id The document id.
|
|
Id DocumentID `json:"id"`
|
|
|
|
// Key The path to the document
|
|
Key string `json:"key"`
|
|
}
|
|
|
|
// DocumentID The document id.
|
|
type DocumentID = openapi_types.UUID
|
|
|
|
// ExportDetails Payload for export trigger response.
|
|
type ExportDetails struct {
|
|
// ClientId The client external id
|
|
ClientId ClientID `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"`
|
|
}
|
|
|
|
// ExportID The export id.
|
|
type ExportID = openapi_types.UUID
|
|
|
|
// 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 output field name.
|
|
FieldName CollectorFieldName `json:"field_name"`
|
|
|
|
// Values The values useful to the filter.
|
|
Values []string `json:"values"`
|
|
}
|
|
|
|
// FieldFilterCondition The possible field filtering conditions.
|
|
type FieldFilterCondition string
|
|
|
|
// IdMessage A single uuid.
|
|
type IdMessage struct {
|
|
// Id Unique identifier for entity.
|
|
Id openapi_types.UUID `json:"id"`
|
|
}
|
|
|
|
// ListDocuments The documents in the client.
|
|
type ListDocuments = []Document
|
|
|
|
// ListQueries A set of queries.
|
|
type ListQueries struct {
|
|
// Queries List of queries.
|
|
Queries []Query `json:"queries"`
|
|
}
|
|
|
|
// Query A logic unit of execution.
|
|
type Query struct {
|
|
// ActiveVersion The desired version.
|
|
ActiveVersion Version `json:"active_version"`
|
|
|
|
// Config Configuration for the query.
|
|
Config *QueryConfig `json:"config,omitempty"`
|
|
|
|
// Id The query id.
|
|
Id QueryID `json:"id"`
|
|
|
|
// LatestVersion The desired version.
|
|
LatestVersion Version `json:"latest_version"`
|
|
|
|
// RequiredQueries List of required query IDs.
|
|
RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"`
|
|
|
|
// Type Specifies the type of the query.
|
|
Type QueryType `json:"type"`
|
|
}
|
|
|
|
// QueryConfig Configuration for the query.
|
|
type QueryConfig = string
|
|
|
|
// QueryCreate The parameters required to create a query.
|
|
type QueryCreate struct {
|
|
// Config Configuration for the query.
|
|
Config *QueryConfig `json:"config,omitempty"`
|
|
|
|
// RequiredQueries List of required query IDs.
|
|
RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"`
|
|
|
|
// Type Specifies the type of the query.
|
|
Type QueryType `json:"type"`
|
|
}
|
|
|
|
// QueryID The query id.
|
|
type QueryID = openapi_types.UUID
|
|
|
|
// QueryTestRequest The properties for a query test request.
|
|
type QueryTestRequest struct {
|
|
// DocumentId The document id.
|
|
DocumentId DocumentID `json:"document_id"`
|
|
|
|
// QueryVersion The desired version.
|
|
QueryVersion Version `json:"query_version"`
|
|
}
|
|
|
|
// QueryTestResponse The response from a query test.
|
|
type QueryTestResponse struct {
|
|
// Value Result of the query test.
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
// QueryType Specifies the type of the query.
|
|
type QueryType string
|
|
|
|
// QueryUpdate The properties that may be updated for a query.
|
|
type QueryUpdate struct {
|
|
// ActiveVersion The desired version.
|
|
ActiveVersion *Version `json:"active_version,omitempty"`
|
|
|
|
// Config Configuration for the query.
|
|
Config *QueryConfig `json:"config,omitempty"`
|
|
|
|
// RequiredQueries List of required query IDs.
|
|
RequiredQueries *RequiredQueryIDs `json:"required_queries,omitempty"`
|
|
}
|
|
|
|
// RequiredQueryIDs List of required query IDs.
|
|
type RequiredQueryIDs = []QueryID
|
|
|
|
// Version The desired version.
|
|
type Version = int32
|
|
|
|
// CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType.
|
|
type CreateClientJSONRequestBody = ClientCreate
|
|
|
|
// UpdateClientJSONRequestBody defines body for UpdateClient for application/json ContentType.
|
|
type UpdateClientJSONRequestBody = ClientUpdate
|
|
|
|
// SetCollectorByClientIdJSONRequestBody defines body for SetCollectorByClientId for application/json ContentType.
|
|
type SetCollectorByClientIdJSONRequestBody = CollectorSet
|
|
|
|
// 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 ClientID) error
|
|
// Update a client
|
|
// (PATCH /client/{id})
|
|
UpdateClient(ctx echo.Context, id ClientID) error
|
|
// Get a collector by client ID
|
|
// (GET /client/{id}/collector)
|
|
GetCollectorByClientId(ctx echo.Context, id ClientID) error
|
|
// Set a collector
|
|
// (PATCH /client/{id}/collector)
|
|
SetCollectorByClientId(ctx echo.Context, id ClientID) error
|
|
// List the documents for a client
|
|
// (GET /client/{id}/documents)
|
|
ListDocumentsByClientId(ctx echo.Context, id ClientID) error
|
|
// Trigger an export
|
|
// (POST /client/{id}/export)
|
|
TriggerExport(ctx echo.Context, id ClientID) error
|
|
// Get client sync status
|
|
// (GET /client/{id}/status)
|
|
GetStatusByClientId(ctx echo.Context, id ClientID) error
|
|
// Check export state.
|
|
// (GET /export/{id})
|
|
ExportState(ctx echo.Context, id ExportID) 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 QueryID) error
|
|
// Update a query
|
|
// (PATCH /query/{id})
|
|
UpdateQuery(ctx echo.Context, id QueryID) error
|
|
// Test a query
|
|
// (POST /query/{id}/test)
|
|
TestQuery(ctx echo.Context, id QueryID) 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 ClientID
|
|
|
|
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 ClientID
|
|
|
|
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 ClientID
|
|
|
|
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
|
|
}
|
|
|
|
// SetCollectorByClientId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) SetCollectorByClientId(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id ClientID
|
|
|
|
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.SetCollectorByClientId(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 ClientID
|
|
|
|
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
|
|
}
|
|
|
|
// TriggerExport converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id ClientID
|
|
|
|
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 ClientID
|
|
|
|
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
|
|
}
|
|
|
|
// ExportState converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id ExportID
|
|
|
|
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
|
|
}
|
|
|
|
// 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 QueryID
|
|
|
|
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 QueryID
|
|
|
|
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 QueryID
|
|
|
|
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.SetCollectorByClientId)
|
|
router.GET(baseURL+"/client/:id/documents", wrapper.ListDocumentsByClientId)
|
|
router.POST(baseURL+"/client/:id/export", wrapper.TriggerExport)
|
|
router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId)
|
|
router.GET(baseURL+"/export/:id", wrapper.ExportState)
|
|
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)
|
|
|
|
}
|
|
|
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
|
var swaggerSpec = []string{
|
|
|
|
"H4sIAAAAAAAC/8xb61PjOBL/V1S++5gHmcDw+MYCu5WrPZgD5mqv9qiUI7cT7TiWkeTM5Kbyv1/p5aeU",
|
|
"OBnC7jfAUqv71091i+8BpsuMppAKHlx9D7KQhUsQwNRvNwmBVExu5c8RcMxIJghNg6vgeQEIq69ocjsI",
|
|
"egGRf81CsQh6QRouIbgKSBT0AgavOWEQBVeC5dALOF7AMpQE/84gDq6Cvw1LDob6Kx8WB282veDuW0aZ",
|
|
"lwtQX4/CRXGw5OJfObC1j4nJLaIxEgtAr3LZ27NiT99IVhjwjKYclI4m6SpMSPQIrzlw0WbPfEdML0Az",
|
|
"Gq0HSiJDu1T0TZg+rVPsoKFlMwonHIVJQr+SdI5CLMgKEF+nmAe9QKwzKeiM0gTCNNj0LGUGoQA3dhmj",
|
|
"GTBBgKOYMoTlUkJTiWH5SW4lUXezsZh3WX8vV2pcrWp+17pSNF4KsejsD8CilGqHY8A3ASwNE6Rowbdw",
|
|
"mSWSzPX1dQkVF4yk8yrNn2i03kqXRD+GTVtSv4j3BkUvMwqiunQMBPgFfBKhyHmb5lMGmMTSCqSpcbVK",
|
|
"OlVoTpIyQ5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HfUoMk/1a2Nf+K6/8GrcWICLo1tGddLqMY/GaHWfS8vJMZg101AXt5pHnidvdY1WFHdbl9wD",
|
|
"bGXtqPGkkdEox8WMCVjQC3KWBFfBQoiMXw2HYUYGZpI+wHQ5XI2UjZnTmvQerJXIvJooz5JpVVXbvPx/",
|
|
"0nr5vul1JGPbNVVKzRZOV2JlY6eg1eo2dKVV1lGGUk0HXano2rlCpV40b142/w8AAP//JXKOSfQ8AAA=",
|
|
}
|
|
|
|
// 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
|
|
}
|