1587da9d11
Fix Fullsuite * save * foundthefix.. * codeandrequire
867 lines
30 KiB
Go
867 lines
30 KiB
Go
// Package queryapi 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 queryapi
|
|
|
|
import (
|
|
"bytes"
|
|
"compress/gzip"
|
|
"encoding/base64"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
"path"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/getkin/kin-openapi/openapi3"
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/oapi-codegen/runtime"
|
|
openapi_types "github.com/oapi-codegen/runtime/types"
|
|
)
|
|
|
|
const (
|
|
PlaceholderAuthScopes = "placeholderAuth.Scopes"
|
|
)
|
|
|
|
// 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 = int64
|
|
|
|
// 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 {
|
|
// ClientId The client external id
|
|
ClientId ClientID `json:"client_id"`
|
|
|
|
// Fields The fields and the value for the document
|
|
Fields map[string]interface{} `json:"fields"`
|
|
|
|
// Hash The document hash
|
|
Hash Hash `json:"hash"`
|
|
|
|
// Id The document id.
|
|
Id DocumentID `json:"id"`
|
|
}
|
|
|
|
// DocumentID The document id.
|
|
type DocumentID = openapi_types.UUID
|
|
|
|
// DocumentSummary The document summary properties.
|
|
type DocumentSummary struct {
|
|
// Hash The document hash
|
|
Hash Hash `json:"hash"`
|
|
|
|
// Id The document id.
|
|
Id DocumentID `json:"id"`
|
|
}
|
|
|
|
// ErrorMessage Description of error
|
|
type ErrorMessage struct {
|
|
// Message Message describing the cause.
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// 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 *time.Time `json:"end_date,omitempty"`
|
|
|
|
// StartDate This first date of ingestion.
|
|
StartDate *time.Time `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
|
|
|
|
// Hash The document hash
|
|
type Hash = 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 = []DocumentSummary
|
|
|
|
// 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
|
|
|
|
// InternalError Description of error
|
|
type InternalError = ErrorMessage
|
|
|
|
// InvalidRequest Description of error
|
|
type InvalidRequest = ErrorMessage
|
|
|
|
// TooManyRequests Description of error
|
|
type TooManyRequests = ErrorMessage
|
|
|
|
// Unauthorized Description of error
|
|
type Unauthorized = ErrorMessage
|
|
|
|
// 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
|
|
// Get document details by its id
|
|
// (GET /document/{id})
|
|
GetDocument(ctx echo.Context, id DocumentID) 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
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetStatusByClientId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetDocument converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetDocument(ctx echo.Context) error {
|
|
var err error
|
|
// ------------- Path parameter "id" -------------
|
|
var id DocumentID
|
|
|
|
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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.GetDocument(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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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))
|
|
}
|
|
|
|
ctx.Set(PlaceholderAuthScopes, []string{})
|
|
|
|
// 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+"/document/:id", wrapper.GetDocument)
|
|
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/+xc63PbRnD/V27QfGr4JiVS6nSmjOQ4bG3ZkeROOpbKOQJL8lIAR90dJDMe/u+de+EN",
|
|
"EqRJJR804w8CcY/dvd3f7u0u/N1xabCiIYSCO5ffnSVgD5j68xYL+EACIuSDB9xlZCUIDZ1L9Qr58h0i",
|
|
"4ZyyAMsXiIRIP6AHR739txcSevTl3wUJoKn/fnCchgPfcLDywbl0up2OHdTtOA2Hu0sIsNyxdMy5HBPg",
|
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/tXie4z3/fV+0zDAtvcf7J",
|
|
"4nz7IWWiMKfJt0h1tq6pbmJQpKJm9QVH3F9kdFoXlwvKfJ18GnDKFKHeo0R57bs3vT2d3no5GScqcdxQ",
|
|
"J13SV0qsgXu7Cl8twf0/rb9uxJhFMlWPzrT4ZlU3aVaGU6putgu/OiZYYo5mACGKG6DfFPnIlRWpJ5nG",
|
|
"89aWiGBf1U3+VxyluE+2Q25nktDPNvWlW8lV97bLiABGcPn107YZnvjKabcp0d9xnoM3vT3BZfMpPmer",
|
|
"sKrmPv480bpao1quG0D2LpbrXs/TXOnSrX+HlMqfUrT9A653ug3irUr+ylVyqwUllhFD8QHlcW0v26vj",
|
|
"iXGcCHxN63aVrr3FvCesycQKkCnEZHF3rxghbqjbryCeAu4a9fCT4/X2ariuX9tvi+Lvx00PYNySeUCB",
|
|
"XGv8W338FevjtZG1LUwb+A8YRGkI8059QqKAWTeOR6HOTlRFM9nvGXNZauDi5OaR7ouvsJFcI/w+ierO",
|
|
"KYg1vetl1GoaeeS/1ZCOnZ6Wot1uYmpN9myNKdfKzKgXuXErr2pM1o26SyFW/LLdjluF289dZWJmj/xK",
|
|
"n6yRyCjbV+gqg2yVTuRJU3I2P7lp1FzGlmrTK+XLt3UXS4q68VqFrFPdtZIblVkplnzdFXQqIbVCNoew",
|
|
"edz8fwAAAP//YgULir1ZAAA=",
|
|
}
|
|
|
|
// 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
|
|
}
|