<?php
/*
 * Copyright 2023 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
 * Generated by gapic-generator-php from the file
 * https://github.com/googleapis/googleapis/blob/master/google/cloud/recaptchaenterprise/v1/recaptchaenterprise.proto
 * Updates to the above are reflected here through a refresh process.
 */

namespace Google\Cloud\RecaptchaEnterprise\V1\Client;

use Google\ApiCore\ApiException;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\PagedListResponse;
use Google\ApiCore\ResourceHelperTrait;
use Google\ApiCore\RetrySettings;
use Google\ApiCore\Transport\TransportInterface;
use Google\ApiCore\ValidationException;
use Google\Auth\FetchAuthTokenInterface;
use Google\Cloud\RecaptchaEnterprise\V1\AddIpOverrideRequest;
use Google\Cloud\RecaptchaEnterprise\V1\AddIpOverrideResponse;
use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentRequest;
use Google\Cloud\RecaptchaEnterprise\V1\AnnotateAssessmentResponse;
use Google\Cloud\RecaptchaEnterprise\V1\Assessment;
use Google\Cloud\RecaptchaEnterprise\V1\CreateAssessmentRequest;
use Google\Cloud\RecaptchaEnterprise\V1\CreateFirewallPolicyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\CreateKeyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\DeleteFirewallPolicyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\DeleteKeyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\FirewallPolicy;
use Google\Cloud\RecaptchaEnterprise\V1\GetFirewallPolicyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\GetKeyRequest;
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;
use Google\Cloud\RecaptchaEnterprise\V1\RetrieveLegacySecretKeyResponse;
use Google\Cloud\RecaptchaEnterprise\V1\SearchRelatedAccountGroupMembershipsRequest;
use Google\Cloud\RecaptchaEnterprise\V1\UpdateFirewallPolicyRequest;
use Google\Cloud\RecaptchaEnterprise\V1\UpdateKeyRequest;
use GuzzleHttp\Promise\PromiseInterface;
use Psr\Log\LoggerInterface;

/**
 * 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.
 *
 * 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.
 *
 * @method PromiseInterface<AddIpOverrideResponse> addIpOverrideAsync(AddIpOverrideRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<AnnotateAssessmentResponse> annotateAssessmentAsync(AnnotateAssessmentRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Assessment> createAssessmentAsync(CreateAssessmentRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<FirewallPolicy> createFirewallPolicyAsync(CreateFirewallPolicyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Key> createKeyAsync(CreateKeyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<void> deleteFirewallPolicyAsync(DeleteFirewallPolicyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<void> deleteKeyAsync(DeleteKeyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<FirewallPolicy> getFirewallPolicyAsync(GetFirewallPolicyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Key> getKeyAsync(GetKeyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Metrics> getMetricsAsync(GetMetricsRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> listFirewallPoliciesAsync(ListFirewallPoliciesRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> listIpOverridesAsync(ListIpOverridesRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> listKeysAsync(ListKeysRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> listRelatedAccountGroupMembershipsAsync(ListRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> listRelatedAccountGroupsAsync(ListRelatedAccountGroupsRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Key> migrateKeyAsync(MigrateKeyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<RemoveIpOverrideResponse> removeIpOverrideAsync(RemoveIpOverrideRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<ReorderFirewallPoliciesResponse> reorderFirewallPoliciesAsync(ReorderFirewallPoliciesRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<RetrieveLegacySecretKeyResponse> retrieveLegacySecretKeyAsync(RetrieveLegacySecretKeyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<PagedListResponse> searchRelatedAccountGroupMembershipsAsync(SearchRelatedAccountGroupMembershipsRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<FirewallPolicy> updateFirewallPolicyAsync(UpdateFirewallPolicyRequest $request, array $optionalArgs = [])
 * @method PromiseInterface<Key> updateKeyAsync(UpdateKeyRequest $request, array $optionalArgs = [])
 */
final class RecaptchaEnterpriseServiceClient
{
    use GapicClientTrait;
    use ResourceHelperTrait;

    /** The name of the service. */
    private const SERVICE_NAME = 'google.cloud.recaptchaenterprise.v1.RecaptchaEnterpriseService';

    /**
     * The default address of the service.
     *
     * @deprecated SERVICE_ADDRESS_TEMPLATE should be used instead.
     */
    private const SERVICE_ADDRESS = 'recaptchaenterprise.googleapis.com';

    /** The address template of the service. */
    private const SERVICE_ADDRESS_TEMPLATE = 'recaptchaenterprise.UNIVERSE_DOMAIN';

    /** The default port of the service. */
    private const DEFAULT_SERVICE_PORT = 443;

    /** The name of the code generator, to be included in the agent header. */
    private const CODEGEN_NAME = 'gapic';

