SearchKnowledgeBaseClientBuilder Class
- java.
lang. Object - com.
azure. search. documents. knowledgebases. SearchKnowledgeBaseClientBuilder
- com.
Implements
public final class SearchKnowledgeBaseClientBuilder
implements AzureKeyCredentialTrait<SearchKnowledgeBaseClientBuilder>, ConfigurationTrait<SearchKnowledgeBaseClientBuilder>, EndpointTrait<SearchKnowledgeBaseClientBuilder>, HttpTrait<SearchKnowledgeBaseClientBuilder>, TokenCredentialTrait<SearchKnowledgeBaseClientBuilder>
This class provides a fluent builder API to help configure and instantiate SearchKnowledgeBaseClient and SearchKnowledgeBaseAsyncClient for interacting with Azure AI Search Knowledge Agents.
Overview
This builder enables the creation of both synchronous and asynchronous clients for Azure AI Search Knowledge Agents, allowing you to interact with knowledge retrieval and knowledgeBase-based search capabilities. The builder supports configuration of authentication, endpoint, knowledgeBase name, API version, and HTTP pipeline options, following Azure SDK for Java standards.
Getting Started
To create a client, configure the required properties such as the service endpoint, knowledgeBase name, API version, and authentication credentials. The builder supports both API key and Microsoft Entra ID (role-based) authentication. Additional options such as custom HTTP pipeline policies, retry options, logging, and serialization can also be configured.
Authentication
Azure AI Search Knowledge Agents support authentication using either an AzureKeyCredential (API key) or a TokenCredential (Microsoft Entra ID). When using Microsoft Entra ID, you may also specify a SearchAudience to target a specific Azure cloud environment.
Client Instantiation
Use buildClient() to create a synchronous SearchKnowledgeBaseClient, or buildAsyncClient() to create an asynchronous SearchKnowledgeBaseAsyncClient. Each call to these methods returns a new client instance with the configured options.
Thread Safety
Client instances created by this builder are thread-safe and intended to be shared and reused across threads. The builder itself is not thread-safe and should not be used concurrently from multiple threads.
Additional Information
- For more information about Azure AI Search Knowledge Agents, see the Azure documentation.
- For authentication details, see the Azure AI Search security documentation.
- For Azure SDK for Java guidelines, see the Azure SDK for Java Introduction.
Constructor Summary
| Constructor | Description |
|---|---|
| SearchKnowledgeBaseClientBuilder() |
Creates a new builder instance. |
Method Summary
Methods inherited from java.lang.Object
Constructor Details
SearchKnowledgeBaseClientBuilder
public SearchKnowledgeBaseClientBuilder()
Creates a new builder instance.
Method Details
addPolicy
public SearchKnowledgeBaseClientBuilder addPolicy(HttpPipelinePolicy policy)
Parameters:
audience
public SearchKnowledgeBaseClientBuilder audience(SearchAudience audience)
Sets the audience for the Azure AI Search instance.
Parameters:
Returns:
buildAsyncClient
public SearchKnowledgeBaseAsyncClient buildAsyncClient()
Builds an asynchronous SearchKnowledgeBaseAsyncClient.
Returns:
buildClient
public SearchKnowledgeBaseClient buildClient()
Builds a synchronous SearchKnowledgeBaseClient.
Returns:
clientOptions
public SearchKnowledgeBaseClientBuilder clientOptions(ClientOptions clientOptions)
Parameters:
configuration
public SearchKnowledgeBaseClientBuilder configuration(Configuration configuration)
Parameters:
credential
public SearchKnowledgeBaseClientBuilder credential(AzureKeyCredential credential)
Parameters:
credential
public SearchKnowledgeBaseClientBuilder credential(TokenCredential credential)
Parameters:
endpoint
public SearchKnowledgeBaseClientBuilder endpoint(String endpoint)
Sets the service endpoint for the Azure AI Search instance.
Parameters:
Returns:
httpClient
public SearchKnowledgeBaseClientBuilder httpClient(HttpClient client)
Parameters:
httpLogOptions
public SearchKnowledgeBaseClientBuilder httpLogOptions(HttpLogOptions logOptions)
Parameters:
knowledgeBaseName
public SearchKnowledgeBaseClientBuilder knowledgeBaseName(String knowledgeBaseName)
Sets the knowledgeBase name for the Azure AI Search knowledgeBase.
Parameters:
Returns:
pipeline
public SearchKnowledgeBaseClientBuilder pipeline(HttpPipeline httpPipeline)
Parameters:
retryOptions
public SearchKnowledgeBaseClientBuilder retryOptions(RetryOptions retryOptions)
Parameters:
serviceVersion
public SearchKnowledgeBaseClientBuilder serviceVersion(SearchServiceVersion apiVersion)
Sets the API version to use for requests.
Parameters:
Returns: