Skip to content

Commit 844b67c

Browse files
refactor(serverless_jobs): returns a list of job runs when starting a job definition (#1997)
Co-authored-by: Mia-Cross <[email protected]>
1 parent 7997819 commit 844b67c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

api/jobs/v1alpha1/jobs_sdk.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ var (
4242
type JobRunState string
4343

4444
const (
45-
JobRunStateUnknownState = JobRunState("unknown_state")
46-
JobRunStateQueued = JobRunState("queued")
47-
JobRunStateScheduled = JobRunState("scheduled")
48-
JobRunStateRunning = JobRunState("running")
49-
JobRunStateSucceeded = JobRunState("succeeded")
50-
JobRunStateFailed = JobRunState("failed")
51-
JobRunStateCanceled = JobRunState("canceled")
45+
JobRunStateUnknownState = JobRunState("unknown_state")
46+
JobRunStateQueued = JobRunState("queued")
47+
JobRunStateScheduled = JobRunState("scheduled")
48+
JobRunStateRunning = JobRunState("running")
49+
JobRunStateSucceeded = JobRunState("succeeded")
50+
JobRunStateFailed = JobRunState("failed")
51+
JobRunStateCanceled = JobRunState("canceled")
52+
JobRunStateInternalError = JobRunState("internal_error")
5253
)
5354

5455
func (enum JobRunState) String() string {
@@ -384,6 +385,11 @@ type StartJobDefinitionRequest struct {
384385
Replicas *uint32 `json:"replicas,omitempty"`
385386
}
386387

388+
// StartJobDefinitionResponse: start job definition response.
389+
type StartJobDefinitionResponse struct {
390+
JobRuns []*JobRun `json:"job_runs"`
391+
}
392+
387393
// StopJobRunRequest: stop job run request.
388394
type StopJobRunRequest struct {
389395
// Region: region to target. If none is passed will use default region from the config.
@@ -620,7 +626,7 @@ func (s *API) DeleteJobDefinition(req *DeleteJobDefinitionRequest, opts ...scw.R
620626
}
621627

622628
// StartJobDefinition: Run an existing job definition by its unique identifier. This will create a new job run.
623-
func (s *API) StartJobDefinition(req *StartJobDefinitionRequest, opts ...scw.RequestOption) (*JobRun, error) {
629+
func (s *API) StartJobDefinition(req *StartJobDefinitionRequest, opts ...scw.RequestOption) (*StartJobDefinitionResponse, error) {
624630
var err error
625631

626632
if req.Region == "" {
@@ -646,7 +652,7 @@ func (s *API) StartJobDefinition(req *StartJobDefinitionRequest, opts ...scw.Req
646652
return nil, err
647653
}
648654

649-
var resp JobRun
655+
var resp StartJobDefinitionResponse
650656

651657
err = s.client.Do(scwReq, &resp, opts...)
652658
if err != nil {

0 commit comments

Comments
 (0)