// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as AssetsAPI from './assets'; import { AssetAddParams, AssetAddResponse, AssetRemoveParams, AssetRemoveResponse, Assets } from './assets'; import * as ModelsAPI from './models'; import { ModelAddParams, ModelAddResponse, ModelRemoveParams, ModelRemoveResponse, Models } from './models'; import { APIPromise } from '../../core/api-promise'; import { CollectionsCursor, type CollectionsCursorParams, PagePromise } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Collections extends APIResource { assets: AssetsAPI.Assets = new AssetsAPI.Assets(this._client); models: ModelsAPI.Models = new ModelsAPI.Models(this._client); /** * Create a new collection */ create(params: CollectionCreateParams, options?: RequestOptions): APIPromise { const { projectId, ...body } = params; return this._client.post('/collections', { query: { projectId }, body, ...options }); } /** * Get the details of a collection */ retrieve( collectionID: string, query: CollectionRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get(path`/collections/${collectionID}`, { query, ...options }); } /** * Update the name and/or thumbnail of a Collection */ update( collectionID: string, params: CollectionUpdateParams, options?: RequestOptions, ): APIPromise { const { projectId, ...body } = params; return this._client.put(path`/collections/${collectionID}`, { query: { projectId }, body, ...options }); } /** * List collections of a team */ list( query: CollectionListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList('/collections', CollectionsCursor, { query, ...options, }); } /** * Delete a collection */ delete( collectionID: string, params: CollectionDeleteParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { projectId } = params ?? {}; return this._client.delete(path`/collections/${collectionID}`, { query: { projectId }, ...options }); } } export type CollectionListResponsesCollectionsCursor = CollectionsCursor; export interface CollectionCreateResponse { collection: CollectionCreateResponse.Collection; } export namespace CollectionCreateResponse { export interface Collection { /** * The collection ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; assetCount: number; /** * The collection creation date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; itemCount: number; modelCount: number; /** * The collection name */ name: string; /** * The owner ID (example: "dcf121faaa1a0a0bbbd9ca1b73d62aea") */ ownerId: string; /** * The collection last update date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ updatedAt: string; /** * The thumbnail for the collection (if any) */ thumbnail?: Collection.Thumbnail; } export namespace Collection { /** * The thumbnail for the collection (if any) */ export interface Thumbnail { assetId: string; url: string; } } } export interface CollectionRetrieveResponse { collection: CollectionRetrieveResponse.Collection; } export namespace CollectionRetrieveResponse { export interface Collection { /** * The collection ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; assetCount: number; /** * The collection creation date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; itemCount: number; modelCount: number; /** * The collection name */ name: string; /** * The owner ID (example: "dcf121faaa1a0a0bbbd9ca1b73d62aea") */ ownerId: string; /** * The collection last update date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ updatedAt: string; /** * The thumbnail for the collection (if any) */ thumbnail?: Collection.Thumbnail; } export namespace Collection { /** * The thumbnail for the collection (if any) */ export interface Thumbnail { assetId: string; url: string; } } } export interface CollectionUpdateResponse { collection: CollectionUpdateResponse.Collection; } export namespace CollectionUpdateResponse { export interface Collection { /** * The collection ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; assetCount: number; /** * The collection creation date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; itemCount: number; modelCount: number; /** * The collection name */ name: string; /** * The owner ID (example: "dcf121faaa1a0a0bbbd9ca1b73d62aea") */ ownerId: string; /** * The collection last update date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ updatedAt: string; /** * The thumbnail for the collection (if any) */ thumbnail?: Collection.Thumbnail; } export namespace Collection { /** * The thumbnail for the collection (if any) */ export interface Thumbnail { assetId: string; url: string; } } } export interface CollectionListResponse { /** * The collection ID (example: "asset_GTrL3mq4SXWyMxkOHRxlpw") */ id: string; assetCount: number; /** * The collection creation date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ createdAt: string; itemCount: number; modelCount: number; /** * The collection name */ name: string; /** * The owner ID (example: "dcf121faaa1a0a0bbbd9ca1b73d62aea") */ ownerId: string; /** * The collection last update date as an ISO string (example: * "2023-02-03T11:19:41.579Z") */ updatedAt: string; /** * The thumbnail for the collection (if any) */ thumbnail?: CollectionListResponse.Thumbnail; } export namespace CollectionListResponse { /** * The thumbnail for the collection (if any) */ export interface Thumbnail { assetId: string; url: string; } } export type CollectionDeleteResponse = unknown; export interface CollectionCreateParams { /** * Body param: The name of the collection. */ name: string; /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; } export interface CollectionRetrieveParams { /** * The projectId used for ownership resource management. Either to assert ownership * or to set the owner of the resource(s) */ projectId?: string; } export interface CollectionUpdateParams { /** * Query param: The projectId used for ownership resource management. Either to * assert ownership or to set the owner of the resource(s) */ projectId?: string; /** * Body param: The new name for the Collection */ name?: string; /** * Body param: The AssetId of the image you want to use as a thumbnail for the * collection. Set to null to unset the thumbnail. */ thumbnail?: string; } export interface CollectionListParams extends CollectionsCursorParams { /** * The number of items to return in the response. The default value is 10, maximum * value is 100, minimum value is 1 */ pageSize?: number; /** * The projectId used for ownership resource management. Either to assert ownership * or to set the owner of the resource(s) */ projectId?: string; } export interface CollectionDeleteParams { /** * The projectId used for ownership resource management. Either to assert ownership * or to set the owner of the resource(s) */ projectId?: string; } Collections.Assets = Assets; Collections.Models = Models; export declare namespace Collections { export { type CollectionCreateResponse as CollectionCreateResponse, type CollectionRetrieveResponse as CollectionRetrieveResponse, type CollectionUpdateResponse as CollectionUpdateResponse, type CollectionListResponse as CollectionListResponse, type CollectionDeleteResponse as CollectionDeleteResponse, type CollectionListResponsesCollectionsCursor as CollectionListResponsesCollectionsCursor, type CollectionCreateParams as CollectionCreateParams, type CollectionRetrieveParams as CollectionRetrieveParams, type CollectionUpdateParams as CollectionUpdateParams, type CollectionListParams as CollectionListParams, type CollectionDeleteParams as CollectionDeleteParams, }; export { Assets as Assets, type AssetAddResponse as AssetAddResponse, type AssetRemoveResponse as AssetRemoveResponse, type AssetAddParams as AssetAddParams, type AssetRemoveParams as AssetRemoveParams, }; export { Models as Models, type ModelAddResponse as ModelAddResponse, type ModelRemoveResponse as ModelRemoveResponse, type ModelAddParams as ModelAddParams, type ModelRemoveParams as ModelRemoveParams, }; }