    /** The default scopes required by the service. */
    public static $serviceScopes = [
        'https://www.googleapis.com/auth/cloud-platform',
    ];

    private static function getClientDefaults()
    {
        return [
            'serviceName' => self::SERVICE_NAME,
            'apiEndpoint' => self::SERVICE_ADDRESS . ':' . self::DEFAULT_SERVICE_PORT,
            'clientConfig' => __DIR__ . '/../resources/recaptcha_enterprise_service_client_config.json',
            'descriptorsConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_descriptor_config.php',
            'gcpApiConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_grpc_config.json',
            'credentialsConfig' => [
                'defaultScopes' => self::$serviceScopes,
            ],
            'transportConfig' => [
                'rest' => [
                    'restClientConfigPath' => __DIR__ . '/../resources/recaptcha_enterprise_service_rest_client_config.php',
                ],
            ],
        ];
    }

    /**
     * Formats a string containing the fully-qualified path to represent a assessment
     * resource.
     *
     * @param string $project
     * @param string $assessment
     *
     * @return string The formatted assessment resource.
     */
    public static function assessmentName(string $project, string $assessment): string
    {
        return self::getPathTemplate('assessment')->render([
            'project' => $project,
            'assessment' => $assessment,
        ]);
    }

    /**
     * Formats a string containing the fully-qualified path to represent a
     * firewall_policy resource.
     *
     * @param string $project
     * @param string $firewallpolicy
     *
     * @return string The formatted firewall_policy resource.
     */
    public static function firewallPolicyName(string $project, string $firewallpolicy): string
    {
        return self::getPathTemplate('firewallPolicy')->render([
            'project' => $project,
            'firewallpolicy' => $firewallpolicy,
        ]);
    }

    /**
     * Formats a string containing the fully-qualified path to represent a key
     * resource.
     *
     * @param string $project
     * @param string $key
     *
     * @return string The formatted key resource.
     */
    public static function keyName(string $project, string $key): string
    {
        return self::getPathTemplate('key')->render([
            'project' => $project,
            'key' => $key,
        ]);
    }

    /**
     * Formats a string containing the fully-qualified path to represent a metrics
     * resource.
     *
     * @param string $project
     * @param string $key
     *
     * @return string The formatted metrics resource.
     */
    public static function metricsName(string $project, string $key): string
    {
        return self::getPathTemplate('metrics')->render([
            'project' => $project,
            'key' => $key,
        ]);
    }

    /**
     * Formats a string containing the fully-qualified path to represent a project
     * resource.
     *
     * @param string $project
     *
     * @return string The formatted project resource.
     */
    public static function projectName(string $project): string
    {
        return self::getPathTemplate('project')->render([
            'project' => $project,
        ]);
    }

    /**
     * Formats a string containing the fully-qualified path to represent a
     * related_account_group resource.
     *
     * @param string $project
     * @param string $relatedaccountgroup
     *
     * @return string The formatted related_account_group resource.
     */
    public static function relatedAccountGroupName(string $project, string $relatedaccountgroup): string
    {
        return self::getPathTemplate('relatedAccountGroup')->render([
            'project' => $project,
            'relatedaccountgroup' => $relatedaccountgroup,
        ]);
    }

    /**
     * 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.
     *
     * @param string  $formattedName The formatted name string
     * @param ?string $template      Optional name of template to match
     *
     * @return array An associative array from name component IDs to component values.
     *
     * @throws ValidationException If $formattedName could not be matched.
     */
    public static function parseName(string $formattedName, ?string $template = null): array
    {
        return self::parseFormattedName($formattedName, $template);
    }

    /**
     * Constructor.
     *
     * @param array $options {
     *     Optional. Options for configuring the service API wrapper.
     *
     *     @type string $apiEndpoint
     *           The address of the API remote host. May optionally include the port, formatted
     *           as "<uri>:<port>". Default 'recaptchaenterprise.googleapis.com:443'.
     *     @type string|array|FetchAuthTokenInterface|CredentialsWrapper $credentials
     *           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
     *           {@see \Google\Auth\FetchAuthTokenInterface} object or
     *           {@see \Google\ApiCore\CredentialsWrapper} object. Note that when one of these
     *           objects are provided, any settings in $credentialsConfig will be ignored.
     *     @type array $credentialsConfig
     *           Options used to configure credentials, including auth token caching, for the
     *           client. For a full list of supporting configuration options, see
     *           {@see \Google\ApiCore\CredentialsWrapper::build()} .
     *     @type bool $disableRetries
     *           Determines whether or not retries defined by the client configuration should be
     *           disabled. Defaults to `false`.
     *     @type string|array $clientConfig
     *           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.
     *     @type string|TransportInterface $transport
     *           The transport used for executing network requests. May be either the string
     *           `rest` or `grpc`. Defaults to `grpc` if gRPC support is detected on the system.
     *           *Advanced usage*: Additionally, it is possible to pass in an already
     *           instantiated {@see \Google\ApiCore\Transport\TransportInterface} object. Note
     *           that when this object is provided, any settings in $transportConfig, and any
     *           $apiEndpoint setting, will be ignored.
     *     @type array $transportConfig
     *           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 {@see \Google\ApiCore\Transport\GrpcTransport::build()} and
     *           {@see \Google\ApiCore\Transport\RestTransport::build()} methods for the
     *           supported options.
     *     @type callable $clientCertSource
     *           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.
     *     @type false|LoggerInterface $logger
     *           A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the
     *           'GOOGLE_SDK_PHP_LOGGING' environment flag
     * }
     *
     * @throws ValidationException
     */
    public function __construct(array $options = [])
    {
        $clientOptions = $this->buildClientOptions($options);
        $this->setClientOptions($clientOptions);
    }

