<?php
/*
 * Copyright 2019 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 generated from the file
 * https://github.com/google/googleapis/blob/master/google/cloud/talent/v4beta1/job_service.proto
 * and updates to that file get reflected here through a refresh process.
 *
 * @experimental
 */

namespace Google\Cloud\Talent\V4beta1\Gapic;

use Google\ApiCore\ApiException;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\GapicClientTrait;
use Google\ApiCore\PathTemplate;
use Google\ApiCore\RetrySettings;
use Google\ApiCore\Transport\TransportInterface;
use Google\ApiCore\ValidationException;
use Google\Auth\FetchAuthTokenInterface;
use Google\Cloud\Talent\V4beta1\BatchDeleteJobsRequest;
use Google\Cloud\Talent\V4beta1\CreateJobRequest;
use Google\Cloud\Talent\V4beta1\DeleteJobRequest;
use Google\Cloud\Talent\V4beta1\GetJobRequest;
use Google\Cloud\Talent\V4beta1\HistogramQuery;
use Google\Cloud\Talent\V4beta1\Job;
use Google\Cloud\Talent\V4beta1\JobQuery;
use Google\Cloud\Talent\V4beta1\JobView;
use Google\Cloud\Talent\V4beta1\ListJobsRequest;
use Google\Cloud\Talent\V4beta1\ListJobsResponse;
use Google\Cloud\Talent\V4beta1\RequestMetadata;
use Google\Cloud\Talent\V4beta1\SearchJobsRequest;
use Google\Cloud\Talent\V4beta1\SearchJobsRequest_CustomRankingInfo;
use Google\Cloud\Talent\V4beta1\SearchJobsResponse;
use Google\Cloud\Talent\V4beta1\UpdateJobRequest;
use Google\Protobuf\FieldMask;
use Google\Protobuf\GPBEmpty;

/**
 * Service Description: A service handles job management, including job CRUD, enumeration and search.
 *
 * 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:
 *
 * ```
 * $jobServiceClient = new JobServiceClient();
 * try {
 *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
 *     $job = new Job();
 *     $response = $jobServiceClient->createJob($formattedParent, $job);
 * } finally {
 *     $jobServiceClient->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.
 *
 * @experimental
 */
class JobServiceGapicClient
{
    use GapicClientTrait;

    /**
     * The name of the service.
     */
    const SERVICE_NAME = 'google.cloud.talent.v4beta1.JobService';

    /**
     * The default address of the service.
     */
    const SERVICE_ADDRESS = 'jobs.googleapis.com';

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

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

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

    private static function getClientDefaults()
    {
        return [
            'serviceName' => self::SERVICE_NAME,
            'serviceAddress' => self::SERVICE_ADDRESS.':'.self::DEFAULT_SERVICE_PORT,
            'clientConfig' => __DIR__.'/../resources/job_service_client_config.json',
            'descriptorsConfigPath' => __DIR__.'/../resources/job_service_descriptor_config.php',
            'gcpApiConfigPath' => __DIR__.'/../resources/job_service_grpc_config.json',
            'credentialsConfig' => [
                'scopes' => self::$serviceScopes,
            ],
            'transportConfig' => [
                'rest' => [
                    'restClientConfigPath' => __DIR__.'/../resources/job_service_rest_client_config.php',
                ],
            ],
        ];
    }

    private static function getProjectNameTemplate()
    {
        if (null == self::$projectNameTemplate) {
            self::$projectNameTemplate = new PathTemplate('projects/{project}');
        }

        return self::$projectNameTemplate;
    }

    private static function getJobNameTemplate()
    {
        if (null == self::$jobNameTemplate) {
            self::$jobNameTemplate = new PathTemplate('projects/{project}/jobs/{job}');
        }

        return self::$jobNameTemplate;
    }

    private static function getPathTemplateMap()
    {
        if (null == self::$pathTemplateMap) {
            self::$pathTemplateMap = [
                'project' => self::getProjectNameTemplate(),
                'job' => self::getJobNameTemplate(),
            ];
        }

        return self::$pathTemplateMap;
    }

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

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

    /**
     * Parses a formatted name string and returns an associative array of the components in the name.
     * The following name formats are supported:
     * Template: Pattern
     * - project: projects/{project}
     * - job: projects/{project}/jobs/{job}.
     *
     * 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.
     * @experimental
     */
    public static function parseName($formattedName, $template = null)
    {
        $templateMap = self::getPathTemplateMap();

        if ($template) {
            if (!isset($templateMap[$template])) {
                throw new ValidationException("Template name $template does not exist");
            }

            return $templateMap[$template]->match($formattedName);
        }

        foreach ($templateMap as $templateName => $pathTemplate) {
            try {
                return $pathTemplate->match($formattedName);
            } catch (ValidationException $ex) {
                // Swallow the exception to continue trying other path templates
            }
        }
        throw new ValidationException("Input did not match any known format. Input: $formattedName");
    }

    /**
     * Constructor.
     *
     * @param array $options {
     *                       Optional. Options for configuring the service API wrapper.
     *
     *     @type string $serviceAddress
     *           The address of the API remote host. May optionally include the port, formatted
     *           as "<uri>:<port>". Default 'jobs.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 $serviceAddress
     *           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.
     * }
     *
     * @throws ValidationException
     * @experimental
     */
    public function __construct(array $options = [])
    {
        $clientOptions = $this->buildClientOptions($options);
        $this->setClientOptions($clientOptions);
    }

