-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for ListIpOverrides and RemoveIpOverride (#7777)
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
1 parent
9e21daa
commit 4d95d21
Showing
30 changed files
with
1,286 additions
and
96 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/list_ip_overrides.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
RecaptchaEnterprise/samples/V1/RecaptchaEnterpriseServiceClient/remove_ip_override.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.