files.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Files = void 0;
  5. const tslib_1 = require("../../../internal/tslib.js");
  6. const resource_1 = require("../../../core/resource.js");
  7. const ContentAPI = tslib_1.__importStar(require("./content.js"));
  8. const content_1 = require("./content.js");
  9. const pagination_1 = require("../../../core/pagination.js");
  10. const headers_1 = require("../../../internal/headers.js");
  11. const uploads_1 = require("../../../internal/uploads.js");
  12. const path_1 = require("../../../internal/utils/path.js");
  13. class Files extends resource_1.APIResource {
  14. constructor() {
  15. super(...arguments);
  16. this.content = new ContentAPI.Content(this._client);
  17. }
  18. /**
  19. * Create a Container File
  20. *
  21. * You can send either a multipart/form-data request with the raw file content, or
  22. * a JSON request with a file ID.
  23. */
  24. create(containerID, body, options) {
  25. return this._client.post((0, path_1.path) `/containers/${containerID}/files`, (0, uploads_1.multipartFormRequestOptions)({ body, ...options }, this._client));
  26. }
  27. /**
  28. * Retrieve Container File
  29. */
  30. retrieve(fileID, params, options) {
  31. const { container_id } = params;
  32. return this._client.get((0, path_1.path) `/containers/${container_id}/files/${fileID}`, options);
  33. }
  34. /**
  35. * List Container files
  36. */
  37. list(containerID, query = {}, options) {
  38. return this._client.getAPIList((0, path_1.path) `/containers/${containerID}/files`, (pagination_1.CursorPage), {
  39. query,
  40. ...options,
  41. });
  42. }
  43. /**
  44. * Delete Container File
  45. */
  46. delete(fileID, params, options) {
  47. const { container_id } = params;
  48. return this._client.delete((0, path_1.path) `/containers/${container_id}/files/${fileID}`, {
  49. ...options,
  50. headers: (0, headers_1.buildHeaders)([{ Accept: '*/*' }, options?.headers]),
  51. });
  52. }
  53. }
  54. exports.Files = Files;
  55. Files.Content = content_1.Content;
  56. //# sourceMappingURL=files.js.map