Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions packages/clients/src/api/jobs/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
unmarshalJobRun,
unmarshalListJobDefinitionsResponse,
unmarshalListJobRunsResponse,
unmarshalStartJobDefinitionResponse,
} from './marshalling.gen'
import type {
CreateJobDefinitionRequest,
Expand All @@ -28,6 +29,7 @@ import type {
ListJobRunsRequest,
ListJobRunsResponse,
StartJobDefinitionRequest,
StartJobDefinitionResponse,
StopJobRunRequest,
UpdateJobDefinitionRequest,
} from './types.gen'
Expand Down Expand Up @@ -168,10 +170,10 @@ export class API extends ParentAPI {
* new job run.
*
* @param request - The request {@link StartJobDefinitionRequest}
* @returns A Promise of JobRun
* @returns A Promise of StartJobDefinitionResponse
*/
startJobDefinition = (request: Readonly<StartJobDefinitionRequest>) =>
this.client.fetch<JobRun>(
this.client.fetch<StartJobDefinitionResponse>(
{
body: JSON.stringify(
marshalStartJobDefinitionRequest(request, this.client.settings),
Expand All @@ -186,7 +188,7 @@ export class API extends ParentAPI {
request.jobDefinitionId,
)}/start`,
},
unmarshalJobRun,
unmarshalStartJobDefinitionResponse,
)

/**
Expand Down
1 change: 1 addition & 0 deletions packages/clients/src/api/jobs/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type {
ListJobRunsRequestOrderBy,
ListJobRunsResponse,
StartJobDefinitionRequest,
StartJobDefinitionResponse,
StopJobRunRequest,
UpdateJobDefinitionRequest,
UpdateJobDefinitionRequestCronScheduleConfig,
Expand Down
15 changes: 15 additions & 0 deletions packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
ListJobDefinitionsResponse,
ListJobRunsResponse,
StartJobDefinitionRequest,
StartJobDefinitionResponse,
UpdateJobDefinitionRequest,
UpdateJobDefinitionRequestCronScheduleConfig,
} from './types.gen'
Expand Down Expand Up @@ -118,6 +119,20 @@ export const unmarshalListJobRunsResponse = (
} as ListJobRunsResponse
}

export const unmarshalStartJobDefinitionResponse = (
data: unknown,
): StartJobDefinitionResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'StartJobDefinitionResponse' failed as data isn't a dictionary.`,
)
}

return {
jobRuns: unmarshalArrayOfObject(data.job_runs, unmarshalJobRun),
} as StartJobDefinitionResponse
}

const marshalCreateJobDefinitionRequestCronScheduleConfig = (
request: CreateJobDefinitionRequestCronScheduleConfig,
defaults: DefaultValues,
Expand Down
5 changes: 5 additions & 0 deletions packages/clients/src/api/jobs/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type JobRunState =
| 'succeeded'
| 'failed'
| 'canceled'
| 'internal_error'

export type ListJobDefinitionsRequestOrderBy =
| 'created_at_asc'
Expand Down Expand Up @@ -182,6 +183,10 @@ export type StartJobDefinitionRequest = {
replicas?: number
}

export interface StartJobDefinitionResponse {
jobRuns: JobRun[]
}

export type StopJobRunRequest = {
/**
* Region to target. If none is passed will use default region from the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export const ListJobRunsRequest = {
},
}

export const StartJobDefinitionRequest = {
replicas: {
greaterThan: 0,
},
}

export const UpdateJobDefinitionRequest = {
cpuLimit: {
greaterThan: 0,
Expand Down