@BetaApi @Generated(value="by gapic-generator-java") public class PredictionApiKeyRegistryClient extends Object implements com.google.api.gax.core.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:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
EventStoreName parent =
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
PredictionApiKeyRegistration predictionApiKeyRegistration =
PredictionApiKeyRegistration.newBuilder().build();
PredictionApiKeyRegistration response =
predictionApiKeyRegistryClient.createPredictionApiKeyRegistration(
parent, predictionApiKeyRegistration);
}
Note: close() needs to be called on the PredictionApiKeyRegistryClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
| CreatePredictionApiKeyRegistration | Register an API key for use with predict method. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
| ListPredictionApiKeyRegistrations | List the registered apiKeys for use with predict method. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
| DeletePredictionApiKeyRegistration | Unregister an apiKey from using for predict method. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return 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 PredictionApiKeyRegistrySettings to create(). For example:
To customize credentials:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
PredictionApiKeyRegistrySettings predictionApiKeyRegistrySettings =
PredictionApiKeyRegistrySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create(predictionApiKeyRegistrySettings);
To customize the endpoint:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
PredictionApiKeyRegistrySettings predictionApiKeyRegistrySettings =
PredictionApiKeyRegistrySettings.newBuilder().setEndpoint(myEndpoint).build();
PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create(predictionApiKeyRegistrySettings);
To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over the wire:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
PredictionApiKeyRegistrySettings predictionApiKeyRegistrySettings =
PredictionApiKeyRegistrySettings.newHttpJsonBuilder().build();
PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create(predictionApiKeyRegistrySettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
| Modifier and Type | Class and Description |
|---|---|
static class |
PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsFixedSizeCollection |
static class |
PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPage |
static class |
PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
PredictionApiKeyRegistryClient(PredictionApiKeyRegistrySettings settings)
Constructs an instance of PredictionApiKeyRegistryClient, using the given settings.
|
protected |
PredictionApiKeyRegistryClient(PredictionApiKeyRegistryStub stub) |
protected PredictionApiKeyRegistryClient(PredictionApiKeyRegistrySettings settings) throws IOException
IOExceptionprotected PredictionApiKeyRegistryClient(PredictionApiKeyRegistryStub stub)
public static final PredictionApiKeyRegistryClient create() throws IOException
IOExceptionpublic static final PredictionApiKeyRegistryClient create(PredictionApiKeyRegistrySettings settings) throws IOException
IOExceptionpublic static final PredictionApiKeyRegistryClient create(PredictionApiKeyRegistryStub stub)
public final PredictionApiKeyRegistrySettings getSettings()
public PredictionApiKeyRegistryStub getStub()
public final PredictionApiKeyRegistration createPredictionApiKeyRegistration(EventStoreName parent, PredictionApiKeyRegistration predictionApiKeyRegistration)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
EventStoreName parent =
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
PredictionApiKeyRegistration predictionApiKeyRegistration =
PredictionApiKeyRegistration.newBuilder().build();
PredictionApiKeyRegistration response =
predictionApiKeyRegistryClient.createPredictionApiKeyRegistration(
parent, predictionApiKeyRegistration);
}
parent - Required. The parent resource path.
`projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store`.predictionApiKeyRegistration - Required. The prediction API key registration.com.google.api.gax.rpc.ApiException - if the remote call failspublic final PredictionApiKeyRegistration createPredictionApiKeyRegistration(String parent, PredictionApiKeyRegistration predictionApiKeyRegistration)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
String parent =
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]").toString();
PredictionApiKeyRegistration predictionApiKeyRegistration =
PredictionApiKeyRegistration.newBuilder().build();
PredictionApiKeyRegistration response =
predictionApiKeyRegistryClient.createPredictionApiKeyRegistration(
parent, predictionApiKeyRegistration);
}
parent - Required. The parent resource path.
`projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store`.predictionApiKeyRegistration - Required. The prediction API key registration.com.google.api.gax.rpc.ApiException - if the remote call failspublic final PredictionApiKeyRegistration createPredictionApiKeyRegistration(CreatePredictionApiKeyRegistrationRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
CreatePredictionApiKeyRegistrationRequest request =
CreatePredictionApiKeyRegistrationRequest.newBuilder()
.setParent(
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]")
.toString())
.setPredictionApiKeyRegistration(PredictionApiKeyRegistration.newBuilder().build())
.build();
PredictionApiKeyRegistration response =
predictionApiKeyRegistryClient.createPredictionApiKeyRegistration(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<CreatePredictionApiKeyRegistrationRequest,PredictionApiKeyRegistration> createPredictionApiKeyRegistrationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
CreatePredictionApiKeyRegistrationRequest request =
CreatePredictionApiKeyRegistrationRequest.newBuilder()
.setParent(
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]")
.toString())
.setPredictionApiKeyRegistration(PredictionApiKeyRegistration.newBuilder().build())
.build();
ApiFuture<PredictionApiKeyRegistration> future =
predictionApiKeyRegistryClient
.createPredictionApiKeyRegistrationCallable()
.futureCall(request);
// Do something.
PredictionApiKeyRegistration response = future.get();
}
public final PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPagedResponse listPredictionApiKeyRegistrations(EventStoreName parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
EventStoreName parent =
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]");
for (PredictionApiKeyRegistration element :
predictionApiKeyRegistryClient.listPredictionApiKeyRegistrations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent placement resource name such as
`projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`com.google.api.gax.rpc.ApiException - if the remote call failspublic final PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPagedResponse listPredictionApiKeyRegistrations(String parent)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
String parent =
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]").toString();
for (PredictionApiKeyRegistration element :
predictionApiKeyRegistryClient.listPredictionApiKeyRegistrations(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent - Required. The parent placement resource name such as
`projects/1234/locations/global/catalogs/default_catalog/eventStores/default_event_store`com.google.api.gax.rpc.ApiException - if the remote call failspublic final PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPagedResponse listPredictionApiKeyRegistrations(ListPredictionApiKeyRegistrationsRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
ListPredictionApiKeyRegistrationsRequest request =
ListPredictionApiKeyRegistrationsRequest.newBuilder()
.setParent(
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (PredictionApiKeyRegistration element :
predictionApiKeyRegistryClient.listPredictionApiKeyRegistrations(request).iterateAll()) {
// doThingsWith(element);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListPredictionApiKeyRegistrationsRequest,PredictionApiKeyRegistryClient.ListPredictionApiKeyRegistrationsPagedResponse> listPredictionApiKeyRegistrationsPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
ListPredictionApiKeyRegistrationsRequest request =
ListPredictionApiKeyRegistrationsRequest.newBuilder()
.setParent(
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<PredictionApiKeyRegistration> future =
predictionApiKeyRegistryClient
.listPredictionApiKeyRegistrationsPagedCallable()
.futureCall(request);
// Do something.
for (PredictionApiKeyRegistration element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListPredictionApiKeyRegistrationsRequest,ListPredictionApiKeyRegistrationsResponse> listPredictionApiKeyRegistrationsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
ListPredictionApiKeyRegistrationsRequest request =
ListPredictionApiKeyRegistrationsRequest.newBuilder()
.setParent(
EventStoreName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[EVENT_STORE]")
.toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
while (true) {
ListPredictionApiKeyRegistrationsResponse response =
predictionApiKeyRegistryClient
.listPredictionApiKeyRegistrationsCallable()
.call(request);
for (PredictionApiKeyRegistration element :
response.getPredictionApiKeyRegistrationsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final void deletePredictionApiKeyRegistration(PredictionApiKeyRegistrationName name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
PredictionApiKeyRegistrationName name =
PredictionApiKeyRegistrationName.of(
"[PROJECT]",
"[LOCATION]",
"[CATALOG]",
"[EVENT_STORE]",
"[PREDICTION_API_KEY_REGISTRATION]");
predictionApiKeyRegistryClient.deletePredictionApiKeyRegistration(name);
}
name - Required. The API key to unregister including full resource path.
`projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/predictionApiKeyRegistrations/<YOUR_API_KEY>`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deletePredictionApiKeyRegistration(String name)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
String name =
PredictionApiKeyRegistrationName.of(
"[PROJECT]",
"[LOCATION]",
"[CATALOG]",
"[EVENT_STORE]",
"[PREDICTION_API_KEY_REGISTRATION]")
.toString();
predictionApiKeyRegistryClient.deletePredictionApiKeyRegistration(name);
}
name - Required. The API key to unregister including full resource path.
`projects/*/locations/global/catalogs/default_catalog/eventStores/default_event_store/predictionApiKeyRegistrations/<YOUR_API_KEY>`com.google.api.gax.rpc.ApiException - if the remote call failspublic final void deletePredictionApiKeyRegistration(DeletePredictionApiKeyRegistrationRequest request)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
DeletePredictionApiKeyRegistrationRequest request =
DeletePredictionApiKeyRegistrationRequest.newBuilder()
.setName(
PredictionApiKeyRegistrationName.of(
"[PROJECT]",
"[LOCATION]",
"[CATALOG]",
"[EVENT_STORE]",
"[PREDICTION_API_KEY_REGISTRATION]")
.toString())
.build();
predictionApiKeyRegistryClient.deletePredictionApiKeyRegistration(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<DeletePredictionApiKeyRegistrationRequest,com.google.protobuf.Empty> deletePredictionApiKeyRegistrationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionApiKeyRegistryClient predictionApiKeyRegistryClient =
PredictionApiKeyRegistryClient.create()) {
DeletePredictionApiKeyRegistrationRequest request =
DeletePredictionApiKeyRegistrationRequest.newBuilder()
.setName(
PredictionApiKeyRegistrationName.of(
"[PROJECT]",
"[LOCATION]",
"[CATALOG]",
"[EVENT_STORE]",
"[PREDICTION_API_KEY_REGISTRATION]")
.toString())
.build();
ApiFuture<Empty> future =
predictionApiKeyRegistryClient
.deletePredictionApiKeyRegistrationCallable()
.futureCall(request);
// Do something.
future.get();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2024 Google LLC. All rights reserved.