Table of Contents

Class CorporaClient

Namespace
GenerativeAI.Clients
Assembly
GenerativeAI.dll

A client for interacting with the Gemini API Corpora endpoint.

public class CorporaClient : BaseClient
Inheritance
CorporaClient
Inherited Members
Extension Methods

Constructors

CorporaClient(IPlatformAdapter, HttpClient?, ILogger?)

A client for interacting with the Gemini API Corpora endpoint.

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

Parameters

platform IPlatformAdapter

The platform adapter that provides platform-specific operations.

httpClient HttpClient

An optional HttpClient instance for making HTTP requests.

logger ILogger

An optional ILogger instance for logging.

See Also

Methods

AddAuthorizationHeader(HttpRequestMessage, bool, CancellationToken)

Adds authorization headers to an HTTP request.

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

Parameters

request HttpRequestMessage

The HTTP request where headers will be added.

requireAccessToken bool

Whether an access token is required for the request.

cancellationToken CancellationToken

Token to monitor for cancellation requests.

Returns

Task

Remarks

Override this method in derived classes to dynamically add authorization headers. By default, this implementation does nothing.

CreateCorpusAsync(Corpus, CancellationToken)

Creates a new Corpus resource.

public Task<Corpus?> CreateCorpusAsync(Corpus corpus, CancellationToken cancellationToken = default)

Parameters

corpus Corpus

The Corpus to create.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Corpus>

The created Corpus.

See Also

DeleteCorpusAsync(string, bool?, CancellationToken)

Deletes a Corpus resource.

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

Parameters

name string

The name of the Corpus to delete.

force bool?

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

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task

A task representing the asynchronous operation.

See Also

GetCorpusAsync(string, CancellationToken)

Gets information about a specific Corpus resource.

public Task<Corpus?> GetCorpusAsync(string name, CancellationToken cancellationToken = default)

Parameters

name string

The name of the Corpus.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Corpus>

The Corpus resource.

See Also

ListCorporaAsync(int?, string?, CancellationToken)

Lists all Corpus resources owned by the user.

public Task<ListCorporaResponse?> ListCorporaAsync(int? pageSize = null, string? pageToken = null, CancellationToken cancellationToken = default)

Parameters

pageSize int?

The maximum number of Corpus resources to return per page.

pageToken string

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

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<ListCorporaResponse>

A list of Corpus resources.

See Also

QueryCorpusAsync(string, QueryCorpusRequest, CancellationToken)

Performs semantic search over a Corpus.

public Task<QueryCorpusResponse?> QueryCorpusAsync(string name, QueryCorpusRequest queryCorpusRequest, CancellationToken cancellationToken = default)

Parameters

name string

The name of the Corpus to query.

queryCorpusRequest QueryCorpusRequest

The QueryCorpusRequest containing the query details.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<QueryCorpusResponse>

The QueryCorpusResponse containing the relevant chunks.

See Also

UpdateCorpusAsync(string, Corpus, string, CancellationToken)

Updates a Corpus resource.

public Task<Corpus?> UpdateCorpusAsync(string corpusName, Corpus corpus, string updateMask, CancellationToken cancellationToken = default)

Parameters

corpusName string

The name of the Corpus to update.

corpus Corpus

The updated Corpus resource.

updateMask string

The list of fields to update.

cancellationToken CancellationToken

A CancellationToken to cancel the operation.

Returns

Task<Corpus>

The updated Corpus resource.

See Also

See Also