Files
query-orchestration/api/queryService/api.gen.go
T
Michael McGuinness 4ec1d51a12 Merged in feature/jobcrud (pull request #35)
Job CRUD + Collector Integration

* startedcreate

* openapispec

* createjobintegration

* jobgetcontroller

* jobcreateclient

* updatejob

* job

* collector
2025-01-24 14:52:56 +00:00

715 lines
26 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 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"`
}
// ExportDetails Payload for export trigger response.
type ExportDetails struct {
// JobId The job id relative to the export.
JobId *openapi_types.UUID `json:"job_id,omitempty"`
// 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"`
}
// JobUpdate defines model for JobUpdate.
type JobUpdate struct {
// CanSync Specifies whether the job is actively syncing
CanSync *bool `json:"can_sync,omitempty"`
}
// 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
// Check export state.
// (GET /job/export/{id})
ExportState(ctx echo.Context, id openapi_types.UUID) 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 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
}
// 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
}
// 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
}
// 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/export/:id", wrapper.ExportState)
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+"/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/+RbX2/bthb/KoTufTTsdN2T37o0HRz0rr1tejFgCAyKOraZ0aJCUk69wN/9gjzUP0u0",
"5CTaMuypTUSeQ/7O7/whD/MYMbnNZAqp0dH8MdJsA1vq/nspOKTmUgE1YH/OlMxAGQ7ua0q37rcJaKZ4",
"ZrhMo3l0swHC3DziBkwis88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ns 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
}