Class RecaptchaEnterpriseServiceClient (3.14.0)

public class RecaptchaEnterpriseServiceClient implements BackgroundResource

Service Description: Service to determine the likelihood an event is legitimate.

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 (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:

  1. 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.
  2. 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.
  3. 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 RecaptchaEnterpriseServiceSettings 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
 RecaptchaEnterpriseServiceSettings recaptchaEnterpriseServiceSettings =
     RecaptchaEnterpriseServiceSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create(recaptchaEnterpriseServiceSettings);
 

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
 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.

Inheritance

java.lang.Object > RecaptchaEnterpriseServiceClient

Implements

BackgroundResource

Static Methods

create()

public static final RecaptchaEnterpriseServiceClient create()

Constructs an instance of RecaptchaEnterpriseServiceClient with default settings.

Returns
Type Description
RecaptchaEnterpriseServiceClient
Exceptions
Type Description
IOException

create(RecaptchaEnterpriseServiceSettings settings)

public static final RecaptchaEnterpriseServiceClient create(RecaptchaEnterpriseServiceSettings settings)

Constructs an instance of RecaptchaEnterpriseServiceClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings RecaptchaEnterpriseServiceSettings
Returns
Type Description
RecaptchaEnterpriseServiceClient
Exceptions
Type Description
IOException

create(RecaptchaEnterpriseServiceStub stub)

public static final RecaptchaEnterpriseServiceClient create(RecaptchaEnterpriseServiceStub stub)

Constructs an instance of RecaptchaEnterpriseServiceClient, using the given stub for making calls. This is for advanced usage - prefer using create(RecaptchaEnterpriseServiceSettings).

Parameter
Name Description
stub RecaptchaEnterpriseServiceStub
Returns
Type Description
RecaptchaEnterpriseServiceClient

Constructors

RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceSettings settings)

protected RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceSettings settings)

Constructs an instance of RecaptchaEnterpriseServiceClient, 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.

Parameter
Name Description
settings RecaptchaEnterpriseServiceSettings

RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceStub stub)

protected RecaptchaEnterpriseServiceClient(RecaptchaEnterpriseServiceStub stub)
Parameter
Name Description
stub RecaptchaEnterpriseServiceStub

Methods

annotateAssessment(AnnotateAssessmentRequest request)

public final AnnotateAssessmentResponse annotateAssessment(AnnotateAssessmentRequest request)

Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   AnnotateAssessmentRequest request =
       AnnotateAssessmentRequest.newBuilder()
           .setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
           .addAllReasons(new ArrayList<AnnotateAssessmentRequest.Reason>())
           .setHashedAccountId(ByteString.EMPTY)
           .setTransactionEvent(TransactionEvent.newBuilder().build())
           .build();
   AnnotateAssessmentResponse response =
       recaptchaEnterpriseServiceClient.annotateAssessment(request);
 }
 
Parameter
Name Description
request AnnotateAssessmentRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
AnnotateAssessmentResponse

annotateAssessment(AssessmentName name, AnnotateAssessmentRequest.Annotation annotation)

public final 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 fraudulent.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   AssessmentName name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]");
   AnnotateAssessmentRequest.Annotation annotation =
       AnnotateAssessmentRequest.Annotation.forNumber(0);
   AnnotateAssessmentResponse response =
       recaptchaEnterpriseServiceClient.annotateAssessment(name, annotation);
 }
 
Parameters
Name Description
name AssessmentName

Required. The resource name of the Assessment, in the format "projects/{project}/assessments/{assessment}".

annotation AnnotateAssessmentRequest.Annotation

Optional. The annotation that will be assigned to the Event. This field can be left empty to provide reasons that apply to an event without concluding whether the event is legitimate or fraudulent.

Returns
Type Description
AnnotateAssessmentResponse

annotateAssessment(String name, AnnotateAssessmentRequest.Annotation annotation)

public final 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 fraudulent.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String name = AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString();
   AnnotateAssessmentRequest.Annotation annotation =
       AnnotateAssessmentRequest.Annotation.forNumber(0);
   AnnotateAssessmentResponse response =
       recaptchaEnterpriseServiceClient.annotateAssessment(name, annotation);
 }
 
Parameters
Name Description
name String

Required. The resource name of the Assessment, in the format "projects/{project}/assessments/{assessment}".

annotation AnnotateAssessmentRequest.Annotation

Optional. The annotation that will be assigned to the Event. This field can be left empty to provide reasons that apply to an event without concluding whether the event is legitimate or fraudulent.

Returns
Type Description
AnnotateAssessmentResponse

