Google Cloud Dialogflow Cx V3 Client - Class TestCasesClient (0.3.4)

Reference documentation and code samples for the Google Cloud Dialogflow Cx V3 Client class TestCasesClient.

Service Description: Service for managing Test Cases and Test Case Results.

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 \ Dialogflow \ Cx \ V3 \ 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.

batchDeleteTestCases

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest

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\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;

/**
 * @param string $formattedParent       The agent to delete test cases from.
 *                                      Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                      {@see TestCasesClient::agentName()} for help formatting this field.
 * @param string $formattedNamesElement Format of test case names: `projects/<Project ID>/locations/
 *                                      <Location ID>/agents/<AgentID>/testCases/<TestCase ID>`. Please see
 *                                      {@see TestCasesClient::testCaseName()} for help formatting this field.
 */
function batch_delete_test_cases_sample(
    string $formattedParent,
    string $formattedNamesElement
): void {
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $formattedNames = [$formattedNamesElement,];
    $request = (new BatchDeleteTestCasesRequest())
        ->setParent($formattedParent)
        ->setNames($formattedNames);

    // Call the API and handle any network failures.
    try {
        $testCasesClient->batchDeleteTestCases($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
{
    $formattedParent = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $formattedNamesElement = TestCasesClient::testCaseName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[TEST_CASE]'
    );

    batch_delete_test_cases_sample($formattedParent, $formattedNamesElement);
}

batchRunTestCases

Kicks off a batch run of test cases.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::batchRunTestCasesAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesRequest

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\Dialogflow\Cx\V3\BatchRunTestCasesRequest;
use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Rpc\Status;

/**
 * @param string $formattedParent           Agent name. Format: `projects/<Project ID>/locations/<Location
 *                                          ID>/agents/ <AgentID>`. Please see
 *                                          {@see TestCasesClient::agentName()} for help formatting this field.
 * @param string $formattedTestCasesElement Format: `projects/<Project ID>/locations/<Location
 *                                          ID>/agents/<Agent ID>/testCases/<TestCase ID>`. Please see
 *                                          {@see TestCasesClient::testCaseName()} for help formatting this field.
 */
function batch_run_test_cases_sample(
    string $formattedParent,
    string $formattedTestCasesElement
): void {
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $formattedTestCases = [$formattedTestCasesElement,];
    $request = (new BatchRunTestCasesRequest())
        ->setParent($formattedParent)
        ->setTestCases($formattedTestCases);

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

        if ($response->operationSucceeded()) {
            /** @var BatchRunTestCasesResponse $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 = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $formattedTestCasesElement = TestCasesClient::testCaseName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[TEST_CASE]'
    );

    batch_run_test_cases_sample($formattedParent, $formattedTestCasesElement);
}

calculateCoverage

Calculates the test coverage for an agent.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::calculateCoverageAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest

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\Dialogflow\Cx\V3\CalculateCoverageResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest;
use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType;
use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;

/**
 * @param string $formattedAgent The agent to calculate coverage for.
 *                               Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                               {@see TestCasesClient::agentName()} for help formatting this field.
 * @param int    $type           The type of coverage requested.
 */
function calculate_coverage_sample(string $formattedAgent, int $type): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $request = (new CalculateCoverageRequest())
        ->setAgent($formattedAgent)
        ->setType($type);

    // Call the API and handle any network failures.
    try {
        /** @var CalculateCoverageResponse $response */
        $response = $testCasesClient->calculateCoverage($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
{
    $formattedAgent = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $type = CoverageType::COVERAGE_TYPE_UNSPECIFIED;

    calculate_coverage_sample($formattedAgent, $type);
}

createTestCase

Creates a test case for the given agent.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::createTestCaseAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest

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\Dialogflow\Cx\V3\TestCase
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;

/**
 * @param string $formattedParent     The agent to create the test case for.
 *                                    Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                    {@see TestCasesClient::agentName()} for help formatting this field.
 * @param string $testCaseDisplayName The human-readable name of the test case, unique within the
 *                                    agent. Limit of 200 characters.
 */
function create_test_case_sample(string $formattedParent, string $testCaseDisplayName): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $testCase = (new TestCase())
        ->setDisplayName($testCaseDisplayName);
    $request = (new CreateTestCaseRequest())
        ->setParent($formattedParent)
        ->setTestCase($testCase);

    // Call the API and handle any network failures.
    try {
        /** @var TestCase $response */
        $response = $testCasesClient->createTestCase($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 = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $testCaseDisplayName = '[DISPLAY_NAME]';

    create_test_case_sample($formattedParent, $testCaseDisplayName);
}

exportTestCases

Exports the test cases under the agent to a Cloud Storage bucket or a local file. Filter can be applied to export a subset of test cases.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::exportTestCasesAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest;
use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The agent where to export test cases from.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see TestCasesClient::agentName()} for help formatting this field.
 */
function export_test_cases_sample(string $formattedParent): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var ExportTestCasesResponse $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 = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');

    export_test_cases_sample($formattedParent);
}

getTestCase

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest

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\Dialogflow\Cx\V3\TestCase
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;

/**
 * @param string $formattedName The name of the testcase.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/testCases/<TestCase ID>`. Please see
 *                              {@see TestCasesClient::testCaseName()} for help formatting this field.
 */
function get_test_case_sample(string $formattedName): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TestCase $response */
        $response = $testCasesClient->getTestCase($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 = TestCasesClient::testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]');

    get_test_case_sample($formattedName);
}

getTestCaseResult

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest

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\Dialogflow\Cx\V3\TestCaseResult
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest;
use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult;

/**
 * @param string $formattedName The name of the testcase.
 *                              Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
 *                              ID>/testCases/<TestCase ID>/results/<TestCaseResult ID>`. Please see
 *                              {@see TestCasesClient::testCaseResultName()} for help formatting this field.
 */
function get_test_case_result_sample(string $formattedName): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var TestCaseResult $response */
        $response = $testCasesClient->getTestCaseResult($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 = TestCasesClient::testCaseResultName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[TEST_CASE]',
        '[RESULT]'
    );

    get_test_case_result_sample($formattedName);
}

importTestCases

Imports the test cases from a Cloud Storage bucket or a local file. It always creates new test cases and won't overwrite any existing ones. The provided ID in the imported test case is neglected.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::importTestCasesAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesRequest;
use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The agent to import test cases to.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see TestCasesClient::agentName()} for help formatting this field.
 */
function import_test_cases_sample(string $formattedParent): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var ImportTestCasesResponse $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 = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');

    import_test_cases_sample($formattedParent);
}

listTestCaseResults

Fetches the list of run results for the given test case. A maximum of 100 results are kept for each test case.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::listTestCaseResultsAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest;
use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult;

/**
 * @param string $formattedParent The test case to list results for.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/
 *                                testCases/<TestCase ID>`. Specify a `-` as a wildcard for TestCase ID to
 *                                list results across multiple test cases. Please see
 *                                {@see TestCasesClient::testCaseName()} for help formatting this field.
 */
function list_test_case_results_sample(string $formattedParent): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

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

        /** @var TestCaseResult $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 = TestCasesClient::testCaseName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[TEST_CASE]'
    );

    list_test_case_results_sample($formattedParent);
}

listTestCases

Fetches a list of test cases for a given agent.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::listTestCasesAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;

/**
 * @param string $formattedParent The agent to list all pages for.
 *                                Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`. Please see
 *                                {@see TestCasesClient::agentName()} for help formatting this field.
 */
function list_test_cases_sample(string $formattedParent): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

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

        /** @var TestCase $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 = TestCasesClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');

    list_test_cases_sample($formattedParent);
}

runTestCase

Kicks off a test case run.

This method is a long-running operation. The returned Operation type has the following method-specific fields:

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::runTestCaseAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\RunTestCaseRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseRequest;
use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName Format of test case name to run: `projects/<Project
 *                              ID>/locations/ <Location ID>/agents/<AgentID>/testCases/<TestCase ID>`. Please see
 *                              {@see TestCasesClient::testCaseName()} for help formatting this field.
 */
function run_test_case_sample(string $formattedName): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var RunTestCaseResponse $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
{
    $formattedName = TestCasesClient::testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]');

    run_test_case_sample($formattedName);
}

