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
platformIPlatformAdapterThe platform adapter that provides platform-specific operations.
httpClientHttpClientAn optional HttpClient instance for making HTTP requests.
loggerILoggerAn 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
requestHttpRequestMessageThe HTTP request where headers will be added.
requireAccessTokenboolWhether an access token is required for the request.
cancellationTokenCancellationTokenToken to monitor for cancellation requests.
Returns
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
corpusCorpusThe Corpus to create.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- See Also
DeleteCorpusAsync(string, bool?, CancellationToken)
Deletes a Corpus resource.
public Task DeleteCorpusAsync(string name, bool? force = null, CancellationToken cancellationToken = default)
Parameters
namestringThe name of the Corpus to delete.
forcebool?If set to true, any Document resources and objects related to this Corpus will also be deleted.
cancellationTokenCancellationTokenA 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
namestringThe name of the Corpus.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- 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
pageSizeint?The maximum number of Corpus resources to return per page.
pageTokenstringA page token, received from a previous ListCorporaAsync(int?, string?, CancellationToken) call.
cancellationTokenCancellationTokenA 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
namestringThe name of the Corpus to query.
queryCorpusRequestQueryCorpusRequestThe QueryCorpusRequest containing the query details.
cancellationTokenCancellationTokenA 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
corpusNamestringThe name of the Corpus to update.
corpusCorpusThe updated Corpus resource.
updateMaskstringThe list of fields to update.
cancellationTokenCancellationTokenA CancellationToken to cancel the operation.
Returns
- See Also