a07037b018
Job Status Endpoint * edpoint
792 lines
29 KiB
Go
792 lines
29 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 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 JobStatus.
|
|
const (
|
|
INSYNC JobStatus = "IN_SYNC"
|
|
NOTSYNCED JobStatus = "NOT_SYNCED"
|
|
)
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// 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 {
|
|
// JobId The job id relative to the export.
|
|
JobId openapi_types.UUID `json:"job_id"`
|
|
|
|
// OutputLocation The location in which the export zip file will be found.
|
|
OutputLocation *string `json:"output_location,omitempty"`
|
|
|
|
// Status The possible export job states.
|
|
Status ExportStatus `json:"status"`
|
|
}
|
|
|
|
// ExportStatus The possible export job 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"`
|
|
|
|
// JobId The job id of the query results to be exported.
|
|
JobId openapi_types.UUID `json:"job_id"`
|
|
}
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// Job defines model for Job.
|
|
type Job struct {
|
|
// CanSync Specifies whether the job is actively syncing
|
|
CanSync bool `json:"can_sync"`
|
|
|
|
// ClientId The client id the job belongs to
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
|
|
// Id The job id
|
|
Id openapi_types.UUID `json:"id"`
|
|
}
|
|
|
|
// JobClient defines model for JobClient.
|
|
type JobClient 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"`
|
|
}
|
|
|
|
// JobCollector JobCollector model.
|
|
type JobCollector struct {
|
|
// ActiveVersion The active version of the collector.
|
|
ActiveVersion int32 `json:"active_version"`
|
|
|
|
// Fields The fields in the job collector.
|
|
Fields []JobCollectorField `json:"fields"`
|
|
|
|
// JobId The ID of the associated job.
|
|
JobId openapi_types.UUID `json:"job_id"`
|
|
|
|
// 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"`
|
|
}
|
|
|
|
// JobCollectorField The field properties for the job collector.
|
|
type JobCollectorField 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"`
|
|
}
|
|
|
|
// JobCollectorUpdate Payload for updating a JobCollector.
|
|
type JobCollectorUpdate struct {
|
|
// ActiveVersion The active version of the collector.
|
|
ActiveVersion *int32 `json:"active_version,omitempty"`
|
|
|
|
// Fields The fields in the job collector.
|
|
Fields *[]JobCollectorField `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"`
|
|
}
|
|
|
|
// JobCreate defines model for JobCreate.
|
|
type JobCreate struct {
|
|
// ClientId The client id the job belongs to
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
}
|
|
|
|
// JobStatus Specifies the status of a job.
|
|
type JobStatus string
|
|
|
|
// JobStatusBody defines model for JobStatusBody.
|
|
type JobStatusBody struct {
|
|
// JobId The job id
|
|
JobId openapi_types.UUID `json:"job_id"`
|
|
|
|
// Status Specifies the status of a job.
|
|
Status JobStatus `json:"status"`
|
|
}
|
|
|
|
// JobUpdate defines model for JobUpdate.
|
|
type JobUpdate struct {
|
|
// CanSync Specifies whether the job is actively syncing
|
|
CanSync *bool `json:"can_sync,omitempty"`
|
|
}
|
|
|
|
// ListDocuments The documents in the job.
|
|
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
|
|
|
|
// CreateJobJSONRequestBody defines body for CreateJob for application/json ContentType.
|
|
type CreateJobJSONRequestBody = JobCreate
|
|
|
|
// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType.
|
|
type TriggerExportJSONRequestBody = ExportTrigger
|
|
|
|
// UpdateJobJSONRequestBody defines body for UpdateJob for application/json ContentType.
|
|
type UpdateJobJSONRequestBody = JobUpdate
|
|
|
|
// UpdateJobCollectorByJobIdJSONRequestBody defines body for UpdateJobCollectorByJobId for application/json ContentType.
|
|
type UpdateJobCollectorByJobIdJSONRequestBody = JobCollectorUpdate
|
|
|
|
// 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
|
|
// Create a new job
|
|
// (POST /job)
|
|
CreateJob(ctx echo.Context) error
|
|
// Trigger an export
|
|
// (POST /job/export)
|
|
TriggerExport(ctx echo.Context) error
|
|
// Get a job by ID
|
|
// (GET /job/{id})
|
|
GetJob(ctx echo.Context, id openapi_types.UUID) error
|
|
// Update a job
|
|
// (PATCH /job/{id})
|
|
UpdateJob(ctx echo.Context, id openapi_types.UUID) error
|
|
// Get a job collector by ID
|
|
// (GET /job/{id}/collector)
|
|
GetJobCollectorByJobId(ctx echo.Context, id openapi_types.UUID) error
|
|
// Update a job collector
|
|
// (PATCH /job/{id}/collector)
|
|
UpdateJobCollectorByJobId(ctx echo.Context, id openapi_types.UUID) error
|
|
// List the documents for a job
|
|
// (GET /job/{id}/documents)
|
|
ListDocumentsByJobId(ctx echo.Context, id openapi_types.UUID) error
|
|
// Check export state.
|
|
// (GET /job/{id}/export)
|
|
ExportState(ctx echo.Context, id openapi_types.UUID) error
|
|
// Get job status by job ID
|
|
// (GET /job/{id}/status)
|
|
GetJobStatusByJobId(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
|
|
}
|
|
|
|
// CreateJob converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) CreateJob(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.CreateJob(ctx)
|
|
return err
|
|
}
|
|
|
|
// TriggerExport converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error {
|
|
var err error
|
|
|
|
// Invoke the callback with all the unmarshaled arguments
|
|
err = w.Handler.TriggerExport(ctx)
|
|
return err
|
|
}
|
|
|
|
// GetJob converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetJob(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.GetJob(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// UpdateJob converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) UpdateJob(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.UpdateJob(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// GetJobCollectorByJobId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetJobCollectorByJobId(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.GetJobCollectorByJobId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// UpdateJobCollectorByJobId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) UpdateJobCollectorByJobId(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.UpdateJobCollectorByJobId(ctx, id)
|
|
return err
|
|
}
|
|
|
|
// ListDocumentsByJobId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) ListDocumentsByJobId(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.ListDocumentsByJobId(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
|
|
}
|
|
|
|
// GetJobStatusByJobId converts echo context to params.
|
|
func (w *ServerInterfaceWrapper) GetJobStatusByJobId(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.GetJobStatusByJobId(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.POST(baseURL+"/job", wrapper.CreateJob)
|
|
router.POST(baseURL+"/job/export", wrapper.TriggerExport)
|
|
router.GET(baseURL+"/job/:id", wrapper.GetJob)
|
|
router.PATCH(baseURL+"/job/:id", wrapper.UpdateJob)
|
|
router.GET(baseURL+"/job/:id/collector", wrapper.GetJobCollectorByJobId)
|
|
router.PATCH(baseURL+"/job/:id/collector", wrapper.UpdateJobCollectorByJobId)
|
|
router.GET(baseURL+"/job/:id/documents", wrapper.ListDocumentsByJobId)
|
|
router.GET(baseURL+"/job/:id/export", wrapper.ExportState)
|
|
router.GET(baseURL+"/job/:id/status", wrapper.GetJobStatusByJobId)
|
|
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/+RbXW/buNL+K4Te99Kws9u98l03yS4c9DQ9TXqwB4vCoKSxzVQmFZJK6g383w/4Kcki",
|
|
"LTmJ2i72qnVMzgxnnvngDP2UZGxbMgpUimT+lIhsA1us/3teEKDynAOWoD6XnJXAJQH9LcVb/dccRMZJ",
|
|
"KQmjyTy53QDK9D6kF0wSuSshmSdCckLXyX4/STjcV4RDnsz/NFQ++1UsvYNMJvuJZf6pzIPMM0yXYkez",
|
|
"rgCLFZK1DEQgXBTskdA1wpkkD4DUNlHLlTJWAKaK5fNP1JH+gmXVFqjsSp5W2ReQYTbmO5QxKjGhSmZ1",
|
|
"lNzR6nCeJCQPU3J7EMmTSbJifItlMk+qSn/ukPkCuzCdEssNkqxHjgObah72nIZ2yMCXX0vG5QVITArR",
|
|
"5f4B7wqGc7RiHIFeiiQn6zVwxEGUjAqYJpMD5d6xdBlTyR1LEckRhwJrHNhTGdrTIVpilSwruSxYhg3d",
|
|
"EBv3LSIUPW5ItmlwQX+REq1IAeiRFAVKAa1YRXPFHL7ibVlofm/ms9mTUd9+9mSgR/L97OmOpfpfSbYg",
|
|
"JN6W++WTIUzy/fQvUoaEFhLLSivn/zmsknnyf7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lrPEWiYdSsXcDRtU2jfN/ef9/wIAAP//ydyWwBBCAAA=",
|
|
}
|
|
|
|
// 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
|
|
}
|