@Generated(value="by gapic-generator-java") public class RecaptchaEnterpriseServiceClient 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:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Assessment assessment = Assessment.newBuilder().build();
Assessment response = recaptchaEnterpriseServiceClient.createAssessment(parent, assessment);
}
Note: close() needs to be called on the RecaptchaEnterpriseServiceClient 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 RecaptchaEnterpriseServiceSettings to create(). For example:
To customize credentials:
RecaptchaEnterpriseServiceSettings recaptchaEnterpriseServiceSettings =
RecaptchaEnterpriseServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create(recaptchaEnterpriseServiceSettings);
To customize the endpoint:
RecaptchaEnterpriseServiceSettings recaptchaEnterpriseServiceSettings =
RecaptchaEnterpriseServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create(recaptchaEnterpriseServiceSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Modifier and Type | Class and Description |
---|---|
static class |
RecaptchaEnterpriseServiceClient.ListKeysFixedSizeCollection |
static class |
RecaptchaEnterpriseServiceClient.ListKeysPage |
static class |
RecaptchaEnterpriseServiceClient.ListKeysPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceSettings settings)
Constructs an instance of RecaptchaEnterpriseServiceClient, using the given settings.
|
protected |
RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceStub stub) |
Modifier and Type | Method and Description |
---|---|
AnnotateAssessmentResponse |
annotateAssessment(AnnotateAssessmentRequest request)
Annotates a previously created Assessment to provide additional information on whether the
event turned out to be authentic or fradulent.
|
AnnotateAssessmentResponse |
annotateAssessment(AssessmentName name,
AnnotateAssessmentRequest.Annotation annotation)
Annotates a previously created Assessment to provide additional information on whether the
event turned out to be authentic or fradulent.
|
AnnotateAssessmentResponse |
annotateAssessment(String name,
AnnotateAssessmentRequest.Annotation annotation)
Annotates a previously created Assessment to provide additional information on whether the
event turned out to be authentic or fradulent.
|
com.google.api.gax.rpc.UnaryCallable<AnnotateAssessmentRequest,AnnotateAssessmentResponse> |
annotateAssessmentCallable()
Annotates a previously created Assessment to provide additional information on whether the
event turned out to be authentic or fradulent.
|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static RecaptchaEnterpriseServiceClient |
create()
Constructs an instance of RecaptchaEnterpriseServiceClient with default settings.
|
static RecaptchaEnterpriseServiceClient |
create(RecaptchaEnterpriseServiceSettings settings)
Constructs an instance of RecaptchaEnterpriseServiceClient, using the given settings.
|
static RecaptchaEnterpriseServiceClient |
create(RecaptchaEnterpriseServiceStub stub)
Constructs an instance of RecaptchaEnterpriseServiceClient, using the given stub for making
calls.
|
Assessment |
createAssessment(CreateAssessmentRequest request)
Creates an Assessment of the likelihood an event is legitimate.
|
Assessment |
createAssessment(ProjectName parent,
Assessment assessment)
Creates an Assessment of the likelihood an event is legitimate.
|
Assessment |
createAssessment(String parent,
Assessment assessment)
Creates an Assessment of the likelihood an event is legitimate.
|
com.google.api.gax.rpc.UnaryCallable<CreateAssessmentRequest,Assessment> |
createAssessmentCallable()
Creates an Assessment of the likelihood an event is legitimate.
|
Key |
createKey(CreateKeyRequest request)
Creates a new reCAPTCHA Enterprise key.
|
com.google.api.gax.rpc.UnaryCallable<CreateKeyRequest,Key> |
createKeyCallable()
Creates a new reCAPTCHA Enterprise key.
|
void |
deleteKey(DeleteKeyRequest request)
Deletes the specified key.
|
com.google.api.gax.rpc.UnaryCallable<DeleteKeyRequest,com.google.protobuf.Empty> |
deleteKeyCallable()
Deletes the specified key.
|
Key |
getKey(GetKeyRequest request)
Returns the specified key.
|
com.google.api.gax.rpc.UnaryCallable<GetKeyRequest,Key> |
getKeyCallable()
Returns the specified key.
|
RecaptchaEnterpriseServiceSettings |
getSettings() |
RecaptchaEnterpriseServiceStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
RecaptchaEnterpriseServiceClient.ListKeysPagedResponse |
listKeys(ListKeysRequest request)
Returns the list of all keys that belong to a project.
|
com.google.api.gax.rpc.UnaryCallable<ListKeysRequest,ListKeysResponse> |
listKeysCallable()
Returns the list of all keys that belong to a project.
|
com.google.api.gax.rpc.UnaryCallable<ListKeysRequest,RecaptchaEnterpriseServiceClient.ListKeysPagedResponse> |
listKeysPagedCallable()
Returns the list of all keys that belong to a project.
|
void |
shutdown() |
void |
shutdownNow() |
Key |
updateKey(UpdateKeyRequest request)
Updates the specified key.
|
com.google.api.gax.rpc.UnaryCallable<UpdateKeyRequest,Key> |
updateKeyCallable()
Updates the specified key.
|
protected RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceStub stub)
public static final RecaptchaEnterpriseServiceClient create() throws IOException
IOException
public static final RecaptchaEnterpriseServiceClient create(RecaptchaEnterpriseServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final RecaptchaEnterpriseServiceClient create(RecaptchaEnterpriseServiceStub stub)
public final RecaptchaEnterpriseServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public RecaptchaEnterpriseServiceStub getStub()
public final Assessment createAssessment(ProjectName parent, Assessment assessment)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Assessment assessment = Assessment.newBuilder().build();
Assessment response = recaptchaEnterpriseServiceClient.createAssessment(parent, assessment);
}
parent
- Required. The name of the project in which the assessment will be created, in the
format "projects/{project}".assessment
- Required. The assessment details.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Assessment createAssessment(String parent, Assessment assessment)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
String parent = ProjectName.of("[PROJECT]").toString();
Assessment assessment = Assessment.newBuilder().build();
Assessment response = recaptchaEnterpriseServiceClient.createAssessment(parent, assessment);
}
parent
- Required. The name of the project in which the assessment will be created, in the
format "projects/{project}".assessment
- Required. The assessment details.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final Assessment createAssessment(CreateAssessmentRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
CreateAssessmentRequest request =
CreateAssessmentRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setAssessment(Assessment.newBuilder().build())
.build();
Assessment response = recaptchaEnterpriseServiceClient.createAssessment(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<CreateAssessmentRequest,Assessment> createAssessmentCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
CreateAssessmentRequest request =
CreateAssessmentRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setAssessment(Assessment.newBuilder().build())
.build();
ApiFuture<Assessment> future =
recaptchaEnterpriseServiceClient.createAssessmentCallable().futureCall(request);
// Do something.
Assessment response = future.get();
}
public final AnnotateAssessmentResponse annotateAssessment(AssessmentName name, AnnotateAssessmentRequest.Annotation annotation)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
AnnotateAssessmentRequest.Annotation annotation =
AnnotateAssessmentRequest.Annotation.forNumber(0);
AnnotateAssessmentResponse response =
recaptchaEnterpriseServiceClient.annotateAssessment(name, annotation);
}
name
- Required. The resource name of the Assessment, in the format
"projects/{project}/assessments/{assessment}".annotation
- Required. The annotation that will be assigned to the Event.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final AnnotateAssessmentResponse annotateAssessment(String name, AnnotateAssessmentRequest.Annotation annotation)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
String name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString();
AnnotateAssessmentRequest.Annotation annotation =
AnnotateAssessmentRequest.Annotation.forNumber(0);
AnnotateAssessmentResponse response =
recaptchaEnterpriseServiceClient.annotateAssessment(name, annotation);
}
name
- Required. The resource name of the Assessment, in the format
"projects/{project}/assessments/{assessment}".annotation
- Required. The annotation that will be assigned to the Event.com.google.api.gax.rpc.ApiException
- if the remote call failspublic final AnnotateAssessmentResponse annotateAssessment(AnnotateAssessmentRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
AnnotateAssessmentRequest request =
AnnotateAssessmentRequest.newBuilder()
.setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
.build();
AnnotateAssessmentResponse response =
recaptchaEnterpriseServiceClient.annotateAssessment(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<AnnotateAssessmentRequest,AnnotateAssessmentResponse> annotateAssessmentCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
AnnotateAssessmentRequest request =
AnnotateAssessmentRequest.newBuilder()
.setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
.build();
ApiFuture<AnnotateAssessmentResponse> future =
recaptchaEnterpriseServiceClient.annotateAssessmentCallable().futureCall(request);
// Do something.
AnnotateAssessmentResponse response = future.get();
}
public final Key createKey(CreateKeyRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
CreateKeyRequest request =
CreateKeyRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setKey(Key.newBuilder().build())
.build();
Key response = recaptchaEnterpriseServiceClient.createKey(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<CreateKeyRequest,Key> createKeyCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
CreateKeyRequest request =
CreateKeyRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setKey(Key.newBuilder().build())
.build();
ApiFuture<Key> future =
recaptchaEnterpriseServiceClient.createKeyCallable().futureCall(request);
// Do something.
Key response = future.get();
}
public final RecaptchaEnterpriseServiceClient.ListKeysPagedResponse listKeys(ListKeysRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
ListKeysRequest request =
ListKeysRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
for (Key element : recaptchaEnterpriseServiceClient.listKeys(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<ListKeysRequest,RecaptchaEnterpriseServiceClient.ListKeysPagedResponse> listKeysPagedCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
ListKeysRequest request =
ListKeysRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.build();
ApiFuture<Key> future =
recaptchaEnterpriseServiceClient.listKeysPagedCallable().futureCall(request);
// Do something.
for (Key element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListKeysRequest,ListKeysResponse> listKeysCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
while (true) {
ListKeysResponse response =
recaptchaEnterpriseServiceClient.listKeysCallable().call(request);
for (Key element : response.getResponsesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final Key getKey(GetKeyRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
GetKeyRequest request =
GetKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
Key response = recaptchaEnterpriseServiceClient.getKey(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<GetKeyRequest,Key> getKeyCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
GetKeyRequest request =
GetKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
ApiFuture<Key> future = recaptchaEnterpriseServiceClient.getKeyCallable().futureCall(request);
// Do something.
Key response = future.get();
}
public final Key updateKey(UpdateKeyRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
UpdateKeyRequest request =
UpdateKeyRequest.newBuilder()
.setKey(Key.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
Key response = recaptchaEnterpriseServiceClient.updateKey(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<UpdateKeyRequest,Key> updateKeyCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
UpdateKeyRequest request =
UpdateKeyRequest.newBuilder()
.setKey(Key.newBuilder().build())
.setUpdateMask(FieldMask.newBuilder().build())
.build();
ApiFuture<Key> future =
recaptchaEnterpriseServiceClient.updateKeyCallable().futureCall(request);
// Do something.
Key response = future.get();
}
public final void deleteKey(DeleteKeyRequest request)
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
DeleteKeyRequest request =
DeleteKeyRequest.newBuilder()
.setName(KeyName.of("[PROJECT]", "[KEY]").toString())
.build();
recaptchaEnterpriseServiceClient.deleteKey(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<DeleteKeyRequest,com.google.protobuf.Empty> deleteKeyCallable()
Sample code:
try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
RecaptchaEnterpriseServiceClient.create()) {
DeleteKeyRequest request =
DeleteKeyRequest.newBuilder()
.setName(KeyName.of("[PROJECT]", "[KEY]").toString())
.build();
ApiFuture<Empty> future =
recaptchaEnterpriseServiceClient.deleteKeyCallable().futureCall(request);
// Do something.
future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2021 Google LLC. All rights reserved.