Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add batch status job API #280

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions batch-job.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,39 @@ func (adm *AdminClient) StartBatchJob(ctx context.Context, job string) (BatchJob
return res, nil
}

// BatchJobStatus contains the last batch job metric
type BatchJobStatus struct {
LastMetric JobMetric
}

// BatchJobStatus returns the status of the given job.
func (adm *AdminClient) BatchJobStatus(ctx context.Context, jobID string) (BatchJobStatus, error) {
values := make(url.Values)
values.Set("jobId", jobID)

resp, err := adm.executeMethod(ctx, http.MethodGet,
requestData{
relPath: adminAPIPrefix + "/status-job",
queryValues: values,
},
)
if err != nil {
return BatchJobStatus{}, err
}
defer closeResponse(resp)
if resp.StatusCode != http.StatusOK {
return BatchJobStatus{}, httpRespToErrorResponse(resp)
}

res := BatchJobStatus{}
dec := json.NewDecoder(resp.Body)
if err = dec.Decode(&res); err != nil {
return res, err
}

return res, nil
}

// DescribeBatchJob - describes a currently running Job.
func (adm *AdminClient) DescribeBatchJob(ctx context.Context, jobID string) (string, error) {
values := make(url.Values)
Expand Down
Loading