Merged in feature/docresult (pull request #105)
Document Result Endpoint * testing * cleantesting * progress * query * lint * readme * dockerclient * api * passtest * tests * test
This commit is contained in:
@@ -0,0 +1,843 @@
|
||||
// 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 properties.
|
||||
type DocumentSummary struct {
|
||||
// Hash The document hash
|
||||
Hash Hash `json:"hash"`
|
||||
|
||||
// Id The document id.
|
||||
Id DocumentID `json:"id"`
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// 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/+xbW3PjNrL+KyycvEUX6mbJOnUeFHuS6OysZzL2bGV3xquCyJaELEXKAGiPMqX/voUb",
|
||||
"r6BEydYktd4qP1giCDS6P3zd6G59RV603kQhhJyh8Ve0AuwDlf9+wBzekjXh4oMPzKNkw0kUorF85ATi",
|
||||
"mUPCRUTXWDxwSOioD85nJJ/+7xMJ/ejp/zhZQ1P9/xmhBoIveL0JAI1Rx3XNoAsXNRDzVrDGYsU1/vIW",
|
||||
"wiVfoXGv20AbzDlQsfg/P7nNy/vvzWvq03eogfh2I6ZknJJwiXa7nXiL4jVwvaOrgEDIp9flDd2twPHk",
|
||||
"U2d63UINRMS3G8xXqIFCvBbzEh81EIWHmFDw0ZjTGLLyfkdhgcbof9qpQtvqKWsnCwuZriMvXu+Rw9fP",
|
||||
"zyJJZnEhy5svm4hWSgLy6VnkSBYWUvwSA91WCTG9dqKFw1fgPIhhLy+KWV0ChgLbRCEDiZdpKCCHgzeU",
|
||||
"RrQsnXnsMKCPQB0Qw4R8VYfIJoUe204HSjmm4SMOiP8BHmJg3La2fO5QNcCZR/72RZbeGbVlTswVDm+3",
|
||||
"oWeRQhlGnxzCHBwE0RMJlw72OHkEh21Dj6VHcx5FAeAQ7RpmZgqYg93wGxptgHICTLCK44mhJArFLtNH",
|
||||
"4lXi1z9/BjB1xt+IkQoUBlefFNDkHPfJtqL5b+DxdFcHGAa+aNzIuVIunEwmqJHjvYsc77VsLJeu+UPk",
|
||||
"b/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agtl8j/NoyW",
|
||||
"rx3sCb6SbYiNvQKwyNwBz5VOVEal5AkT9b0IuRVxp6rz8oL6DL6M7L/KIZzIOC/TZrKhkeCEMjh1Z4Fq",
|
||||
"MzgTOeZ7GCrYUQuq2U9qvvVNL69pxdAi4ZtcG9Hrixi18dLGksxJ0b0xlRybdgzVIFi2DT3z+5RasaL+",
|
||||
"wcu3CRSLP7GpZla9hdcVM5qfF6U2PM8NVyDMEHjd7AjPRGCyoTlpMtAwUxWmEr6u027Yc+ZJ1BoWPJln",
|
||||
"rwxKfmHbqZVe1kdnS20SV4re9qPqagXevxSkvJhSc95lnSjXepdHU9pECOdEU747ttqZrTBz5gChkzQm",
|
||||
"voYkrDBdrkeztceVHYum9BflEksPppnkYKYkyPe/ZLsuZaOjRwkHSrD9dmE6cs58ozDLWCA1Ke7gtdwl",
|
||||
"HhLVGwzJItbk/VTBp0b5SZUvj64+qU6l80Ts2caVU2pPDxnZ/gTRu6or/rfs9JQYxgLWhLBOqDcpCO8v",
|
||||
"N6V4PRNF6V7AKvO/tvRtYpNczjbPTkc5t6Rp4rgKU4beahSYzs5q+8tLqiBk+seTX8TpPo+k7eaEipMC",
|
||||
"4WsvONXmnzbX3XfPwKjV976RnbuSvlS/Xhyq+2CVG87/jKSQPQPGz47YbDtiBWwL/YfHJNDccwirWwZt",
|
||||
"0ioZWRy8hnSz3O1+1Ms56aPBd6Gpi0Z+7CX9UrJFK6YBGqMV5xs2brf9yPt92/KidfuxI1Gv1yjO9M7g",
|
||||
"VkRsgeQgEbDJnApLG7/ySZpdo+Y0ptCSnalYfKk7WVqSSeYq3fPrzpVG53qmRPN1Z1A3xcwM+Svi7n73",
|
||||
"7wAAAP//OVAUyb5OAAA=",
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user