// 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 { // ExampleProperty Example property for JobCollector. ExampleProperty *string `json:"example_property,omitempty"` } // JobCollectorCreate Payload for creating a JobCollector. type JobCollectorCreate struct { // ExampleProperty Example property for JobCollectorCreate. ExampleProperty *string `json:"example_property,omitempty"` } // JobCollectorUpdate Payload for updating a JobCollector. type JobCollectorUpdate struct { // ExampleProperty Example property for JobCollectorUpdate. ExampleProperty *string `json:"example_property,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 // CreateJobCollectorJSONRequestBody defines body for CreateJobCollector for application/json ContentType. type CreateJobCollectorJSONRequestBody = JobCollectorCreate // UpdateJobCollectorJSONRequestBody defines body for UpdateJobCollector for application/json ContentType. type UpdateJobCollectorJSONRequestBody = 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 /export) TriggerExport(ctx echo.Context) error // Check export state. // (GET /export/{id}) ExportState(ctx echo.Context, id string) error // Create a job collector // (POST /job-collectors) CreateJobCollector(ctx echo.Context) error // Get a job collector by ID // (GET /job-collectors/{id}) GetJobCollectorById(ctx echo.Context, id string) error // Update a job collector // (PUT /job-collectors/{id}) UpdateJobCollector(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 } // CreateJobCollector converts echo context to params. func (w *ServerInterfaceWrapper) CreateJobCollector(ctx echo.Context) error { var err error // Invoke the callback with all the unmarshaled arguments err = w.Handler.CreateJobCollector(ctx) return err } // GetJobCollectorById converts echo context to params. func (w *ServerInterfaceWrapper) GetJobCollectorById(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.GetJobCollectorById(ctx, id) return err } // UpdateJobCollector converts echo context to params. func (w *ServerInterfaceWrapper) UpdateJobCollector(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.UpdateJobCollector(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+"/export", wrapper.TriggerExport) router.GET(baseURL+"/export/:id", wrapper.ExportState) router.POST(baseURL+"/job-collectors", wrapper.CreateJobCollector) router.GET(baseURL+"/job-collectors/:id", wrapper.GetJobCollectorById) router.PUT(baseURL+"/job-collectors/:id", wrapper.UpdateJobCollector) 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/9RaX2/bOBL/KgTvHn12ut0nv3WTtHDR2/RS97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APPm57KxnlQejoJfVG2p8/VRAwg", "WbDnu3JP1HWfzDeiOZmKv/v4Ly9Ucwuaky7h4knYM4Z4rCYR4W/aFgyHKf5u1AdW6PV7QfJzh/vaCRU0", "flcj6gfU/HDz8YHu4jHXassZsP6ID9vDgO954iue8Lykuh9QecZ6X+PRD2oUaHV1Z+B6zK7uK8g10BLr", "usIHwI9U9npbhfEZ6bwe57BKyLNW8xQ+tebnyaMnQrN2HiKnoByd0ZadBO0d+HS1O78PqyH7efqv8vtE", "X4Q2G64fk5JDc1bD1GjKunmZWLoe1o9F6XlAH/aYiP0JGq94VDmoMPQmiSfptNKN05kJfGKryXyyWF9/", "A1qEDO4n77rwo3PSW7ebf5bSmtVBaGq+lyLViPtlEyT+4jGcJU+tv/yikEhSc4+j/4LwOMp5QacJ5/aA", "3qaR/qgVK2g9dAbX6hda4CleW5ub6WRCcj4uP3ePqdpMtq+wg6/U1pZ3UxHOhD8GBOaIc+hVS7o0zrgf", "DZPSuJJEwlJXkqEyw1AtEtacpu2/7P8JAAD//02yIGRmKQAA", } // 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 }