Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit aba39fa

Browse files
feat: add GetMetrics and MigrateKey methods to reCAPTCHA enterprise API (#574)
* feat: add GetMetrics and MigrateKey methods to reCAPTCHA enterprise API PiperOrigin-RevId: 396937887 Source-Link: googleapis/googleapis@020672e Source-Link: https://github.com/googleapis/googleapis-gen/commit/a5847907eb3607837f10f93e95fdfcc0a98e6f21 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYTU4NDc5MDdlYjM2MDc4MzdmMTBmOTNlOTVmZGZjYzBhOThlNmYyMSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 343c9c6 commit aba39fa

File tree

40 files changed

+10569
-228
lines changed

40 files changed

+10569
-228
lines changed

google-cloud-recaptchaenterprise/src/main/java/com/google/cloud/recaptchaenterprise/v1/RecaptchaEnterpriseServiceClient.java

Lines changed: 165 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@
3737
import com.google.recaptchaenterprise.v1.CreateKeyRequest;
3838
import com.google.recaptchaenterprise.v1.DeleteKeyRequest;
3939
import com.google.recaptchaenterprise.v1.GetKeyRequest;
40+
import com.google.recaptchaenterprise.v1.GetMetricsRequest;
4041
import com.google.recaptchaenterprise.v1.Key;
4142
import com.google.recaptchaenterprise.v1.ListKeysRequest;
4243
import com.google.recaptchaenterprise.v1.ListKeysResponse;
44+
import com.google.recaptchaenterprise.v1.Metrics;
45+
import com.google.recaptchaenterprise.v1.MetricsName;
46+
import com.google.recaptchaenterprise.v1.MigrateKeyRequest;
4347
import com.google.recaptchaenterprise.v1.ProjectName;
4448
import com.google.recaptchaenterprise.v1.UpdateKeyRequest;
4549
import java.io.IOException;
@@ -275,7 +279,7 @@ public final UnaryCallable<CreateAssessmentRequest, Assessment> createAssessment
275279
// AUTO-GENERATED DOCUMENTATION AND METHOD.
276280
/**
277281
* Annotates a previously created Assessment to provide additional information on whether the
278-
* event turned out to be authentic or fradulent.
282+
* event turned out to be authentic or fraudulent.
279283
*
280284
* <p>Sample code:
281285
*
@@ -292,7 +296,9 @@ public final UnaryCallable<CreateAssessmentRequest, Assessment> createAssessment
292296
*
293297
* @param name Required. The resource name of the Assessment, in the format
294298
* "projects/{project}/assessments/{assessment}".
295-
* @param annotation Required. The annotation that will be assigned to the Event.
299+
* @param annotation Optional. The annotation that will be assigned to the Event. This field can
300+
* be left empty to provide reasons that apply to an event without concluding whether the
301+
* event is legitimate or fraudulent.
296302
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
297303
*/
298304
public final AnnotateAssessmentResponse annotateAssessment(
@@ -308,7 +314,7 @@ public final AnnotateAssessmentResponse annotateAssessment(
308314
// AUTO-GENERATED DOCUMENTATION AND METHOD.
309315
/**
310316
* Annotates a previously created Assessment to provide additional information on whether the
311-
* event turned out to be authentic or fradulent.
317+
* event turned out to be authentic or fraudulent.
312318
*
313319
* <p>Sample code:
314320
*
@@ -325,7 +331,9 @@ public final AnnotateAssessmentResponse annotateAssessment(
325331
*
326332
* @param name Required. The resource name of the Assessment, in the format
327333
* "projects/{project}/assessments/{assessment}".
328-
* @param annotation Required. The annotation that will be assigned to the Event.
334+
* @param annotation Optional. The annotation that will be assigned to the Event. This field can
335+
* be left empty to provide reasons that apply to an event without concluding whether the
336+
* event is legitimate or fraudulent.
329337
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
330338
*/
331339
public final AnnotateAssessmentResponse annotateAssessment(
@@ -338,7 +346,7 @@ public final AnnotateAssessmentResponse annotateAssessment(
338346
// AUTO-GENERATED DOCUMENTATION AND METHOD.
339347
/**
340348
* Annotates a previously created Assessment to provide additional information on whether the
341-
* event turned out to be authentic or fradulent.
349+
* event turned out to be authentic or fraudulent.
342350
*
343351
* <p>Sample code:
344352
*
@@ -348,6 +356,7 @@ public final AnnotateAssessmentResponse annotateAssessment(
348356
* AnnotateAssessmentRequest request =
349357
* AnnotateAssessmentRequest.newBuilder()
350358
* .setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
359+
* .addAllReasons(new ArrayList<AnnotateAssessmentRequest.Reason>())
351360
* .build();
352361
* AnnotateAssessmentResponse response =
353362
* recaptchaEnterpriseServiceClient.annotateAssessment(request);
@@ -364,7 +373,7 @@ public final AnnotateAssessmentResponse annotateAssessment(AnnotateAssessmentReq
364373
// AUTO-GENERATED DOCUMENTATION AND METHOD.
365374
/**
366375
* Annotates a previously created Assessment to provide additional information on whether the
367-
* event turned out to be authentic or fradulent.
376+
* event turned out to be authentic or fraudulent.
368377
*
369378
* <p>Sample code:
370379
*
@@ -374,6 +383,7 @@ public final AnnotateAssessmentResponse annotateAssessment(AnnotateAssessmentReq
374383
* AnnotateAssessmentRequest request =
375384
* AnnotateAssessmentRequest.newBuilder()
376385
* .setName(AssessmentName.of("[PROJECT]", "[ASSESSMENT]").toString())
386+
* .addAllReasons(new ArrayList<AnnotateAssessmentRequest.Reason>())
377387
* .build();
378388
* ApiFuture<AnnotateAssessmentResponse> future =
379389
* recaptchaEnterpriseServiceClient.annotateAssessmentCallable().futureCall(request);
@@ -669,6 +679,155 @@ public final UnaryCallable<DeleteKeyRequest, Empty> deleteKeyCallable() {
669679
return stub.deleteKeyCallable();
670680
}
671681

682+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
683+
/**
684+
* Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can
685+
* be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must
686+
* be authenticated as one of the current owners of the reCAPTCHA Site Key, and your user must
687+
* have the reCAPTCHA Enterprise Admin IAM role in the destination project.
688+
*
689+
* <p>Sample code:
690+
*
691+
* <pre>{@code
692+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
693+
* RecaptchaEnterpriseServiceClient.create()) {
694+
* MigrateKeyRequest request =
695+
* MigrateKeyRequest.newBuilder()
696+
* .setName(KeyName.of("[PROJECT]", "[KEY]").toString())
697+
* .build();
698+
* Key response = recaptchaEnterpriseServiceClient.migrateKey(request);
699+
* }
700+
* }</pre>
701+
*
702+
* @param request The request object containing all of the parameters for the API call.
703+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
704+
*/
705+
public final Key migrateKey(MigrateKeyRequest request) {
706+
return migrateKeyCallable().call(request);
707+
}
708+
709+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
710+
/**
711+
* Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise. Once a key is migrated, it can
712+
* be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must
713+
* be authenticated as one of the current owners of the reCAPTCHA Site Key, and your user must
714+
* have the reCAPTCHA Enterprise Admin IAM role in the destination project.
715+
*
716+
* <p>Sample code:
717+
*
718+
* <pre>{@code
719+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
720+
* RecaptchaEnterpriseServiceClient.create()) {
721+
* MigrateKeyRequest request =
722+
* MigrateKeyRequest.newBuilder()
723+
* .setName(KeyName.of("[PROJECT]", "[KEY]").toString())
724+
* .build();
725+
* ApiFuture<Key> future =
726+
* recaptchaEnterpriseServiceClient.migrateKeyCallable().futureCall(request);
727+
* // Do something.
728+
* Key response = future.get();
729+
* }
730+
* }</pre>
731+
*/
732+
public final UnaryCallable<MigrateKeyRequest, Key> migrateKeyCallable() {
733+
return stub.migrateKeyCallable();
734+
}
735+
736+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
737+
/**
738+
* Get some aggregated metrics for a Key. This data can be used to build dashboards.
739+
*
740+
* <p>Sample code:
741+
*
742+
* <pre>{@code
743+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
744+
* RecaptchaEnterpriseServiceClient.create()) {
745+
* MetricsName name = MetricsName.of("[PROJECT]", "[KEY]");
746+
* Metrics response = recaptchaEnterpriseServiceClient.getMetrics(name);
747+
* }
748+
* }</pre>
749+
*
750+
* @param name Required. The name of the requested metrics, in the format
751+
* "projects/{project}/keys/{key}/metrics".
752+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
753+
*/
754+
public final Metrics getMetrics(MetricsName name) {
755+
GetMetricsRequest request =
756+
GetMetricsRequest.newBuilder().setName(name == null ? null : name.toString()).build();
757+
return getMetrics(request);
758+
}
759+
760+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
761+
/**
762+
* Get some aggregated metrics for a Key. This data can be used to build dashboards.
763+
*
764+
* <p>Sample code:
765+
*
766+
* <pre>{@code
767+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
768+
* RecaptchaEnterpriseServiceClient.create()) {
769+
* String name = MetricsName.of("[PROJECT]", "[KEY]").toString();
770+
* Metrics response = recaptchaEnterpriseServiceClient.getMetrics(name);
771+
* }
772+
* }</pre>
773+
*
774+
* @param name Required. The name of the requested metrics, in the format
775+
* "projects/{project}/keys/{key}/metrics".
776+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
777+
*/
778+
public final Metrics getMetrics(String name) {
779+
GetMetricsRequest request = GetMetricsRequest.newBuilder().setName(name).build();
780+
return getMetrics(request);
781+
}
782+
783+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
784+
/**
785+
* Get some aggregated metrics for a Key. This data can be used to build dashboards.
786+
*
787+
* <p>Sample code:
788+
*
789+
* <pre>{@code
790+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
791+
* RecaptchaEnterpriseServiceClient.create()) {
792+
* GetMetricsRequest request =
793+
* GetMetricsRequest.newBuilder()
794+
* .setName(MetricsName.of("[PROJECT]", "[KEY]").toString())
795+
* .build();
796+
* Metrics response = recaptchaEnterpriseServiceClient.getMetrics(request);
797+
* }
798+
* }</pre>
799+
*
800+
* @param request The request object containing all of the parameters for the API call.
801+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
802+
*/
803+
public final Metrics getMetrics(GetMetricsRequest request) {
804+
return getMetricsCallable().call(request);
805+
}
806+
807+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
808+
/**
809+
* Get some aggregated metrics for a Key. This data can be used to build dashboards.
810+
*
811+
* <p>Sample code:
812+
*
813+
* <pre>{@code
814+
* try (RecaptchaEnterpriseServiceClient recaptchaEnterpriseServiceClient =
815+
* RecaptchaEnterpriseServiceClient.create()) {
816+
* GetMetricsRequest request =
817+
* GetMetricsRequest.newBuilder()
818+
* .setName(MetricsName.of("[PROJECT]", "[KEY]").toString())
819+
* .build();
820+
* ApiFuture<Metrics> future =
821+
* recaptchaEnterpriseServiceClient.getMetricsCallable().futureCall(request);
822+
* // Do something.
823+
* Metrics response = future.get();
824+
* }
825+
* }</pre>
826+
*/
827+
public final UnaryCallable<GetMetricsRequest, Metrics> getMetricsCallable() {
828+
return stub.getMetricsCallable();
829+
}
830+
672831
@Override
673832
public final void close() {
674833
stub.close();

google-cloud-recaptchaenterprise/src/main/java/com/google/cloud/recaptchaenterprise/v1/RecaptchaEnterpriseServiceSettings.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@
3838
import com.google.recaptchaenterprise.v1.CreateKeyRequest;
3939
import com.google.recaptchaenterprise.v1.DeleteKeyRequest;
4040
import com.google.recaptchaenterprise.v1.GetKeyRequest;
41+
import com.google.recaptchaenterprise.v1.GetMetricsRequest;
4142
import com.google.recaptchaenterprise.v1.Key;
4243
import com.google.recaptchaenterprise.v1.ListKeysRequest;
4344
import com.google.recaptchaenterprise.v1.ListKeysResponse;
45+
import com.google.recaptchaenterprise.v1.Metrics;
46+
import com.google.recaptchaenterprise.v1.MigrateKeyRequest;
4447
import com.google.recaptchaenterprise.v1.UpdateKeyRequest;
4548
import java.io.IOException;
4649
import java.util.List;
@@ -122,6 +125,16 @@ public UnaryCallSettings<DeleteKeyRequest, Empty> deleteKeySettings() {
122125
return ((RecaptchaEnterpriseServiceStubSettings) getStubSettings()).deleteKeySettings();
123126
}
124127

128+
/** Returns the object with the settings used for calls to migrateKey. */
129+
public UnaryCallSettings<MigrateKeyRequest, Key> migrateKeySettings() {
130+
return ((RecaptchaEnterpriseServiceStubSettings) getStubSettings()).migrateKeySettings();
131+
}
132+
133+
/** Returns the object with the settings used for calls to getMetrics. */
134+
public UnaryCallSettings<GetMetricsRequest, Metrics> getMetricsSettings() {
135+
return ((RecaptchaEnterpriseServiceStubSettings) getStubSettings()).getMetricsSettings();
136+
}
137+
125138
public static final RecaptchaEnterpriseServiceSettings create(
126139
RecaptchaEnterpriseServiceStubSettings stub) throws IOException {
127140
return new RecaptchaEnterpriseServiceSettings.Builder(stub.toBuilder()).build();
@@ -258,6 +271,16 @@ public UnaryCallSettings.Builder<DeleteKeyRequest, Empty> deleteKeySettings() {
258271
return getStubSettingsBuilder().deleteKeySettings();
259272
}
260273

274+
/** Returns the builder for the settings used for calls to migrateKey. */
275+
public UnaryCallSettings.Builder<MigrateKeyRequest, Key> migrateKeySettings() {
276+
return getStubSettingsBuilder().migrateKeySettings();
277+
}
278+
279+
/** Returns the builder for the settings used for calls to getMetrics. */
280+
public UnaryCallSettings.Builder<GetMetricsRequest, Metrics> getMetricsSettings() {
281+
return getStubSettingsBuilder().getMetricsSettings();
282+
}
283+
261284
@Override
262285
public RecaptchaEnterpriseServiceSettings build() throws IOException {
263286
return new RecaptchaEnterpriseServiceSettings(this);

google-cloud-recaptchaenterprise/src/main/java/com/google/cloud/recaptchaenterprise/v1/gapic_metadata.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@
2525
"GetKey": {
2626
"methods": ["getKey", "getKeyCallable"]
2727
},
28+
"GetMetrics": {
29+
"methods": ["getMetrics", "getMetrics", "getMetrics", "getMetricsCallable"]
30+
},
2831
"ListKeys": {
2932
"methods": ["listKeys", "listKeysPagedCallable", "listKeysCallable"]
3033
},
34+
"MigrateKey": {
35+
"methods": ["migrateKey", "migrateKeyCallable"]
36+
},
3137
"UpdateKey": {
3238
"methods": ["updateKey", "updateKeyCallable"]
3339
}

0 commit comments

Comments
 (0)