Merged in feature/jobstatusendpoint (pull request #85)
Job Status Endpoint * edpoint
This commit is contained in:
+118
-3
@@ -139,9 +139,6 @@ type Job struct {
|
||||
|
||||
// Id The job id
|
||||
Id openapi_types.UUID `json:"id"`
|
||||
|
||||
// Status Specifies the status of a job.
|
||||
Status JobStatus `json:"status"`
|
||||
}
|
||||
|
||||
// JobClient defines model for JobClient.
|
||||
@@ -210,6 +207,15 @@ type JobCreate struct {
|
||||
// JobStatus Specifies the status of a job.
|
||||
type JobStatus string
|
||||
|
||||
// JobStatusBody defines model for JobStatusBody.
|
||||
type JobStatusBody struct {
|
||||
// JobId The job id
|
||||
JobId openapi_types.UUID `json:"job_id"`
|
||||
|
||||
// Status Specifies the status of a job.
|
||||
Status JobStatus `json:"status"`
|
||||
}
|
||||
|
||||
// JobUpdate defines model for JobUpdate.
|
||||
type JobUpdate struct {
|
||||
// CanSync Specifies whether the job is actively syncing
|
||||
@@ -433,6 +439,9 @@ type ClientInterface interface {
|
||||
// ExportState request
|
||||
ExportState(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// GetJobStatusByJobId request
|
||||
GetJobStatusByJobId(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
// ListQueries request
|
||||
ListQueries(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
||||
|
||||
@@ -659,6 +668,18 @@ func (c *Client) ExportState(ctx context.Context, id openapi_types.UUID, reqEdit
|
||||
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 {
|
||||
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) ListQueries(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
||||
req, err := NewListQueriesRequest(c.Server)
|
||||
if err != nil {
|
||||
@@ -1186,6 +1207,40 @@ func NewExportStateRequest(server string, id openapi_types.UUID) (*http.Request,
|
||||
return req, nil
|
||||
}
|
||||
|
||||
// NewGetJobStatusByJobIdRequest generates requests for GetJobStatusByJobId
|
||||
func NewGetJobStatusByJobIdRequest(server string, id openapi_types.UUID) (*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/status", 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
|
||||
}
|
||||
|
||||
// NewListQueriesRequest generates requests for ListQueries
|
||||
func NewListQueriesRequest(server string) (*http.Request, error) {
|
||||
var err error
|
||||
@@ -1469,6 +1524,9 @@ type ClientWithResponsesInterface interface {
|
||||
// ExportStateWithResponse request
|
||||
ExportStateWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*ExportStateResponse, error)
|
||||
|
||||
// GetJobStatusByJobIdWithResponse request
|
||||
GetJobStatusByJobIdWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJobStatusByJobIdResponse, error)
|
||||
|
||||
// ListQueriesWithResponse request
|
||||
ListQueriesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListQueriesResponse, error)
|
||||
|
||||
@@ -1730,6 +1788,28 @@ func (r ExportStateResponse) StatusCode() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
type GetJobStatusByJobIdResponse struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
JSON200 *JobStatusBody
|
||||
}
|
||||
|
||||
// Status returns HTTPResponse.Status
|
||||
func (r GetJobStatusByJobIdResponse) Status() string {
|
||||
if r.HTTPResponse != nil {
|
||||
return r.HTTPResponse.Status
|
||||
}
|
||||
return http.StatusText(0)
|
||||
}
|
||||
|
||||
// StatusCode returns HTTPResponse.StatusCode
|
||||
func (r GetJobStatusByJobIdResponse) StatusCode() int {
|
||||
if r.HTTPResponse != nil {
|
||||
return r.HTTPResponse.StatusCode
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ListQueriesResponse struct {
|
||||
Body []byte
|
||||
HTTPResponse *http.Response
|
||||
@@ -1986,6 +2066,15 @@ func (c *ClientWithResponses) ExportStateWithResponse(ctx context.Context, id op
|
||||
return ParseExportStateResponse(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...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ParseGetJobStatusByJobIdResponse(rsp)
|
||||
}
|
||||
|
||||
// ListQueriesWithResponse request returning *ListQueriesResponse
|
||||
func (c *ClientWithResponses) ListQueriesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ListQueriesResponse, error) {
|
||||
rsp, err := c.ListQueries(ctx, reqEditors...)
|
||||
@@ -2311,6 +2400,32 @@ func ParseExportStateResponse(rsp *http.Response) (*ExportStateResponse, error)
|
||||
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)
|
||||
defer func() { _ = rsp.Body.Close() }()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := &GetJobStatusByJobIdResponse{
|
||||
Body: bodyBytes,
|
||||
HTTPResponse: rsp,
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
||||
var dest JobStatusBody
|
||||
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response.JSON200 = &dest
|
||||
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// ParseListQueriesResponse parses an HTTP response from a ListQueriesWithResponse call
|
||||
func ParseListQueriesResponse(rsp *http.Response) (*ListQueriesResponse, error) {
|
||||
bodyBytes, err := io.ReadAll(rsp.Body)
|
||||
|
||||
Reference in New Issue
Block a user