    /**
     * Creates a new job.
     *
     * Typically, the job becomes searchable within 10 seconds, but it may take
     * up to 5 minutes.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
     *     $job = new Job();
     *     $response = $jobServiceClient->createJob($formattedParent, $job);
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $parent Required.
     *
     * The resource name of the project under which the job is created.
     *
     * The format is "projects/{project_id}", for example,
     * "projects/api-test-project".
     * @param Job $job Required.
     *
     * The Job to be created.
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\Cloud\Talent\V4beta1\Job
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function createJob($parent, $job, array $optionalArgs = [])
    {
        $request = new CreateJobRequest();
        $request->setParent($parent);
        $request->setJob($job);

        return $this->startCall(
            'CreateJob',
            Job::class,
            $optionalArgs,
            $request
        )->wait();
    }

    /**
     * Retrieves the specified job, whose status is OPEN or recently EXPIRED
     * within the last 90 days.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedName = $jobServiceClient->jobName('[PROJECT]', '[JOB]');
     *     $response = $jobServiceClient->getJob($formattedName);
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $name Required.
     *
     * The resource name of the job to retrieve.
     *
     * The format is "projects/{project_id}/jobs/{job_id}",
     * for example, "projects/api-test-project/jobs/1234".
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\Cloud\Talent\V4beta1\Job
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function getJob($name, array $optionalArgs = [])
    {
        $request = new GetJobRequest();
        $request->setName($name);

        return $this->startCall(
            'GetJob',
            Job::class,
            $optionalArgs,
            $request
        )->wait();
    }

    /**
     * Updates specified job.
     *
     * Typically, updated contents become visible in search results within 10
     * seconds, but it may take up to 5 minutes.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $job = new Job();
     *     $response = $jobServiceClient->updateJob($job);
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param Job $job Required.
     *
     * The Job to be updated.
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type FieldMask $updateMask
     *          Optional but strongly recommended to be provided for the best service
     *          experience.
     *
     *          If [update_mask][google.cloud.talent.v4beta1.UpdateJobRequest.update_mask] is provided, only the specified fields in
     *          [job][google.cloud.talent.v4beta1.UpdateJobRequest.job] are updated. Otherwise all the fields are updated.
     *
     *          A field mask to restrict the fields that are updated. Only
     *          top level fields of [Job][google.cloud.talent.v4beta1.Job] are supported.
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\Cloud\Talent\V4beta1\Job
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function updateJob($job, array $optionalArgs = [])
    {
        $request = new UpdateJobRequest();
        $request->setJob($job);
        if (isset($optionalArgs['updateMask'])) {
            $request->setUpdateMask($optionalArgs['updateMask']);
        }

        return $this->startCall(
            'UpdateJob',
            Job::class,
            $optionalArgs,
            $request
        )->wait();
    }

    /**
     * Deletes the specified job.
     *
     * Typically, the job becomes unsearchable within 10 seconds, but it may take
     * up to 5 minutes.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedName = $jobServiceClient->jobName('[PROJECT]', '[JOB]');
     *     $jobServiceClient->deleteJob($formattedName);
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $name Required.
     *
     * The resource name of the job to be deleted.
     *
     * The format is "projects/{project_id}/jobs/{job_id}",
     * for example, "projects/api-test-project/jobs/1234".
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function deleteJob($name, array $optionalArgs = [])
    {
        $request = new DeleteJobRequest();
        $request->setName($name);

        return $this->startCall(
            'DeleteJob',
            GPBEmpty::class,
            $optionalArgs,
            $request
        )->wait();
    }

    /**
     * Lists jobs by filter.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
     *     $filter = '';
     *     // Iterate over pages of elements
     *     $pagedResponse = $jobServiceClient->listJobs($formattedParent, $filter);
     *     foreach ($pagedResponse->iteratePages() as $page) {
     *         foreach ($page as $element) {
     *             // doSomethingWith($element);
     *         }
     *     }
     *
     *
     *     // Alternatively:
     *
     *     // Iterate through all elements
     *     $pagedResponse = $jobServiceClient->listJobs($formattedParent, $filter);
     *     foreach ($pagedResponse->iterateAllElements() as $element) {
     *         // doSomethingWith($element);
     *     }
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $parent Required.
     *
     * The resource name of the project under which the job is created.
     *
     * The format is "projects/{project_id}", for example,
     * "projects/api-test-project".
     * @param string $filter Required.
     *
     * The filter string specifies the jobs to be enumerated.
     *
     * Supported operator: =, AND
     *
     * The fields eligible for filtering are:
     *
     * * `companyName` (Required)
     * * `requisitionId` (Optional)
     *
     * Sample Query:
     *
     * * companyName = "projects/api-test-project/companies/123"
     * * companyName = "projects/api-test-project/companies/123" AND requisitionId
     * = "req-1"
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type string $pageToken
     *          A page token is used to specify a page of values to be returned.
     *          If no page token is specified (the default), the first page
     *          of values will be returned. Any page token used here must have
     *          been generated by a previous call to the API.
     *     @type int $pageSize
     *          The maximum number of resources contained in the underlying API
     *          response. The API may return fewer values in a page, even if
     *          there are additional values to be retrieved.
     *     @type int $jobView
     *          Optional.
     *
     *          The desired job attributes returned for jobs in the
     *          search response. Defaults to [JobView.JOB_VIEW_FULL][google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL] if no value is
     *          specified.
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\JobView}
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\ApiCore\PagedListResponse
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function listJobs($parent, $filter, array $optionalArgs = [])
    {
        $request = new ListJobsRequest();
        $request->setParent($parent);
        $request->setFilter($filter);
        if (isset($optionalArgs['pageToken'])) {
            $request->setPageToken($optionalArgs['pageToken']);
        }
        if (isset($optionalArgs['pageSize'])) {
            $request->setPageSize($optionalArgs['pageSize']);
        }
        if (isset($optionalArgs['jobView'])) {
            $request->setJobView($optionalArgs['jobView']);
        }

        return $this->getPagedListResponse(
            'ListJobs',
            $optionalArgs,
            ListJobsResponse::class,
            $request
        );
    }

    /**
     * Deletes a list of [Job][google.cloud.talent.v4beta1.Job]s by filter.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
     *     $filter = '';
     *     $jobServiceClient->batchDeleteJobs($formattedParent, $filter);
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $parent Required.
     *
     * The resource name of the project under which the job is created.
     *
     * The format is "projects/{project_id}", for example,
     * "projects/api-test-project".
     * @param string $filter Required.
     *
     * The filter string specifies the jobs to be deleted.
     *
     * Supported operator: =, AND
     *
     * The fields eligible for filtering are:
     *
     * * `companyName` (Required)
     * * `requisitionId` (Required)
     *
     * Sample Query: companyName = "projects/api-test-project/companies/123" AND
     * requisitionId = "req-1"
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function batchDeleteJobs($parent, $filter, array $optionalArgs = [])
    {
        $request = new BatchDeleteJobsRequest();
        $request->setParent($parent);
        $request->setFilter($filter);

        return $this->startCall(
            'BatchDeleteJobs',
            GPBEmpty::class,
            $optionalArgs,
            $request
        )->wait();
    }

    /**
     * Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest].
     *
     * This call constrains the [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs
     * present in the database, and only returns jobs that the caller has
     * permission to search against.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
     *     $requestMetadata = new RequestMetadata();
     *     // Iterate over pages of elements
     *     $pagedResponse = $jobServiceClient->searchJobs($formattedParent, $requestMetadata);
     *     foreach ($pagedResponse->iteratePages() as $page) {
     *         foreach ($page as $element) {
     *             // doSomethingWith($element);
     *         }
     *     }
     *
     *
     *     // Alternatively:
     *
     *     // Iterate through all elements
     *     $pagedResponse = $jobServiceClient->searchJobs($formattedParent, $requestMetadata);
     *     foreach ($pagedResponse->iterateAllElements() as $element) {
     *         // doSomethingWith($element);
     *     }
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $parent Required.
     *
     * The resource name of the project to search within.
     *
     * The format is "projects/{project_id}", for example,
     * "projects/api-test-project".
     * @param RequestMetadata $requestMetadata Required.
     *
     * The meta information collected about the job searcher, used to improve the
     * search quality of the service.. The identifiers, (such as `user_id`) are
     * provided by users, and must be unique and consistent.
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type int $searchMode
     *          Optional.
     *
     *          Mode of a search.
     *
     *          Defaults to [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH].
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\SearchJobsRequest_SearchMode}
     *     @type JobQuery $jobQuery
     *          Optional.
     *
     *          Query used to search against jobs, such as keyword, location filters, etc.
     *     @type bool $enableBroadening
     *          Optional.
     *
     *          Controls whether to broaden the search when it produces sparse results.
     *          Broadened queries append results to the end of the matching results
     *          list.
     *
     *          Defaults to false.
     *     @type bool $requirePreciseResultSize
     *          Optional.
     *
     *          Controls if the search job request requires the return of a precise
     *          count of the first 300 results. Setting this to `true` ensures
     *          consistency in the number of results per page. Best practice is to set this
     *          value to true if a client allows users to jump directly to a
     *          non-sequential search results page.
     *
     *          Enabling this flag may adversely impact performance.
     *
     *          Defaults to false.
     *     @type HistogramQuery[] $histogramQueries
     *          Optional.
     *
     *          An expression specifies a histogram request against matching jobs.
     *
     *          Expression syntax is an aggregation function call with histogram facets and
     *          other options.
     *
     *          Available aggregation function calls are:
     *          * `count(string_histogram_facet)`: Count the number of matching entities,
     *          for each distinct attribute value.
     *          * `count(numeric_histogram_facet, list of buckets)`: Count the number of
     *          matching entities within each bucket.
     *
     *          Data types:
     *
     *          * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+.
     *          * String: string like "any string with backslash escape for quote(\")."
     *          * Number: whole number and floating point number like 10, -1 and -0.01.
     *          * List: list of elements with comma(,) separator surrounded by square
     *          brackets, for example, [1, 2, 3] and ["one", "two", "three"].
     *
     *          Built-in constants:
     *
     *          * MIN (minimum number similar to java Double.MIN_VALUE)
     *          * MAX (maximum number similar to java Double.MAX_VALUE)
     *
     *          Built-in functions:
     *
     *          * bucket(start, end[, label]): bucket built-in function creates a bucket
     *          with range of [start, end). Note that the end is exclusive, for example,
     *          bucket(1, MAX, "positive number") or bucket(1, 10).
     *
     *          Job histogram facets:
     *
     *          * company_id: histogram by [Job.distributor_company_id][].
     *          * company_display_name: histogram by [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name].
     *          * employment_type: histogram by [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], for example,
     *          "FULL_TIME", "PART_TIME".
     *          * company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL",
     *          "MEDIUM", "BIG".
     *          * publish_time_in_month: histogram by the [Job.publish_time][] in months.
     *          Must specify list of numeric buckets in spec.
     *          * publish_time_in_year: histogram by the [Job.publish_time][] in years.
     *          Must specify list of numeric buckets in spec.
     *          * degree_type: histogram by the [Job.degree_type][], for example,
     *          "Bachelors", "Masters".
     *          * job_level: histogram by the [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], for example, "Entry
     *          Level".
     *          * country: histogram by the country code of jobs, for example, "US", "FR".
     *          * admin1: histogram by the admin1 code of jobs, which is a global
     *          placeholder referring to the state, province, or the particular term a
     *          country uses to define the geographic structure below the country level,
     *          for example, "CA", "IL".
     *          * city: histogram by a combination of the "city name, admin1 code". For
     *          example,  "Mountain View, CA", "New York, NY".
     *          * admin1_country: histogram by a combination of the "admin1 code, country",
     *          for example, "CA, US", "IL, US".
     *          * city_coordinate: histogram by the city center's GPS coordinates (latitude
     *          and longitude), for example, 37.4038522,-122.0987765. Since the coordinates
     *          of a city center can change, customers may need to refresh them
     *          periodically.
     *          * locale: histogram by the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], for example, "en-US",
     *          "fr-FR".
     *          * language: histogram by the language subtag of the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code],
     *          for example, "en", "fr".
     *          * category: histogram by the [JobCategory][google.cloud.talent.v4beta1.JobCategory], for example,
     *          "COMPUTER_AND_IT", "HEALTHCARE".
     *          * base_compensation_unit: histogram by the [CompensationUnit][] of base
     *          salary, for example, "WEEKLY", "MONTHLY".
     *          * base_compensation: histogram by the base salary. Must specify list of
     *          numeric buckets to group results by.
     *          * annualized_base_compensation: histogram by the base annualized salary.
     *          Must specify list of numeric buckets to group results by.
     *          * annualized_total_compensation: histogram by the total annualized salary.
     *          Must specify list of numeric buckets to group results by.
     *          * string_custom_attribute: histogram by string [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes].
     *          Values can be accessed via square bracket notations like
     *          string_custom_attribute["key1"].
     *          * numeric_custom_attribute: histogram by numeric [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes].
     *          Values can be accessed via square bracket notations like
     *          numeric_custom_attribute["key1"]. Must specify list of numeric buckets to
     *          group results by.
     *
     *          Example expressions:
     *          * count(admin1)
     *          * count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000),
     *          bucket(100000, MAX)])
     *          * count(string_custom_attribute["some-string-custom-attribute"])
     *          * count(numeric_custom_attribute["some-numeric-custom-attribute"],
     *          [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])
     *     @type int $jobView
     *          Optional.
     *
     *          The desired job attributes returned for jobs in the
     *          search response. Defaults to [JobView.SMALL][] if no value is specified.
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\JobView}
     *     @type int $offset
     *          Optional.
     *
     *          An integer that specifies the current offset (that is, starting result
     *          location, amongst the jobs deemed by the API as relevant) in search
     *          results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] is unset.
     *
     *          For example, 0 means to  return results starting from the first matching
     *          job, and 10 means to return from the 11th job. This can be used for
     *          pagination, (for example, pageSize = 10 and offset = 10 means to return
     *          from the second page).
     *     @type int $pageSize
     *          The maximum number of resources contained in the underlying API
     *          response. The API may return fewer values in a page, even if
     *          there are additional values to be retrieved.
     *     @type string $pageToken
     *          A page token is used to specify a page of values to be returned.
     *          If no page token is specified (the default), the first page
     *          of values will be returned. Any page token used here must have
     *          been generated by a previous call to the API.
     *     @type string $orderBy
     *          Optional.
     *
     *          The criteria determining how search results are sorted. Default is
     *          "relevance desc".
     *
     *          Supported options are:
     *
     *          * "relevance desc": By relevance descending, as determined by the API
     *          algorithms. Relevance thresholding of query results is only available
     *          with this ordering.
     *          * "posting`_`publish`_`time desc": By [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time]
     *          descending.
     *          * "posting`_`update`_`time desc": By [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time]
     *          descending.
     *          * "title": By [Job.title][google.cloud.talent.v4beta1.Job.title] ascending.
     *          * "title desc": By [Job.title][google.cloud.talent.v4beta1.Job.title] descending.
     *          * "annualized`_`base`_`compensation": By job's
     *          [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] ascending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`base`_`compensation desc": By job's
     *          [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] descending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`total`_`compensation": By job's
     *          [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] ascending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`total`_`compensation desc": By job's
     *          [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] descending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "custom`_`ranking desc": By the relevance score adjusted to the
     *          [SearchJobsRequest.custom_ranking_info.ranking_expression][] with weight
     *          factor assigned by
     *          [SearchJobsRequest.custom_ranking_info.importance_level][] in descending
     *          order.
     *          * "location`_`distance": By the distance between the location on jobs and
     *           locations specified in the
     *          [SearchJobsRequest.job_query.location_filters][].
     *          When this order is selected, the
     *          [SearchJobsRequest.job_query.location_filters][] must not be empty. When
     *          a job has multiple locations, the location closest to one of the locations
     *          specified in the location filter will be used to calculate location
     *          distance. Distance is calculated by the distance between two lat/long
     *          coordinates, with a precision of 10e-4 degrees (11.3 meters).
     *          Jobs that don't have locations specified will be ranked below jobs having
     *          locations.
     *          Diversification strategy is still applied unless explicitly disabled in
     *          [SearchJobsRequest.diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level].
     *     @type int $diversificationLevel
     *          Optional.
     *
     *          Controls whether highly similar jobs are returned next to each other in
     *          the search results. Jobs are identified as highly similar based on
     *          their titles, job categories, and locations. Highly similar results are
     *          clustered so that only one representative job of the cluster is
     *          displayed to the job seeker higher up in the results, with the other jobs
     *          being displayed lower down in the results.
     *
     *          Defaults to [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] if no value
     *          is specified.
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\SearchJobsRequest_DiversificationLevel}
     *     @type SearchJobsRequest_CustomRankingInfo $customRankingInfo
     *          Optional.
     *
     *          Controls over how job documents get ranked on top of existing relevance
     *          score (determined by API algorithm).
     *     @type bool $disableKeywordMatch
     *          Optional.
     *
     *          Controls whether to disable exact keyword match on [Job.job_title][],
     *          [Job.description][google.cloud.talent.v4beta1.Job.description], [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], [Job.locations][0],
     *          [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. When disable keyword match is turned off, a
     *          keyword match returns jobs that do not match given category filters when
     *          there are matching keywords. For example, for the query "program manager,"
     *          a result is returned even if the job posting has the title "software
     *          developer," which doesn't fall into "program manager" ontology, but does
     *          have "program manager" appearing in its description.
     *
     *          For queries like "cloud" that don't contain title or
     *          location specific ontology, jobs with "cloud" keyword matches are returned
     *          regardless of this flag's value.
     *
     *          Please use [Company.keyword_searchable_custom_fields][] or
     *          [Company.keyword_searchable_custom_attributes][] if company specific
     *          globally matched custom field/attribute string values is needed. Enabling
     *          keyword match improves recall of subsequent search requests.
     *
     *          Defaults to false.
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\ApiCore\PagedListResponse
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function searchJobs($parent, $requestMetadata, array $optionalArgs = [])
    {
        $request = new SearchJobsRequest();
        $request->setParent($parent);
        $request->setRequestMetadata($requestMetadata);
        if (isset($optionalArgs['searchMode'])) {
            $request->setSearchMode($optionalArgs['searchMode']);
        }
        if (isset($optionalArgs['jobQuery'])) {
            $request->setJobQuery($optionalArgs['jobQuery']);
        }
        if (isset($optionalArgs['enableBroadening'])) {
            $request->setEnableBroadening($optionalArgs['enableBroadening']);
        }
        if (isset($optionalArgs['requirePreciseResultSize'])) {
            $request->setRequirePreciseResultSize($optionalArgs['requirePreciseResultSize']);
        }
        if (isset($optionalArgs['histogramQueries'])) {
            $request->setHistogramQueries($optionalArgs['histogramQueries']);
        }
        if (isset($optionalArgs['jobView'])) {
            $request->setJobView($optionalArgs['jobView']);
        }
        if (isset($optionalArgs['offset'])) {
            $request->setOffset($optionalArgs['offset']);
        }
        if (isset($optionalArgs['pageSize'])) {
            $request->setPageSize($optionalArgs['pageSize']);
        }
        if (isset($optionalArgs['pageToken'])) {
            $request->setPageToken($optionalArgs['pageToken']);
        }
        if (isset($optionalArgs['orderBy'])) {
            $request->setOrderBy($optionalArgs['orderBy']);
        }
        if (isset($optionalArgs['diversificationLevel'])) {
            $request->setDiversificationLevel($optionalArgs['diversificationLevel']);
        }
        if (isset($optionalArgs['customRankingInfo'])) {
            $request->setCustomRankingInfo($optionalArgs['customRankingInfo']);
        }
        if (isset($optionalArgs['disableKeywordMatch'])) {
            $request->setDisableKeywordMatch($optionalArgs['disableKeywordMatch']);
        }

        return $this->getPagedListResponse(
            'SearchJobs',
            $optionalArgs,
            SearchJobsResponse::class,
            $request
        );
    }

    /**
     * Searches for jobs using the provided [SearchJobsRequest][google.cloud.talent.v4beta1.SearchJobsRequest].
     *
     * This API call is intended for the use case of targeting passive job
     * seekers (for example, job seekers who have signed up to receive email
     * alerts about potential job opportunities), and has different algorithmic
     * adjustments that are targeted to passive job seekers.
     *
     * This call constrains the [visibility][google.cloud.talent.v4beta1.Job.visibility] of jobs
     * present in the database, and only returns jobs the caller has
     * permission to search against.
     *
     * Sample code:
     * ```
     * $jobServiceClient = new JobServiceClient();
     * try {
     *     $formattedParent = $jobServiceClient->projectName('[PROJECT]');
     *     $requestMetadata = new RequestMetadata();
     *     // Iterate over pages of elements
     *     $pagedResponse = $jobServiceClient->searchJobsForAlert($formattedParent, $requestMetadata);
     *     foreach ($pagedResponse->iteratePages() as $page) {
     *         foreach ($page as $element) {
     *             // doSomethingWith($element);
     *         }
     *     }
     *
     *
     *     // Alternatively:
     *
     *     // Iterate through all elements
     *     $pagedResponse = $jobServiceClient->searchJobsForAlert($formattedParent, $requestMetadata);
     *     foreach ($pagedResponse->iterateAllElements() as $element) {
     *         // doSomethingWith($element);
     *     }
     * } finally {
     *     $jobServiceClient->close();
     * }
     * ```
     *
     * @param string $parent Required.
     *
     * The resource name of the project to search within.
     *
     * The format is "projects/{project_id}", for example,
     * "projects/api-test-project".
     * @param RequestMetadata $requestMetadata Required.
     *
     * The meta information collected about the job searcher, used to improve the
     * search quality of the service.. The identifiers, (such as `user_id`) are
     * provided by users, and must be unique and consistent.
     * @param array $optionalArgs {
     *                            Optional.
     *
     *     @type int $searchMode
     *          Optional.
     *
     *          Mode of a search.
     *
     *          Defaults to [SearchMode.JOB_SEARCH][google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH].
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\SearchJobsRequest_SearchMode}
     *     @type JobQuery $jobQuery
     *          Optional.
     *
     *          Query used to search against jobs, such as keyword, location filters, etc.
     *     @type bool $enableBroadening
     *          Optional.
     *
     *          Controls whether to broaden the search when it produces sparse results.
     *          Broadened queries append results to the end of the matching results
     *          list.
     *
     *          Defaults to false.
     *     @type bool $requirePreciseResultSize
     *          Optional.
     *
     *          Controls if the search job request requires the return of a precise
     *          count of the first 300 results. Setting this to `true` ensures
     *          consistency in the number of results per page. Best practice is to set this
     *          value to true if a client allows users to jump directly to a
     *          non-sequential search results page.
     *
     *          Enabling this flag may adversely impact performance.
     *
     *          Defaults to false.
     *     @type HistogramQuery[] $histogramQueries
     *          Optional.
     *
     *          An expression specifies a histogram request against matching jobs.
     *
     *          Expression syntax is an aggregation function call with histogram facets and
     *          other options.
     *
     *          Available aggregation function calls are:
     *          * `count(string_histogram_facet)`: Count the number of matching entities,
     *          for each distinct attribute value.
     *          * `count(numeric_histogram_facet, list of buckets)`: Count the number of
     *          matching entities within each bucket.
     *
     *          Data types:
     *
     *          * Histogram facet: facet names with format [a-zA-Z][a-zA-Z0-9_]+.
     *          * String: string like "any string with backslash escape for quote(\")."
     *          * Number: whole number and floating point number like 10, -1 and -0.01.
     *          * List: list of elements with comma(,) separator surrounded by square
     *          brackets, for example, [1, 2, 3] and ["one", "two", "three"].
     *
     *          Built-in constants:
     *
     *          * MIN (minimum number similar to java Double.MIN_VALUE)
     *          * MAX (maximum number similar to java Double.MAX_VALUE)
     *
     *          Built-in functions:
     *
     *          * bucket(start, end[, label]): bucket built-in function creates a bucket
     *          with range of [start, end). Note that the end is exclusive, for example,
     *          bucket(1, MAX, "positive number") or bucket(1, 10).
     *
     *          Job histogram facets:
     *
     *          * company_id: histogram by [Job.distributor_company_id][].
     *          * company_display_name: histogram by [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name].
     *          * employment_type: histogram by [Job.employment_types][google.cloud.talent.v4beta1.Job.employment_types], for example,
     *          "FULL_TIME", "PART_TIME".
     *          * company_size: histogram by [CompanySize][google.cloud.talent.v4beta1.CompanySize], for example, "SMALL",
     *          "MEDIUM", "BIG".
     *          * publish_time_in_month: histogram by the [Job.publish_time][] in months.
     *          Must specify list of numeric buckets in spec.
     *          * publish_time_in_year: histogram by the [Job.publish_time][] in years.
     *          Must specify list of numeric buckets in spec.
     *          * degree_type: histogram by the [Job.degree_type][], for example,
     *          "Bachelors", "Masters".
     *          * job_level: histogram by the [Job.job_level][google.cloud.talent.v4beta1.Job.job_level], for example, "Entry
     *          Level".
     *          * country: histogram by the country code of jobs, for example, "US", "FR".
     *          * admin1: histogram by the admin1 code of jobs, which is a global
     *          placeholder referring to the state, province, or the particular term a
     *          country uses to define the geographic structure below the country level,
     *          for example, "CA", "IL".
     *          * city: histogram by a combination of the "city name, admin1 code". For
     *          example,  "Mountain View, CA", "New York, NY".
     *          * admin1_country: histogram by a combination of the "admin1 code, country",
     *          for example, "CA, US", "IL, US".
     *          * city_coordinate: histogram by the city center's GPS coordinates (latitude
     *          and longitude), for example, 37.4038522,-122.0987765. Since the coordinates
     *          of a city center can change, customers may need to refresh them
     *          periodically.
     *          * locale: histogram by the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code], for example, "en-US",
     *          "fr-FR".
     *          * language: histogram by the language subtag of the [Job.language_code][google.cloud.talent.v4beta1.Job.language_code],
     *          for example, "en", "fr".
     *          * category: histogram by the [JobCategory][google.cloud.talent.v4beta1.JobCategory], for example,
     *          "COMPUTER_AND_IT", "HEALTHCARE".
     *          * base_compensation_unit: histogram by the [CompensationUnit][] of base
     *          salary, for example, "WEEKLY", "MONTHLY".
     *          * base_compensation: histogram by the base salary. Must specify list of
     *          numeric buckets to group results by.
     *          * annualized_base_compensation: histogram by the base annualized salary.
     *          Must specify list of numeric buckets to group results by.
     *          * annualized_total_compensation: histogram by the total annualized salary.
     *          Must specify list of numeric buckets to group results by.
     *          * string_custom_attribute: histogram by string [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes].
     *          Values can be accessed via square bracket notations like
     *          string_custom_attribute["key1"].
     *          * numeric_custom_attribute: histogram by numeric [Job.custom_attributes][google.cloud.talent.v4beta1.Job.custom_attributes].
     *          Values can be accessed via square bracket notations like
     *          numeric_custom_attribute["key1"]. Must specify list of numeric buckets to
     *          group results by.
     *
     *          Example expressions:
     *          * count(admin1)
     *          * count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000),
     *          bucket(100000, MAX)])
     *          * count(string_custom_attribute["some-string-custom-attribute"])
     *          * count(numeric_custom_attribute["some-numeric-custom-attribute"],
     *          [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative"])
     *     @type int $jobView
     *          Optional.
     *
     *          The desired job attributes returned for jobs in the
     *          search response. Defaults to [JobView.SMALL][] if no value is specified.
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\JobView}
     *     @type int $offset
     *          Optional.
     *
     *          An integer that specifies the current offset (that is, starting result
     *          location, amongst the jobs deemed by the API as relevant) in search
     *          results. This field is only considered if [page_token][google.cloud.talent.v4beta1.SearchJobsRequest.page_token] is unset.
     *
     *          For example, 0 means to  return results starting from the first matching
     *          job, and 10 means to return from the 11th job. This can be used for
     *          pagination, (for example, pageSize = 10 and offset = 10 means to return
     *          from the second page).
     *     @type int $pageSize
     *          The maximum number of resources contained in the underlying API
     *          response. The API may return fewer values in a page, even if
     *          there are additional values to be retrieved.
     *     @type string $pageToken
     *          A page token is used to specify a page of values to be returned.
     *          If no page token is specified (the default), the first page
     *          of values will be returned. Any page token used here must have
     *          been generated by a previous call to the API.
     *     @type string $orderBy
     *          Optional.
     *
     *          The criteria determining how search results are sorted. Default is
     *          "relevance desc".
     *
     *          Supported options are:
     *
     *          * "relevance desc": By relevance descending, as determined by the API
     *          algorithms. Relevance thresholding of query results is only available
     *          with this ordering.
     *          * "posting`_`publish`_`time desc": By [Job.posting_publish_time][google.cloud.talent.v4beta1.Job.posting_publish_time]
     *          descending.
     *          * "posting`_`update`_`time desc": By [Job.posting_update_time][google.cloud.talent.v4beta1.Job.posting_update_time]
     *          descending.
     *          * "title": By [Job.title][google.cloud.talent.v4beta1.Job.title] ascending.
     *          * "title desc": By [Job.title][google.cloud.talent.v4beta1.Job.title] descending.
     *          * "annualized`_`base`_`compensation": By job's
     *          [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] ascending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`base`_`compensation desc": By job's
     *          [CompensationInfo.annualized_base_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range] descending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`total`_`compensation": By job's
     *          [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] ascending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "annualized`_`total`_`compensation desc": By job's
     *          [CompensationInfo.annualized_total_compensation_range][google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range] descending. Jobs
     *          whose annualized base compensation is unspecified are put at the end of
     *          search results.
     *          * "custom`_`ranking desc": By the relevance score adjusted to the
     *          [SearchJobsRequest.custom_ranking_info.ranking_expression][] with weight
     *          factor assigned by
     *          [SearchJobsRequest.custom_ranking_info.importance_level][] in descending
     *          order.
     *          * "location`_`distance": By the distance between the location on jobs and
     *           locations specified in the
     *          [SearchJobsRequest.job_query.location_filters][].
     *          When this order is selected, the
     *          [SearchJobsRequest.job_query.location_filters][] must not be empty. When
     *          a job has multiple locations, the location closest to one of the locations
     *          specified in the location filter will be used to calculate location
     *          distance. Distance is calculated by the distance between two lat/long
     *          coordinates, with a precision of 10e-4 degrees (11.3 meters).
     *          Jobs that don't have locations specified will be ranked below jobs having
     *          locations.
     *          Diversification strategy is still applied unless explicitly disabled in
     *          [SearchJobsRequest.diversification_level][google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level].
     *     @type int $diversificationLevel
     *          Optional.
     *
     *          Controls whether highly similar jobs are returned next to each other in
     *          the search results. Jobs are identified as highly similar based on
     *          their titles, job categories, and locations. Highly similar results are
     *          clustered so that only one representative job of the cluster is
     *          displayed to the job seeker higher up in the results, with the other jobs
     *          being displayed lower down in the results.
     *
     *          Defaults to [DiversificationLevel.SIMPLE][google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE] if no value
     *          is specified.
     *          For allowed values, use constants defined on {@see \Google\Cloud\Talent\V4beta1\SearchJobsRequest_DiversificationLevel}
     *     @type SearchJobsRequest_CustomRankingInfo $customRankingInfo
     *          Optional.
     *
     *          Controls over how job documents get ranked on top of existing relevance
     *          score (determined by API algorithm).
     *     @type bool $disableKeywordMatch
     *          Optional.
     *
     *          Controls whether to disable exact keyword match on [Job.job_title][],
     *          [Job.description][google.cloud.talent.v4beta1.Job.description], [Job.company_display_name][google.cloud.talent.v4beta1.Job.company_display_name], [Job.locations][0],
     *          [Job.qualifications][google.cloud.talent.v4beta1.Job.qualifications]. When disable keyword match is turned off, a
     *          keyword match returns jobs that do not match given category filters when
     *          there are matching keywords. For example, for the query "program manager,"
     *          a result is returned even if the job posting has the title "software
     *          developer," which doesn't fall into "program manager" ontology, but does
     *          have "program manager" appearing in its description.
     *
     *          For queries like "cloud" that don't contain title or
     *          location specific ontology, jobs with "cloud" keyword matches are returned
     *          regardless of this flag's value.
     *
     *          Please use [Company.keyword_searchable_custom_fields][] or
     *          [Company.keyword_searchable_custom_attributes][] if company specific
     *          globally matched custom field/attribute string values is needed. Enabling
     *          keyword match improves recall of subsequent search requests.
     *
     *          Defaults to false.
     *     @type RetrySettings|array $retrySettings
     *          Retry settings to use for this call. Can be a
     *          {@see Google\ApiCore\RetrySettings} object, or an associative array
     *          of retry settings parameters. See the documentation on
     *          {@see Google\ApiCore\RetrySettings} for example usage.
     * }
     *
     * @return \Google\ApiCore\PagedListResponse
     *
     * @throws ApiException if the remote call fails
     * @experimental
     */
    public function searchJobsForAlert($parent, $requestMetadata, array $optionalArgs = [])
    {
        $request = new SearchJobsRequest();
        $request->setParent($parent);
        $request->setRequestMetadata($requestMetadata);
        if (isset($optionalArgs['searchMode'])) {
            $request->setSearchMode($optionalArgs['searchMode']);
        }
        if (isset($optionalArgs['jobQuery'])) {
            $request->setJobQuery($optionalArgs['jobQuery']);
        }
        if (isset($optionalArgs['enableBroadening'])) {
            $request->setEnableBroadening($optionalArgs['enableBroadening']);
        }
        if (isset($optionalArgs['requirePreciseResultSize'])) {
            $request->setRequirePreciseResultSize($optionalArgs['requirePreciseResultSize']);
        }
        if (isset($optionalArgs['histogramQueries'])) {
            $request->setHistogramQueries($optionalArgs['histogramQueries']);
        }
        if (isset($optionalArgs['jobView'])) {
            $request->setJobView($optionalArgs['jobView']);
        }
        if (isset($optionalArgs['offset'])) {
            $request->setOffset($optionalArgs['offset']);
        }
        if (isset($optionalArgs['pageSize'])) {
            $request->setPageSize($optionalArgs['pageSize']);
        }
        if (isset($optionalArgs['pageToken'])) {
            $request->setPageToken($optionalArgs['pageToken']);
        }
        if (isset($optionalArgs['orderBy'])) {
            $request->setOrderBy($optionalArgs['orderBy']);
        }
        if (isset($optionalArgs['diversificationLevel'])) {
            $request->setDiversificationLevel($optionalArgs['diversificationLevel']);
        }
        if (isset($optionalArgs['customRankingInfo'])) {
            $request->setCustomRankingInfo($optionalArgs['customRankingInfo']);
        }
        if (isset($optionalArgs['disableKeywordMatch'])) {
            $request->setDisableKeywordMatch($optionalArgs['disableKeywordMatch']);
        }

        return $this->getPagedListResponse(
            'SearchJobsForAlert',
            $optionalArgs,
            SearchJobsResponse::class,
            $request
        );
    }
}
