Skip to content

@ubstream/ubstream-node-client-sdk / Exports / LibrariesCollectionsClient

Class: LibrariesCollectionsClient

This class provides access to methods concerning features in a library collection context.

Hierarchy

  • AbstractClient

LibrariesCollectionsClient

Table of contents

Properties

Methods

Properties

authz

Readonly authz: LibrariesCollectionsAuthzClient

Attribute to access all methods concerning authorizations of libraries collections.


medias

Readonly medias: LibrariesCollectionsMediasClient

Attribute to access all methods concerning medias in libraries collections.

Methods

createCollection

createCollection(libraryId, collectionId, newCollection): Promise<IPublicLibraryCollectionData>

Parameters

Name Type Description
libraryId string The uuid of the targeted library.
collectionId string The uuid of the parent collection.
newCollection IPublicLibraryCollectionForm The new collection to be added.
  • title : The title of the new collection.
  • Returns

    Promise<IPublicLibraryCollectionData>

    Promise object representing the created collection.

    Summary

    Create a new collection in the specified library's collection.

    Example

    const newCollection = await client.libraries.collections.createCollection("library_id", "collection_id", { title: 'new_title' });
    

    deleteCollection

    deleteCollection(libraryId, collectionId): Promise<IPublicHttpResponseDataWithRequestId>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.

    Returns

    Promise<IPublicHttpResponseDataWithRequestId>

    Promise object representing the created collection.

    Summary

    Delete a collection in the specified library.

    Example

    const { requestId } = await client.libraries.collections.deleteCollection("library_id", "collection_id");
    

    downloadCollection

    downloadCollection(libraryId, collectionId, options?): Promise<IUbstreamHttpResponseStream>

    Download a collection's content. If you request low resolution or plain text, the resources might not be ready to be downloaded. To prevent this call prepareDownloadForMedia first and wait for the request completion by polling on getRequestStatus.

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library
    collectionId string The uuid of the targeted media
    options? IPublicDownloadCollectionsOptions Options of the download.

    Returns

    Promise<IUbstreamHttpResponseStream>

    Promise object representing a readable stream, the content-type and the name of the file downloaded.

    Summary

    Download a collection's content : this method can be used to download the content of a collection.

    Example

    const response = await client.libraries.collections.downloadCollection(
      "library_id",
      "collection_id",
      {
          quality: PublicDownloadQuality.ORIGINAL,
          language: "en",
          multiLang: false,
          includesMetadata: false,
          metadataFormat: PublicDownloadMetadataFormat.JSON,
          metadataStrategy: PublicDownloadMetadataStrategy.BY_FILE,
          recursive: false
      },
    );
    // Use the readable stream to retrieve the resource.
    const writer = fs.createWriteStream(`./${response.filename}`);
    await new Promise(((resolve, reject) => {
      writer.on('error', (e) => {
          reject(e);
      })
      writer.on('close', () => {
          resolve(undefined);
      })
      response.stream.pipe(writer);
    }));
    

    getCollectionById

    getCollectionById(libraryId, collectionId): Promise<IPublicLibraryCollectionData>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.

    Returns

    Promise<IPublicLibraryCollectionData>

    Promise object representing the specified library's collection.

    Summary

    Retrieve the specified library's collection by its uuid.

    Example

    const collection = await client.libraries.collections.getCollectionById("library_id", "collection_id");
    

    listAllCollections

    listAllCollections(libraryId): Promise<IPublicLibraryCollectionQuery>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.

    Returns

    Promise<IPublicLibraryCollectionQuery>

    Promise object representing all library's collections.

    Summary

    Retrieve all library's collections.

    Example

    const result = await client.libraries.collections.listAllCollections(libraryId);
    const collections = result.$resources;
    

    listCollectionsOfCollection

    listCollectionsOfCollection(libraryId, collectionId): Promise<IPublicLibraryCollectionQuery>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.

    Returns

    Promise<IPublicLibraryCollectionQuery>

    Promise object representing sub collections of the specified library's collection.

    Summary

    Retrieve sub collections of the specified library's collection.

    Example

    const result = await client.libraries.collections.listCollectionsOfCollection(libId, rootCollectionId);
    const collections = result.$resources;
    

    moveCollection

    moveCollection(libraryId, collectionId, collectionToMoveId): Promise<IPublicHttpResponseDataWithRequestId>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.
    collectionToMoveId string The uuid of the source collection (the collection that needs to be moved).

    Returns

    Promise<IPublicHttpResponseDataWithRequestId>

    Promise object containing the request ID to use to check the request completion.

    Summary

    Move the source collection into the target collection.

    Example

    await client.libraries.collections.moveCollection("library_id", "collection_id", "collectionToMove_id");
    

    prepareDownloadForCollection

    prepareDownloadForCollection(libraryId, collectionId, options?): Promise<IPublicHttpResponseDataWithRequestId>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.
    options? IPublicDownloadOptions Options of the download.

    Returns

    Promise<IPublicHttpResponseDataWithRequestId>

    Promise object containing the request ID to use to check the request completion.

    Summary

    Prepare the download of the content of a collection. The missing resources will be generated.

    Example

    const downloadOptions = {
          quality: PublicDownloadQuality.LOWER,
          language: "en",
          multiLang: false,
          includesMetadata: false,
          metadataFormat: PublicDownloadMetadataFormat.JSON,
          metadataStrategy: PublicDownloadMetadataStrategy.BY_FILE,
    };
    const prepareResponse = await client.libraries.collections.prepareDownloadForCollection (
         "library_id",
         "collection_id",
         downloadOptions,
    );
    
    // Wait for the request completion here by polling on getRequestStatus:
    // await client.requests.getRequestStatus(prepareResponse.requestId)
    ...
    
    // start the download
    const response = await client.libraries.collections.downloadCollection (
         "library_id",
         "collection_id",
         downloadOptions,
    );
    

    renameCollection

    renameCollection(libraryId, collectionId, newTitle, lang?): Promise<void>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.
    newTitle string The new title to apply.
    lang? string The title's language. Defaults to language set by accept-language header

    Returns

    Promise<void>

    Summary

    Rename a collection in the specified library.

    Example

    await client.libraries.collections.renameCollection("library_id", "collection_id", "newTitle");
    // or
    await client.libraries.collections.renameCollection("library_id", "collection_id", "newTitle", "lang");
    

    reorderCollection

    reorderCollection(libraryId, collectionId, subCollectionIds): Promise<IPublicHttpResponseDataWithRequestId>

    Parameters

    Name Type Description
    libraryId string The uuid of the targeted library.
    collectionId string The uuid of the targeted collection.
    subCollectionIds string[] The ids of sub-collections reordered.

    Returns

    Promise<IPublicHttpResponseDataWithRequestId>

    Summary

    Reorder the sub-collections of collection.

    Example

    await client.libraries.collections.reorderCollection("library_id", "collection_id", ["subCollection_id_1", "subCollection_id_2"]);