Google Cloud Talent Solution V4 Client - Class JobServiceClient (2.0.0)

Reference documentation and code samples for the Google Cloud Talent Solution V4 Client class JobServiceClient.

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.

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.

Namespace

Google \ Cloud \ Talent \ V4 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string 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 Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

batchCreateJobs

Begins executing a batch create jobs operation.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::batchCreateJobsAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchCreateJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Talent\V4\BatchCreateJobsRequest;
use Google\Cloud\Talent\V4\BatchCreateJobsResponse;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\Job;
use Google\Rpc\Status;

/**
 * @param string $formattedParent      The resource name of the tenant under which the job is created.
 *
 *                                     The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                     "projects/foo/tenants/bar". Please see
 *                                     {@see JobServiceClient::tenantName()} for help formatting this field.
 * @param string $formattedJobsCompany The resource name of the company listing the job.
 *
 *                                     The format is
 *                                     "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". For
 *                                     example, "projects/foo/tenants/bar/companies/baz". Please see
 *                                     {@see JobServiceClient::companyName()} for help formatting this field.
 * @param string $jobsRequisitionId    The requisition ID, also referred to as the posting ID, is
 *                                     assigned by the client to identify a job. This field is intended to be used
 *                                     by clients for client identification and tracking of postings. A job isn't
 *                                     allowed to be created if there is another job with the same
 *                                     [company][google.cloud.talent.v4.Job.name],
 *                                     [language_code][google.cloud.talent.v4.Job.language_code] and
 *                                     [requisition_id][google.cloud.talent.v4.Job.requisition_id].
 *
 *                                     The maximum number of allowed characters is 255.
 * @param string $jobsTitle            The title of the job, such as "Software Engineer"
 *
 *                                     The maximum number of allowed characters is 500.
 * @param string $jobsDescription      The description of the job, which typically includes a
 *                                     multi-paragraph description of the company and related information.
 *                                     Separate fields are provided on the job object for
 *                                     [responsibilities][google.cloud.talent.v4.Job.responsibilities],
 *                                     [qualifications][google.cloud.talent.v4.Job.qualifications], and other job
 *                                     characteristics. Use of these separate job fields is recommended.
 *
 *                                     This field accepts and sanitizes HTML input, and also accepts
 *                                     bold, italic, ordered list, and unordered list markup tags.
 *
 *                                     The maximum number of allowed characters is 100,000.
 */