updateTestCase

Updates the specified test case.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::updateTestCaseAsync() .

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest

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\Dialogflow\Cx\V3\TestCase
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;
use Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest;
use Google\Protobuf\FieldMask;

/**
 * @param string $testCaseDisplayName The human-readable name of the test case, unique within the
 *                                    agent. Limit of 200 characters.
 */
function update_test_case_sample(string $testCaseDisplayName): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $testCase = (new TestCase())
        ->setDisplayName($testCaseDisplayName);
    $updateMask = new FieldMask();
    $request = (new UpdateTestCaseRequest())
        ->setTestCase($testCase)
        ->setUpdateMask($updateMask);

    // Call the API and handle any network failures.
    try {
        /** @var TestCase $response */
        $response = $testCasesClient->updateTestCase($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
{
    $testCaseDisplayName = '[DISPLAY_NAME]';

    update_test_case_sample($testCaseDisplayName);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;

/**
 * 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 get_location_sample(): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

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

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\Dialogflow\Cx\V3\Client\TestCasesClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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\Dialogflow\Cx\V3\Client\TestCasesClient;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;

/**
 * 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 list_locations_sample(): void
{
    // Create a client.
    $testCasesClient = new TestCasesClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

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

        /** @var Location $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());
    }
}

batchDeleteTestCasesAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\BatchDeleteTestCasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

batchRunTestCasesAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

calculateCoverageAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createTestCaseAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreateTestCaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

exportTestCasesAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getTestCaseAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetTestCaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getTestCaseResultAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetTestCaseResultRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

importTestCasesAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listTestCaseResultsAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListTestCaseResultsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listTestCasesAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

runTestCaseAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\RunTestCaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateTestCaseAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\UpdateTestCaseRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
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::agentName

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

Parameters
Name Description
project string
location string
agent string
Returns
Type Description
string The formatted agent resource.

static::entityTypeName

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

Parameters
Name Description
project string
location string
agent string
entityType string
Returns
Type Description
string The formatted entity_type resource.

static::environmentName

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

Parameters
Name Description
project string
location string
agent string
environment string
Returns
Type Description
string The formatted environment resource.

static::flowName

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

Parameters
Name Description
project string
location string
agent string
flow string
Returns
Type Description
string The formatted flow resource.

static::intentName

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

Parameters
Name Description
project string
location string
agent string
intent string
Returns
Type Description
string The formatted intent resource.

static::pageName

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

Parameters
Name Description
project string
location string
agent string
flow string
page string
Returns
Type Description
string The formatted page resource.

static::projectLocationAgentFlowTransitionRouteGroupName

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

Parameters
Name Description
project string
location string
agent string
flow string
transitionRouteGroup string
Returns
Type Description
string The formatted project_location_agent_flow_transition_route_group resource.

static::projectLocationAgentTransitionRouteGroupName

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

Parameters
Name Description
project string
location string
agent string
transitionRouteGroup string
Returns
Type Description
string The formatted project_location_agent_transition_route_group resource.

static::testCaseName

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

Parameters
Name Description
project string
location string
agent string
testCase string
Returns
Type Description
string The formatted test_case resource.

static::testCaseResultName

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

Parameters
Name Description
project string
location string
agent string
testCase string
result string
Returns
Type Description
string The formatted test_case_result resource.

static::transitionRouteGroupName

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

Parameters
Name Description
project string
location string
agent string
flow string
transitionRouteGroup string
Returns
Type Description
string The formatted transition_route_group resource.

static::webhookName

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

Parameters
Name Description
project string
location string
agent string
webhook string
Returns
Type Description
string The formatted webhook 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

  • agent: projects/{project}/locations/{location}/agents/{agent}
  • entityType: projects/{project}/locations/{location}/agents/{agent}/entityTypes/{entity_type}
  • environment: projects/{project}/locations/{location}/agents/{agent}/environments/{environment}
  • flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}
  • intent: projects/{project}/locations/{location}/agents/{agent}/intents/{intent}
  • page: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/pages/{page}
  • projectLocationAgentFlowTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}
  • projectLocationAgentTransitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/transitionRouteGroups/{transition_route_group}
  • testCase: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}
  • testCaseResult: projects/{project}/locations/{location}/agents/{agent}/testCases/{test_case}/results/{result}
  • transitionRouteGroup: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}/transitionRouteGroups/{transition_route_group}
  • webhook: projects/{project}/locations/{location}/agents/{agent}/webhooks/{webhook}

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.