annotateAssessmentCallable()

public final UnaryCallable<AnnotateAssessmentRequest,AnnotateAssessmentResponse> annotateAssessmentCallable()

Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   AnnotateAssessmentRequest request =
       AnnotateAssessmentRequest.newBuilder()
           .setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
           .addAllReasons(new ArrayList<AnnotateAssessmentRequest.Reason>())
           .setHashedAccountId(ByteString.EMPTY)
           .setTransactionEvent(TransactionEvent.newBuilder().build())
           .build();
   ApiFuture<AnnotateAssessmentResponse> future =
       recaptchaEnterpriseServiceClient.annotateAssessmentCallable().futureCall(request);
   // Do something.
   AnnotateAssessmentResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<AnnotateAssessmentRequest,AnnotateAssessmentResponse>

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

close()

public final void close()

createAssessment(CreateAssessmentRequest request)

public final Assessment createAssessment(CreateAssessmentRequest request)

Creates an Assessment of the likelihood an event is legitimate.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   CreateAssessmentRequest request =
       CreateAssessmentRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setAssessment(Assessment.newBuilder().build())
           .build();
   Assessment response = recaptchaEnterpriseServiceClient.createAssessment(request);
 }
 
Parameter
Name Description
request CreateAssessmentRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Assessment

createAssessment(ProjectName parent, Assessment assessment)

public final Assessment createAssessment(ProjectName parent, Assessment assessment)

Creates an Assessment of the likelihood an event is legitimate.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Assessment assessment = Assessment.newBuilder().build();
   Assessment response = recaptchaEnterpriseServiceClient.createAssessment(parent, assessment);
 }
 
Parameters
Name Description
parent ProjectName

Required. The name of the project in which the assessment will be created, in the format "projects/{project}".

assessment Assessment

Required. The assessment details.

Returns
Type Description
Assessment

createAssessment(String parent, Assessment assessment)

public final Assessment createAssessment(String parent, Assessment assessment)

Creates an Assessment of the likelihood an event is legitimate.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Assessment assessment = Assessment.newBuilder().build();
   Assessment response = recaptchaEnterpriseServiceClient.createAssessment(parent, assessment);
 }
 
Parameters
Name Description
parent String

Required. The name of the project in which the assessment will be created, in the format "projects/{project}".

assessment Assessment

Required. The assessment details.

Returns
Type Description
Assessment

createAssessmentCallable()

public final UnaryCallable<CreateAssessmentRequest,Assessment> createAssessmentCallable()

Creates an Assessment of the likelihood an event is legitimate.

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 (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();
 }
 
Returns
Type Description
UnaryCallable<CreateAssessmentRequest,Assessment>

createKey(CreateKeyRequest request)

public final Key createKey(CreateKeyRequest request)

Creates a new reCAPTCHA Enterprise key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   CreateKeyRequest request =
       CreateKeyRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setKey(Key.newBuilder().build())
           .build();
   Key response = recaptchaEnterpriseServiceClient.createKey(request);
 }
 
Parameter
Name Description
request CreateKeyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Key

createKey(ProjectName parent, Key key)

public final Key createKey(ProjectName parent, Key key)

Creates a new reCAPTCHA Enterprise key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Key key = Key.newBuilder().build();
   Key response = recaptchaEnterpriseServiceClient.createKey(parent, key);
 }
 
Parameters
Name Description
parent ProjectName

Required. The name of the project in which the key will be created, in the format "projects/{project}".

key Key

Required. Information to create a reCAPTCHA Enterprise key.

Returns
Type Description
Key

createKey(String parent, Key key)

public final Key createKey(String parent, Key key)

Creates a new reCAPTCHA Enterprise key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Key key = Key.newBuilder().build();
   Key response = recaptchaEnterpriseServiceClient.createKey(parent, key);
 }
 
Parameters
Name Description
parent String

Required. The name of the project in which the key will be created, in the format "projects/{project}".

key Key

Required. Information to create a reCAPTCHA Enterprise key.

Returns
Type Description
Key

createKeyCallable()

public final UnaryCallable<CreateKeyRequest,Key> createKeyCallable()

Creates a new reCAPTCHA Enterprise key.

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 (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();
 }
 
Returns
Type Description
UnaryCallable<CreateKeyRequest,Key>

deleteKey(DeleteKeyRequest request)

public final void deleteKey(DeleteKeyRequest request)

Deletes the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   DeleteKeyRequest request =
       DeleteKeyRequest.newBuilder()
           .setName(KeyName.of("[PROJECT]", "[KEY]").toString())
           .build();
   recaptchaEnterpriseServiceClient.deleteKey(request);
 }
 
