Skip to content

Commit

Permalink
feat: support for ListIpOverrides and RemoveIpOverride (#7777)
Browse files Browse the repository at this point in the history
feat: enable Akamai web application firewall
docs: minor updates to reference documentation
PiperOrigin-RevId: 691017365
Source-Link: googleapis/googleapis@f28656a
Source-Link: googleapis/googleapis-gen@537296f
Copy-Tag: eyJwIjoiUmVjYXB0Y2hhRW50ZXJwcmlzZS8uT3dsQm90LnlhbWwiLCJoIjoiNTM3Mjk2ZjVjM2Y3ODE5MzdhYzZkZmVmYzEzOGE1YTZmN2FlYzJkYyJ9
  • Loading branch information
gcf-owl-bot[bot] authored Oct 31, 2024
1 parent 9e21daa commit 4d95d21
Show file tree
Hide file tree
Showing 30 changed files with 1,286 additions and 96 deletions.
Binary file modified RecaptchaEnterprise/metadata/V1/Recaptchaenterprise.php
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* @param string $formattedName 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.
*/
function annotate_assessment_sample(string $formattedName, int $annotation): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Enterprise actions can be executed.
* A project may have a maximum of 1000 policies.
*
* @param string $formattedParent The name of the project this policy will apply to, in the format
* @param string $formattedParent The name of the project this policy applies to, in the format
* `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_ListIpOverrides_sync]
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData;
use Google\Cloud\RecaptchaEnterprise\V1\ListIpOverridesRequest;

/**
* Lists all IP overrides for a key.
*
* @param string $formattedParent 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.
*/
function list_ip_overrides_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();

// Prepare the request message.
$request = (new ListIpOverridesRequest())
->setParent($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]
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* GENERATED CODE WARNING
* This file was automatically generated - do not edit!
*/

require_once __DIR__ . '/../../../vendor/autoload.php';

// [START recaptchaenterprise_v1_generated_RecaptchaEnterpriseService_RemoveIpOverride_sync]
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData;
use Google\Cloud\RecaptchaEnterprise\V1\IpOverrideData\OverrideType;
use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideRequest;
use Google\Cloud\RecaptchaEnterprise\V1\RemoveIpOverrideResponse;

/**
* 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.
*
* @param string $formattedName 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 string $ipOverrideDataIp The IP address to override (can be IPv4, IPv6 or CIDR).
* The IP override must be a valid IPv4 or IPv6 address, or a CIDR range.
* The IP override must be a public IP address.
* Example of IPv4: 168.192.5.6
* Example of IPv6: 2001:0000:130F:0000:0000:09C0:876A:130B
* Example of IPv4 with CIDR: 168.192.5.0/24
* Example of IPv6 with CIDR: 2001:0DB8:1234::/48
* @param int $ipOverrideDataOverrideType Describes the type of IP override.
*/
function remove_ip_override_sample(
string $formattedName,
string $ipOverrideDataIp,
int $ipOverrideDataOverrideType
): void {
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();

// Prepare the request message.
$ipOverrideData = (new IpOverrideData())
->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]
20 changes: 10 additions & 10 deletions RecaptchaEnterprise/src/V1/AnnotateAssessmentRequest.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [])
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
Loading

0 comments on commit 4d95d21

Please sign in to comment.