// 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"` // 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/9RaUW/bOBL+KwTvHn12ut0nv3WTtHDR2/RS97DAojBocmQ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b0uZqI", "ASAL9nwX90Rd90m+Ec1hVfwpyH+MoZpb0Jx0ARcPx54xxWM1iQx/07ZgeJjiT0l9wQq9fm+Q/NzhvnZC", "FRq/q5H1A2p+uPn4RHf5mGu15QxYf8aH7WHm9zz5FU94XlLdD1F5xnpfx6M/qFGi1dWdgesxu7qvINdA", "y1jXFT4E/Ehlr7dVMT6DzutxDquEPGs1T8Wn1vw8PHoiNWvnIXIqlKMz2rKTQXsHnq525/dhdch+nv6r", "/GTRl6HNhuvHUHJozuowNZqyLi8TS9fD+rGIngf0YY/J2J+g8YpHlYMKQy9JPEmnlW6cziTwia0m88li", "ff0NaBEY3E/edeFH56S3bjf/UqU1q4PQ1HwvRKoR98sGSPzFYzhKnlp/+UUhQVJzH0f/BeFxkPOCTgPO", "7QG9TUf6o1asoPXQGVyrX2iBp3htbW6mkwnJ+bj8Aj6majPZvsIufKW2trybCnAm/H0gMAecQ69awqVx", "xv1omJTGlSQSlrqSDJUZhmqRsOY0bf9l/08AAAD//yOojal5KQAA", } // 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 }