batches.js 1.5 KB

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