2025-01-15 19:45:51 +00:00
|
|
|
// 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"
|
2025-01-24 14:52:56 +00:00
|
|
|
openapi_types "github.com/oapi-codegen/runtime/types"
|
2025-01-15 19:45:51 +00:00
|
|
|
)
|
|
|
|
|
|
2025-01-16 13:49:07 +00:00
|
|
|
// 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"
|
|
|
|
|
)
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// Defines values for QueryType.
|
|
|
|
|
const (
|
|
|
|
|
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
|
|
|
|
JSONEXTRACTOR QueryType = "JSON_EXTRACTOR"
|
|
|
|
|
)
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// 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"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-16 13:49:07 +00:00
|
|
|
// ExportDetails Payload for export trigger response.
|
|
|
|
|
type ExportDetails struct {
|
|
|
|
|
// JobId The job id relative to the export.
|
2025-02-03 17:45:00 +00:00
|
|
|
JobId openapi_types.UUID `json:"job_id"`
|
2025-01-16 13:49:07 +00:00
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// ExportTrigger Payload for triggering an export.
|
|
|
|
|
type ExportTrigger struct {
|
2025-01-16 13:49:07 +00:00
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
JobId openapi_types.UUID `json:"job_id"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-16 13:49:07 +00:00
|
|
|
// 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
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// IdMessage defines model for IdMessage.
|
|
|
|
|
type IdMessage struct {
|
2025-01-16 13:49:07 +00:00
|
|
|
// Id Unique identifier for entity.
|
2025-01-24 14:52:56 +00:00
|
|
|
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"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// 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
|
2025-01-24 14:52:56 +00:00
|
|
|
Id openapi_types.UUID `json:"id"`
|
2025-01-21 18:24:14 +00:00
|
|
|
|
|
|
|
|
// Name The client name
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// JobCollector JobCollector model.
|
|
|
|
|
type JobCollector struct {
|
2025-01-21 12:28:46 +00:00
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
JobId openapi_types.UUID `json:"job_id"`
|
2025-01-21 12:28:46 +00:00
|
|
|
|
|
|
|
|
// 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"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-21 12:28:46 +00:00
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
QueryId openapi_types.UUID `json:"query_id"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JobCollectorUpdate Payload for updating a JobCollector.
|
|
|
|
|
type JobCollectorUpdate struct {
|
2025-01-21 12:28:46 +00:00
|
|
|
// 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"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
// JobCreate defines model for JobCreate.
|
|
|
|
|
type JobCreate struct {
|
|
|
|
|
// ClientId The client id the job belongs to
|
|
|
|
|
ClientId openapi_types.UUID `json:"client_id"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JobUpdate defines model for JobUpdate.
|
|
|
|
|
type JobUpdate struct {
|
|
|
|
|
// CanSync Specifies whether the job is actively syncing
|
|
|
|
|
CanSync *bool `json:"can_sync,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
Id openapi_types.UUID `json:"id"`
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
// LatestVersion The latest version of the query.
|
|
|
|
|
LatestVersion int32 `json:"latest_version"`
|
|
|
|
|
|
|
|
|
|
// RequiredQueries List of required query IDs.
|
2025-01-24 14:52:56 +00:00
|
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
DocumentId openapi_types.UUID `json:"document_id"`
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
// 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.
|
2025-01-24 14:52:56 +00:00
|
|
|
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType.
|
|
|
|
|
type CreateClientJSONRequestBody = ClientCreate
|
|
|
|
|
|
|
|
|
|
// UpdateClientJSONRequestBody defines body for UpdateClient for application/json ContentType.
|
|
|
|
|
type UpdateClientJSONRequestBody = ClientUpdate
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
// CreateJobJSONRequestBody defines body for CreateJob for application/json ContentType.
|
|
|
|
|
type CreateJobJSONRequestBody = JobCreate
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType.
|
|
|
|
|
type TriggerExportJSONRequestBody = ExportTrigger
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
// UpdateJobJSONRequestBody defines body for UpdateJob for application/json ContentType.
|
|
|
|
|
type UpdateJobJSONRequestBody = JobUpdate
|
|
|
|
|
|
2025-01-21 12:28:46 +00:00
|
|
|
// UpdateJobCollectorByJobIdJSONRequestBody defines body for UpdateJobCollectorByJobId for application/json ContentType.
|
|
|
|
|
type UpdateJobCollectorByJobIdJSONRequestBody = JobCollectorUpdate
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
// 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 {
|
2025-01-21 18:24:14 +00:00
|
|
|
// Create a new client
|
2025-01-24 14:52:56 +00:00
|
|
|
// (POST /client)
|
2025-01-21 18:24:14 +00:00
|
|
|
CreateClient(ctx echo.Context) error
|
|
|
|
|
// Get a client by ID
|
2025-01-24 14:52:56 +00:00
|
|
|
// (GET /client/{id})
|
|
|
|
|
GetClient(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-21 18:24:14 +00:00
|
|
|
// Update a client
|
2025-01-24 14:52:56 +00:00
|
|
|
// (PATCH /client/{id})
|
|
|
|
|
UpdateClient(ctx echo.Context, id openapi_types.UUID) error
|
|
|
|
|
// Create a new job
|
|
|
|
|
// (POST /job)
|
|
|
|
|
CreateJob(ctx echo.Context) error
|
2025-01-15 19:45:51 +00:00
|
|
|
// Trigger an export
|
2025-01-21 12:28:46 +00:00
|
|
|
// (POST /job/export)
|
2025-01-15 19:45:51 +00:00
|
|
|
TriggerExport(ctx echo.Context) error
|
2025-01-24 14:52:56 +00:00
|
|
|
// 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
|
2025-01-15 19:45:51 +00:00
|
|
|
// Get a job collector by ID
|
2025-01-21 12:28:46 +00:00
|
|
|
// (GET /job/{id}/collector)
|
2025-01-24 14:52:56 +00:00
|
|
|
GetJobCollectorByJobId(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-15 19:45:51 +00:00
|
|
|
// Update a job collector
|
2025-01-21 12:28:46 +00:00
|
|
|
// (PATCH /job/{id}/collector)
|
2025-01-24 14:52:56 +00:00
|
|
|
UpdateJobCollectorByJobId(ctx echo.Context, id openapi_types.UUID) error
|
2025-02-03 17:45:00 +00:00
|
|
|
// Check export state.
|
|
|
|
|
// (GET /job/{id}/export)
|
|
|
|
|
ExportState(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-15 19:45:51 +00:00
|
|
|
// List queries
|
2025-01-24 14:52:56 +00:00
|
|
|
// (GET /query)
|
2025-01-15 19:45:51 +00:00
|
|
|
ListQueries(ctx echo.Context) error
|
|
|
|
|
// Create a new query
|
2025-01-24 14:52:56 +00:00
|
|
|
// (POST /query)
|
2025-01-15 19:45:51 +00:00
|
|
|
CreateQuery(ctx echo.Context) error
|
|
|
|
|
// Get a query by ID
|
2025-01-24 14:52:56 +00:00
|
|
|
// (GET /query/{id})
|
|
|
|
|
GetQuery(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-15 19:45:51 +00:00
|
|
|
// Update a query
|
2025-01-24 14:52:56 +00:00
|
|
|
// (PATCH /query/{id})
|
|
|
|
|
UpdateQuery(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-15 19:45:51 +00:00
|
|
|
// Test a query
|
2025-01-24 14:52:56 +00:00
|
|
|
// (POST /query/{id}/test)
|
|
|
|
|
TestQuery(ctx echo.Context, id openapi_types.UUID) error
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ServerInterfaceWrapper converts echo contexts to parameters.
|
|
|
|
|
type ServerInterfaceWrapper struct {
|
|
|
|
|
Handler ServerInterface
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// 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" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-21 18:24:14 +00:00
|
|
|
|
|
|
|
|
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" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-21 18:24:14 +00:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 19:45:51 +00:00
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:45:00 +00:00
|
|
|
// GetJob converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) GetJob(ctx echo.Context) error {
|
2025-01-16 13:49:07 +00:00
|
|
|
var err error
|
|
|
|
|
// ------------- Path parameter "id" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-16 13:49:07 +00:00
|
|
|
|
|
|
|
|
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
|
2025-02-03 17:45:00 +00:00
|
|
|
err = w.Handler.GetJob(ctx, id)
|
2025-01-16 13:49:07 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:45:00 +00:00
|
|
|
// UpdateJob converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) UpdateJob(ctx echo.Context) error {
|
2025-01-24 14:52:56 +00:00
|
|
|
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
|
2025-02-03 17:45:00 +00:00
|
|
|
err = w.Handler.UpdateJob(ctx, id)
|
2025-01-24 14:52:56 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:45:00 +00:00
|
|
|
// GetJobCollectorByJobId converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) GetJobCollectorByJobId(ctx echo.Context) error {
|
2025-01-24 14:52:56 +00:00
|
|
|
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
|
2025-02-03 17:45:00 +00:00
|
|
|
err = w.Handler.GetJobCollectorByJobId(ctx, id)
|
2025-01-24 14:52:56 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:45:00 +00:00
|
|
|
// UpdateJobCollectorByJobId converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) UpdateJobCollectorByJobId(ctx echo.Context) error {
|
2025-01-15 19:45:51 +00:00
|
|
|
var err error
|
|
|
|
|
// ------------- Path parameter "id" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
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
|
2025-02-03 17:45:00 +00:00
|
|
|
err = w.Handler.UpdateJobCollectorByJobId(ctx, id)
|
2025-01-15 19:45:51 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 17:45:00 +00:00
|
|
|
// ExportState converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error {
|
2025-01-15 19:45:51 +00:00
|
|
|
var err error
|
|
|
|
|
// ------------- Path parameter "id" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
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
|
2025-02-03 17:45:00 +00:00
|
|
|
err = w.Handler.ExportState(ctx, id)
|
2025-01-15 19:45:51 +00:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-21 18:24:14 +00:00
|
|
|
// GetQuery converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) GetQuery(ctx echo.Context) error {
|
2025-01-15 19:45:51 +00:00
|
|
|
var err error
|
|
|
|
|
// ------------- Path parameter "id" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
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
|
2025-01-21 18:24:14 +00:00
|
|
|
err = w.Handler.GetQuery(ctx, id)
|
2025-01-15 19:45:51 +00:00
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateQuery converts echo context to params.
|
|
|
|
|
func (w *ServerInterfaceWrapper) UpdateQuery(ctx echo.Context) error {
|
|
|
|
|
var err error
|
|
|
|
|
// ------------- Path parameter "id" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
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" -------------
|
2025-01-24 14:52:56 +00:00
|
|
|
var id openapi_types.UUID
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
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)
|
2025-01-21 12:28:46 +00:00
|
|
|
router.POST(baseURL+"/job/export", wrapper.TriggerExport)
|
2025-01-24 14:52:56 +00:00
|
|
|
router.GET(baseURL+"/job/:id", wrapper.GetJob)
|
|
|
|
|
router.PATCH(baseURL+"/job/:id", wrapper.UpdateJob)
|
2025-01-21 12:28:46 +00:00
|
|
|
router.GET(baseURL+"/job/:id/collector", wrapper.GetJobCollectorByJobId)
|
|
|
|
|
router.PATCH(baseURL+"/job/:id/collector", wrapper.UpdateJobCollectorByJobId)
|
2025-02-03 17:45:00 +00:00
|
|
|
router.GET(baseURL+"/job/:id/export", wrapper.ExportState)
|
2025-01-24 14:52:56 +00:00
|
|
|
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)
|
2025-01-15 19:45:51 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
|
|
|
|
var swaggerSpec = []string{
|
|
|
|
|
|
2025-01-24 14:52:56 +00:00
|
|
|
"H4sIAAAAAAAC/+RbX2/bthb/KoTufTTsdN2T37o0HRz0rr1tejFgCAyKOraZ0aJCUk69wN/9gjzUP0u0",
|
|
|
|
|
"5CTaMuypTUSeQ/7O7/whD/MYMbnNZAqp0dH8MdJsA1vq/nspOKTmUgE1YH/OlMxAGQ7ua0q37rcJaKZ4",
|
|
|
|
|
"ZrhMo3l0swHC3DziBkwis88gmkfaKJ6uo8NhEim4z7mCJJr/hlJuy1EyvgNmosPEK/+WJZ3KGU2Xep+y",
|
|
|
|
|
"9gIWK2KqNXBNqBDygadrQpnhOyB2mq7WFUspgKZW5dN31Fr91fdMKvMeDOVCt2V+pnshaUJWUhFwQ4lR",
|
|
|
|
|
"fL0GRRToTKYaptHkaM93Ml7ypHuBdzImPCEKBHWbNNKhgLKtqJVUW2qieZTnPGnvYRLJ3GS5WQrJKMrt",
|
|
|
|
|
"UlN8JTwlDxvONjUt5A+ekRUXQB64ECQGspJ5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xdbm",
|
|
|
|
|
"FfxhMkzMnYxrMmpXDWcIqE4vTVGt08tQmVXh5YU18B8qBYvxmpRmaX+4Pfw/AAD///6KTOeVOgAA",
|
2025-01-15 19:45:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
}
|