- 4.59.0 (latest)
- 4.58.0
- 4.57.0
- 4.55.0
- 4.54.0
- 4.53.0
- 4.52.0
- 4.51.0
- 4.50.0
- 4.49.0
- 4.48.0
- 4.47.0
- 4.46.0
- 4.45.0
- 4.43.0
- 4.42.0
- 4.41.0
- 4.40.0
- 4.39.0
- 4.38.0
- 4.37.0
- 4.36.0
- 4.35.0
- 4.34.0
- 4.33.0
- 4.30.0
- 4.29.0
- 4.28.0
- 4.27.0
- 4.26.0
- 4.25.0
- 4.24.0
- 4.23.0
- 4.22.0
- 4.21.0
- 4.20.0
- 4.19.0
- 4.18.0
- 4.17.0
- 4.15.0
- 4.14.0
- 4.13.0
- 4.12.0
- 4.11.0
- 4.10.0
- 4.9.1
- 4.8.6
- 4.7.5
- 4.6.0
- 4.5.11
- 4.4.0
- 4.3.1
public class KnowledgeBasesClient implements BackgroundResource
Service Description: Service for managing KnowledgeBases.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
KnowledgeBaseName name =
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name);
}
Note: close() needs to be called on the KnowledgeBasesClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of KnowledgeBasesSettings to create(). For example:
To customize credentials:
KnowledgeBasesSettings knowledgeBasesSettings =
KnowledgeBasesSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings);
To customize the endpoint:
KnowledgeBasesSettings knowledgeBasesSettings =
KnowledgeBasesSettings.newBuilder().setEndpoint(myEndpoint).build();
KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create(knowledgeBasesSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Implements
BackgroundResourceConstructors
KnowledgeBasesClient(KnowledgeBasesSettings settings)
protected KnowledgeBasesClient(KnowledgeBasesSettings settings)
Constructs an instance of KnowledgeBasesClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
Name | Description |
settings | KnowledgeBasesSettings |
KnowledgeBasesClient(KnowledgeBasesStub stub)
protected KnowledgeBasesClient(KnowledgeBasesStub stub)
Name | Description |
stub | KnowledgeBasesStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration | long |
unit | TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
close()
public final void close()
create()
public static final KnowledgeBasesClient create()
Constructs an instance of KnowledgeBasesClient with default settings.
Type | Description |
KnowledgeBasesClient |
Type | Description |
IOException |
create(KnowledgeBasesSettings settings)
public static final KnowledgeBasesClient create(KnowledgeBasesSettings settings)
Constructs an instance of KnowledgeBasesClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.
Name | Description |
settings | KnowledgeBasesSettings |
Type | Description |
KnowledgeBasesClient |
Type | Description |
IOException |
create(KnowledgeBasesStub stub)
public static final KnowledgeBasesClient create(KnowledgeBasesStub stub)
Constructs an instance of KnowledgeBasesClient, using the given stub for making calls. This is for advanced usage - prefer using create(KnowledgeBasesSettings).
Name | Description |
stub | KnowledgeBasesStub |
Type | Description |
KnowledgeBasesClient |
createKnowledgeBase(CreateKnowledgeBaseRequest request)
public final KnowledgeBase createKnowledgeBase(CreateKnowledgeBaseRequest request)
Creates a knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
CreateKnowledgeBaseRequest request =
CreateKnowledgeBaseRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setKnowledgeBase(KnowledgeBase.newBuilder().build())
.build();
KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(request);
}
Name | Description |
request | CreateKnowledgeBaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
KnowledgeBase |
createKnowledgeBase(LocationName parent, KnowledgeBase knowledgeBase)
public final KnowledgeBase createKnowledgeBase(LocationName parent, KnowledgeBase knowledgeBase)
Creates a knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build();
KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase);
}
Name | Description |
parent | LocationName Required. The project to create a knowledge base for. Format:
|
knowledgeBase | KnowledgeBase Required. The knowledge base to create. |
Type | Description |
KnowledgeBase |
createKnowledgeBase(ProjectName parent, KnowledgeBase knowledgeBase)
public final KnowledgeBase createKnowledgeBase(ProjectName parent, KnowledgeBase knowledgeBase)
Creates a knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build();
KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase);
}
Name | Description |
parent | ProjectName Required. The project to create a knowledge base for. Format:
|
knowledgeBase | KnowledgeBase Required. The knowledge base to create. |
Type | Description |
KnowledgeBase |
createKnowledgeBase(String parent, KnowledgeBase knowledgeBase)
public final KnowledgeBase createKnowledgeBase(String parent, KnowledgeBase knowledgeBase)
Creates a knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build();
KnowledgeBase response = knowledgeBasesClient.createKnowledgeBase(parent, knowledgeBase);
}
Name | Description |
parent | String Required. The project to create a knowledge base for. Format:
|
knowledgeBase | KnowledgeBase Required. The knowledge base to create. |
Type | Description |
KnowledgeBase |
createKnowledgeBaseCallable()
public final UnaryCallable<CreateKnowledgeBaseRequest,KnowledgeBase> createKnowledgeBaseCallable()
Creates a knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
CreateKnowledgeBaseRequest request =
CreateKnowledgeBaseRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setKnowledgeBase(KnowledgeBase.newBuilder().build())
.build();
ApiFuture
Type | Description |
UnaryCallable<CreateKnowledgeBaseRequest,KnowledgeBase> |
deleteKnowledgeBase(DeleteKnowledgeBaseRequest request)
public final void deleteKnowledgeBase(DeleteKnowledgeBaseRequest request)
Deletes the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
DeleteKnowledgeBaseRequest request =
DeleteKnowledgeBaseRequest.newBuilder()
.setName(
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
.toString())
.setForce(true)
.build();
knowledgeBasesClient.deleteKnowledgeBase(request);
}
Name | Description |
request | DeleteKnowledgeBaseRequest The request object containing all of the parameters for the API call. |
deleteKnowledgeBase(KnowledgeBaseName name)
public final void deleteKnowledgeBase(KnowledgeBaseName name)
Deletes the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
KnowledgeBaseName name =
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
knowledgeBasesClient.deleteKnowledgeBase(name);
}
Name | Description |
name | KnowledgeBaseName Required. The name of the knowledge base to delete. Format: |
deleteKnowledgeBase(String name)
public final void deleteKnowledgeBase(String name)
Deletes the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
String name =
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString();
knowledgeBasesClient.deleteKnowledgeBase(name);
}
Name | Description |
name | String Required. The name of the knowledge base to delete. Format: |
deleteKnowledgeBaseCallable()
public final UnaryCallable<DeleteKnowledgeBaseRequest,Empty> deleteKnowledgeBaseCallable()
Deletes the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
DeleteKnowledgeBaseRequest request =
DeleteKnowledgeBaseRequest.newBuilder()
.setName(
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
.toString())
.setForce(true)
.build();
ApiFuture
Type | Description |
UnaryCallable<DeleteKnowledgeBaseRequest,Empty> |
getKnowledgeBase(GetKnowledgeBaseRequest request)
public final KnowledgeBase getKnowledgeBase(GetKnowledgeBaseRequest request)
Retrieves the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
GetKnowledgeBaseRequest request =
GetKnowledgeBaseRequest.newBuilder()
.setName(
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
.toString())
.build();
KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(request);
}
Name | Description |
request | GetKnowledgeBaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
KnowledgeBase |
getKnowledgeBase(KnowledgeBaseName name)
public final KnowledgeBase getKnowledgeBase(KnowledgeBaseName name)
Retrieves the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
KnowledgeBaseName name =
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]");
KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name);
}
Name | Description |
name | KnowledgeBaseName Required. The name of the knowledge base to retrieve. Format |
Type | Description |
KnowledgeBase |
getKnowledgeBase(String name)
public final KnowledgeBase getKnowledgeBase(String name)
Retrieves the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
String name =
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]").toString();
KnowledgeBase response = knowledgeBasesClient.getKnowledgeBase(name);
}
Name | Description |
name | String Required. The name of the knowledge base to retrieve. Format |
Type | Description |
KnowledgeBase |
getKnowledgeBaseCallable()
public final UnaryCallable<GetKnowledgeBaseRequest,KnowledgeBase> getKnowledgeBaseCallable()
Retrieves the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
GetKnowledgeBaseRequest request =
GetKnowledgeBaseRequest.newBuilder()
.setName(
KnowledgeBaseName.ofProjectKnowledgeBaseName("[PROJECT]", "[KNOWLEDGE_BASE]")
.toString())
.build();
ApiFuture
Type | Description |
UnaryCallable<GetKnowledgeBaseRequest,KnowledgeBase> |
getSettings()
public final KnowledgeBasesSettings getSettings()
Type | Description |
KnowledgeBasesSettings |
getStub()
public KnowledgeBasesStub getStub()
Type | Description |
KnowledgeBasesStub |
isShutdown()
public boolean isShutdown()
Type | Description |
boolean |
isTerminated()
public boolean isTerminated()
Type | Description |
boolean |
listKnowledgeBases(ListKnowledgeBasesRequest request)
public final KnowledgeBasesClient.ListKnowledgeBasesPagedResponse listKnowledgeBases(ListKnowledgeBasesRequest request)
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
ListKnowledgeBasesRequest request =
ListKnowledgeBasesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(request).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
request | ListKnowledgeBasesRequest The request object containing all of the parameters for the API call. |
Type | Description |
KnowledgeBasesClient.ListKnowledgeBasesPagedResponse |
listKnowledgeBases(LocationName parent)
public final KnowledgeBasesClient.ListKnowledgeBasesPagedResponse listKnowledgeBases(LocationName parent)
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | LocationName Required. The project to list of knowledge bases for. Format:
|
Type | Description |
KnowledgeBasesClient.ListKnowledgeBasesPagedResponse |
listKnowledgeBases(ProjectName parent)
public final KnowledgeBasesClient.ListKnowledgeBasesPagedResponse listKnowledgeBases(ProjectName parent)
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | ProjectName Required. The project to list of knowledge bases for. Format:
|
Type | Description |
KnowledgeBasesClient.ListKnowledgeBasesPagedResponse |
listKnowledgeBases(String parent)
public final KnowledgeBasesClient.ListKnowledgeBasesPagedResponse listKnowledgeBases(String parent)
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
for (KnowledgeBase element : knowledgeBasesClient.listKnowledgeBases(parent).iterateAll()) {
// doThingsWith(element);
}
}
Name | Description |
parent | String Required. The project to list of knowledge bases for. Format:
|
Type | Description |
KnowledgeBasesClient.ListKnowledgeBasesPagedResponse |
listKnowledgeBasesCallable()
public final UnaryCallable<ListKnowledgeBasesRequest,ListKnowledgeBasesResponse> listKnowledgeBasesCallable()
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
ListKnowledgeBasesRequest request =
ListKnowledgeBasesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListKnowledgeBasesResponse response =
knowledgeBasesClient.listKnowledgeBasesCallable().call(request);
for (KnowledgeBase element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
Type | Description |
UnaryCallable<ListKnowledgeBasesRequest,ListKnowledgeBasesResponse> |
listKnowledgeBasesPagedCallable()
public final UnaryCallable<ListKnowledgeBasesRequest,KnowledgeBasesClient.ListKnowledgeBasesPagedResponse> listKnowledgeBasesPagedCallable()
Returns the list of all knowledge bases of the specified agent.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
ListKnowledgeBasesRequest request =
ListKnowledgeBasesRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture
Type | Description |
UnaryCallable<ListKnowledgeBasesRequest,ListKnowledgeBasesPagedResponse> |
shutdown()
public void shutdown()
shutdownNow()
public void shutdownNow()
updateKnowledgeBase(KnowledgeBase knowledgeBase, FieldMask updateMask)
public final KnowledgeBase updateKnowledgeBase(KnowledgeBase knowledgeBase, FieldMask updateMask)
Updates the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
KnowledgeBase knowledgeBase = KnowledgeBase.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(knowledgeBase, updateMask);
}
Name | Description |
knowledgeBase | KnowledgeBase Required. The knowledge base to update. |
updateMask | FieldMask Optional. Not specified means |
Type | Description |
KnowledgeBase |
updateKnowledgeBase(UpdateKnowledgeBaseRequest request)
public final KnowledgeBase updateKnowledgeBase(UpdateKnowledgeBaseRequest request)
Updates the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
UpdateKnowledgeBaseRequest request =
UpdateKnowledgeBaseRequest.newBuilder()
.setKnowledgeBase(KnowledgeBase.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
KnowledgeBase response = knowledgeBasesClient.updateKnowledgeBase(request);
}
Name | Description |
request | UpdateKnowledgeBaseRequest The request object containing all of the parameters for the API call. |
Type | Description |
KnowledgeBase |
updateKnowledgeBaseCallable()
public final UnaryCallable<UpdateKnowledgeBaseRequest,KnowledgeBase> updateKnowledgeBaseCallable()
Updates the specified knowledge base.
Sample code:
try (KnowledgeBasesClient knowledgeBasesClient = KnowledgeBasesClient.create()) {
UpdateKnowledgeBaseRequest request =
UpdateKnowledgeBaseRequest.newBuilder()
.setKnowledgeBase(KnowledgeBase.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture
Type | Description |
UnaryCallable<UpdateKnowledgeBaseRequest,KnowledgeBase> |