Merged in feature/apitidyup (pull request #24)
Export API Clean Up * exportapi
This commit is contained in:
+120
-31
@@ -18,21 +18,82 @@ import (
|
|||||||
"github.com/oapi-codegen/runtime"
|
"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.
|
// Defines values for QueryType.
|
||||||
const (
|
const (
|
||||||
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
||||||
JSONEXTRACTOR QueryType = "JSON_EXTRACTOR"
|
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.
|
// ExportTrigger Payload for triggering an export.
|
||||||
type ExportTrigger struct {
|
type ExportTrigger struct {
|
||||||
// ExampleProperty Example property for ExportTrigger.
|
// FieldFilters Filter the scope based on field output values.
|
||||||
ExampleProperty *string `json:"example_property,omitempty"`
|
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.
|
// IdMessage defines model for IdMessage.
|
||||||
type IdMessage struct {
|
type IdMessage struct {
|
||||||
// Id Unique identifier.
|
// Id Unique identifier for entity.
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +205,11 @@ type TestQueryJSONRequestBody = QueryTestRequest
|
|||||||
// ServerInterface represents all server handlers.
|
// ServerInterface represents all server handlers.
|
||||||
type ServerInterface interface {
|
type ServerInterface interface {
|
||||||
// Trigger an export
|
// Trigger an export
|
||||||
// (POST /exports/trigger)
|
// (POST /export)
|
||||||
TriggerExport(ctx echo.Context) error
|
TriggerExport(ctx echo.Context) error
|
||||||
|
// Check export state.
|
||||||
|
// (GET /export/{id})
|
||||||
|
ExportState(ctx echo.Context, id string) error
|
||||||
// Create a job collector
|
// Create a job collector
|
||||||
// (POST /job-collectors)
|
// (POST /job-collectors)
|
||||||
CreateJobCollector(ctx echo.Context) error
|
CreateJobCollector(ctx echo.Context) error
|
||||||
@@ -189,6 +253,22 @@ func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error {
|
|||||||
return err
|
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.
|
// CreateJobCollector converts echo context to params.
|
||||||
func (w *ServerInterfaceWrapper) CreateJobCollector(ctx echo.Context) error {
|
func (w *ServerInterfaceWrapper) CreateJobCollector(ctx echo.Context) error {
|
||||||
var err error
|
var err error
|
||||||
@@ -340,7 +420,8 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
|
|||||||
Handler: si,
|
Handler: si,
|
||||||
}
|
}
|
||||||
|
|
||||||
router.POST(baseURL+"/exports/trigger", wrapper.TriggerExport)
|
router.POST(baseURL+"/export", wrapper.TriggerExport)
|
||||||
|
router.GET(baseURL+"/export/:id", wrapper.ExportState)
|
||||||
router.POST(baseURL+"/job-collectors", wrapper.CreateJobCollector)
|
router.POST(baseURL+"/job-collectors", wrapper.CreateJobCollector)
|
||||||
router.GET(baseURL+"/job-collectors/:id", wrapper.GetJobCollectorById)
|
router.GET(baseURL+"/job-collectors/:id", wrapper.GetJobCollectorById)
|
||||||
router.PUT(baseURL+"/job-collectors/:id", wrapper.UpdateJobCollector)
|
router.PUT(baseURL+"/job-collectors/:id", wrapper.UpdateJobCollector)
|
||||||
@@ -356,32 +437,40 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL
|
|||||||
// Base64 encoded, gzipped, json marshaled Swagger object
|
// Base64 encoded, gzipped, json marshaled Swagger object
|
||||||
var swaggerSpec = []string{
|
var swaggerSpec = []string{
|
||||||
|
|
||||||
"H4sIAAAAAAAC/9RZS2/bOBD+KwR3j17bfZx8S5Ns4aLbZFN3UaAIAloc2wwkUSFHbo3C/31BUm9RkVzb",
|
"H4sIAAAAAAAC/9RaUW/bOBL+KwTvHn12ut0nv3WTtHDR2/RS97DAojBocmQzS5MKSbn1Bv7vC5KSTEmU",
|
||||||
"RXtrZHKe33wznH6ngYwSGUOMms6+Ux1sIGL2n9ffEqlwocR6Dcp84KADJRIUMqYzest2oWScrKQi6A6J",
|
"LTdJkT61lsgZzsw33wxHecBUbXIlQVqDpw/Y0DVsiP/v9bdcaXsFlnDhHzAwVPPcciXxFH8kO6EIQ5nS",
|
||||||
"eE1YTMBeHNMRTZRMQKEAKxC+sSgJ4SH7umvLvHYnSH7CCq/ZYaTiLgE6oxqNQrrfF1/k8hECpPsRnfN/",
|
"CPxSZDVfrUAjDSZX0sAYj3CuVQ7acvAi7tRywVlX2HwN6E4tEWdIgyCWbwFZhewaStlOlN3lgKfYWM3l",
|
||||||
"QGu2BqOjboXgbb2fYvGUAhEcYhQr0aVGwVMqFHA6+2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J2J+g8YpHlYMKQy9JPEmnlW6cziTwia0m88li",
|
||||||
|
"ff0NaBEY3E/edeFH56S3bjf/UqU1q4PQ1HwvRKoR98sGSPzFYzhKnlp/+UUhQVJzH0f/BeFxkPOCTgPO",
|
||||||
|
"7QG9TUf6o1asoPXQGVyrX2iBp3htbW6mkwnJ+bj8Aj6majPZvsIufKW2trybCnAm/H0gMAecQ69awqVx",
|
||||||
|
"xv1omJTGlSQSlrqSDJUZhmqRsOY0bf9l/08AAAD//yOojal5KQAA",
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSwagger returns the content of the embedded swagger specification file
|
// GetSwagger returns the content of the embedded swagger specification file
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ import (
|
|||||||
func (s *Controllers) TriggerExport(ctx echo.Context) error {
|
func (s *Controllers) TriggerExport(ctx echo.Context) error {
|
||||||
return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"})
|
return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Controllers) ExportState(ctx echo.Context, id string) error {
|
||||||
|
return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"})
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@@ -25,3 +26,19 @@ func TestTriggerExport(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusOK, rec.Code)
|
assert.Equal(t, http.StatusOK, rec.Code)
|
||||||
assert.NotEmpty(t, rec.Body.String())
|
assert.NotEmpty(t, rec.Body.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExportState(t *testing.T) {
|
||||||
|
e := echo.New()
|
||||||
|
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(""))
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
ctx := e.NewContext(req, rec)
|
||||||
|
|
||||||
|
cons := queryservice.NewControllers(validator.New(), &queryservice.Services{})
|
||||||
|
|
||||||
|
id := uuid.NewString()
|
||||||
|
|
||||||
|
err := cons.ExportState(ctx, id)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, http.StatusOK, rec.Code)
|
||||||
|
assert.NotEmpty(t, rec.Body.String())
|
||||||
|
}
|
||||||
|
|||||||
@@ -132,5 +132,5 @@ require (
|
|||||||
golang.org/x/sys v0.28.0 // indirect
|
golang.org/x/sys v0.28.0 // indirect
|
||||||
golang.org/x/text v0.21.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20241209162323-e6fa225c2576 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|||||||
+174
-4
@@ -16,21 +16,82 @@ import (
|
|||||||
"github.com/oapi-codegen/runtime"
|
"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.
|
// Defines values for QueryType.
|
||||||
const (
|
const (
|
||||||
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
CONTEXTFULL QueryType = "CONTEXT_FULL"
|
||||||
JSONEXTRACTOR QueryType = "JSON_EXTRACTOR"
|
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.
|
// ExportTrigger Payload for triggering an export.
|
||||||
type ExportTrigger struct {
|
type ExportTrigger struct {
|
||||||
// ExampleProperty Example property for ExportTrigger.
|
// FieldFilters Filter the scope based on field output values.
|
||||||
ExampleProperty *string `json:"example_property,omitempty"`
|
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.
|
// IdMessage defines model for IdMessage.
|
||||||
type IdMessage struct {
|
type IdMessage struct {
|
||||||
// Id Unique identifier.
|
// Id Unique identifier for entity.
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +278,9 @@ type ClientInterface interface {
|
|||||||
|
|
||||||
TriggerExport(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
TriggerExport(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||||
|
|
||||||
|
// ExportState request
|
||||||
|
ExportState(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||||
|
|
||||||
// CreateJobCollectorWithBody request with any body
|
// CreateJobCollectorWithBody request with any body
|
||||||
CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||||
|
|
||||||
@@ -279,6 +343,18 @@ func (c *Client) TriggerExport(ctx context.Context, body TriggerExportJSONReques
|
|||||||
return c.Client.Do(req)
|
return c.Client.Do(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) ExportState(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||||
|
req, err := NewExportStateRequest(c.Server, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req = req.WithContext(ctx)
|
||||||
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return c.Client.Do(req)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
func (c *Client) CreateJobCollectorWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||||
req, err := NewCreateJobCollectorRequestWithBody(c.Server, contentType, body)
|
req, err := NewCreateJobCollectorRequestWithBody(c.Server, contentType, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -467,7 +543,7 @@ func NewTriggerExportRequestWithBody(server string, contentType string, body io.
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
operationPath := fmt.Sprintf("/exports/trigger")
|
operationPath := fmt.Sprintf("/export")
|
||||||
if operationPath[0] == '/' {
|
if operationPath[0] == '/' {
|
||||||
operationPath = "." + operationPath
|
operationPath = "." + operationPath
|
||||||
}
|
}
|
||||||
@@ -487,6 +563,40 @@ func NewTriggerExportRequestWithBody(server string, contentType string, body io.
|
|||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewExportStateRequest generates requests for ExportState
|
||||||
|
func NewExportStateRequest(server string, id string) (*http.Request, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
var pathParam0 string
|
||||||
|
|
||||||
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
serverURL, err := url.Parse(server)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
operationPath := fmt.Sprintf("/export/%s", pathParam0)
|
||||||
|
if operationPath[0] == '/' {
|
||||||
|
operationPath = "." + operationPath
|
||||||
|
}
|
||||||
|
|
||||||
|
queryURL, err := serverURL.Parse(operationPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return req, nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewCreateJobCollectorRequest calls the generic CreateJobCollector builder with application/json body
|
// NewCreateJobCollectorRequest calls the generic CreateJobCollector builder with application/json body
|
||||||
func NewCreateJobCollectorRequest(server string, body CreateJobCollectorJSONRequestBody) (*http.Request, error) {
|
func NewCreateJobCollectorRequest(server string, body CreateJobCollectorJSONRequestBody) (*http.Request, error) {
|
||||||
var bodyReader io.Reader
|
var bodyReader io.Reader
|
||||||
@@ -885,6 +995,9 @@ type ClientWithResponsesInterface interface {
|
|||||||
|
|
||||||
TriggerExportWithResponse(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error)
|
TriggerExportWithResponse(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error)
|
||||||
|
|
||||||
|
// ExportStateWithResponse request
|
||||||
|
ExportStateWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ExportStateResponse, error)
|
||||||
|
|
||||||
// CreateJobCollectorWithBodyWithResponse request with any body
|
// CreateJobCollectorWithBodyWithResponse request with any body
|
||||||
CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error)
|
CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error)
|
||||||
|
|
||||||
@@ -945,6 +1058,28 @@ func (r TriggerExportResponse) StatusCode() int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExportStateResponse struct {
|
||||||
|
Body []byte
|
||||||
|
HTTPResponse *http.Response
|
||||||
|
JSON200 *ExportDetails
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status returns HTTPResponse.Status
|
||||||
|
func (r ExportStateResponse) Status() string {
|
||||||
|
if r.HTTPResponse != nil {
|
||||||
|
return r.HTTPResponse.Status
|
||||||
|
}
|
||||||
|
return http.StatusText(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusCode returns HTTPResponse.StatusCode
|
||||||
|
func (r ExportStateResponse) StatusCode() int {
|
||||||
|
if r.HTTPResponse != nil {
|
||||||
|
return r.HTTPResponse.StatusCode
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
type CreateJobCollectorResponse struct {
|
type CreateJobCollectorResponse struct {
|
||||||
Body []byte
|
Body []byte
|
||||||
HTTPResponse *http.Response
|
HTTPResponse *http.Response
|
||||||
@@ -1157,6 +1292,15 @@ func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, bod
|
|||||||
return ParseTriggerExportResponse(rsp)
|
return ParseTriggerExportResponse(rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ExportStateWithResponse request returning *ExportStateResponse
|
||||||
|
func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) {
|
||||||
|
rsp, err := c.ExportState(ctx, id, reqEditors...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ParseExportStateResponse(rsp)
|
||||||
|
}
|
||||||
|
|
||||||
// CreateJobCollectorWithBodyWithResponse request with arbitrary body returning *CreateJobCollectorResponse
|
// CreateJobCollectorWithBodyWithResponse request with arbitrary body returning *CreateJobCollectorResponse
|
||||||
func (c *ClientWithResponses) CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error) {
|
func (c *ClientWithResponses) CreateJobCollectorWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJobCollectorResponse, error) {
|
||||||
rsp, err := c.CreateJobCollectorWithBody(ctx, contentType, body, reqEditors...)
|
rsp, err := c.CreateJobCollectorWithBody(ctx, contentType, body, reqEditors...)
|
||||||
@@ -1304,6 +1448,32 @@ func ParseTriggerExportResponse(rsp *http.Response) (*TriggerExportResponse, err
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ParseExportStateResponse parses an HTTP response from a ExportStateWithResponse call
|
||||||
|
func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error) {
|
||||||
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||||
|
defer func() { _ = rsp.Body.Close() }()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response := &ExportStateResponse{
|
||||||
|
Body: bodyBytes,
|
||||||
|
HTTPResponse: rsp,
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
||||||
|
var dest ExportDetails
|
||||||
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.JSON200 = &dest
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ParseCreateJobCollectorResponse parses an HTTP response from a CreateJobCollectorWithResponse call
|
// ParseCreateJobCollectorResponse parses an HTTP response from a CreateJobCollectorWithResponse call
|
||||||
func ParseCreateJobCollectorResponse(rsp *http.Response) (*CreateJobCollectorResponse, error) {
|
func ParseCreateJobCollectorResponse(rsp *http.Response) (*CreateJobCollectorResponse, error) {
|
||||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ tasks:
|
|||||||
- touch .env
|
- touch .env
|
||||||
fullsuite:
|
fullsuite:
|
||||||
cmds:
|
cmds:
|
||||||
|
- task generate
|
||||||
- task lint
|
- task lint
|
||||||
- task test:unit:coverage
|
- task test:unit:coverage
|
||||||
- task test:integration
|
- task test:integration
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ paths:
|
|||||||
'404':
|
'404':
|
||||||
description: Job collector not found.
|
description: Job collector not found.
|
||||||
|
|
||||||
/exports/trigger:
|
/export:
|
||||||
post:
|
post:
|
||||||
operationId: triggerExport
|
operationId: triggerExport
|
||||||
tags:
|
tags:
|
||||||
@@ -251,6 +251,32 @@ paths:
|
|||||||
$ref: '#/components/schemas/IdMessage'
|
$ref: '#/components/schemas/IdMessage'
|
||||||
'400':
|
'400':
|
||||||
description: Invalid request body.
|
description: Invalid request body.
|
||||||
|
'404':
|
||||||
|
description: Job not found.
|
||||||
|
|
||||||
|
/export/{id}:
|
||||||
|
get:
|
||||||
|
operationId: exportState
|
||||||
|
tags:
|
||||||
|
- ExportService
|
||||||
|
summary: Check export state.
|
||||||
|
description: Checks the current state of an export.
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
description: The ID of the export.
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Export has been completed.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ExportDetails'
|
||||||
|
'404':
|
||||||
|
description: Export job not found.
|
||||||
|
|
||||||
|
|
||||||
components:
|
components:
|
||||||
@@ -366,7 +392,7 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
type: string
|
type: string
|
||||||
description: Unique identifier.
|
description: Unique identifier for entity.
|
||||||
required:
|
required:
|
||||||
- id
|
- id
|
||||||
|
|
||||||
@@ -397,7 +423,81 @@ components:
|
|||||||
ExportTrigger:
|
ExportTrigger:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
example_property:
|
job_id:
|
||||||
type: string
|
type: string
|
||||||
description: Example property for ExportTrigger.
|
description: The job id of the query results to be exported.
|
||||||
|
ingestion_filters:
|
||||||
|
type: object
|
||||||
|
description: Filter the scope based on ingestion parameters.
|
||||||
|
properties:
|
||||||
|
start_date:
|
||||||
|
type: string
|
||||||
|
description: This first date of ingestion.
|
||||||
|
end_date:
|
||||||
|
type: string
|
||||||
|
description: The last date of ingestion.
|
||||||
|
field_filters:
|
||||||
|
type: array
|
||||||
|
description: Filter the scope based on field output values.
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/FieldFilter'
|
||||||
description: Payload for triggering an export.
|
description: Payload for triggering an export.
|
||||||
|
required:
|
||||||
|
- job_id
|
||||||
|
|
||||||
|
FieldFilter:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
field_name:
|
||||||
|
type: string
|
||||||
|
description: The name of the field in question.
|
||||||
|
condition:
|
||||||
|
$ref: "#/components/schemas/FieldFilterCondition"
|
||||||
|
values:
|
||||||
|
type: array
|
||||||
|
description: The values useful to the filter.
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: Filtering a column
|
||||||
|
required:
|
||||||
|
- field_name
|
||||||
|
- condition
|
||||||
|
- values
|
||||||
|
|
||||||
|
FieldFilterCondition:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- less_than
|
||||||
|
- greater_than
|
||||||
|
- closed_interval
|
||||||
|
- open_interval
|
||||||
|
- left_closed_interval
|
||||||
|
- right_closed_interval
|
||||||
|
- include
|
||||||
|
- exclude
|
||||||
|
description: The possible field filtering conditions.
|
||||||
|
|
||||||
|
ExportStatus:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- completed
|
||||||
|
- in_progress
|
||||||
|
- failed
|
||||||
|
description: The possible export job states.
|
||||||
|
|
||||||
|
ExportDetails:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
job_id:
|
||||||
|
type: string
|
||||||
|
description: The job id relative to the export.
|
||||||
|
status:
|
||||||
|
$ref: '#/components/schemas/ExportStatus'
|
||||||
|
output_location:
|
||||||
|
type: string
|
||||||
|
description: The location in which the export zip file will be found.
|
||||||
|
example: s3://{bucket}/{clientid}/{jobid}/{timestamp}_{exportid}.zip
|
||||||
|
description: Payload for export trigger response.
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- status
|
||||||
|
|||||||
Reference in New Issue
Block a user