feat: implement listing a page of files

This commit is contained in:
Stevan Freeborn
2025-07-14 23:30:02 -05:00
parent c212ebffcd
commit 9d5c620167
5 changed files with 144 additions and 0 deletions
@@ -388,6 +388,15 @@ public class AnthropicApiClient : IAnthropicApiClient
return await CreateResultAsync<AnthropicFile>(response);
}
/// <inheritdoc/>
public async Task<AnthropicResult<Page<AnthropicFile>>> ListFilesAsync(PagingRequest? request = null, CancellationToken cancellationToken = default)
{
var pagingRequest = request ?? new PagingRequest();
var endpoint = $"{FilesEndpoint}?{pagingRequest.ToQueryParameters()}";
var response = await SendRequestAsync(endpoint, cancellationToken: cancellationToken);
return await CreateResultAsync<Page<AnthropicFile>>(response);
}
private async IAsyncEnumerable<AnthropicResult<Page<T>>> GetAllPagesAsync<T>(string endpoint, int limit = 20, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var pagingRequest = new PagingRequest(limit: limit);