function batch_create_jobs_sample(
    string $formattedParent,
    string $formattedJobsCompany,
    string $jobsRequisitionId,
    string $jobsTitle,
    string $jobsDescription
): void {
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $job = (new Job())
        ->setCompany($formattedJobsCompany)
        ->setRequisitionId($jobsRequisitionId)
        ->setTitle($jobsTitle)
        ->setDescription($jobsDescription);
    $jobs = [$job,];
    $request = (new BatchCreateJobsRequest())
        ->setParent($formattedParent)
        ->setJobs($jobs);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $jobServiceClient->batchCreateJobs($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var BatchCreateJobsResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');
    $formattedJobsCompany = JobServiceClient::companyName('[PROJECT]', '[TENANT]', '[COMPANY]');
    $jobsRequisitionId = '[REQUISITION_ID]';
    $jobsTitle = '[TITLE]';
    $jobsDescription = '[DESCRIPTION]';

    batch_create_jobs_sample(
        $formattedParent,
        $formattedJobsCompany,
        $jobsRequisitionId,
        $jobsTitle,
        $jobsDescription
    );
}

batchDeleteJobs

Begins executing a batch delete jobs operation.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::batchDeleteJobsAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchDeleteJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Talent\V4\BatchDeleteJobsRequest;
use Google\Cloud\Talent\V4\BatchDeleteJobsResponse;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The resource name of the tenant under which the job is created.
 *
 *                                The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                "projects/foo/tenants/bar".
 *
 *                                The parent of all of the jobs specified in `names` must match this field. Please see
 *                                {@see JobServiceClient::tenantName()} for help formatting this field.
 */
function batch_delete_jobs_sample(string $formattedParent): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $request = (new BatchDeleteJobsRequest())
        ->setParent($formattedParent);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $jobServiceClient->batchDeleteJobs($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var BatchDeleteJobsResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');

    batch_delete_jobs_sample($formattedParent);
}

batchUpdateJobs

Begins executing a batch update jobs operation.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::batchUpdateJobsAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchUpdateJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Talent\V4\BatchUpdateJobsRequest;
use Google\Cloud\Talent\V4\BatchUpdateJobsResponse;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\Job;
use Google\Rpc\Status;

/**
 * @param string $formattedParent      The resource name of the tenant under which the job is created.
 *
 *                                     The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                     "projects/foo/tenants/bar". Please see
 *                                     {@see JobServiceClient::tenantName()} for help formatting this field.
 * @param string $formattedJobsCompany The resource name of the company listing the job.
 *
 *                                     The format is
 *                                     "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". For
 *                                     example, "projects/foo/tenants/bar/companies/baz". Please see
 *                                     {@see JobServiceClient::companyName()} for help formatting this field.
 * @param string $jobsRequisitionId    The requisition ID, also referred to as the posting ID, is
 *                                     assigned by the client to identify a job. This field is intended to be used
 *                                     by clients for client identification and tracking of postings. A job isn't
 *                                     allowed to be created if there is another job with the same
 *                                     [company][google.cloud.talent.v4.Job.name],
 *                                     [language_code][google.cloud.talent.v4.Job.language_code] and
 *                                     [requisition_id][google.cloud.talent.v4.Job.requisition_id].
 *
 *                                     The maximum number of allowed characters is 255.
 * @param string $jobsTitle            The title of the job, such as "Software Engineer"
 *
 *                                     The maximum number of allowed characters is 500.
 * @param string $jobsDescription      The description of the job, which typically includes a
 *                                     multi-paragraph description of the company and related information.
 *                                     Separate fields are provided on the job object for
 *                                     [responsibilities][google.cloud.talent.v4.Job.responsibilities],
 *                                     [qualifications][google.cloud.talent.v4.Job.qualifications], and other job
 *                                     characteristics. Use of these separate job fields is recommended.
 *
 *                                     This field accepts and sanitizes HTML input, and also accepts
 *                                     bold, italic, ordered list, and unordered list markup tags.
 *
 *                                     The maximum number of allowed characters is 100,000.
 */
function batch_update_jobs_sample(
    string $formattedParent,
    string $formattedJobsCompany,
    string $jobsRequisitionId,
    string $jobsTitle,
    string $jobsDescription
): void {
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $job = (new Job())
        ->setCompany($formattedJobsCompany)
        ->setRequisitionId($jobsRequisitionId)
        ->setTitle($jobsTitle)
        ->setDescription($jobsDescription);
    $jobs = [$job,];
    $request = (new BatchUpdateJobsRequest())
        ->setParent($formattedParent)
        ->setJobs($jobs);

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $jobServiceClient->batchUpdateJobs($request);
        $response->pollUntilComplete();

        if ($response->operationSucceeded()) {
            /** @var BatchUpdateJobsResponse $result */
            $result = $response->getResult();
            printf('Operation successful with response data: %s' . PHP_EOL, $result->serializeToJsonString());
        } else {
            /** @var Status $error */
            $error = $response->getError();
            printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');
    $formattedJobsCompany = JobServiceClient::companyName('[PROJECT]', '[TENANT]', '[COMPANY]');
    $jobsRequisitionId = '[REQUISITION_ID]';
    $jobsTitle = '[TITLE]';
    $jobsDescription = '[DESCRIPTION]';

    batch_update_jobs_sample(
        $formattedParent,
        $formattedJobsCompany,
        $jobsRequisitionId,
        $jobsTitle,
        $jobsDescription
    );
}

createJob

Creates a new job.

Typically, the job becomes searchable within 10 seconds, but it may take up to 5 minutes.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::createJobAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\CreateJobRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Talent\V4\Job
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\CreateJobRequest;
use Google\Cloud\Talent\V4\Job;

/**
 * @param string $formattedParent     The resource name of the tenant under which the job is created.
 *
 *                                    The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                    "projects/foo/tenants/bar". Please see
 *                                    {@see JobServiceClient::tenantName()} for help formatting this field.
 * @param string $formattedJobCompany The resource name of the company listing the job.
 *
 *                                    The format is
 *                                    "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". For
 *                                    example, "projects/foo/tenants/bar/companies/baz". Please see
 *                                    {@see JobServiceClient::companyName()} for help formatting this field.
 * @param string $jobRequisitionId    The requisition ID, also referred to as the posting ID, is
 *                                    assigned by the client to identify a job. This field is intended to be used
 *                                    by clients for client identification and tracking of postings. A job isn't
 *                                    allowed to be created if there is another job with the same
 *                                    [company][google.cloud.talent.v4.Job.name],
 *                                    [language_code][google.cloud.talent.v4.Job.language_code] and
 *                                    [requisition_id][google.cloud.talent.v4.Job.requisition_id].
 *
 *                                    The maximum number of allowed characters is 255.
 * @param string $jobTitle            The title of the job, such as "Software Engineer"
 *
 *                                    The maximum number of allowed characters is 500.
 * @param string $jobDescription      The description of the job, which typically includes a
 *                                    multi-paragraph description of the company and related information.
 *                                    Separate fields are provided on the job object for
 *                                    [responsibilities][google.cloud.talent.v4.Job.responsibilities],
 *                                    [qualifications][google.cloud.talent.v4.Job.qualifications], and other job
 *                                    characteristics. Use of these separate job fields is recommended.
 *
 *                                    This field accepts and sanitizes HTML input, and also accepts
 *                                    bold, italic, ordered list, and unordered list markup tags.
 *
 *                                    The maximum number of allowed characters is 100,000.
 */
function create_job_sample(
    string $formattedParent,
    string $formattedJobCompany,
    string $jobRequisitionId,
    string $jobTitle,
    string $jobDescription
): void {
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $job = (new Job())
        ->setCompany($formattedJobCompany)
        ->setRequisitionId($jobRequisitionId)
        ->setTitle($jobTitle)
        ->setDescription($jobDescription);
    $request = (new CreateJobRequest())
        ->setParent($formattedParent)
        ->setJob($job);

    // Call the API and handle any network failures.
    try {
        /** @var Job $response */
        $response = $jobServiceClient->createJob($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');
    $formattedJobCompany = JobServiceClient::companyName('[PROJECT]', '[TENANT]', '[COMPANY]');
    $jobRequisitionId = '[REQUISITION_ID]';
    $jobTitle = '[TITLE]';
    $jobDescription = '[DESCRIPTION]';

    create_job_sample(
        $formattedParent,
        $formattedJobCompany,
        $jobRequisitionId,
        $jobTitle,
        $jobDescription
    );
}

deleteJob

Deletes the specified job.

Typically, the job becomes unsearchable within 10 seconds, but it may take up to 5 minutes.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::deleteJobAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\DeleteJobRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\DeleteJobRequest;

/**
 * @param string $formattedName The resource name of the job to be deleted.
 *
 *                              The format is
 *                              "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For
 *                              example, "projects/foo/tenants/bar/jobs/baz". Please see
 *                              {@see JobServiceClient::jobName()} for help formatting this field.
 */
function delete_job_sample(string $formattedName): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $request = (new DeleteJobRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        $jobServiceClient->deleteJob($request);
        printf('Call completed successfully.' . PHP_EOL);
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = JobServiceClient::jobName('[PROJECT]', '[TENANT]', '[JOB]');

    delete_job_sample($formattedName);
}

getJob

Retrieves the specified job, whose status is OPEN or recently EXPIRED within the last 90 days.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::getJobAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\GetJobRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Talent\V4\Job
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\GetJobRequest;
use Google\Cloud\Talent\V4\Job;

/**
 * @param string $formattedName The resource name of the job to retrieve.
 *
 *                              The format is
 *                              "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For
 *                              example, "projects/foo/tenants/bar/jobs/baz". Please see
 *                              {@see JobServiceClient::jobName()} for help formatting this field.
 */
function get_job_sample(string $formattedName): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $request = (new GetJobRequest())
        ->setName($formattedName);

    // Call the API and handle any network failures.
    try {
        /** @var Job $response */
        $response = $jobServiceClient->getJob($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = JobServiceClient::jobName('[PROJECT]', '[TENANT]', '[JOB]');

    get_job_sample($formattedName);
}

listJobs

Lists jobs by filter.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::listJobsAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\ListJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\Job;
use Google\Cloud\Talent\V4\ListJobsRequest;

/**
 * @param string $formattedParent The resource name of the tenant under which the job is created.
 *
 *                                The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                "projects/foo/tenants/bar". Please see
 *                                {@see JobServiceClient::tenantName()} for help formatting this field.
 * @param string $filter          The filter string specifies the jobs to be enumerated.
 *
 *                                Supported operator: =, AND
 *
 *                                The fields eligible for filtering are:
 *
 *                                * `companyName`
 *                                * `requisitionId`
 *                                * `status` Available values: OPEN, EXPIRED, ALL. Defaults to
 *                                OPEN if no value is specified.
 *
 *                                At least one of `companyName` and `requisitionId` must present or an
 *                                INVALID_ARGUMENT error is thrown.
 *
 *                                Sample Query:
 *
 *                                * companyName = "projects/foo/tenants/bar/companies/baz"
 *                                * companyName = "projects/foo/tenants/bar/companies/baz" AND
 *                                requisitionId = "req-1"
 *                                * companyName = "projects/foo/tenants/bar/companies/baz" AND
 *                                status = "EXPIRED"
 *                                * requisitionId = "req-1"
 *                                * requisitionId = "req-1" AND status = "EXPIRED"
 */
function list_jobs_sample(string $formattedParent, string $filter): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $request = (new ListJobsRequest())
        ->setParent($formattedParent)
        ->setFilter($filter);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $jobServiceClient->listJobs($request);

        /** @var Job $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');
    $filter = '[FILTER]';

    list_jobs_sample($formattedParent, $filter);
}

searchJobs

Searches for jobs using the provided SearchJobsRequest.

This call constrains the visibility of jobs present in the database, and only returns jobs that the caller has permission to search against.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::searchJobsAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\SearchJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Talent\V4\SearchJobsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\RequestMetadata;
use Google\Cloud\Talent\V4\SearchJobsRequest;
use Google\Cloud\Talent\V4\SearchJobsResponse;

/**
 * @param string $formattedParent The resource name of the tenant to search within.
 *
 *                                The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                "projects/foo/tenants/bar". Please see
 *                                {@see JobServiceClient::tenantName()} for help formatting this field.
 */
function search_jobs_sample(string $formattedParent): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $requestMetadata = new RequestMetadata();
    $request = (new SearchJobsRequest())
        ->setParent($formattedParent)
        ->setRequestMetadata($requestMetadata);

    // Call the API and handle any network failures.
    try {
        /** @var SearchJobsResponse $response */
        $response = $jobServiceClient->searchJobs($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');

    search_jobs_sample($formattedParent);
}

searchJobsForAlert

Searches for jobs using the provided 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), it has different algorithmic adjustments that are designed to specifically target passive job seekers.

This call constrains the visibility of jobs present in the database, and only returns jobs the caller has permission to search against.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::searchJobsForAlertAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\SearchJobsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Talent\V4\SearchJobsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\RequestMetadata;
use Google\Cloud\Talent\V4\SearchJobsRequest;
use Google\Cloud\Talent\V4\SearchJobsResponse;

/**
 * @param string $formattedParent The resource name of the tenant to search within.
 *
 *                                The format is "projects/{project_id}/tenants/{tenant_id}". For example,
 *                                "projects/foo/tenants/bar". Please see
 *                                {@see JobServiceClient::tenantName()} for help formatting this field.
 */
function search_jobs_for_alert_sample(string $formattedParent): void
{
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $requestMetadata = new RequestMetadata();
    $request = (new SearchJobsRequest())
        ->setParent($formattedParent)
        ->setRequestMetadata($requestMetadata);

    // Call the API and handle any network failures.
    try {
        /** @var SearchJobsResponse $response */
        $response = $jobServiceClient->searchJobsForAlert($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedParent = JobServiceClient::tenantName('[PROJECT]', '[TENANT]');

    search_jobs_for_alert_sample($formattedParent);
}

updateJob

Updates specified job.

Typically, updated contents become visible in search results within 10 seconds, but it may take up to 5 minutes.

The async variant is Google\Cloud\Talent\V4\Client\JobServiceClient::updateJobAsync() .

Parameters
Name Description
request Google\Cloud\Talent\V4\UpdateJobRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\Cloud\Talent\V4\Job
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Talent\V4\Client\JobServiceClient;
use Google\Cloud\Talent\V4\Job;
use Google\Cloud\Talent\V4\UpdateJobRequest;

/**
 * @param string $formattedJobCompany The resource name of the company listing the job.
 *
 *                                    The format is
 *                                    "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}". For
 *                                    example, "projects/foo/tenants/bar/companies/baz". Please see
 *                                    {@see JobServiceClient::companyName()} for help formatting this field.
 * @param string $jobRequisitionId    The requisition ID, also referred to as the posting ID, is
 *                                    assigned by the client to identify a job. This field is intended to be used
 *                                    by clients for client identification and tracking of postings. A job isn't
 *                                    allowed to be created if there is another job with the same
 *                                    [company][google.cloud.talent.v4.Job.name],
 *                                    [language_code][google.cloud.talent.v4.Job.language_code] and
 *                                    [requisition_id][google.cloud.talent.v4.Job.requisition_id].
 *
 *                                    The maximum number of allowed characters is 255.
 * @param string $jobTitle            The title of the job, such as "Software Engineer"
 *
 *                                    The maximum number of allowed characters is 500.
 * @param string $jobDescription      The description of the job, which typically includes a
 *                                    multi-paragraph description of the company and related information.
 *                                    Separate fields are provided on the job object for
 *                                    [responsibilities][google.cloud.talent.v4.Job.responsibilities],
 *                                    [qualifications][google.cloud.talent.v4.Job.qualifications], and other job
 *                                    characteristics. Use of these separate job fields is recommended.
 *
 *                                    This field accepts and sanitizes HTML input, and also accepts
 *                                    bold, italic, ordered list, and unordered list markup tags.
 *
 *                                    The maximum number of allowed characters is 100,000.
 */
function update_job_sample(
    string $formattedJobCompany,
    string $jobRequisitionId,
    string $jobTitle,
    string $jobDescription
): void {
    // Create a client.
    $jobServiceClient = new JobServiceClient();

    // Prepare the request message.
    $job = (new Job())
        ->setCompany($formattedJobCompany)
        ->setRequisitionId($jobRequisitionId)
        ->setTitle($jobTitle)
        ->setDescription($jobDescription);
    $request = (new UpdateJobRequest())
        ->setJob($job);

    // Call the API and handle any network failures.
    try {
        /** @var Job $response */
        $response = $jobServiceClient->updateJob($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedJobCompany = JobServiceClient::companyName('[PROJECT]', '[TENANT]', '[COMPANY]');
    $jobRequisitionId = '[REQUISITION_ID]';
    $jobTitle = '[TITLE]';
    $jobDescription = '[DESCRIPTION]';

    update_job_sample($formattedJobCompany, $jobRequisitionId, $jobTitle, $jobDescription);
}

batchCreateJobsAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchCreateJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

batchDeleteJobsAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchDeleteJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

batchUpdateJobsAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\BatchUpdateJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createJobAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\CreateJobRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteJobAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\DeleteJobRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getJobAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\GetJobRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listJobsAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\ListJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

searchJobsAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\SearchJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

searchJobsForAlertAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\SearchJobsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateJobAsync

Parameters
Name Description
request Google\Cloud\Talent\V4\UpdateJobRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::companyName

Formats a string containing the fully-qualified path to represent a company resource.

Parameters
Name Description
project string
tenant string
company string
Returns
Type Description
string The formatted company resource.

static::jobName

Formats a string containing the fully-qualified path to represent a job resource.

Parameters
Name Description
project string
tenant string
job string
Returns
Type Description
string The formatted job resource.

static::tenantName

Formats a string containing the fully-qualified path to represent a tenant resource.

Parameters
Name Description
project string
tenant string
Returns
Type Description
string The formatted tenant resource.

static::parseName

Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported: Template: Pattern

  • company: projects/{project}/tenants/{tenant}/companies/{company}
  • job: projects/{project}/tenants/{tenant}/jobs/{job}
  • tenant: projects/{project}/tenants/{tenant}

The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.

Parameters
Name Description
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
Type Description
array An associative array from name component IDs to component values.