    /** Handles execution of the async variants for each documented method. */
    public function __call($method, $args)
    {
        if (substr($method, -5) !== 'Async') {
            trigger_error('Call to undefined method ' . __CLASS__ . "::$method()", E_USER_ERROR);
        }

        array_unshift($args, substr($method, 0, -5));
        return call_user_func_array([$this, 'startAsyncCall'], $args);
    }

    /**
     * Adds an IP override to a key. The following restrictions hold:
     * * The maximum number of IP overrides per key is 100.
     * * For any conflict (such as IP already exists or IP part of an existing
     * IP range), an error is returned.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::addIpOverrideAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/add_ip_override.php
     *
     * @param AddIpOverrideRequest $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 AddIpOverrideResponse
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function addIpOverride(AddIpOverrideRequest $request, array $callOptions = []): AddIpOverrideResponse
    {
        return $this->startApiCall('AddIpOverride', $request, $callOptions)->wait();
    }

    /**
     * Annotates a previously created Assessment to provide additional information
     * on whether the event turned out to be authentic or fraudulent.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::annotateAssessmentAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/annotate_assessment.php
     *
     * @param AnnotateAssessmentRequest $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 AnnotateAssessmentResponse
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function annotateAssessment(AnnotateAssessmentRequest $request, array $callOptions = []): AnnotateAssessmentResponse
    {
        return $this->startApiCall('AnnotateAssessment', $request, $callOptions)->wait();
    }

    /**
     * Creates an Assessment of the likelihood an event is legitimate.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::createAssessmentAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/create_assessment.php
     *
     * @param CreateAssessmentRequest $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 Assessment
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function createAssessment(CreateAssessmentRequest $request, array $callOptions = []): Assessment
    {
        return $this->startApiCall('CreateAssessment', $request, $callOptions)->wait();
    }

    /**
     * Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA
     * Enterprise actions can be executed.
     * A project may have a maximum of 1000 policies.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::createFirewallPolicyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/create_firewall_policy.php
     *
     * @param CreateFirewallPolicyRequest $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 FirewallPolicy
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function createFirewallPolicy(CreateFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy
    {
        return $this->startApiCall('CreateFirewallPolicy', $request, $callOptions)->wait();
    }

    /**
     * Creates a new reCAPTCHA Enterprise key.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::createKeyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/create_key.php
     *
     * @param CreateKeyRequest $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 Key
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function createKey(CreateKeyRequest $request, array $callOptions = []): Key
    {
        return $this->startApiCall('CreateKey', $request, $callOptions)->wait();
    }

    /**
     * Deletes the specified firewall policy.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::deleteFirewallPolicyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/delete_firewall_policy.php
     *
     * @param DeleteFirewallPolicyRequest $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.
     * }
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function deleteFirewallPolicy(DeleteFirewallPolicyRequest $request, array $callOptions = []): void
    {
        $this->startApiCall('DeleteFirewallPolicy', $request, $callOptions)->wait();
    }

    /**
     * Deletes the specified key.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::deleteKeyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/delete_key.php
     *
     * @param DeleteKeyRequest $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.
     * }
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function deleteKey(DeleteKeyRequest $request, array $callOptions = []): void
    {
        $this->startApiCall('DeleteKey', $request, $callOptions)->wait();
    }

    /**
     * Returns the specified firewall policy.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::getFirewallPolicyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/get_firewall_policy.php
     *
     * @param GetFirewallPolicyRequest $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 FirewallPolicy
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function getFirewallPolicy(GetFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy
    {
        return $this->startApiCall('GetFirewallPolicy', $request, $callOptions)->wait();
    }

    /**
     * Returns the specified key.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::getKeyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/get_key.php
     *
     * @param GetKeyRequest $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 Key
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function getKey(GetKeyRequest $request, array $callOptions = []): Key
    {
        return $this->startApiCall('GetKey', $request, $callOptions)->wait();
    }

    /**
     * Get some aggregated metrics for a Key. This data can be used to build
     * dashboards.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::getMetricsAsync()}
     * .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/get_metrics.php
     *
     * @param GetMetricsRequest $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 Metrics
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function getMetrics(GetMetricsRequest $request, array $callOptions = []): Metrics
    {
        return $this->startApiCall('GetMetrics', $request, $callOptions)->wait();
    }

    /**
     * Returns the list of all firewall policies that belong to a project.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::listFirewallPoliciesAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/list_firewall_policies.php
     *
     * @param ListFirewallPoliciesRequest $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 listFirewallPolicies(ListFirewallPoliciesRequest $request, array $callOptions = []): PagedListResponse
    {
        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.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::listKeysAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/list_keys.php
     *
     * @param ListKeysRequest $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 listKeys(ListKeysRequest $request, array $callOptions = []): PagedListResponse
    {
        return $this->startApiCall('ListKeys', $request, $callOptions);
    }

    /**
     * Get memberships in a group of related accounts.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::listRelatedAccountGroupMembershipsAsync()}
     * .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_group_memberships.php
     *
     * @param ListRelatedAccountGroupMembershipsRequest $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 listRelatedAccountGroupMemberships(ListRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse
    {
        return $this->startApiCall('ListRelatedAccountGroupMemberships', $request, $callOptions);
    }

    /**
     * List groups of related accounts.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::listRelatedAccountGroupsAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/list_related_account_groups.php
     *
     * @param ListRelatedAccountGroupsRequest $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 listRelatedAccountGroups(ListRelatedAccountGroupsRequest $request, array $callOptions = []): PagedListResponse
    {
        return $this->startApiCall('ListRelatedAccountGroups', $request, $callOptions);
    }

    /**
     * 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.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::migrateKeyAsync()}
     * .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/migrate_key.php
     *
     * @param MigrateKeyRequest $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 Key
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function migrateKey(MigrateKeyRequest $request, array $callOptions = []): Key
    {
        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.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::reorderFirewallPoliciesAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/reorder_firewall_policies.php
     *
     * @param ReorderFirewallPoliciesRequest $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 ReorderFirewallPoliciesResponse
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function reorderFirewallPolicies(ReorderFirewallPoliciesRequest $request, array $callOptions = []): ReorderFirewallPoliciesResponse
    {
        return $this->startApiCall('ReorderFirewallPolicies', $request, $callOptions)->wait();
    }

    /**
     * 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.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::retrieveLegacySecretKeyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/retrieve_legacy_secret_key.php
     *
     * @param RetrieveLegacySecretKeyRequest $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 RetrieveLegacySecretKeyResponse
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function retrieveLegacySecretKey(RetrieveLegacySecretKeyRequest $request, array $callOptions = []): RetrieveLegacySecretKeyResponse
    {
        return $this->startApiCall('RetrieveLegacySecretKey', $request, $callOptions)->wait();
    }

    /**
     * Search group memberships related to a given account.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::searchRelatedAccountGroupMembershipsAsync()}
     * .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/search_related_account_group_memberships.php
     *
     * @param SearchRelatedAccountGroupMembershipsRequest $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 searchRelatedAccountGroupMemberships(SearchRelatedAccountGroupMembershipsRequest $request, array $callOptions = []): PagedListResponse
    {
        return $this->startApiCall('SearchRelatedAccountGroupMemberships', $request, $callOptions);
    }

    /**
     * Updates the specified firewall policy.
     *
     * The async variant is
     * {@see RecaptchaEnterpriseServiceClient::updateFirewallPolicyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/update_firewall_policy.php
     *
     * @param UpdateFirewallPolicyRequest $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 FirewallPolicy
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function updateFirewallPolicy(UpdateFirewallPolicyRequest $request, array $callOptions = []): FirewallPolicy
    {
        return $this->startApiCall('UpdateFirewallPolicy', $request, $callOptions)->wait();
    }

    /**
     * Updates the specified key.
     *
     * The async variant is {@see RecaptchaEnterpriseServiceClient::updateKeyAsync()} .
     *
     * @example samples/V1/RecaptchaEnterpriseServiceClient/update_key.php
     *
     * @param UpdateKeyRequest $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 Key
     *
     * @throws ApiException Thrown if the API call fails.
     */
    public function updateKey(UpdateKeyRequest $request, array $callOptions = []): Key
    {
        return $this->startApiCall('UpdateKey', $request, $callOptions)->wait();
    }
}
