/// <summary> /// Searches a library for files according to the query. /// </summary> /// <param name="documentLibraryClient">The IDocumentLibraryClient instance.</param> /// <param name="libraryId">The library ID.</param> /// <param name="query">The search query.</param> /// <param name="tenantId">Optional. Specifies which tenant to use.</param> /// <param name="filter">Extra filters to aplly to the search.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The search results.</returns> public static async Task <ICollection <SearchResult <LibrarySearchResult> > > SearchLibraryAsync(this IDocumentLibraryClient documentLibraryClient, Guid libraryId, string query, Guid?tenantId = null, string?filter = null, CancellationToken cancellationToken = default) { if (documentLibraryClient is null) { throw new ArgumentNullException(nameof(documentLibraryClient)); } Result <ICollection <SearchResult <LibrarySearchResult> > > result = await documentLibraryClient.SearchLibraryResultAsync(libraryId, query, tenantId, filter, cancellationToken).ConfigureAwait(false); if (result.IsSuccess) { return(result.Value); } throw ApiException.Create(result.Error); }