space.schedule.update()

Change some of a job’s fields and keep the rest.

Changes the fields you give and keeps the rest. It reads the job, merges your change into it, and saves the whole job.

function update(
  id: string,
  change: Partial<JobInput>,
  options?: CallOptions
): Promise<Job>

Parameters

idstringRequired

The job’s ID: 26 lowercase letters and digits.

changeJobChangeRequired

Any of the fields create() takes: name, description, schedule, timeZone, target, signing, retry, and attemptDeadlineSeconds, with the same rules. A field you leave out keeps its current value.

options.signalAbortSignal

Cancels the call.

options.timeoutMsnumber

How long each of the two requests may take, in milliseconds. The timeoutMs set in createSpace when you leave it out, 30,000 by default.

target, signing, and retry are merged field by field, so { retry: { count: 5 } } changes only the number of retries and keeps the waits, and { target: { body: "{}" } } keeps the URL, method, and headers. To remove the headers, give headers: {}.

The merged job is checked against every rule before it is saved, so a change that breaks one fails with validation_failed and the job stays as it was. When the schedule or time zone changes, the next run time is worked out again.

Returns

A promise of the changed job.

The job is read and then saved as a whole, so a change someone else makes between the two is overwritten. Both requests are sent again, up to retries times, when they fail in a way that may pass, such as a network failure or 503.

Errors

CodeWhen
validation_failedid is not a job ID, or the merged job breaks a rule. issues names each field
not_foundThe project has no job with that ID
job_name_takenAnother job in the project has the new name, ignoring case

Every call can also fail with the codes shared by all of space, such as missing_project or network_error. See SpaceError.

Example

update-job.ts
import { space } from "digitospace"

const job = await space.schedule.update("01m3c081d2wj4g63qcr53pa1yh", {
  schedule: "0 3 * * *",
  retry: { count: 5, minBackoffSeconds: 30 },
})

console.log(job.schedule, job.nextRunAt)

Last updated