diff --git a/api/queryService/api.gen.go b/api/queryService/api.gen.go index c9f01c25..89f33eda 100644 --- a/api/queryService/api.gen.go +++ b/api/queryService/api.gen.go @@ -105,9 +105,6 @@ type ExportTrigger struct { // 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 @@ -305,15 +302,15 @@ 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 +// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType. +type TriggerExportJSONRequestBody = ExportTrigger + // CreateQueryJSONRequestBody defines body for CreateQuery for application/json ContentType. type CreateQueryJSONRequestBody = QueryCreate @@ -337,9 +334,6 @@ type ServerInterface interface { // Create a new job // (POST /job) CreateJob(ctx echo.Context) error - // Trigger an export - // (POST /job/export) - TriggerExport(ctx echo.Context) error // Get a job by ID // (GET /job/{id}) GetJob(ctx echo.Context, id openapi_types.UUID) error @@ -358,6 +352,9 @@ type ServerInterface interface { // Check export state. // (GET /job/{id}/export) ExportState(ctx echo.Context, id openapi_types.UUID) error + // Trigger an export + // (POST /job/{id}/export) + TriggerExport(ctx echo.Context, id openapi_types.UUID) error // Get job status by job ID // (GET /job/{id}/status) GetJobStatusByJobId(ctx echo.Context, id openapi_types.UUID) error @@ -433,15 +430,6 @@ func (w *ServerInterfaceWrapper) CreateJob(ctx echo.Context) error { 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 -} - // GetJob converts echo context to params. func (w *ServerInterfaceWrapper) GetJob(ctx echo.Context) error { var err error @@ -538,6 +526,22 @@ func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error { return err } +// TriggerExport converts echo context to params. +func (w *ServerInterfaceWrapper) TriggerExport(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.TriggerExport(ctx, id) + return err +} + // GetJobStatusByJobId converts echo context to params. func (w *ServerInterfaceWrapper) GetJobStatusByJobId(ctx echo.Context) error { var err error @@ -652,13 +656,13 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL 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/: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+"/job/:id/documents", wrapper.ListDocumentsByJobId) router.GET(baseURL+"/job/:id/export", wrapper.ExportState) + router.POST(baseURL+"/job/:id/export", wrapper.TriggerExport) router.GET(baseURL+"/job/:id/status", wrapper.GetJobStatusByJobId) router.GET(baseURL+"/query", wrapper.ListQueries) router.POST(baseURL+"/query", wrapper.CreateQuery) @@ -671,51 +675,50 @@ func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ - "H4sIAAAAAAAC/+Rb3W/bOBL/VwjdPRp2ut0nv3WTdOGg1/Sa9LCHRWFQ1NhmKpMKSTn1Bv7fF/zSh0VZ", - "smN1s9inNhE5w5n5zQdnmOeI8HXGGTAlo+lzJMkK1tj89zKlwNSlAKxA/5wJnoFQFMxXhtfmtwlIImim", - "KGfRNLpfASJmHzILRpHaZhBNI6kEZctotxtFAh5zKiCJpr9bKl+LVTx+AKKi3cgx/5IlQeYEs7ncMtI8", - "wGyBVHkGKhFOU/5E2RJhougGkN4my3PFnKeAmWZ5ukSN019xkq+BqebJ45x8AxVmY78hwpnClOkza1ES", - "T6vBeRTRJEzJ70E0iUbRgos1VtE0ynPzc4PMN9iG6WRYrZDiHefYs6nh4eS0tEMGvv6ecaGuQGGayib3", - "T3ibcpygBRcIzFKkBF0uQSABMuNMwjga7Sn3gcfzNpU88BjRBAlIscGBk8rSHvfREs9Vlqt5ygm2dENs", - "/FdEGXpaUbKqcEF/0AwtaAroiaYpigEteM4SzRy+43WWGn5vp5PJs1XfbvJsoUeT3eT5gcfmX0XXIBVe", - "Z7v5syVMk934D5qFDi0VVrlRzr8FLKJp9K9J6fAT5+0Ta4w7u3bfnk6rBa12a94VzAJQ4lLSOC10oe2h", - "CYI08rN8rXnps6WgQLOjbJ4JvhQgtb8uME0hqTAvZbTM7y08DkPJYcjEA1Yxfh1HCwppMl/QVIEIiPPe", - "fDCGlYRngGIsIUGcIbMRWaCgDU5zKx1VsO60wXu915KOypiChcBb4+psCVIf4JRzFZtRhgVeg97fFBtY", - "MvfxNoBsLBXSnxFflATHLaATqpUUlWhBRU9ioejaw825TQOPOYitDhh5qqR2+djjD5IePh92hBD+q8Zr", - "sYvBHCI8zdesoXrCWUJ9VOmJkstiz27kINuewvQXrxWLUsq0etqNaOEbpma/oVzCIk99KLW4rOG9QbSO", - "6j39VmQY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DkJo4cnh8LPNnmeHTaesh5meHXsApqZhLfVXQ2OZlz1wcdB0PAYRfw5ODIeE", + "w55pMyH1meZxCVRu7U6lsuv+y/aGx7Nk6NKkVKoNs0rRe2dbyNpVfnm22M+0UpwTUq68ifjTjleQhJXK", + "R6RjMBCGOS33ZmEvydNK1WEztmLUGUBeEif1RnpHEutYKm7cVYc93pY9/VAWe936H5DD/nSg7aAspdf6", + "vMwLprmovKGDTrwAjpZivSSZSy4DJbMXHfatZ2toXK6AfLNxQXIhdJluXqeaiVn9pagfEtW7VxgyEvzH", + "0oFIsAvQCksUAzBUvqM9DdKNNYqXusYO45r/ndKnXTUrSw4D38FLzYxRRQ1+115jZ4Jr9Go61b0ktmoO", + "hM3+m+XXdJu59l7bnxXlnbpVQh0IKi95q6FwD1wvXpbnsijJ2gDdlmVupv1DarLa/LwFz53kZ77/+Dax", + "9vgblmc6KB6LOXBnnZ76s+r6M33zUJ4IqkBQHD7pi9n4wAd8wSYQDu/2NThHNJgz/rHUrYgA07r3XN+j", + "O2RHFEf3h+wkfxhcrY9qXxOq2tHIwF2iR2fYFqeW2XNCr8i6+vAVt/LrQPniHpG0WffsPaNSaQ8sm6nS", + "v/opJ4V/9d21lro97qyDZ+wLG+vW/wNeS4/KrIkqXjq8msAIgvn1dyC5RXPzpELkzD4QbMN1/4/H9opm", + "kGrwMKm/JOkfK+fm715mBHDo3pjRPW9+UaVsnrh0hp3eA2ITDrBPgic5KYf1IKJRlIs0mkYrpTI5nUxw", + "RsfuL0/HhK8nmzeRjhbHbZ/ebeFvaf+KFhKkuJs4ySpa/YnTbtSPzAOPazRqndojCFTlp0+qUdoeQ7Pq", + "KtVJNvoffUlWlZcj5rm0LxV7e6pR8W9Pu6+7PwMAAP//WyCUh9g/AAA=", } // GetSwagger returns the content of the embedded swagger specification file diff --git a/api/queryService/export.go b/api/queryService/export.go index 62130839..431a53b7 100644 --- a/api/queryService/export.go +++ b/api/queryService/export.go @@ -7,7 +7,7 @@ import ( "github.com/oapi-codegen/runtime/types" ) -func (s *Controllers) TriggerExport(ctx echo.Context) error { +func (s *Controllers) TriggerExport(ctx echo.Context, id types.UUID) error { return ctx.JSON(http.StatusOK, map[string]string{"status": "export triggered"}) } diff --git a/api/queryService/export_test.go b/api/queryService/export_test.go index dedf3400..e0354963 100644 --- a/api/queryService/export_test.go +++ b/api/queryService/export_test.go @@ -22,7 +22,9 @@ func TestTriggerExport(t *testing.T) { cons := queryservice.NewControllers(validator.New(), &queryservice.Services{}) - err := cons.TriggerExport(ctx) + id := uuid.New() + + err := cons.TriggerExport(ctx, id) assert.NoError(t, err) assert.Equal(t, http.StatusOK, rec.Code) assert.NotEmpty(t, rec.Body.String()) diff --git a/pkg/queryService/api.gen.go b/pkg/queryService/api.gen.go index 74744882..6b1d981d 100644 --- a/pkg/queryService/api.gen.go +++ b/pkg/queryService/api.gen.go @@ -103,9 +103,6 @@ type ExportTrigger struct { // 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 @@ -303,15 +300,15 @@ 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 +// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType. +type TriggerExportJSONRequestBody = ExportTrigger + // CreateQueryJSONRequestBody defines body for CreateQuery for application/json ContentType. type CreateQueryJSONRequestBody = QueryCreate @@ -412,11 +409,6 @@ type ClientInterface interface { CreateJob(ctx context.Context, body CreateJobJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // TriggerExportWithBody request with any body - TriggerExportWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - TriggerExport(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetJob request GetJob(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -439,6 +431,11 @@ type ClientInterface interface { // ExportState request ExportState(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // TriggerExportWithBody request with any body + TriggerExportWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + TriggerExport(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetJobStatusByJobId request GetJobStatusByJobId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -548,30 +545,6 @@ func (c *Client) CreateJob(ctx context.Context, body CreateJobJSONRequestBody, r return c.Client.Do(req) } -func (c *Client) TriggerExportWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewTriggerExportRequestWithBody(c.Server, contentType, body) - 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) TriggerExport(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewTriggerExportRequest(c.Server, body) - 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) GetJob(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetJobRequest(c.Server, id) if err != nil { @@ -668,6 +641,30 @@ func (c *Client) ExportState(ctx context.Context, id openapi_types.UUID, reqEdit return c.Client.Do(req) } +func (c *Client) TriggerExportWithBody(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTriggerExportRequestWithBody(c.Server, id, contentType, body) + 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) TriggerExport(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTriggerExportRequest(c.Server, id, body) + 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) GetJobStatusByJobId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetJobStatusByJobIdRequest(c.Server, id) if err != nil { @@ -937,46 +934,6 @@ func NewCreateJobRequestWithBody(server string, contentType string, body io.Read return req, nil } -// NewTriggerExportRequest calls the generic TriggerExport builder with application/json body -func NewTriggerExportRequest(server string, body TriggerExportJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewTriggerExportRequestWithBody(server, "application/json", bodyReader) -} - -// NewTriggerExportRequestWithBody generates requests for TriggerExport with any type of body -func NewTriggerExportRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/job/export") - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } - - req.Header.Add("Content-Type", contentType) - - return req, nil -} - // NewGetJobRequest generates requests for GetJob func NewGetJobRequest(server string, id openapi_types.UUID) (*http.Request, error) { var err error @@ -1207,6 +1164,53 @@ func NewExportStateRequest(server string, id openapi_types.UUID) (*http.Request, return req, nil } +// NewTriggerExportRequest calls the generic TriggerExport builder with application/json body +func NewTriggerExportRequest(server string, id openapi_types.UUID, body TriggerExportJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTriggerExportRequestWithBody(server, id, "application/json", bodyReader) +} + +// NewTriggerExportRequestWithBody generates requests for TriggerExport with any type of body +func NewTriggerExportRequestWithBody(server string, id openapi_types.UUID, contentType string, body io.Reader) (*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("/job/%s/export", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewGetJobStatusByJobIdRequest generates requests for GetJobStatusByJobId func NewGetJobStatusByJobIdRequest(server string, id openapi_types.UUID) (*http.Request, error) { var err error @@ -1497,11 +1501,6 @@ type ClientWithResponsesInterface interface { CreateJobWithResponse(ctx context.Context, body CreateJobJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJobResponse, error) - // TriggerExportWithBodyWithResponse request with any body - TriggerExportWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) - - TriggerExportWithResponse(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) - // GetJobWithResponse request GetJobWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobResponse, error) @@ -1524,6 +1523,11 @@ type ClientWithResponsesInterface interface { // ExportStateWithResponse request ExportStateWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error) + // TriggerExportWithBodyWithResponse request with any body + TriggerExportWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) + + TriggerExportWithResponse(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) + // GetJobStatusByJobIdWithResponse request GetJobStatusByJobIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobStatusByJobIdResponse, error) @@ -1636,28 +1640,6 @@ func (r CreateJobResponse) StatusCode() int { return 0 } -type TriggerExportResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *IdMessage -} - -// Status returns HTTPResponse.Status -func (r TriggerExportResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r TriggerExportResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} - type GetJobResponse struct { Body []byte HTTPResponse *http.Response @@ -1788,6 +1770,28 @@ func (r ExportStateResponse) StatusCode() int { return 0 } +type TriggerExportResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *IdMessage +} + +// Status returns HTTPResponse.Status +func (r TriggerExportResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TriggerExportResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type GetJobStatusByJobIdResponse struct { Body []byte HTTPResponse *http.Response @@ -1979,23 +1983,6 @@ func (c *ClientWithResponses) CreateJobWithResponse(ctx context.Context, body Cr return ParseCreateJobResponse(rsp) } -// TriggerExportWithBodyWithResponse request with arbitrary body returning *TriggerExportResponse -func (c *ClientWithResponses) TriggerExportWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { - rsp, err := c.TriggerExportWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseTriggerExportResponse(rsp) -} - -func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { - rsp, err := c.TriggerExport(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseTriggerExportResponse(rsp) -} - // GetJobWithResponse request returning *GetJobResponse func (c *ClientWithResponses) GetJobWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobResponse, error) { rsp, err := c.GetJob(ctx, id, reqEditors...) @@ -2066,6 +2053,23 @@ func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id op return ParseExportStateResponse(rsp) } +// TriggerExportWithBodyWithResponse request with arbitrary body returning *TriggerExportResponse +func (c *ClientWithResponses) TriggerExportWithBodyWithResponse(ctx context.Context, id openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { + rsp, err := c.TriggerExportWithBody(ctx, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTriggerExportResponse(rsp) +} + +func (c *ClientWithResponses) TriggerExportWithResponse(ctx context.Context, id openapi_types.UUID, body TriggerExportJSONRequestBody, reqEditors ...RequestEditorFn) (*TriggerExportResponse, error) { + rsp, err := c.TriggerExport(ctx, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTriggerExportResponse(rsp) +} + // GetJobStatusByJobIdWithResponse request returning *GetJobStatusByJobIdResponse func (c *ClientWithResponses) GetJobStatusByJobIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobStatusByJobIdResponse, error) { rsp, err := c.GetJobStatusByJobId(ctx, id, reqEditors...) @@ -2238,32 +2242,6 @@ func ParseCreateJobResponse(rsp *http.Response) (*CreateJobResponse, error) { return response, nil } -// ParseTriggerExportResponse parses an HTTP response from a TriggerExportWithResponse call -func ParseTriggerExportResponse(rsp *http.Response) (*TriggerExportResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err - } - - response := &TriggerExportResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } - - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest IdMessage - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - } - - return response, nil -} - // ParseGetJobResponse parses an HTTP response from a GetJobWithResponse call func ParseGetJobResponse(rsp *http.Response) (*GetJobResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -2400,6 +2378,32 @@ func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error) return response, nil } +// ParseTriggerExportResponse parses an HTTP response from a TriggerExportWithResponse call +func ParseTriggerExportResponse(rsp *http.Response) (*TriggerExportResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TriggerExportResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest IdMessage + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + } + + return response, nil +} + // ParseGetJobStatusByJobIdResponse parses an HTTP response from a GetJobStatusByJobIdWithResponse call func ParseGetJobStatusByJobIdResponse(rsp *http.Response) (*GetJobStatusByJobIdResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/serviceAPIs/queryService.yaml b/serviceAPIs/queryService.yaml index 113f8601..a4d11916 100644 --- a/serviceAPIs/queryService.yaml +++ b/serviceAPIs/queryService.yaml @@ -355,29 +355,6 @@ paths: "400": description: Invalid request body. - /job/export: - post: - operationId: triggerExport - tags: - - ExportService - summary: Trigger an export - description: Initiates the export process. - requestBody: - required: true - content: - application/json: - schema: - $ref: "#/components/schemas/ExportTrigger" - responses: - "201": - description: Export triggered successfully. - content: - application/json: - schema: - $ref: "#/components/schemas/IdMessage" - "400": - description: Invalid request body. - /job/{id}/export: parameters: - in: path @@ -402,6 +379,27 @@ paths: $ref: "#/components/schemas/ExportDetails" "400": description: Invalid body. + post: + operationId: triggerExport + tags: + - ExportService + summary: Trigger an export + description: Initiates the export process. + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ExportTrigger" + responses: + "201": + description: Export triggered successfully. + content: + application/json: + schema: + $ref: "#/components/schemas/IdMessage" + "400": + description: Invalid request body. components: schemas: @@ -717,10 +715,6 @@ components: ExportTrigger: type: object properties: - job_id: - type: string - format: uuid - description: The job id of the query results to be exported. ingestion_filters: type: object description: Filter the scope based on ingestion parameters. @@ -737,8 +731,6 @@ components: items: $ref: "#/components/schemas/FieldFilter" description: Payload for triggering an export. - required: - - job_id FieldFilter: type: object diff --git a/test/queryService/exportservice_test.go b/test/queryService/exportservice_test.go index 43784791..ef3f9139 100644 --- a/test/queryService/exportservice_test.go +++ b/test/queryService/exportservice_test.go @@ -7,6 +7,7 @@ import ( "queryorchestration/internal/test" queryservice "queryorchestration/pkg/queryService" + "github.com/google/uuid" "github.com/stretchr/testify/assert" ) @@ -25,7 +26,9 @@ func TestExportService(t *testing.T) { client, err := queryservice.NewClientWithResponses(c.URI) assert.NoError(t, err) - idRes, err := client.TriggerExportWithResponse(ctx, queryservice.ExportTrigger{}) + id := uuid.New() + + idRes, err := client.TriggerExportWithResponse(ctx, id, queryservice.ExportTrigger{}) assert.NoError(t, err) assert.NotNil(t, idRes) }