Table of Contents

Class DocumentsClient

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

A client for interacting with the Documents API.

public class DocumentsClient : BaseClient
Inheritance
DocumentsClient
Inherited Members
Extension Methods

Constructors

DocumentsClient(IPlatformAdapter, HttpClient?, ILogger?)

A client for interacting with the Documents API. Provides methods to create, query, list, retrieve, update, and delete document resources.

public DocumentsClient(IPlatformAdapter platform, HttpClient? httpClient = null, ILogger? logger = null)

Parameters

platform IPlatformAdapter
httpClient HttpClient
logger ILogger

Remarks

This client simplifies interaction with the backend endpoint handling document-related operations.

See Also

Methods

AddAuthorizationHeader(HttpRequestMessage, bool, CancellationToken)

Adds the authorization header to the HTTP request.

protected override Task AddAuthorizationHeader(HttpRequestMessage request, bool requireAccessToken = false, CancellationToken cancellationToken = default)

Parameters

request HttpRequestMessage

The HTTP request message.

requireAccessToken bool

Whether an access token is required.

cancellationToken CancellationToken

A cancellation token to cancel the operation.

Returns

Task

A task representing the asynchronous operation.

CreateDocumentAsync(string, Document, CancellationToken)

Creates a new Document resource.

public Task<Document?> CreateDocumentAsync(string parent, Document document, CancellationToken cancellationToken = default)

Parameters

parent string

The name of the Corpus where this Document will be created. Required.

document Document

The Document to create.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Document>

The created Document.

See Also

DeleteDocumentAsync(string, bool?, CancellationToken)

Deletes a Document resource.

public Task DeleteDocumentAsync(string name, bool? force = null, CancellationToken cancellationToken = default)

Parameters

name string

The resource name of the Document to delete. Required.

force bool?

If set to true, any Chunk resources and objects related to this Document will also be deleted. Optional.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A task representing the asynchronous operation.

See Also

GetDocumentAsync(string, CancellationToken)

Gets information about a specific Document resource.

public Task<Document?> GetDocumentAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The name of the Document to retrieve. Required.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Document>

The Document resource.

See Also

ListDocumentsAsync(string, int?, string?, CancellationToken)

Lists all Document resources in a Corpus.

public Task<ListDocumentsResponse?> ListDocumentsAsync(string parent, int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

parent string

The name of the Corpus containing Document resources. Required.

pageSize int?

The maximum number of Document resources to return (per page). Optional.

pageToken string

A page token, received from a previous ListDocumentsAsync(string, int?, string?, CancellationToken) call. Optional.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<ListDocumentsResponse>

A list of Document resources.

See Also

QueryDocumentAsync(string, QueryDocumentRequest, CancellationToken)

Performs semantic search over a Document.

public Task<QueryDocumentResponse?> QueryDocumentAsync(string name, QueryDocumentRequest queryDocumentRequest, CancellationToken cancellationToken = default)

Parameters

name string

The name of the Document to query. Required.

queryDocumentRequest QueryDocumentRequest

The query parameters.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<QueryDocumentResponse>

A list of RelevantChunk resources.

See Also

UpdateDocumentAsync(string, Document, string, CancellationToken)

Updates a Document resource.

public Task<Document?> UpdateDocumentAsync(string name, Document document, string updateMask, CancellationToken cancellationToken = default)

Parameters

name string

The resource name of the Document.

document Document

The Document resource to update.

updateMask string

The list of fields to update. Required.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Document>

The updated Document resource.

See Also

See Also