Reference documentation and code samples for the Google Cloud Recaptcha Enterprise V1 Client class RecaptchaEnterpriseServiceClient.
Service Description: Service to determine the likelihood an event is legitimate.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
try {
$formattedName = $recaptchaEnterpriseServiceClient->assessmentName('[PROJECT]', '[ASSESSMENT]');
$annotation = Annotation::ANNOTATION_UNSPECIFIED;
$response = $recaptchaEnterpriseServiceClient->annotateAssessment($formattedName, $annotation);
} finally {
$recaptchaEnterpriseServiceClient->close();
}
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
This service has a new (beta) implementation. See Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient to use the new surface.
Namespace
Google \ Cloud \ RecaptchaEnterprise \ V1Methods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. May be either the string |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
annotateAssessment
Annotates a previously created Assessment to provide additional information on whether the event turned out to be authentic or fraudulent.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The resource name of the Assessment, in the format
|
annotation |
int
Optional. The annotation that will be assigned to the Event. This field can be left empty to provide reasons that apply to an event without concluding whether the event is legitimate or fraudulent. For allowed values, use constants defined on Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation |
optionalArgs |
array
Optional. |
↳ reasons |
int[]
Optional. Reasons for the annotation that are assigned to the event. For allowed values, use constants defined on Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Reason |
↳ accountId |
string
Optional. A stable account identifier to apply to the assessment. This is an alternative to setting |
↳ hashedAccountId |
string
Optional. A stable hashed account identifier to apply to the assessment. This is an alternative to setting |
↳ transactionEvent |
TransactionEvent
Optional. If the assessment is part of a payment transaction, provide details on payment lifecycle events that occur in the transaction. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest\Annotation;
use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @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 will be assigned to the Event. This field can
* be left empty to provide reasons that apply to an event without concluding
* whether the event is legitimate or fraudulent.
*/
function annotate_assessment_sample(string $formattedName, int $annotation): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var AnnotateAssessmentResponse $response */
$response = $recaptchaEnterpriseServiceClient->annotateAssessment($formattedName, $annotation);
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::assessmentName('[PROJECT]', '[ASSESSMENT]');
$annotation = Annotation::ANNOTATION_UNSPECIFIED;
annotate_assessment_sample($formattedName, $annotation);
}
createAssessment
Creates an Assessment of the likelihood an event is legitimate.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project in which the assessment will be created,
in the format |
assessment |
Google\Cloud\RecaptchaEnterprise\V1\Assessment
Required. The assessment details. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Assessment |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Assessment;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedParent The name of the project in which the assessment will be created,
* in the format `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
function create_assessment_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Prepare any non-scalar elements to be passed along with the request.
$assessment = new Assessment();
// Call the API and handle any network failures.
try {
/** @var Assessment $response */
$response = $recaptchaEnterpriseServiceClient->createAssessment($formattedParent, $assessment);
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
{
$formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]');
create_assessment_sample($formattedParent);
}
createFirewallPolicy
Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed.
A project may have a maximum of 1000 policies.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project this policy will apply to, in the format
|
firewallPolicy |
Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy
Required. Information to create the policy. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedParent The name of the project this policy will apply to, in the format
* `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
function create_firewall_policy_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Prepare any non-scalar elements to be passed along with the request.
$firewallPolicy = new FirewallPolicy();
// Call the API and handle any network failures.
try {
/** @var FirewallPolicy $response */
$response = $recaptchaEnterpriseServiceClient->createFirewallPolicy(
$formattedParent,
$firewallPolicy
);
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
{
$formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]');
create_firewall_policy_sample($formattedParent);
}
createKey
Creates a new reCAPTCHA Enterprise key.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project in which the key will be created, in the
format |
key |
Google\Cloud\RecaptchaEnterprise\V1\Key
Required. Information to create a reCAPTCHA Enterprise key. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Key |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedParent The name of the project in which the key will be created, in the
* format `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
* @param string $keyDisplayName Human-readable display name of this key. Modifiable by user.
*/
function create_key_sample(string $formattedParent, string $keyDisplayName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Prepare any non-scalar elements to be passed along with the request.
$key = (new Key())
->setDisplayName($keyDisplayName);
// Call the API and handle any network failures.
try {
/** @var Key $response */
$response = $recaptchaEnterpriseServiceClient->createKey($formattedParent, $key);
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
{
$formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]');
$keyDisplayName = '[DISPLAY_NAME]';
create_key_sample($formattedParent, $keyDisplayName);
}
deleteFirewallPolicy
Deletes the specified firewall policy.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the policy to be deleted, in the format
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the policy to be deleted, in the format
* `projects/{project}/firewallpolicies/{firewallpolicy}`. Please see
* {@see RecaptchaEnterpriseServiceClient::firewallPolicyName()} for help formatting this field.
*/
function delete_firewall_policy_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
$recaptchaEnterpriseServiceClient->deleteFirewallPolicy($formattedName);
printf('Call completed successfully.' . PHP_EOL);
} 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::firewallPolicyName(
'[PROJECT]',
'[FIREWALLPOLICY]'
);
delete_firewall_policy_sample($formattedName);
}
deleteKey
Deletes the specified key.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the key to be deleted, in the format
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the key to be deleted, in the format
* `projects/{project}/keys/{key}`. Please see
* {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field.
*/
function delete_key_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
$recaptchaEnterpriseServiceClient->deleteKey($formattedName);
printf('Call completed successfully.' . PHP_EOL);
} 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]');
delete_key_sample($formattedName);
}
getFirewallPolicy
Returns the specified firewall policy.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the requested policy, in the format
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the requested policy, in the format
* `projects/{project}/firewallpolicies/{firewallpolicy}`. Please see
* {@see RecaptchaEnterpriseServiceClient::firewallPolicyName()} for help formatting this field.
*/
function get_firewall_policy_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var FirewallPolicy $response */
$response = $recaptchaEnterpriseServiceClient->getFirewallPolicy($formattedName);
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::firewallPolicyName(
'[PROJECT]',
'[FIREWALLPOLICY]'
);
get_firewall_policy_sample($formattedName);
}
getKey
Returns the specified key.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the requested key, in the format
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Key |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the requested key, in the format
* `projects/{project}/keys/{key}`. Please see
* {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field.
*/
function get_key_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var Key $response */
$response = $recaptchaEnterpriseServiceClient->getKey($formattedName);
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]');
get_key_sample($formattedName);
}
getMetrics
Get some aggregated metrics for a Key. This data can be used to build dashboards.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the requested metrics, in the format
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Metrics |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Metrics;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the requested metrics, in the format
* `projects/{project}/keys/{key}/metrics`. Please see
* {@see RecaptchaEnterpriseServiceClient::metricsName()} for help formatting this field.
*/
function get_metrics_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var Metrics $response */
$response = $recaptchaEnterpriseServiceClient->getMetrics($formattedName);
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::metricsName('[PROJECT]', '[KEY]');
get_metrics_sample($formattedName);
}
listFirewallPolicies
Returns the list of all firewall policies that belong to a project.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project to list the policies for, in the format
|
optionalArgs |
array
Optional. |
↳ pageSize |
int
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. |
↳ pageToken |
string
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. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedParent The name of the project to list the policies for, in the format
* `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
function list_firewall_policies_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->listFirewallPolicies($formattedParent);
/** @var FirewallPolicy $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::projectName('[PROJECT]');
list_firewall_policies_sample($formattedParent);
}
listKeys
Returns the list of all keys that belong to a project.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project that contains the keys that will be
listed, in the format |
optionalArgs |
array
Optional. |
↳ pageSize |
int
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. |
↳ pageToken |
string
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. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedParent The name of the project that contains the keys that will be
* listed, in the format `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
function list_keys_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->listKeys($formattedParent);
/** @var Key $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::projectName('[PROJECT]');
list_keys_sample($formattedParent);
}
listRelatedAccountGroupMemberships
Get memberships in a group of related accounts.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The resource name for the related account group in the format
|
optionalArgs |
array
Optional. |
↳ pageSize |
int
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. |
↳ pageToken |
string
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. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroupMembership;
/**
* @param string $formattedParent The resource name for the related account group in the format
* `projects/{project}/relatedaccountgroups/{relatedaccountgroup}`. Please see
* {@see RecaptchaEnterpriseServiceClient::relatedAccountGroupName()} for help formatting this field.
*/
function list_related_account_group_memberships_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->listRelatedAccountGroupMemberships($formattedParent);
/** @var RelatedAccountGroupMembership $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::relatedAccountGroupName(
'[PROJECT]',
'[RELATEDACCOUNTGROUP]'
);
list_related_account_group_memberships_sample($formattedParent);
}
listRelatedAccountGroups
List groups of related accounts.
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project to list related account groups from, in
the format |
optionalArgs |
array
Optional. |
↳ pageSize |
int
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. |
↳ pageToken |
string
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. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroup;
/**
* @param string $formattedParent The name of the project to list related account groups from, in
* the format `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::projectName()} for help formatting this field.
*/
function list_related_account_groups_sample(string $formattedParent): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->listRelatedAccountGroups($formattedParent);
/** @var RelatedAccountGroup $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::projectName('[PROJECT]');
list_related_account_groups_sample($formattedParent);
}
migrateKey
Migrates an existing key from reCAPTCHA to reCAPTCHA Enterprise.
Once a key is migrated, it can be used from either product. SiteVerify requests are billed as CreateAssessment calls. You must be authenticated as one of the current owners of the reCAPTCHA Key, and your user must have the reCAPTCHA Enterprise Admin IAM role in the destination project.
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the key to be migrated, in the format
|
optionalArgs |
array
Optional. |
↳ skipBillingCheck |
bool
Optional. If true, skips the billing check. A reCAPTCHA Enterprise key or migrated key behaves differently than a reCAPTCHA (non-Enterprise version) key when you reach a quota limit (see https://cloud.google.com/recaptcha-enterprise/quotas#quota_limit). To avoid any disruption of your usage, we check that a billing account is present. If your usage of reCAPTCHA is under the free quota, you can safely skip the billing check and proceed with the migration. See https://cloud.google.com/recaptcha-enterprise/docs/billing-information. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Key |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $formattedName The name of the key to be migrated, in the format
* `projects/{project}/keys/{key}`. Please see
* {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field.
*/
function migrate_key_sample(string $formattedName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var Key $response */
$response = $recaptchaEnterpriseServiceClient->migrateKey($formattedName);
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]');
migrate_key_sample($formattedName);
}
retrieveLegacySecretKey
Returns the secret key related to the specified public key.
You must use the legacy secret key only in a 3rd party integration with legacy reCAPTCHA.
Parameters | |
---|---|
Name | Description |
key |
string
Required. The public key name linked to the requested secret key in the
format |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse;
/**
* @param string $formattedKey The public key name linked to the requested secret key in the
* format `projects/{project}/keys/{key}`. Please see
* {@see RecaptchaEnterpriseServiceClient::keyName()} for help formatting this field.
*/
function retrieve_legacy_secret_key_sample(string $formattedKey): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var RetrieveLegacySecretKeyResponse $response */
$response = $recaptchaEnterpriseServiceClient->retrieveLegacySecretKey($formattedKey);
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
{
$formattedKey = RecaptchaEnterpriseServiceClient::keyName('[PROJECT]', '[KEY]');
retrieve_legacy_secret_key_sample($formattedKey);
}
searchRelatedAccountGroupMemberships
Search group memberships related to a given account.
Parameters | |
---|---|
Name | Description |
project |
string
Required. The name of the project to search related account group
memberships from. Specify the project name in the following format:
|
optionalArgs |
array
Optional. |
↳ hashedAccountId |
string
Optional. The unique stable hashed user identifier used to search connections. The identifier should correspond to a |
↳ pageSize |
int
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. |
↳ pageToken |
string
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. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\RelatedAccountGroupMembership;
/**
* @param string $formattedProject The name of the project to search related account group
* memberships from. Specify the project name in the following format:
* `projects/{project}`. Please see
* {@see RecaptchaEnterpriseServiceClient::relatedAccountGroupName()} for help formatting this field.
*/
function search_related_account_group_memberships_sample(string $formattedProject): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->searchRelatedAccountGroupMemberships(
$formattedProject
);
/** @var RelatedAccountGroupMembership $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
{
$formattedProject = RecaptchaEnterpriseServiceClient::relatedAccountGroupName(
'[PROJECT]',
'[RELATEDACCOUNTGROUP]'
);
search_related_account_group_memberships_sample($formattedProject);
}
updateFirewallPolicy
Updates the specified firewall policy.
Parameters | |
---|---|
Name | Description |
firewallPolicy |
Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy
Required. The policy to update. |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
Optional. The mask to control which fields of the policy get updated. If the mask is not present, all fields will be updated. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* 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 update_firewall_policy_sample(): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Prepare any non-scalar elements to be passed along with the request.
$firewallPolicy = new FirewallPolicy();
// Call the API and handle any network failures.
try {
/** @var FirewallPolicy $response */
$response = $recaptchaEnterpriseServiceClient->updateFirewallPolicy($firewallPolicy);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
updateKey
Updates the specified key.
Parameters | |
---|---|
Name | Description |
key |
Google\Cloud\RecaptchaEnterprise\V1\Key
Required. The key to update. |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
Optional. The mask to control which fields of the key get updated. If the mask is not present, all fields will be updated. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\RecaptchaEnterprise\V1\Key |
use Google\ApiCore\ApiException;
use Google\Cloud\RecaptchaEnterprise\V1\Key;
use Google\Cloud\RecaptchaEnterprise\V1\RecaptchaEnterpriseServiceClient;
/**
* @param string $keyDisplayName Human-readable display name of this key. Modifiable by user.
*/
function update_key_sample(string $keyDisplayName): void
{
// Create a client.
$recaptchaEnterpriseServiceClient = new RecaptchaEnterpriseServiceClient();
// Prepare any non-scalar elements to be passed along with the request.
$key = (new Key())
->setDisplayName($keyDisplayName);
// Call the API and handle any network failures.
try {
/** @var Key $response */
$response = $recaptchaEnterpriseServiceClient->updateKey($key);
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
{
$keyDisplayName = '[DISPLAY_NAME]';
update_key_sample($keyDisplayName);
}
static::assessmentName
Formats a string containing the fully-qualified path to represent a assessment resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
assessment |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted assessment resource. |
static::firewallPolicyName
Formats a string containing the fully-qualified path to represent a firewall_policy resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
firewallpolicy |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted firewall_policy resource. |
static::keyName
Formats a string containing the fully-qualified path to represent a key resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
key |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted key resource. |
static::metricsName
Formats a string containing the fully-qualified path to represent a metrics resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
key |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted metrics resource. |
static::projectName
Formats a string containing the fully-qualified path to represent a project resource.
Parameter | |
---|---|
Name | Description |
project |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project resource. |
static::relatedAccountGroupName
Formats a string containing the fully-qualified path to represent a related_account_group resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
relatedaccountgroup |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted related_account_group resource. |
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- assessment: projects/{project}/assessments/{assessment}
- firewallPolicy: projects/{project}/firewallpolicies/{firewallpolicy}
- key: projects/{project}/keys/{key}
- metrics: projects/{project}/keys/{key}/metrics
- project: projects/{project}
- relatedAccountGroup: projects/{project}/relatedaccountgroups/{relatedaccountgroup}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array | An associative array from name component IDs to component values. |
Constants
SERVICE_NAME
Value: 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService'
The name of the service.
SERVICE_ADDRESS
Value: 'recaptchaenterprise.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.