// 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" ) // 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" ) // ExportDetails Payload for export trigger response. type ExportDetails struct { // JobId The job id relative to the export. JobId *string `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 string `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 string `json:"id"` } // 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 string `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 string `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"` } // 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 string `json:"id"` // LatestVersion The latest version of the query. LatestVersion int32 `json:"latest_version"` // RequiredQueries List of required query IDs. RequiredQueries *[]string `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 *[]string `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 string `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 *[]string `json:"required_queries,omitempty"` } // TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType. type TriggerExportJSONRequestBody = ExportTrigger // 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 { // Trigger an export // (POST /job/export) TriggerExport(ctx echo.Context) error // Check export state. // (GET /job/export/{id}) ExportState(ctx echo.Context, id string) error // Get a job collector by ID // (GET /job/{id}/collector) GetJobCollectorByJobId(ctx echo.Context, id string) error // Update a job collector // (PATCH /job/{id}/collector) UpdateJobCollectorByJobId(ctx echo.Context, id string) error // List queries // (GET /queries) ListQueries(ctx echo.Context) error // Create a new query // (POST /queries) CreateQuery(ctx echo.Context) error // Deprecate a query // (DELETE /queries/{id}) DeprecateQuery(ctx echo.Context, id string) error // Get a query by ID // (GET /queries/{id}) GetQueryById(ctx echo.Context, id string) error // Update a query // (PATCH /queries/{id}) UpdateQuery(ctx echo.Context, id string) error // Test a query // (POST /queries/{id}/test) TestQuery(ctx echo.Context, id string) error } // ServerInterfaceWrapper converts echo contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } // 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 string 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 } // GetJobCollectorByJobId converts echo context to params. func (w *ServerInterfaceWrapper) GetJobCollectorByJobId(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- var id string 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 string 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 } // DeprecateQuery converts echo context to params. func (w *ServerInterfaceWrapper) DeprecateQuery(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- var id string 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.DeprecateQuery(ctx, id) return err } // GetQueryById converts echo context to params. func (w *ServerInterfaceWrapper) GetQueryById(ctx echo.Context) error { var err error // ------------- Path parameter "id" ------------- var id string 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.GetQueryById(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 string 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 string 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+"/job/export", wrapper.TriggerExport) router.GET(baseURL+"/job/export/:id", wrapper.ExportState) router.GET(baseURL+"/job/:id/collector", wrapper.GetJobCollectorByJobId) router.PATCH(baseURL+"/job/:id/collector", wrapper.UpdateJobCollectorByJobId) router.GET(baseURL+"/queries", wrapper.ListQueries) router.POST(baseURL+"/queries", wrapper.CreateQuery) router.DELETE(baseURL+"/queries/:id", wrapper.DeprecateQuery) router.GET(baseURL+"/queries/:id", wrapper.GetQueryById) router.PATCH(baseURL+"/queries/:id", wrapper.UpdateQuery) router.POST(baseURL+"/queries/:id/test", wrapper.TestQuery) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/+RaX2/bOBL/KgTvHg073e6T39okLVz0Nr3UPSywKAyaHNnMUqRCUm69gb/7gaQkUxZl", "y/mz6KJPiS1yhjO/3/zhyA+YqrxQEqQ1ePqADV1DTvy/198Lpe0VWMKF/4KBoZoXliuJp/gT2QpFGMqU", "RuCXIqv5agUaaTCFkgbGeIQLrQrQloMXcaeWC866wuZrQHdqiThDGgSxfAPIKmTXUMl2ouy2ADzFxmou", "V3g3wqq0RWkXQlES5KTE1k8Rl+jbmtN1JBX9xQuUcQHoGxcCLQFlqpTMKYPvJC+E1/d6Opk8LEv6J9jd", "5IEKDtJytps83Kml/2t5DsaSvNgtHoJgznbjv3iROrSxxJbeGf/WkOEp/tdkD8Gk8v8kOP9zWLvbjbCG", "+5JrYHj6B+YMN3K+NirU8g6odSpam5NOKZQxfCkaPzjfO4FgvO2yzJ0edy4BFpw6LheFVisNxuARzggX", "wCLle/uC8nmgwnHaVHzhcoWIjIBucybjINgi48KCTpjzzj/woBqqCkBLYoAhJZHfiAJJ0IaIMljHLeQn", "/f/O7Q2inVGVlURrsnWfuVyBcQd4zLmazaggmuTg9nfNBskWjFjoYTUxFrnHSGV7geMewmnbK4oblHE9", "UNguQbYBIa0y74b7EvTWJYdSWOPCe1nzD1haWUz6Sk+K7zFYPTh4jiGqRJnLjqupkozXGWQgKy6bPbtR", "RVFJ8h603JPaC4GVXDp39IMW6JqWFp6h0kBWijpNBh62+N0R2mbxgX8jG0aRR5qjnHD8ZezDIwknmJ81", "oDSaWplHgDELuyZO/0oDsaDrj1QoA2zBpQW9IQKPsCpAxp8FZHbRXab5ap36nksqSgY+54f/Umltxv4D", "xpCVR7hNnxT7v0h+XwLizNWKjIMOdVJabrenud7D8w9qeamEAGpVgujxU5QrBqKbVAh1pXWxAW16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6r7YOgb2pCPIvgO0+7XDh0unpmL9fuefkqsiUFLAIma1wP9AF/vXy/04uzx", "qKPRIzEegLSDeELjaVgS7FuwmsMGDCLIhIJD25c6tNwibg2aXXUxfw82vsq93X5QyxkbAr9TMbtq0mH7", "CvlD06A1ZEyw4EPLeSzQ5XiI75f3kuA9WES6wMyuIirEJ9sTwhcBuu4riybENPf914GCb9yufbvcWHFI", "gCDjkRzYp4C2WtcXernPSIbnL02JMc+g+nSSA2XVrrxUQRnAtmDPIeFOUs3lnqgLO5lwRHtSEb+Z9O8G", "qeYWNCdd3sWTkReM9VhNItTfHFowHKb4zWYfWKH36wXJ30PvGyfU0PhdrfBP9nrhLu1QaO7DId5dPBZa", "bTgD1h/4YXsY+LxMfMU3/h+p8QuoUH+wJwZpu8x7iTEe/aBGgdb0cgxcr9HVfQWFBlph3ZT4APiR0t5s", "qzE+I50313tWC3nRsp7Cp9H8Mnn0RGg2zkPkFJSjM/qyk6C9B5+utm+351bgBjJdKf7xG7FqXt0Xoe3O", "6+9JyaFLa2BqdWfdvDy8LYvS84B27CkR+w9ovOLR1aDC0JsknqXTSjdOZybwia0ntcliff0daBkyuJ/E", "6tKPUklv3W7/cOpgbgOhqXksReqR549NkHgCPpwlz62/mjAnktTc41i9dn4K5byg04Rze0Bv0kh/0oqV", "tBlCgmv1Sy3wFK+tLcx0MiEFH1c/+RxTlU82r7CDr9J2KO+mJpwJP1cF5oiz71UrurTOuBsNk9K6kkTC", "UleSoTLDcCUS1p6q7L7u/h8AAP//+pSl8AgsAAA=", } // 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 }