(jobId: string, payload: any, options: InvokeOptions = {})
| 540 | } |
| 541 | |
| 542 | async invokeJob(jobId: string, payload: any, options: InvokeOptions = {}) { |
| 543 | const apiKey = await this.#apiKey(); |
| 544 | |
| 545 | this.#logger.debug("Invoking Job", { |
| 546 | jobId, |
| 547 | }); |
| 548 | |
| 549 | const body: InvokeJobRequestBody = { |
| 550 | payload, |
| 551 | context: options.context ?? {}, |
| 552 | options: { |
| 553 | accountId: options.accountId, |
| 554 | callbackUrl: options.callbackUrl, |
| 555 | }, |
| 556 | }; |
| 557 | |
| 558 | return await zodfetch(InvokeJobResponseSchema, `${this.#apiUrl}/api/v1/jobs/${jobId}/invoke`, { |
| 559 | method: "POST", |
| 560 | headers: { |
| 561 | "Content-Type": "application/json", |
| 562 | Authorization: `Bearer ${apiKey}`, |
| 563 | ...(options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}), |
| 564 | }, |
| 565 | body: JSON.stringify(body), |
| 566 | }); |
| 567 | } |
| 568 | |
| 569 | async cancelRunsForJob(jobId: string) { |
| 570 | const apiKey = await this.#apiKey(); |
no test coverage detected