Parameter
Name Description
request DeleteKeyRequest

The request object containing all of the parameters for the API call.

deleteKey(KeyName name)

public final void deleteKey(KeyName name)

Deletes the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   KeyName name = KeyName.of("[PROJECT]", "[KEY]");
   recaptchaEnterpriseServiceClient.deleteKey(name);
 }
 
Parameter
Name Description
name KeyName

Required. The name of the key to be deleted, in the format "projects/{project}/keys/{key}".

deleteKey(String name)

public final void deleteKey(String name)

Deletes the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String name = KeyName.of("[PROJECT]", "[KEY]").toString();
   recaptchaEnterpriseServiceClient.deleteKey(name);
 }
 
Parameter
Name Description
name String

Required. The name of the key to be deleted, in the format "projects/{project}/keys/{key}".

deleteKeyCallable()

public final UnaryCallable<DeleteKeyRequest,Empty> deleteKeyCallable()

Deletes the specified key.

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 (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();
 }
 
Returns
Type Description
UnaryCallable<DeleteKeyRequest,Empty>

getKey(GetKeyRequest request)

public final Key getKey(GetKeyRequest request)

Returns the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   GetKeyRequest request =
       GetKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
   Key response = recaptchaEnterpriseServiceClient.getKey(request);
 }
 
Parameter
Name Description
request GetKeyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Key

getKey(KeyName name)

public final Key getKey(KeyName name)

Returns the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   KeyName name = KeyName.of("[PROJECT]", "[KEY]");
   Key response = recaptchaEnterpriseServiceClient.getKey(name);
 }
 
Parameter
Name Description
name KeyName

Required. The name of the requested key, in the format "projects/{project}/keys/{key}".

Returns
Type Description
Key

getKey(String name)

public final Key getKey(String name)

Returns the specified key.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String name = KeyName.of("[PROJECT]", "[KEY]").toString();
   Key response = recaptchaEnterpriseServiceClient.getKey(name);
 }
 
Parameter
Name Description
name String

Required. The name of the requested key, in the format "projects/{project}/keys/{key}".

Returns
Type Description
Key

getKeyCallable()

public final UnaryCallable<GetKeyRequest,Key> getKeyCallable()

Returns the specified key.

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 (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();
 }
 
Returns
Type Description
UnaryCallable<GetKeyRequest,Key>

getMetrics(GetMetricsRequest request)

public final Metrics getMetrics(GetMetricsRequest request)

Get some aggregated metrics for a Key. This data can be used to build dashboards.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   GetMetricsRequest request =
       GetMetricsRequest.newBuilder()
           .setName(MetricsName.of("[PROJECT]", "[KEY]").toString())
           .build();
   Metrics response = recaptchaEnterpriseServiceClient.getMetrics(request);
 }
 
Parameter
Name Description
request GetMetricsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Metrics

getMetrics(MetricsName name)

public final Metrics getMetrics(MetricsName name)

Get some aggregated metrics for a Key. This data can be used to build dashboards.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   MetricsName name = MetricsName.of("[PROJECT]", "[KEY]");
   Metrics response = recaptchaEnterpriseServiceClient.getMetrics(name);
 }
 
Parameter
Name Description
name MetricsName

Required. The name of the requested metrics, in the format "projects/{project}/keys/{key}/metrics".

Returns
Type Description
Metrics

getMetrics(String name)

public final Metrics getMetrics(String name)

Get some aggregated metrics for a Key. This data can be used to build dashboards.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   String name = MetricsName.of("[PROJECT]", "[KEY]").toString();
   Metrics response = recaptchaEnterpriseServiceClient.getMetrics(name);
 }
 
Parameter
Name Description
name String

Required. The name of the requested metrics, in the format "projects/{project}/keys/{key}/metrics".

Returns
Type Description
Metrics

getMetricsCallable()

public final UnaryCallable<GetMetricsRequest,Metrics> getMetricsCallable()

Get some aggregated metrics for a Key. This data can be used to build dashboards.

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 (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
     RecaptchaEnterpriseServiceClient.create()) {
   GetMetricsRequest request =
       GetMetricsRequest.newBuilder()
           .setName(MetricsName.of("[PROJECT]", "[KEY]").toString())
           .build();
   ApiFuture<Metrics> future =
       recaptchaEnterpriseServiceClient.getMetricsCallable().futureCall(request);
   // Do something.
   Metrics response = future.get();
 }
 
Returns
Type Description