files.mjs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. import { APIResource } from "../../../core/resource.mjs";
  3. import * as ContentAPI from "./content.mjs";
  4. import { Content } from "./content.mjs";
  5. import { CursorPage } from "../../../core/pagination.mjs";
  6. import { buildHeaders } from "../../../internal/headers.mjs";
  7. import { multipartFormRequestOptions } from "../../../internal/uploads.mjs";
  8. import { path } from "../../../internal/utils/path.mjs";
  9. export class Files extends APIResource {
  10. constructor() {
  11. super(...arguments);
  12. this.content = new ContentAPI.Content(this._client);
  13. }
  14. /**
  15. * Create a Container File
  16. *
  17. * You can send either a multipart/form-data request with the raw file content, or
  18. * a JSON request with a file ID.
  19. */
  20. create(containerID, body, options) {
  21. return this._client.post(path `/containers/${containerID}/files`, multipartFormRequestOptions({ body, ...options }, this._client));
  22. }
  23. /**
  24. * Retrieve Container File
  25. */
  26. retrieve(fileID, params, options) {
  27. const { container_id } = params;
  28. return this._client.get(path `/containers/${container_id}/files/${fileID}`, options);
  29. }
  30. /**
  31. * List Container files
  32. */
  33. list(containerID, query = {}, options) {
  34. return this._client.getAPIList(path `/containers/${containerID}/files`, (CursorPage), {
  35. query,
  36. ...options,
  37. });
  38. }
  39. /**
  40. * Delete Container File
  41. */
  42. delete(fileID, params, options) {
  43. const { container_id } = params;
  44. return this._client.delete(path `/containers/${container_id}/files/${fileID}`, {
  45. ...options,
  46. headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
  47. });
  48. }
  49. }
  50. Files.Content = Content;
  51. //# sourceMappingURL=files.mjs.map