From 4d95d210ed316d1e3235e076ad5c71a1082d3164 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:20:22 -0400 Subject: [PATCH] feat: support for ListIpOverrides and RemoveIpOverride (#7777) feat: enable Akamai web application firewall docs: minor updates to reference documentation PiperOrigin-RevId: 691017365 Source-Link: https://github.com/googleapis/googleapis/commit/f28656a54e9b507dc244f9da70474fdb75ac5555 Source-Link: https://github.com/googleapis/googleapis-gen/commit/537296f5c3f781937ac6dfefc138a5a6f7aec2dc Copy-Tag: eyJwIjoiUmVjYXB0Y2hhRW50ZXJwcmlzZS8uT3dsQm90LnlhbWwiLCJoIjoiNTM3Mjk2ZjVjM2Y3ODE5MzdhYzZkZmVmYzEzOGE1YTZmN2FlYzJkYyJ9 --- .../metadata/V1/Recaptchaenterprise.php | Bin 23619 -> 24536 bytes .../annotate_assessment.php | 4 +- .../create_firewall_policy.php | 2 +- .../list_ip_overrides.php | 77 ++++++++ .../list_keys.php | 2 +- .../remove_ip_override.php | 95 ++++++++++ .../src/V1/AnnotateAssessmentRequest.php | 20 +-- .../RecaptchaEnterpriseServiceClient.php | 63 +++++++ .../src/V1/CreateFirewallPolicyRequest.php | 10 +- RecaptchaEnterprise/src/V1/Event.php | 16 +- RecaptchaEnterprise/src/V1/FirewallAction.php | 30 ++-- .../src/V1/FirewallAction/RedirectAction.php | 2 +- .../RecaptchaEnterpriseServiceGapicClient.php | 149 ++++++++++++++- RecaptchaEnterprise/src/V1/IOSKeySettings.php | 32 ++-- RecaptchaEnterprise/src/V1/Key.php | 6 +- .../src/V1/ListIpOverridesRequest.php | 170 ++++++++++++++++++ .../src/V1/ListIpOverridesResponse.php | 105 +++++++++++ .../src/V1/ListKeysRequest.php | 10 +- RecaptchaEnterprise/src/V1/Metrics.php | 8 +- .../src/V1/RemoveIpOverrideRequest.php | 132 ++++++++++++++ .../src/V1/RemoveIpOverrideResponse.php | 33 ++++ RecaptchaEnterprise/src/V1/TestingOptions.php | 24 +-- .../src/V1/WafSettings/WafService.php | 9 +- RecaptchaEnterprise/src/V1/WebKeySettings.php | 16 +- .../src/V1/gapic_metadata.json | 10 ++ ...tcha_enterprise_service_client_config.json | 10 ++ ...a_enterprise_service_descriptor_config.php | 32 ++++ ..._enterprise_service_rest_client_config.php | 23 +++ .../RecaptchaEnterpriseServiceClientTest.php | 152 ++++++++++++++++ .../RecaptchaEnterpriseServiceClientTest.php | 140 +++++++++++++++ 30 files changed, 1286 insertions(+), 96 deletions(-) create mode 100644 RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_ip_overrides.php create mode 100644 RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php create mode 100644 RecaptchaEnterprise/src/V1/ListIpOverridesRequest.php create mode 100644 RecaptchaEnterprise/src/V1/ListIpOverridesResponse.php create mode 100644 RecaptchaEnterprise/src/V1/RemoveIpOverrideRequest.php create mode 100644 RecaptchaEnterprise/src/V1/RemoveIpOverrideResponse.php diff --git a/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php b/RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php index 17b08e15de3384e1a3615a12f09ab860802baf0a..c7e9e4a574c14ed42143dc54e05fb36d13918590 100644 GIT binary patch delta 469 zcmX@SgYm|G#tqCYtj*gQxojtT+irGcF>&Nt&B!Gll$x7gmO6Ql%Mu4EE(r+Fv%tSB zwWugFB{e9uxFA2TI8~{WkxR@cv$zByRUDLBSejZ~B4o$KR*+bfnpZN}SJP~AfRm9% zEtfckT8KG9o?JYc1@S-|LB>zk)zP2qsetParent($formattedParent); + + // Call the API and handle any network failures. + try { + /** @var PagedListResponse $response */ + $response = $recaptchaEnterpriseServiceClient->listIpOverrides($request); + + /** @var IpOverrideData $element */ + foreach ($response as $element) { + printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString()); + } + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedParent = RecaptchaEnterpriseServiceClient::keyName('[PROJECT]', '[KEY]'); + + list_ip_overrides_sample($formattedParent); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListIpOverrides_sync] diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php index a56138803722..5994d374f851 100644 --- a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php @@ -32,7 +32,7 @@ /** * Returns the list of all keys that belong to a project. * - * @param string $formattedParent The name of the project that contains the keys that are + * @param string $formattedParent The name of the project that contains the keys that is * listed, in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. */ diff --git a/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php new file mode 100644 index 000000000000..bcd40ed3b151 --- /dev/null +++ b/RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php @@ -0,0 +1,95 @@ +setIp($ipOverrideDataIp) + ->setOverrideType($ipOverrideDataOverrideType); + $request = (new RemoveIpOverrideRequest()) + ->setName($formattedName) + ->setIpOverrideData($ipOverrideData); + + // Call the API and handle any network failures. + try { + /** @var RemoveIpOverrideResponse $response */ + $response = $recaptchaEnterpriseServiceClient->removeIpOverride($request); + printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString()); + } catch (ApiException $ex) { + printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage()); + } +} + +/** + * Helper to execute the sample. + * + * This sample 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, + * please see the apiEndpoint client configuration option for more details. + */ +function callSample(): void +{ + $formattedName = RecaptchaEnterpriseServiceClient::keyName('[PROJECT]', '[KEY]'); + $ipOverrideDataIp = '[IP]'; + $ipOverrideDataOverrideType = OverrideType::OVERRIDE_TYPE_UNSPECIFIED; + + remove_ip_override_sample($formattedName, $ipOverrideDataIp, $ipOverrideDataOverrideType); +} +// [END recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RemoveIpOverride_sync] diff --git a/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php b/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php index 9fd92369df93..fb85125d5825 100644 --- a/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php +++ b/RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php @@ -23,8 +23,8 @@ class AnnotateAssessmentRequest extends \Google\Protobuf\Internal\Message */ private $name = ''; /** - * Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * Optional. The annotation that is 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. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation annotation = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -65,8 +65,8 @@ class AnnotateAssessmentRequest extends \Google\Protobuf\Internal\Message * @param string $name Required. The resource name of the Assessment, in the format * `projects/{project}/assessments/{assessment}`. Please see * {@see RecaptchaEnterpriseServiceClient::assessmentName()} for help formatting this field. - * @param int $annotation Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * @param int $annotation Optional. The annotation that is 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. * For allowed values, use constants defined on {@see \Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation} * @@ -91,8 +91,8 @@ public static function build(string $name, int $annotation): self * Required. The resource name of the Assessment, in the format * `projects/{project}/assessments/{assessment}`. * @type int $annotation - * Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * Optional. The annotation that is 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. * @type array|\Google\Protobuf\Internal\RepeatedField $reasons * Optional. Reasons for the annotation that are assigned to the event. @@ -144,8 +144,8 @@ public function setName($var) } /** - * Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * Optional. The annotation that is 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. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation annotation = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -157,8 +157,8 @@ public function getAnnotation() } /** - * Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * Optional. The annotation that is 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. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AnnotateAssessmentRequest.Annotation annotation = 2 [(.google.api.field_behavior) = OPTIONAL]; diff --git a/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php b/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php index f1c696dae386..4d8c34088512 100644 --- a/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php +++ b/RecaptchaEnterprise/src/V1/Client/RecaptchaEnterpriseServiceClient.php @@ -49,11 +49,14 @@ use Google\Cloud\RecaptchaEnterprise\V1\GetMetricsRequest; use Google\Cloud\RecaptchaEnterprise\V1\Key; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsRequest; use Google\Cloud\RecaptchaEnterprise\V1\Metrics; use Google\Cloud\RecaptchaEnterprise\V1\MigrateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyRequest; @@ -85,10 +88,12 @@ * @method PromiseInterface getKeyAsync(GetKeyRequest $request, array $optionalArgs = []) * @method PromiseInterface getMetricsAsync(GetMetricsRequest $request, array $optionalArgs = []) * @method PromiseInterface listFirewallPoliciesAsync(ListFirewallPoliciesRequest $request, array $optionalArgs = []) + * @method PromiseInterface listIpOverridesAsync(ListIpOverridesRequest $request, array $optionalArgs = []) * @method PromiseInterface listKeysAsync(ListKeysRequest $request, array $optionalArgs = []) * @method PromiseInterface listRelatedAccountGroupMembershipsAsync(ListRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = []) * @method PromiseInterface listRelatedAccountGroupsAsync(ListRelatedAccountGroupsRequest $request, array $optionalArgs = []) * @method PromiseInterface migrateKeyAsync(MigrateKeyRequest $request, array $optionalArgs = []) + * @method PromiseInterface removeIpOverrideAsync(RemoveIpOverrideRequest $request, array $optionalArgs = []) * @method PromiseInterface reorderFirewallPoliciesAsync(ReorderFirewallPoliciesRequest $request, array $optionalArgs = []) * @method PromiseInterface retrieveLegacySecretKeyAsync(RetrieveLegacySecretKeyRequest $request, array $optionalArgs = []) * @method PromiseInterface searchRelatedAccountGroupMembershipsAsync(SearchRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = []) @@ -640,6 +645,33 @@ public function listFirewallPolicies(ListFirewallPoliciesRequest $request, array return $this->startApiCall('ListFirewallPolicies', $request, $callOptions); } + /** + * Lists all IP overrides for a key. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::listIpOverridesAsync()} . + * + * @example samples/V1/RecaptchaEnterpriseServiceClient/list_ip_overrides.php + * + * @param ListIpOverridesRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return PagedListResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function listIpOverrides(ListIpOverridesRequest $request, array $callOptions = []): PagedListResponse + { + return $this->startApiCall('ListIpOverrides', $request, $callOptions); + } + /** * Returns the list of all keys that belong to a project. * @@ -753,6 +785,37 @@ public function migrateKey(MigrateKeyRequest $request, array $callOptions = []): return $this->startApiCall('MigrateKey', $request, $callOptions)->wait(); } + /** + * Removes an IP override from a key. The following restrictions hold: + * * If the IP isn't found in an existing IP override, a `NOT_FOUND` error + * is returned. + * * If the IP is found in an existing IP override, but the + * override type does not match, a `NOT_FOUND` error is returned. + * + * The async variant is + * {@see RecaptchaEnterpriseServiceClient::removeIpOverrideAsync()} . + * + * @example samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php + * + * @param RemoveIpOverrideRequest $request A request to house fields associated with the call. + * @param array $callOptions { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return RemoveIpOverrideResponse + * + * @throws ApiException Thrown if the API call fails. + */ + public function removeIpOverride(RemoveIpOverrideRequest $request, array $callOptions = []): RemoveIpOverrideResponse + { + return $this->startApiCall('RemoveIpOverride', $request, $callOptions)->wait(); + } + /** * Reorders all firewall policies. * diff --git a/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php b/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php index d74794853ef8..eaf40a09a08d 100644 --- a/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php +++ b/RecaptchaEnterprise/src/V1/CreateFirewallPolicyRequest.php @@ -16,7 +16,7 @@ class CreateFirewallPolicyRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The name of the project this policy will apply to, in the format + * Required. The name of the project this policy applies to, in the format * `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -30,7 +30,7 @@ class CreateFirewallPolicyRequest extends \Google\Protobuf\Internal\Message private $firewall_policy = null; /** - * @param string $parent Required. The name of the project this policy will apply to, in the format + * @param string $parent Required. The name of the project this policy applies to, in the format * `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * @param \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewallPolicy Required. Information to create the policy. @@ -53,7 +53,7 @@ public static function build(string $parent, \Google\Cloud\RecaptchaEnterprise\V * Optional. Data for populating the Message object. * * @type string $parent - * Required. The name of the project this policy will apply to, in the format + * Required. The name of the project this policy applies to, in the format * `projects/{project}`. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy $firewall_policy * Required. Information to create the policy. @@ -65,7 +65,7 @@ public function __construct($data = NULL) { } /** - * Required. The name of the project this policy will apply to, in the format + * Required. The name of the project this policy applies to, in the format * `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -77,7 +77,7 @@ public function getParent() } /** - * Required. The name of the project this policy will apply to, in the format + * Required. The name of the project this policy applies to, in the format * `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/RecaptchaEnterprise/src/V1/Event.php b/RecaptchaEnterprise/src/V1/Event.php index ca4fc33bb46f..95b5943cf5ad 100644 --- a/RecaptchaEnterprise/src/V1/Event.php +++ b/RecaptchaEnterprise/src/V1/Event.php @@ -62,7 +62,7 @@ class Event extends \Google\Protobuf\Internal\Message protected $hashed_account_id = ''; /** * Optional. Flag for a reCAPTCHA express request for an assessment without a - * token. If enabled, `site_key` must reference an express key. + * token. If enabled, `site_key` must reference an Express site key. * * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -103,7 +103,7 @@ class Event extends \Google\Protobuf\Internal\Message private $firewall_policy_evaluation = false; /** * Optional. Data describing a payment transaction to be assessed. Sending - * this data enables reCAPTCHA Fraud Prevention and the + * this data enables reCAPTCHA Enterprise Fraud Prevention and the * FraudPreventionAssessment component in the response. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TransactionData transaction_data = 13 [(.google.api.field_behavior) = OPTIONAL]; @@ -153,7 +153,7 @@ class Event extends \Google\Protobuf\Internal\Message * be hashed using hmac-sha256 with stable secret. * @type bool $express * Optional. Flag for a reCAPTCHA express request for an assessment without a - * token. If enabled, `site_key` must reference an express key. + * token. If enabled, `site_key` must reference an Express site key. * @type string $requested_uri * Optional. The URI resource the user requested that triggered an assessment. * @type bool $waf_token_assessment @@ -170,7 +170,7 @@ class Event extends \Google\Protobuf\Internal\Message * suggested firewall action is returned in the response. * @type \Google\Cloud\RecaptchaEnterprise\V1\TransactionData $transaction_data * Optional. Data describing a payment transaction to be assessed. Sending - * this data enables reCAPTCHA Fraud Prevention and the + * this data enables reCAPTCHA Enterprise Fraud Prevention and the * FraudPreventionAssessment component in the response. * @type \Google\Cloud\RecaptchaEnterprise\V1\UserInfo $user_info * Optional. Information about the user that generates this event, when they @@ -364,7 +364,7 @@ public function setHashedAccountId($var) /** * Optional. Flag for a reCAPTCHA express request for an assessment without a - * token. If enabled, `site_key` must reference an express key. + * token. If enabled, `site_key` must reference an Express site key. * * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; * @return bool @@ -376,7 +376,7 @@ public function getExpress() /** * Optional. Flag for a reCAPTCHA express request for an assessment without a - * token. If enabled, `site_key` must reference an express key. + * token. If enabled, `site_key` must reference an Express site key. * * Generated from protobuf field bool express = 14 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var @@ -530,7 +530,7 @@ public function setFirewallPolicyEvaluation($var) /** * Optional. Data describing a payment transaction to be assessed. Sending - * this data enables reCAPTCHA Fraud Prevention and the + * this data enables reCAPTCHA Enterprise Fraud Prevention and the * FraudPreventionAssessment component in the response. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TransactionData transaction_data = 13 [(.google.api.field_behavior) = OPTIONAL]; @@ -553,7 +553,7 @@ public function clearTransactionData() /** * Optional. Data describing a payment transaction to be assessed. Sending - * this data enables reCAPTCHA Fraud Prevention and the + * this data enables reCAPTCHA Enterprise Fraud Prevention and the * FraudPreventionAssessment component in the response. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TransactionData transaction_data = 13 [(.google.api.field_behavior) = OPTIONAL]; diff --git a/RecaptchaEnterprise/src/V1/FirewallAction.php b/RecaptchaEnterprise/src/V1/FirewallAction.php index ee934704ec1c..b5be30f5734f 100644 --- a/RecaptchaEnterprise/src/V1/FirewallAction.php +++ b/RecaptchaEnterprise/src/V1/FirewallAction.php @@ -28,19 +28,19 @@ class FirewallAction extends \Google\Protobuf\Internal\Message * The user request did not match any policy and should be allowed * access to the requested resource. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\BlockAction $block - * This action will deny access to a given page. The user will get an HTTP + * This action denies access to a given page. The user gets an HTTP * error code. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\IncludeRecaptchaScriptAction $include_recaptcha_script - * This action will inject reCAPTCHA JavaScript code into the HTML page + * This action injects reCAPTCHA JavaScript code into the HTML page * returned by the site backend. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\RedirectAction $redirect - * This action will redirect the request to a ReCaptcha interstitial to + * This action redirects the request to a reCAPTCHA interstitial to * attach a token. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SubstituteAction $substitute - * This action will transparently serve a different page to an offending + * This action transparently serves a different page to an offending * user. * @type \Google\Cloud\RecaptchaEnterprise\V1\FirewallAction\SetHeaderAction $set_header - * This action will set a custom header but allow the request to continue + * This action sets a custom header but allow the request to continue * to the customer backend. * } */ @@ -83,7 +83,7 @@ public function setAllow($var) } /** - * This action will deny access to a given page. The user will get an HTTP + * This action denies access to a given page. The user gets an HTTP * error code. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.BlockAction block = 2; @@ -100,7 +100,7 @@ public function hasBlock() } /** - * This action will deny access to a given page. The user will get an HTTP + * This action denies access to a given page. The user gets an HTTP * error code. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.BlockAction block = 2; @@ -116,7 +116,7 @@ public function setBlock($var) } /** - * This action will inject reCAPTCHA JavaScript code into the HTML page + * This action injects reCAPTCHA JavaScript code into the HTML page * returned by the site backend. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.IncludeRecaptchaScriptAction include_recaptcha_script = 6; @@ -133,7 +133,7 @@ public function hasIncludeRecaptchaScript() } /** - * This action will inject reCAPTCHA JavaScript code into the HTML page + * This action injects reCAPTCHA JavaScript code into the HTML page * returned by the site backend. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.IncludeRecaptchaScriptAction include_recaptcha_script = 6; @@ -149,7 +149,7 @@ public function setIncludeRecaptchaScript($var) } /** - * This action will redirect the request to a ReCaptcha interstitial to + * This action redirects the request to a reCAPTCHA interstitial to * attach a token. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction redirect = 5; @@ -166,7 +166,7 @@ public function hasRedirect() } /** - * This action will redirect the request to a ReCaptcha interstitial to + * This action redirects the request to a reCAPTCHA interstitial to * attach a token. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction redirect = 5; @@ -182,7 +182,7 @@ public function setRedirect($var) } /** - * This action will transparently serve a different page to an offending + * This action transparently serves a different page to an offending * user. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SubstituteAction substitute = 3; @@ -199,7 +199,7 @@ public function hasSubstitute() } /** - * This action will transparently serve a different page to an offending + * This action transparently serves a different page to an offending * user. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SubstituteAction substitute = 3; @@ -215,7 +215,7 @@ public function setSubstitute($var) } /** - * This action will set a custom header but allow the request to continue + * This action sets a custom header but allow the request to continue * to the customer backend. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SetHeaderAction set_header = 4; @@ -232,7 +232,7 @@ public function hasSetHeader() } /** - * This action will set a custom header but allow the request to continue + * This action sets a custom header but allow the request to continue * to the customer backend. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.FirewallAction.SetHeaderAction set_header = 4; diff --git a/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php b/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php index 6151c5b27f83..308c3b4c9f5a 100644 --- a/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php +++ b/RecaptchaEnterprise/src/V1/FirewallAction/RedirectAction.php @@ -10,7 +10,7 @@ /** * A redirect action returns a 307 (temporary redirect) response, pointing - * the user to a ReCaptcha interstitial page to attach a token. + * the user to a reCAPTCHA interstitial page to attach a token. * * Generated from protobuf message google.cloud.recaptchaenterprise.v1.FirewallAction.RedirectAction */ diff --git a/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php b/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php index 0d4ac148e3be..2a48c5f48c2d 100644 --- a/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php +++ b/RecaptchaEnterprise/src/V1/Gapic/RecaptchaEnterpriseServiceGapicClient.php @@ -52,6 +52,8 @@ use Google\Cloud\RecaptchaEnterprise\V1\Key; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; @@ -60,6 +62,8 @@ use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsResponse; use Google\Cloud\RecaptchaEnterprise\V1\Metrics; use Google\Cloud\RecaptchaEnterprise\V1\MigrateKeyRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyRequest; @@ -534,8 +538,8 @@ public function addIpOverride( * * @param string $name Required. The resource name of the Assessment, in the format * `projects/{project}/assessments/{assessment}`. - * @param int $annotation Optional. The annotation that is assigned to the Event. This field can - * be left empty to provide reasons that apply to an event without concluding + * @param int $annotation Optional. The annotation that is 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. * For allowed values, use constants defined on {@see \Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation} * @param array $optionalArgs { @@ -678,7 +682,7 @@ public function createAssessment( * } * ``` * - * @param string $parent Required. The name of the project this policy will apply to, in the format + * @param string $parent Required. The name of the project this policy applies to, in the format * `projects/{project}`. * @param FirewallPolicy $firewallPolicy Required. Information to create the policy. * @param array $optionalArgs { @@ -1090,6 +1094,84 @@ public function listFirewallPolicies($parent, array $optionalArgs = []) ); } + /** + * Lists all IP overrides for a key. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedParent = $recaptchaEnterpriseServiceClient->keyName('[PROJECT]', '[KEY]'); + * // Iterate over pages of elements + * $pagedResponse = $recaptchaEnterpriseServiceClient->listIpOverrides($formattedParent); + * foreach ($pagedResponse->iteratePages() as $page) { + * foreach ($page as $element) { + * // doSomethingWith($element); + * } + * } + * // Alternatively: + * // Iterate through all elements + * $pagedResponse = $recaptchaEnterpriseServiceClient->listIpOverrides($formattedParent); + * foreach ($pagedResponse->iterateAllElements() as $element) { + * // doSomethingWith($element); + * } + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $parent Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. + * @param array $optionalArgs { + * Optional. + * + * @type int $pageSize + * The maximum number of resources contained in the underlying API + * response. The API may return fewer values in a page, even if + * there are additional values to be retrieved. + * @type string $pageToken + * A page token is used to specify a page of values to be returned. + * If no page token is specified (the default), the first page + * of values will be returned. Any page token used here must have + * been generated by a previous call to the API. + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\ApiCore\PagedListResponse + * + * @throws ApiException if the remote call fails + */ + public function listIpOverrides($parent, array $optionalArgs = []) + { + $request = new ListIpOverridesRequest(); + $requestParamHeaders = []; + $request->setParent($parent); + $requestParamHeaders['parent'] = $parent; + if (isset($optionalArgs['pageSize'])) { + $request->setPageSize($optionalArgs['pageSize']); + } + + if (isset($optionalArgs['pageToken'])) { + $request->setPageToken($optionalArgs['pageToken']); + } + + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->getPagedListResponse( + 'ListIpOverrides', + $optionalArgs, + ListIpOverridesResponse::class, + $request + ); + } + /** * Returns the list of all keys that belong to a project. * @@ -1116,7 +1198,7 @@ public function listFirewallPolicies($parent, array $optionalArgs = []) * } * ``` * - * @param string $parent Required. The name of the project that contains the keys that are + * @param string $parent Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. * @param array $optionalArgs { * Optional. @@ -1393,6 +1475,65 @@ public function migrateKey($name, array $optionalArgs = []) )->wait(); } + /** + * Removes an IP override from a key. The following restrictions hold: + * * If the IP isn't found in an existing IP override, a `NOT_FOUND` error + * is returned. + * * If the IP is found in an existing IP override, but the + * override type does not match, a `NOT_FOUND` error is returned. + * + * Sample code: + * ``` + * $recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient(); + * try { + * $formattedName = $recaptchaEnterpriseServiceClient->keyName('[PROJECT]', '[KEY]'); + * $ipOverrideData = new IpOverrideData(); + * $response = $recaptchaEnterpriseServiceClient->removeIpOverride($formattedName, $ipOverrideData); + * } finally { + * $recaptchaEnterpriseServiceClient->close(); + * } + * ``` + * + * @param string $name Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. + * @param IpOverrideData $ipOverrideData Required. IP override to be removed from the key. + * @param array $optionalArgs { + * Optional. + * + * @type RetrySettings|array $retrySettings + * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an + * associative array of retry settings parameters. See the documentation on + * {@see RetrySettings} for example usage. + * } + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse + * + * @throws ApiException if the remote call fails + */ + public function removeIpOverride( + $name, + $ipOverrideData, + array $optionalArgs = [] + ) { + $request = new RemoveIpOverrideRequest(); + $requestParamHeaders = []; + $request->setName($name); + $request->setIpOverrideData($ipOverrideData); + $requestParamHeaders['name'] = $name; + $requestParams = new RequestParamsHeaderDescriptor( + $requestParamHeaders + ); + $optionalArgs['headers'] = isset($optionalArgs['headers']) + ? array_merge($requestParams->getHeader(), $optionalArgs['headers']) + : $requestParams->getHeader(); + return $this->startCall( + 'RemoveIpOverride', + RemoveIpOverrideResponse::class, + $optionalArgs, + $request + )->wait(); + } + /** * Reorders all firewall policies. * diff --git a/RecaptchaEnterprise/src/V1/IOSKeySettings.php b/RecaptchaEnterprise/src/V1/IOSKeySettings.php index b682092cc240..a751a2c0049c 100644 --- a/RecaptchaEnterprise/src/V1/IOSKeySettings.php +++ b/RecaptchaEnterprise/src/V1/IOSKeySettings.php @@ -30,10 +30,10 @@ class IOSKeySettings extends \Google\Protobuf\Internal\Message private $allowed_bundle_ids; /** * Optional. Apple Developer account details for the app that is protected by - * the reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks - * like Apple App Attest and Apple DeviceCheck to protect your app from abuse. - * Providing these fields allows reCAPTCHA Enterprise to get a better - * assessment of the integrity of your app. + * the reCAPTCHA Key. reCAPTCHA leverages platform-specific checks like Apple + * App Attest and Apple DeviceCheck to protect your app from abuse. Providing + * these fields allows reCAPTCHA to get a better assessment of the integrity + * of your app. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -52,10 +52,10 @@ class IOSKeySettings extends \Google\Protobuf\Internal\Message * Example: 'com.companyname.productname.appname' * @type \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId $apple_developer_id * Optional. Apple Developer account details for the app that is protected by - * the reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks - * like Apple App Attest and Apple DeviceCheck to protect your app from abuse. - * Providing these fields allows reCAPTCHA Enterprise to get a better - * assessment of the integrity of your app. + * the reCAPTCHA Key. reCAPTCHA leverages platform-specific checks like Apple + * App Attest and Apple DeviceCheck to protect your app from abuse. Providing + * these fields allows reCAPTCHA to get a better assessment of the integrity + * of your app. * } */ public function __construct($data = NULL) { @@ -119,10 +119,10 @@ public function setAllowedBundleIds($var) /** * Optional. Apple Developer account details for the app that is protected by - * the reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks - * like Apple App Attest and Apple DeviceCheck to protect your app from abuse. - * Providing these fields allows reCAPTCHA Enterprise to get a better - * assessment of the integrity of your app. + * the reCAPTCHA Key. reCAPTCHA leverages platform-specific checks like Apple + * App Attest and Apple DeviceCheck to protect your app from abuse. Providing + * these fields allows reCAPTCHA to get a better assessment of the integrity + * of your app. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId|null @@ -144,10 +144,10 @@ public function clearAppleDeveloperId() /** * Optional. Apple Developer account details for the app that is protected by - * the reCAPTCHA Key. reCAPTCHA Enterprise leverages platform-specific checks - * like Apple App Attest and Apple DeviceCheck to protect your app from abuse. - * Providing these fields allows reCAPTCHA Enterprise to get a better - * assessment of the integrity of your app. + * the reCAPTCHA Key. reCAPTCHA leverages platform-specific checks like Apple + * App Attest and Apple DeviceCheck to protect your app from abuse. Providing + * these fields allows reCAPTCHA to get a better assessment of the integrity + * of your app. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.AppleDeveloperId apple_developer_id = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param \Google\Cloud\RecaptchaEnterprise\V1\AppleDeveloperId $var diff --git a/RecaptchaEnterprise/src/V1/Key.php b/RecaptchaEnterprise/src/V1/Key.php index 4cc838118bf3..c329e908fd3f 100644 --- a/RecaptchaEnterprise/src/V1/Key.php +++ b/RecaptchaEnterprise/src/V1/Key.php @@ -74,7 +74,7 @@ class Key extends \Google\Protobuf\Internal\Message * @type \Google\Cloud\RecaptchaEnterprise\V1\IOSKeySettings $ios_settings * Settings for keys that can be used by iOS apps. * @type \Google\Cloud\RecaptchaEnterprise\V1\ExpressKeySettings $express_settings - * Settings specific to keys that can be used for reCAPTCHA Express. + * Settings for keys that can be used by reCAPTCHA Express. * @type array|\Google\Protobuf\Internal\MapField $labels * Optional. See [Creating and managing labels] * (https://cloud.google.com/recaptcha/docs/labels). @@ -239,7 +239,7 @@ public function setIosSettings($var) } /** - * Settings specific to keys that can be used for reCAPTCHA Express. + * Settings for keys that can be used by reCAPTCHA Express. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.ExpressKeySettings express_settings = 11; * @return \Google\Cloud\RecaptchaEnterprise\V1\ExpressKeySettings|null @@ -255,7 +255,7 @@ public function hasExpressSettings() } /** - * Settings specific to keys that can be used for reCAPTCHA Express. + * Settings for keys that can be used by reCAPTCHA Express. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.ExpressKeySettings express_settings = 11; * @param \Google\Cloud\RecaptchaEnterprise\V1\ExpressKeySettings $var diff --git a/RecaptchaEnterprise/src/V1/ListIpOverridesRequest.php b/RecaptchaEnterprise/src/V1/ListIpOverridesRequest.php new file mode 100644 index 000000000000..9411617a5f32 --- /dev/null +++ b/RecaptchaEnterprise/src/V1/ListIpOverridesRequest.php @@ -0,0 +1,170 @@ +google.cloud.recaptchaenterprise.v1.ListIpOverridesRequest + */ +class ListIpOverridesRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $parent = ''; + /** + * Optional. The maximum number of overrides to return. Default is 10. Max + * limit is 100. If the number of overrides is less than the page_size, all + * overrides are returned. If the page size is more than 100, it is coerced to + * 100. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_size = 0; + /** + * Optional. The next_page_token value returned from a previous + * ListIpOverridesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + */ + private $page_token = ''; + + /** + * @param string $parent Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. Please see + * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesRequest + * + * @experimental + */ + public static function build(string $parent): self + { + return (new self()) + ->setParent($parent); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $parent + * Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. + * @type int $page_size + * Optional. The maximum number of overrides to return. Default is 10. Max + * limit is 100. If the number of overrides is less than the page_size, all + * overrides are returned. If the page size is more than 100, it is coerced to + * 100. + * @type string $page_token + * Optional. The next_page_token value returned from a previous + * ListIpOverridesRequest, if any. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getParent() + { + return $this->parent; + } + + /** + * Required. The parent key for which the IP overrides are listed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setParent($var) + { + GPBUtil::checkString($var, True); + $this->parent = $var; + + return $this; + } + + /** + * Optional. The maximum number of overrides to return. Default is 10. Max + * limit is 100. If the number of overrides is less than the page_size, all + * overrides are returned. If the page size is more than 100, it is coerced to + * 100. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @return int + */ + public function getPageSize() + { + return $this->page_size; + } + + /** + * Optional. The maximum number of overrides to return. Default is 10. Max + * limit is 100. If the number of overrides is less than the page_size, all + * overrides are returned. If the page size is more than 100, it is coerced to + * 100. + * + * Generated from protobuf field int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * @param int $var + * @return $this + */ + public function setPageSize($var) + { + GPBUtil::checkInt32($var); + $this->page_size = $var; + + return $this; + } + + /** + * Optional. The next_page_token value returned from a previous + * ListIpOverridesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @return string + */ + public function getPageToken() + { + return $this->page_token; + } + + /** + * Optional. The next_page_token value returned from a previous + * ListIpOverridesRequest, if any. + * + * Generated from protobuf field string page_token = 3 [(.google.api.field_behavior) = OPTIONAL]; + * @param string $var + * @return $this + */ + public function setPageToken($var) + { + GPBUtil::checkString($var, True); + $this->page_token = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/ListIpOverridesResponse.php b/RecaptchaEnterprise/src/V1/ListIpOverridesResponse.php new file mode 100644 index 000000000000..0904013bd50e --- /dev/null +++ b/RecaptchaEnterprise/src/V1/ListIpOverridesResponse.php @@ -0,0 +1,105 @@ +google.cloud.recaptchaenterprise.v1.ListIpOverridesResponse + */ +class ListIpOverridesResponse extends \Google\Protobuf\Internal\Message +{ + /** + * IP Overrides details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_overrides = 1; + */ + private $ip_overrides; + /** + * Token to retrieve the next page of results. If this field is empty, no keys + * remain in the results. + * + * Generated from protobuf field string next_page_token = 2; + */ + private $next_page_token = ''; + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type array<\Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData>|\Google\Protobuf\Internal\RepeatedField $ip_overrides + * IP Overrides details. + * @type string $next_page_token + * Token to retrieve the next page of results. If this field is empty, no keys + * remain in the results. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * IP Overrides details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_overrides = 1; + * @return \Google\Protobuf\Internal\RepeatedField + */ + public function getIpOverrides() + { + return $this->ip_overrides; + } + + /** + * IP Overrides details. + * + * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_overrides = 1; + * @param array<\Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData>|\Google\Protobuf\Internal\RepeatedField $var + * @return $this + */ + public function setIpOverrides($var) + { + $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData::class); + $this->ip_overrides = $arr; + + return $this; + } + + /** + * Token to retrieve the next page of results. If this field is empty, no keys + * remain in the results. + * + * Generated from protobuf field string next_page_token = 2; + * @return string + */ + public function getNextPageToken() + { + return $this->next_page_token; + } + + /** + * Token to retrieve the next page of results. If this field is empty, no keys + * remain in the results. + * + * Generated from protobuf field string next_page_token = 2; + * @param string $var + * @return $this + */ + public function setNextPageToken($var) + { + GPBUtil::checkString($var, True); + $this->next_page_token = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/ListKeysRequest.php b/RecaptchaEnterprise/src/V1/ListKeysRequest.php index b75c2d5d36bd..b2fa1187e61f 100644 --- a/RecaptchaEnterprise/src/V1/ListKeysRequest.php +++ b/RecaptchaEnterprise/src/V1/ListKeysRequest.php @@ -16,7 +16,7 @@ class ListKeysRequest extends \Google\Protobuf\Internal\Message { /** - * Required. The name of the project that contains the keys that are + * Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -38,7 +38,7 @@ class ListKeysRequest extends \Google\Protobuf\Internal\Message private $page_token = ''; /** - * @param string $parent Required. The name of the project that contains the keys that are + * @param string $parent Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. Please see * {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field. * @@ -59,7 +59,7 @@ public static function build(string $parent): self * Optional. Data for populating the Message object. * * @type string $parent - * Required. The name of the project that contains the keys that are + * Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. * @type int $page_size * Optional. The maximum number of keys to return. Default is 10. Max limit is @@ -75,7 +75,7 @@ public function __construct($data = NULL) { } /** - * Required. The name of the project that contains the keys that are + * Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { @@ -87,7 +87,7 @@ public function getParent() } /** - * Required. The name of the project that contains the keys that are + * Required. The name of the project that contains the keys that is * listed, in the format `projects/{project}`. * * Generated from protobuf field string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { diff --git a/RecaptchaEnterprise/src/V1/Metrics.php b/RecaptchaEnterprise/src/V1/Metrics.php index e4b38840a77b..4dbaea7c4279 100644 --- a/RecaptchaEnterprise/src/V1/Metrics.php +++ b/RecaptchaEnterprise/src/V1/Metrics.php @@ -37,7 +37,7 @@ class Metrics extends \Google\Protobuf\Internal\Message private $score_metrics; /** * Metrics are continuous and in order by dates, and in the granularity - * of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + * of day. Only challenge-based keys (CHECKBOX, INVISIBLE) have * challenge-based data. * * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.ChallengeMetrics challenge_metrics = 3; @@ -60,7 +60,7 @@ class Metrics extends \Google\Protobuf\Internal\Message * of day. All Key types should have score-based data. * @type array<\Google\Cloud\RecaptchaEnterprise\V1\ChallengeMetrics>|\Google\Protobuf\Internal\RepeatedField $challenge_metrics * Metrics are continuous and in order by dates, and in the granularity - * of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + * of day. Only challenge-based keys (CHECKBOX, INVISIBLE) have * challenge-based data. * } */ @@ -163,7 +163,7 @@ public function setScoreMetrics($var) /** * Metrics are continuous and in order by dates, and in the granularity - * of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + * of day. Only challenge-based keys (CHECKBOX, INVISIBLE) have * challenge-based data. * * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.ChallengeMetrics challenge_metrics = 3; @@ -176,7 +176,7 @@ public function getChallengeMetrics() /** * Metrics are continuous and in order by dates, and in the granularity - * of day. Only challenge-based keys (CHECKBOX, INVISIBLE), will have + * of day. Only challenge-based keys (CHECKBOX, INVISIBLE) have * challenge-based data. * * Generated from protobuf field repeated .google.cloud.recaptchaenterprise.v1.ChallengeMetrics challenge_metrics = 3; diff --git a/RecaptchaEnterprise/src/V1/RemoveIpOverrideRequest.php b/RecaptchaEnterprise/src/V1/RemoveIpOverrideRequest.php new file mode 100644 index 000000000000..c8a7dc776a8e --- /dev/null +++ b/RecaptchaEnterprise/src/V1/RemoveIpOverrideRequest.php @@ -0,0 +1,132 @@ +google.cloud.recaptchaenterprise.v1.RemoveIpOverrideRequest + */ +class RemoveIpOverrideRequest extends \Google\Protobuf\Internal\Message +{ + /** + * Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + */ + private $name = ''; + /** + * Required. IP override to be removed from the key. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_override_data = 2 [(.google.api.field_behavior) = REQUIRED]; + */ + private $ip_override_data = null; + + /** + * @param string $name Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. Please see + * {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field. + * @param \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData $ipOverrideData Required. IP override to be removed from the key. + * + * @return \Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideRequest + * + * @experimental + */ + public static function build(string $name, \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData $ipOverrideData): self + { + return (new self()) + ->setName($name) + ->setIpOverrideData($ipOverrideData); + } + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * @type string $name + * Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. + * @type \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData $ip_override_data + * Required. IP override to be removed from the key. + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + + /** + * Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Required. The name of the key from which the IP override is removed, in the + * format `projects/{project}/keys/{key}`. + * + * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { + * @param string $var + * @return $this + */ + public function setName($var) + { + GPBUtil::checkString($var, True); + $this->name = $var; + + return $this; + } + + /** + * Required. IP override to be removed from the key. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_override_data = 2 [(.google.api.field_behavior) = REQUIRED]; + * @return \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData|null + */ + public function getIpOverrideData() + { + return $this->ip_override_data; + } + + public function hasIpOverrideData() + { + return isset($this->ip_override_data); + } + + public function clearIpOverrideData() + { + unset($this->ip_override_data); + } + + /** + * Required. IP override to be removed from the key. + * + * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.IpOverrideData ip_override_data = 2 [(.google.api.field_behavior) = REQUIRED]; + * @param \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData $var + * @return $this + */ + public function setIpOverrideData($var) + { + GPBUtil::checkMessage($var, \Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData::class); + $this->ip_override_data = $var; + + return $this; + } + +} + diff --git a/RecaptchaEnterprise/src/V1/RemoveIpOverrideResponse.php b/RecaptchaEnterprise/src/V1/RemoveIpOverrideResponse.php new file mode 100644 index 000000000000..c6cb317ffd7b --- /dev/null +++ b/RecaptchaEnterprise/src/V1/RemoveIpOverrideResponse.php @@ -0,0 +1,33 @@ +google.cloud.recaptchaenterprise.v1.RemoveIpOverrideResponse + */ +class RemoveIpOverrideResponse extends \Google\Protobuf\Internal\Message +{ + + /** + * Constructor. + * + * @param array $data { + * Optional. Data for populating the Message object. + * + * } + */ + public function __construct($data = NULL) { + \GPBMetadata\Google\Cloud\Recaptchaenterprise\V1\Recaptchaenterprise::initOnce(); + parent::__construct($data); + } + +} + diff --git a/RecaptchaEnterprise/src/V1/TestingOptions.php b/RecaptchaEnterprise/src/V1/TestingOptions.php index aeb1cae39c37..9089785eee65 100644 --- a/RecaptchaEnterprise/src/V1/TestingOptions.php +++ b/RecaptchaEnterprise/src/V1/TestingOptions.php @@ -16,15 +16,15 @@ class TestingOptions extends \Google\Protobuf\Internal\Message { /** - * Optional. All assessments for this Key will return this score. Must be - * between 0 (likely not legitimate) and 1 (likely legitimate) inclusive. + * Optional. All assessments for this Key return this score. Must be between 0 + * (likely not legitimate) and 1 (likely legitimate) inclusive. * * Generated from protobuf field float testing_score = 1 [(.google.api.field_behavior) = OPTIONAL]; */ private $testing_score = 0.0; /** * Optional. For challenge-based keys only (CHECKBOX, INVISIBLE), all - * challenge requests for this site will return nocaptcha if NOCAPTCHA, or an + * challenge requests for this site return nocaptcha if NOCAPTCHA, or an * unsolvable challenge if CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TestingOptions.TestingChallenge testing_challenge = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -38,11 +38,11 @@ class TestingOptions extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type float $testing_score - * Optional. All assessments for this Key will return this score. Must be - * between 0 (likely not legitimate) and 1 (likely legitimate) inclusive. + * Optional. All assessments for this Key return this score. Must be between 0 + * (likely not legitimate) and 1 (likely legitimate) inclusive. * @type int $testing_challenge * Optional. For challenge-based keys only (CHECKBOX, INVISIBLE), all - * challenge requests for this site will return nocaptcha if NOCAPTCHA, or an + * challenge requests for this site return nocaptcha if NOCAPTCHA, or an * unsolvable challenge if CHALLENGE. * } */ @@ -52,8 +52,8 @@ public function __construct($data = NULL) { } /** - * Optional. All assessments for this Key will return this score. Must be - * between 0 (likely not legitimate) and 1 (likely legitimate) inclusive. + * Optional. All assessments for this Key return this score. Must be between 0 + * (likely not legitimate) and 1 (likely legitimate) inclusive. * * Generated from protobuf field float testing_score = 1 [(.google.api.field_behavior) = OPTIONAL]; * @return float @@ -64,8 +64,8 @@ public function getTestingScore() } /** - * Optional. All assessments for this Key will return this score. Must be - * between 0 (likely not legitimate) and 1 (likely legitimate) inclusive. + * Optional. All assessments for this Key return this score. Must be between 0 + * (likely not legitimate) and 1 (likely legitimate) inclusive. * * Generated from protobuf field float testing_score = 1 [(.google.api.field_behavior) = OPTIONAL]; * @param float $var @@ -81,7 +81,7 @@ public function setTestingScore($var) /** * Optional. For challenge-based keys only (CHECKBOX, INVISIBLE), all - * challenge requests for this site will return nocaptcha if NOCAPTCHA, or an + * challenge requests for this site return nocaptcha if NOCAPTCHA, or an * unsolvable challenge if CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TestingOptions.TestingChallenge testing_challenge = 2 [(.google.api.field_behavior) = OPTIONAL]; @@ -94,7 +94,7 @@ public function getTestingChallenge() /** * Optional. For challenge-based keys only (CHECKBOX, INVISIBLE), all - * challenge requests for this site will return nocaptcha if NOCAPTCHA, or an + * challenge requests for this site return nocaptcha if NOCAPTCHA, or an * unsolvable challenge if CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.TestingOptions.TestingChallenge testing_challenge = 2 [(.google.api.field_behavior) = OPTIONAL]; diff --git a/RecaptchaEnterprise/src/V1/WafSettings/WafService.php b/RecaptchaEnterprise/src/V1/WafSettings/WafService.php index dce269321856..e56c885cea57 100644 --- a/RecaptchaEnterprise/src/V1/WafSettings/WafService.php +++ b/RecaptchaEnterprise/src/V1/WafSettings/WafService.php @@ -7,7 +7,7 @@ use UnexpectedValueException; /** - * Web Application Firewalls supported by reCAPTCHA Enterprise. + * Web Application Firewalls supported by reCAPTCHA. * * Protobuf type google.cloud.recaptchaenterprise.v1.WafSettings.WafService */ @@ -37,12 +37,19 @@ class WafService * Generated from protobuf enum CLOUDFLARE = 4; */ const CLOUDFLARE = 4; + /** + * Akamai + * + * Generated from protobuf enum AKAMAI = 5; + */ + const AKAMAI = 5; private static $valueToName = [ self::WAF_SERVICE_UNSPECIFIED => 'WAF_SERVICE_UNSPECIFIED', self::CA => 'CA', self::FASTLY => 'FASTLY', self::CLOUDFLARE => 'CLOUDFLARE', + self::AKAMAI => 'AKAMAI', ]; public static function name($value) diff --git a/RecaptchaEnterprise/src/V1/WebKeySettings.php b/RecaptchaEnterprise/src/V1/WebKeySettings.php index e2769bf8c85e..e7212e33013e 100644 --- a/RecaptchaEnterprise/src/V1/WebKeySettings.php +++ b/RecaptchaEnterprise/src/V1/WebKeySettings.php @@ -16,7 +16,7 @@ class WebKeySettings extends \Google\Protobuf\Internal\Message { /** - * Optional. If set to true, it means allowed_domains will not be enforced. + * Optional. If set to true, it means allowed_domains are not enforced. * * Generated from protobuf field bool allow_all_domains = 3 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -46,7 +46,7 @@ class WebKeySettings extends \Google\Protobuf\Internal\Message /** * Optional. Settings for the frequency and difficulty at which this key * triggers captcha challenges. This should only be specified for - * IntegrationTypes CHECKBOX and INVISIBLE. + * IntegrationTypes CHECKBOX and INVISIBLE and SCORE_AND_CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.WebKeySettings.ChallengeSecurityPreference challenge_security_preference = 5 [(.google.api.field_behavior) = OPTIONAL]; */ @@ -59,7 +59,7 @@ class WebKeySettings extends \Google\Protobuf\Internal\Message * Optional. Data for populating the Message object. * * @type bool $allow_all_domains - * Optional. If set to true, it means allowed_domains will not be enforced. + * Optional. If set to true, it means allowed_domains are not enforced. * @type array|\Google\Protobuf\Internal\RepeatedField $allowed_domains * Optional. Domains or subdomains of websites allowed to use the key. All * subdomains of an allowed domain are automatically allowed. A valid domain @@ -73,7 +73,7 @@ class WebKeySettings extends \Google\Protobuf\Internal\Message * @type int $challenge_security_preference * Optional. Settings for the frequency and difficulty at which this key * triggers captcha challenges. This should only be specified for - * IntegrationTypes CHECKBOX and INVISIBLE. + * IntegrationTypes CHECKBOX and INVISIBLE and SCORE_AND_CHALLENGE. * } */ public function __construct($data = NULL) { @@ -82,7 +82,7 @@ public function __construct($data = NULL) { } /** - * Optional. If set to true, it means allowed_domains will not be enforced. + * Optional. If set to true, it means allowed_domains are not enforced. * * Generated from protobuf field bool allow_all_domains = 3 [(.google.api.field_behavior) = OPTIONAL]; * @return bool @@ -93,7 +93,7 @@ public function getAllowAllDomains() } /** - * Optional. If set to true, it means allowed_domains will not be enforced. + * Optional. If set to true, it means allowed_domains are not enforced. * * Generated from protobuf field bool allow_all_domains = 3 [(.google.api.field_behavior) = OPTIONAL]; * @param bool $var @@ -196,7 +196,7 @@ public function setIntegrationType($var) /** * Optional. Settings for the frequency and difficulty at which this key * triggers captcha challenges. This should only be specified for - * IntegrationTypes CHECKBOX and INVISIBLE. + * IntegrationTypes CHECKBOX and INVISIBLE and SCORE_AND_CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.WebKeySettings.ChallengeSecurityPreference challenge_security_preference = 5 [(.google.api.field_behavior) = OPTIONAL]; * @return int @@ -209,7 +209,7 @@ public function getChallengeSecurityPreference() /** * Optional. Settings for the frequency and difficulty at which this key * triggers captcha challenges. This should only be specified for - * IntegrationTypes CHECKBOX and INVISIBLE. + * IntegrationTypes CHECKBOX and INVISIBLE and SCORE_AND_CHALLENGE. * * Generated from protobuf field .google.cloud.recaptchaenterprise.v1.WebKeySettings.ChallengeSecurityPreference challenge_security_preference = 5 [(.google.api.field_behavior) = OPTIONAL]; * @param int $var diff --git a/RecaptchaEnterprise/src/V1/gapic_metadata.json b/RecaptchaEnterprise/src/V1/gapic_metadata.json index 7a795f4739cf..43e4b3c3ad2c 100644 --- a/RecaptchaEnterprise/src/V1/gapic_metadata.json +++ b/RecaptchaEnterprise/src/V1/gapic_metadata.json @@ -65,6 +65,11 @@ "listFirewallPolicies" ] }, + "ListIpOverrides": { + "methods": [ + "listIpOverrides" + ] + }, "ListKeys": { "methods": [ "listKeys" @@ -85,6 +90,11 @@ "migrateKey" ] }, + "RemoveIpOverride": { + "methods": [ + "removeIpOverride" + ] + }, "ReorderFirewallPolicies": { "methods": [ "reorderFirewallPolicies" diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json index 1fbdfbaa419d..8de76c7b19f3 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_client_config.json @@ -81,6 +81,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "ListIpOverrides": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ListKeys": { "timeout_millis": 600000, "retry_codes_name": "no_retry_1_codes", @@ -101,6 +106,11 @@ "retry_codes_name": "no_retry_codes", "retry_params_name": "no_retry_params" }, + "RemoveIpOverride": { + "timeout_millis": 60000, + "retry_codes_name": "no_retry_codes", + "retry_params_name": "no_retry_params" + }, "ReorderFirewallPolicies": { "timeout_millis": 60000, "retry_codes_name": "no_retry_codes", diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php index 7161900dc029..676193e04bbf 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_descriptor_config.php @@ -163,6 +163,26 @@ ], ], ], + 'ListIpOverrides' => [ + 'pageStreaming' => [ + 'requestPageTokenGetMethod' => 'getPageToken', + 'requestPageTokenSetMethod' => 'setPageToken', + 'requestPageSizeGetMethod' => 'getPageSize', + 'requestPageSizeSetMethod' => 'setPageSize', + 'responsePageTokenGetMethod' => 'getNextPageToken', + 'resourcesGetMethod' => 'getIpOverrides', + ], + 'callType' => \Google\ApiCore\Call::PAGINATED_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesResponse', + 'headerParams' => [ + [ + 'keyName' => 'parent', + 'fieldAccessors' => [ + 'getParent', + ], + ], + ], + ], 'ListKeys' => [ 'pageStreaming' => [ 'requestPageTokenGetMethod' => 'getPageToken', @@ -235,6 +255,18 @@ ], ], ], + 'RemoveIpOverride' => [ + 'callType' => \Google\ApiCore\Call::UNARY_CALL, + 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse', + 'headerParams' => [ + [ + 'keyName' => 'name', + 'fieldAccessors' => [ + 'getName', + ], + ], + ], + ], 'ReorderFirewallPolicies' => [ 'callType' => \Google\ApiCore\Call::UNARY_CALL, 'responseType' => 'Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesResponse', diff --git a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php index cf28799784f0..43261e80848d 100644 --- a/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php +++ b/RecaptchaEnterprise/src/V1/resources/recaptcha_enterprise_service_rest_client_config.php @@ -149,6 +149,17 @@ ], ], ], + 'ListIpOverrides' => [ + 'method' => 'get', + 'uriTemplate' => '/v1/{parent=projects/*/keys/*}:listIpOverrides', + 'placeholders' => [ + 'parent' => [ + 'getters' => [ + 'getParent', + ], + ], + ], + ], 'ListKeys' => [ 'method' => 'get', 'uriTemplate' => '/v1/{parent=projects/*}/keys', @@ -194,6 +205,18 @@ ], ], ], + 'RemoveIpOverride' => [ + 'method' => 'post', + 'uriTemplate' => '/v1/{name=projects/*/keys/*}:removeIpOverride', + 'body' => '*', + 'placeholders' => [ + 'name' => [ + 'getters' => [ + 'getName', + ], + ], + ], + ], 'ReorderFirewallPolicies' => [ 'method' => 'post', 'uriTemplate' => '/v1/{parent=projects/*}/firewallpolicies:reorder', diff --git a/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php b/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php index 2f8c44b17e8c..65f3cd7edf5b 100644 --- a/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php +++ b/RecaptchaEnterprise/tests/Unit/V1/Client/RecaptchaEnterpriseServiceClientTest.php @@ -47,6 +47,8 @@ use Google\Cloud\RecaptchaEnterprise\V1\Key; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesRequest; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsRequest; @@ -57,6 +59,8 @@ use Google\Cloud\RecaptchaEnterprise\V1\MigrateKeyRequest; use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroup; use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroupMembership; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideRequest; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesRequest; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyRequest; @@ -857,6 +861,78 @@ public function listFirewallPoliciesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listIpOverridesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $ipOverridesElement = new IpOverrideData(); + $ipOverrides = [ + $ipOverridesElement, + ]; + $expectedResponse = new ListIpOverridesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setIpOverrides($ipOverrides); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $request = (new ListIpOverridesRequest()) + ->setParent($formattedParent); + $response = $gapicClient->listIpOverrides($request); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getIpOverrides()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListIpOverrides', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listIpOverridesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $request = (new ListIpOverridesRequest()) + ->setParent($formattedParent); + try { + $gapicClient->listIpOverrides($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listKeysTest() { @@ -1139,6 +1215,82 @@ public function migrateKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function removeIpOverrideTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new RemoveIpOverrideResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $ipOverrideData = new IpOverrideData(); + $ipOverrideDataIp = 'ipOverrideDataIp1421737572'; + $ipOverrideData->setIp($ipOverrideDataIp); + $ipOverrideDataOverrideType = OverrideType::OVERRIDE_TYPE_UNSPECIFIED; + $ipOverrideData->setOverrideType($ipOverrideDataOverrideType); + $request = (new RemoveIpOverrideRequest()) + ->setName($formattedName) + ->setIpOverrideData($ipOverrideData); + $response = $gapicClient->removeIpOverride($request); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RemoveIpOverride', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getIpOverrideData(); + $this->assertProtobufEquals($ipOverrideData, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function removeIpOverrideExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $ipOverrideData = new IpOverrideData(); + $ipOverrideDataIp = 'ipOverrideDataIp1421737572'; + $ipOverrideData->setIp($ipOverrideDataIp); + $ipOverrideDataOverrideType = OverrideType::OVERRIDE_TYPE_UNSPECIFIED; + $ipOverrideData->setOverrideType($ipOverrideDataOverrideType); + $request = (new RemoveIpOverrideRequest()) + ->setName($formattedName) + ->setIpOverrideData($ipOverrideData); + try { + $gapicClient->removeIpOverride($request); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function reorderFirewallPoliciesTest() { diff --git a/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php b/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php index 089b4d878935..262d365dac89 100644 --- a/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php +++ b/RecaptchaEnterprise/tests/Unit/V1/RecaptchaEnterpriseServiceClientTest.php @@ -35,6 +35,7 @@ use Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData\OverrideType; use Google\Cloud\RecaptchaEnterprise\V1\Key; use Google\Cloud\RecaptchaEnterprise\V1\ListFirewallPoliciesResponse; +use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListKeysResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupMembershipsResponse; use Google\Cloud\RecaptchaEnterprise\V1\ListRelatedAccountGroupsResponse; @@ -42,6 +43,7 @@ use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient; use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroup; use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroupMembership; +use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse; use Google\Cloud\RecaptchaEnterprise\V1\ReorderFirewallPoliciesResponse; use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse; use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsResponse; @@ -783,6 +785,74 @@ public function listFirewallPoliciesExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function listIpOverridesTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $nextPageToken = ''; + $ipOverridesElement = new IpOverrideData(); + $ipOverrides = [ + $ipOverridesElement, + ]; + $expectedResponse = new ListIpOverridesResponse(); + $expectedResponse->setNextPageToken($nextPageToken); + $expectedResponse->setIpOverrides($ipOverrides); + $transport->addResponse($expectedResponse); + // Mock request + $formattedParent = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $response = $gapicClient->listIpOverrides($formattedParent); + $this->assertEquals($expectedResponse, $response->getPage()->getResponseObject()); + $resources = iterator_to_array($response->iterateAllElements()); + $this->assertSame(1, count($resources)); + $this->assertEquals($expectedResponse->getIpOverrides()[0], $resources[0]); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/ListIpOverrides', $actualFuncCall); + $actualValue = $actualRequestObject->getParent(); + $this->assertProtobufEquals($formattedParent, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function listIpOverridesExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedParent = $gapicClient->keyName('[PROJECT]', '[KEY]'); + try { + $gapicClient->listIpOverrides($formattedParent); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function listKeysTest() { @@ -1049,6 +1119,76 @@ public function migrateKeyExceptionTest() $this->assertTrue($transport->isExhausted()); } + /** @test */ + public function removeIpOverrideTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + // Mock response + $expectedResponse = new RemoveIpOverrideResponse(); + $transport->addResponse($expectedResponse); + // Mock request + $formattedName = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $ipOverrideData = new IpOverrideData(); + $ipOverrideDataIp = 'ipOverrideDataIp1421737572'; + $ipOverrideData->setIp($ipOverrideDataIp); + $ipOverrideDataOverrideType = OverrideType::OVERRIDE_TYPE_UNSPECIFIED; + $ipOverrideData->setOverrideType($ipOverrideDataOverrideType); + $response = $gapicClient->removeIpOverride($formattedName, $ipOverrideData); + $this->assertEquals($expectedResponse, $response); + $actualRequests = $transport->popReceivedCalls(); + $this->assertSame(1, count($actualRequests)); + $actualFuncCall = $actualRequests[0]->getFuncCall(); + $actualRequestObject = $actualRequests[0]->getRequestObject(); + $this->assertSame('/google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService/RemoveIpOverride', $actualFuncCall); + $actualValue = $actualRequestObject->getName(); + $this->assertProtobufEquals($formattedName, $actualValue); + $actualValue = $actualRequestObject->getIpOverrideData(); + $this->assertProtobufEquals($ipOverrideData, $actualValue); + $this->assertTrue($transport->isExhausted()); + } + + /** @test */ + public function removeIpOverrideExceptionTest() + { + $transport = $this->createTransport(); + $gapicClient = $this->createClient([ + 'transport' => $transport, + ]); + $this->assertTrue($transport->isExhausted()); + $status = new stdClass(); + $status->code = Code::DATA_LOSS; + $status->details = 'internal error'; + $expectedExceptionMessage = json_encode([ + 'message' => 'internal error', + 'code' => Code::DATA_LOSS, + 'status' => 'DATA_LOSS', + 'details' => [], + ], JSON_PRETTY_PRINT); + $transport->addResponse(null, $status); + // Mock request + $formattedName = $gapicClient->keyName('[PROJECT]', '[KEY]'); + $ipOverrideData = new IpOverrideData(); + $ipOverrideDataIp = 'ipOverrideDataIp1421737572'; + $ipOverrideData->setIp($ipOverrideDataIp); + $ipOverrideDataOverrideType = OverrideType::OVERRIDE_TYPE_UNSPECIFIED; + $ipOverrideData->setOverrideType($ipOverrideDataOverrideType); + try { + $gapicClient->removeIpOverride($formattedName, $ipOverrideData); + // If the $gapicClient method call did not throw, fail the test + $this->fail('Expected an ApiException, but no exception was thrown.'); + } catch (ApiException $ex) { + $this->assertEquals($status->code, $ex->getCode()); + $this->assertEquals($expectedExceptionMessage, $ex->getMessage()); + } + // Call popReceivedCalls to ensure the stub is exhausted + $transport->popReceivedCalls(); + $this->assertTrue($transport->isExhausted()); + } + /** @test */ public function reorderFirewallPoliciesTest() {