batches.mjs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. import { APIResource } from "../resource.mjs";
  3. import { isRequestOptions } from "../core.mjs";
  4. import { CursorPage } from "../pagination.mjs";
  5. export class Batches extends APIResource {
  6. /**
  7. * Creates and executes a batch from an uploaded file of requests
  8. */
  9. create(body, options) {
  10. return this._client.post('/batches', { body, ...options });
  11. }
  12. /**
  13. * Retrieves a batch.
  14. */
  15. retrieve(batchId, options) {
  16. return this._client.get(`/batches/${batchId}`, options);
  17. }
  18. list(query = {}, options) {
  19. if (isRequestOptions(query)) {
  20. return this.list({}, query);
  21. }
  22. return this._client.getAPIList('/batches', BatchesPage, { query, ...options });
  23. }
  24. /**
  25. * Cancels an in-progress batch. The batch will be in status `cancelling` for up to
  26. * 10 minutes, before changing to `cancelled`, where it will have partial results
  27. * (if any) available in the output file.
  28. */
  29. cancel(batchId, options) {
  30. return this._client.post(`/batches/${batchId}/cancel`, options);
  31. }
  32. }
  33. export class BatchesPage extends CursorPage {
  34. }
  35. Batches.BatchesPage = BatchesPage;
  36. //# sourceMappingURL=batches.mjs.map