@Generated(value="by gapic-generator") @BetaApi public class CompletionClient extends Object implements BackgroundResource
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 (CompletionClient completionClient = CompletionClient.create()) {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String query = "";
int pageSize = 0;
CompleteQueryRequest request = CompleteQueryRequest.newBuilder()
.setParent(parent.toString())
.setQuery(query)
.setPageSize(pageSize)
.build();
CompleteQueryResponse response = completionClient.completeQuery(request);
}
Note: close() needs to be called on the completionClient 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:
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 CompletionSettings to create(). For example:
To customize credentials:
CompletionSettings completionSettings =
CompletionSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
CompletionClient completionClient =
CompletionClient.create(completionSettings);
To customize the endpoint:
CompletionSettings completionSettings =
CompletionSettings.newBuilder().setEndpoint(myEndpoint).build();
CompletionClient completionClient =
CompletionClient.create(completionSettings);
Modifier | Constructor and Description |
---|---|
protected |
CompletionClient(CompletionSettings settings)
Constructs an instance of CompletionClient, using the given settings.
|
protected |
CompletionClient(CompletionStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
com.google.cloud.talent.v4beta1.CompleteQueryResponse |
completeQuery(com.google.cloud.talent.v4beta1.CompleteQueryRequest request)
Completes the specified prefix with keyword suggestions.
|
UnaryCallable<com.google.cloud.talent.v4beta1.CompleteQueryRequest,com.google.cloud.talent.v4beta1.CompleteQueryResponse> |
completeQueryCallable()
Completes the specified prefix with keyword suggestions.
|
static CompletionClient |
create()
Constructs an instance of CompletionClient with default settings.
|
static CompletionClient |
create(CompletionSettings settings)
Constructs an instance of CompletionClient, using the given settings.
|
static CompletionClient |
create(CompletionStub stub)
Constructs an instance of CompletionClient, using the given stub for making calls.
|
CompletionSettings |
getSettings() |
CompletionStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
void |
shutdownNow() |
protected CompletionClient(CompletionSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected CompletionClient(CompletionStub stub)
public static final CompletionClient create() throws IOException
IOException
public static final CompletionClient create(CompletionSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final CompletionClient create(CompletionStub stub)
public final CompletionSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public CompletionStub getStub()
public final com.google.cloud.talent.v4beta1.CompleteQueryResponse completeQuery(com.google.cloud.talent.v4beta1.CompleteQueryRequest request)
Sample code:
try (CompletionClient completionClient = CompletionClient.create()) {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String query = "";
int pageSize = 0;
CompleteQueryRequest request = CompleteQueryRequest.newBuilder()
.setParent(parent.toString())
.setQuery(query)
.setPageSize(pageSize)
.build();
CompleteQueryResponse response = completionClient.completeQuery(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.cloud.talent.v4beta1.CompleteQueryRequest,com.google.cloud.talent.v4beta1.CompleteQueryResponse> completeQueryCallable()
Sample code:
try (CompletionClient completionClient = CompletionClient.create()) {
TenantOrProjectName parent = TenantName.of("[PROJECT]", "[TENANT]");
String query = "";
int pageSize = 0;
CompleteQueryRequest request = CompleteQueryRequest.newBuilder()
.setParent(parent.toString())
.setQuery(query)
.setPageSize(pageSize)
.build();
ApiFuture<CompleteQueryResponse> future = completionClient.completeQueryCallable().futureCall(request);
// Do something
CompleteQueryResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.