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
5 changes: 4 additions & 1 deletion packages/clients/src/api/jobs/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import type { Region } from '../../../bridge'
import {
marshalCreateJobDefinitionRequest,
marshalStartJobDefinitionRequest,
marshalUpdateJobDefinitionRequest,
unmarshalJobDefinition,
unmarshalJobRun,
Expand Down Expand Up @@ -172,7 +173,9 @@ export class API extends ParentAPI {
startJobDefinition = (request: Readonly<StartJobDefinitionRequest>) =>
this.client.fetch<JobRun>(
{
body: '{}',
body: JSON.stringify(
marshalStartJobDefinitionRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/serverless-jobs/v1alpha1/regions/${validatePathParam(
Expand Down
12 changes: 12 additions & 0 deletions packages/clients/src/api/jobs/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {
JobRun,
ListJobDefinitionsResponse,
ListJobRunsResponse,
StartJobDefinitionRequest,
UpdateJobDefinitionRequest,
UpdateJobDefinitionRequestCronScheduleConfig,
} from './types.gen'
Expand Down Expand Up @@ -67,8 +68,10 @@ export const unmarshalJobRun = (data: unknown): JobRun => {
}

return {
command: data.command,
cpuLimit: data.cpu_limit,
createdAt: unmarshalDate(data.created_at),
environmentVariables: data.environment_variables,
errorMessage: data.error_message,
exitCode: data.exit_code,
id: data.id,
Expand Down Expand Up @@ -148,6 +151,15 @@ export const marshalCreateJobDefinitionRequest = (
project_id: request.projectId ?? defaults.defaultProjectId,
})

export const marshalStartJobDefinitionRequest = (
request: StartJobDefinitionRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
command: request.command,
environment_variables: request.environmentVariables,
replicas: request.replicas,
})

const marshalUpdateJobDefinitionRequestCronScheduleConfig = (
request: UpdateJobDefinitionRequestCronScheduleConfig,
defaults: DefaultValues,
Expand Down
8 changes: 8 additions & 0 deletions packages/clients/src/api/jobs/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export interface JobRun {
errorMessage: string
cpuLimit: number
memoryLimit: number
command: string
environmentVariables: Record<string, string>
/**
* Region to target. If none is passed will use default region from the
* config.
Expand Down Expand Up @@ -172,6 +174,12 @@ export type StartJobDefinitionRequest = {
region?: Region
/** UUID of the job definition to start. */
jobDefinitionId: string
/** Contextual startup command for this specific job run. */
command?: string
/** Contextual environment variables for this specific job run. */
environmentVariables?: Record<string, string>
/** Number of jobs to run. */
replicas?: number
}

export type StopJobRunRequest = {
Expand Down