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. Sample code to get started:
$testCasesClient = new TestCasesClient();
try {
$formattedParent = $testCasesClient->agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
$formattedNames = [
$testCasesClient->testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]'),
];
$testCasesClient->batchDeleteTestCases($formattedParent, $formattedNames);
} finally {
$testCasesClient->close();
}
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Namespace
Google \ Cloud \ Dialogflow \ Cx \ V3Methods
__construct
Constructor.
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
Batch deletes test cases.
parent
string
Required. The agent to delete test cases from.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
names
string[]
Required. Format of test case names: projects/<Project ID>/locations/
<Location ID>/agents/<AgentID>/testCases/<TestCase ID>
.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\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 any non-scalar elements to be passed along with the request.
$formattedNames = [$formattedNamesElement,];
// Call the API and handle any network failures.
try {
$testCasesClient->batchDeleteTestCases($formattedParent, $formattedNames);
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:
-
metadata
: BatchRunTestCasesMetadata -
response
: BatchRunTestCasesResponse
parent
string
Required. Agent name. Format: projects/<Project ID>/locations/<Location
ID>/agents/ <AgentID>
.
testCases
string[]
Required. Format: projects/<Project ID>/locations/<Location
ID>/agents/<Agent ID>/testCases/<TestCase ID>
.
optionalArgs
array
Optional.
↳ environment
string
Optional. If not set, draft environment is assumed. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID>
.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\BatchRunTestCasesResponse;
use Google\Cloud\Dialogflow\Cx\V3\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 any non-scalar elements to be passed along with the request.
$formattedTestCases = [$formattedTestCasesElement,];
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $testCasesClient->batchRunTestCases($formattedParent, $formattedTestCases);
$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.
agent
string
Required. The agent to calculate coverage for.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
type
int
Required. The type of coverage requested. For allowed values, use constants defined on Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageRequest\CoverageType;
use Google\Cloud\Dialogflow\Cx\V3\CalculateCoverageResponse;
use Google\Cloud\Dialogflow\Cx\V3\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();
// Call the API and handle any network failures.
try {
/** @var CalculateCoverageResponse $response */
$response = $testCasesClient->calculateCoverage($formattedAgent, $type);
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.
parent
string
Required. The agent to create the test case for.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
testCase
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
/**
* @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 any non-scalar elements to be passed along with the request.
$testCase = (new TestCase())
->setDisplayName($testCaseDisplayName);
// Call the API and handle any network failures.
try {
/** @var TestCase $response */
$response = $testCasesClient->createTestCase($formattedParent, $testCase);
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:
-
metadata
: ExportTestCasesMetadata -
response
: ExportTestCasesResponse
parent
string
Required. The agent where to export test cases from.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
optionalArgs
array
Optional.
↳ gcsUri
string
The Google Cloud Storage
URI to export the test cases to. The format of this URI must be gs://<bucket-name>/<object-name>
. If unspecified, the serialized test cases is returned inline. Dialogflow performs a write operation for the Cloud Storage object on the caller's behalf, so your request authentication must have write permissions for the object. For more information, see Dialogflow access control
.
↳ dataFormat
int
The data format of the exported test cases. If not specified, BLOB
is assumed. For allowed values, use constants defined on Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesRequest\DataFormat
↳ filter
string
The filter expression used to filter exported test cases, see API Filtering . The expression is case insensitive and supports the following syntax: name =
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\ExportTestCasesResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $testCasesClient->exportTestCases($formattedParent);
$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
Gets a test case.
name
string
Required. The name of the testcase.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent
ID>/testCases/<TestCase ID>
.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var TestCase $response */
$response = $testCasesClient->getTestCase($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = TestCasesClient::testCaseName('[PROJECT]', '[LOCATION]', '[AGENT]', '[TEST_CASE]');
get_test_case_sample($formattedName);
}
getTestCaseResult
Gets a test case result.
name
string
Required. The name of the testcase.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent
ID>/testCases/<TestCase ID>/results/<TestCaseResult ID>
.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var TestCaseResult $response */
$response = $testCasesClient->getTestCaseResult($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = 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:
-
metadata
: ImportTestCasesMetadata -
response
: ImportTestCasesResponse
parent
string
Required. The agent to import test cases to.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
optionalArgs
array
Optional.
↳ gcsUri
string
The Google Cloud Storage
URI to import test cases from. The format of this URI must be gs://<bucket-name>/<object-name>
. Dialogflow performs a read operation for the Cloud Storage object on the caller's behalf, so your request authentication must have read permissions for the object. For more information, see Dialogflow access control
.
↳ content
string
Uncompressed raw byte content for test cases.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\ImportTestCasesResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $testCasesClient->importTestCases($formattedParent);
$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.
parent
string
Required. 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.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ filter
string
The filter expression used to filter test case results. See API Filtering . The expression is case insensitive. Only 'AND' is supported for logical operators. The supported syntax is listed below in detail:
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCaseResult;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $testCasesClient->listTestCaseResults($formattedParent);
/** @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.
parent
string
Required. The agent to list all pages for.
Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>
.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ view
int
Specifies whether response should include all fields or just the metadata. For allowed values, use constants defined on Google\Cloud\Dialogflow\Cx\V3\ListTestCasesRequest\TestCaseView
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $testCasesClient->listTestCases($formattedParent);
/** @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:
-
metadata
: RunTestCaseMetadata -
response
: RunTestCaseResponse
name
string
Required. Format of test case name to run: projects/<Project
ID>/locations/ <Location ID>/agents/<AgentID>/testCases/<TestCase ID>
.
optionalArgs
array
Optional.
↳ environment
string
Optional. Environment name. If not set, draft environment is assumed. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/environments/<Environment ID>
.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\RunTestCaseResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $testCasesClient->runTestCase($formattedName);
$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.
testCase
updateMask
Google\Protobuf\FieldMask
Required. The mask to specify which fields should be updated. The creationTime
and lastTestResult
cannot be updated.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\TestCase;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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 any non-scalar elements to be passed along with the request.
$testCase = (new TestCase())
->setDisplayName($testCaseDisplayName);
$updateMask = new FieldMask();
// Call the API and handle any network failures.
try {
/** @var TestCase $response */
$response = $testCasesClient->updateTestCase($testCase, $updateMask);
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.
optionalArgs
array
Optional.
↳ name
string
Resource name for the location.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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();
// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $testCasesClient->getLocation();
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.
optionalArgs
array
Optional.
↳ name
string
The resource that owns the locations collection, if applicable.
↳ filter
string
The standard list filter.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dialogflow\Cx\V3\TestCasesClient;
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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $testCasesClient->listLocations();
/** @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());
}
}
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
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.
operationName
string
The name of the long running operation
methodName
string
The name of the method used to start the operation
static::agentName
Formats a string containing the fully-qualified path to represent a agent resource.
project
string
location
string
agent
string
string
static::entityTypeName
Formats a string containing the fully-qualified path to represent a entity_type resource.
project
string
location
string
agent
string
entityType
string
string
static::environmentName
Formats a string containing the fully-qualified path to represent a environment resource.
project
string
location
string
agent
string
environment
string
string
static::flowName
Formats a string containing the fully-qualified path to represent a flow resource.
project
string
location
string
agent
string
flow
string
string
static::intentName
Formats a string containing the fully-qualified path to represent a intent resource.
project
string
location
string
agent
string
intent
string
string
static::pageName
Formats a string containing the fully-qualified path to represent a page resource.
project
string
location
string
agent
string
flow
string
page
string
string
static::projectLocationAgentFlowTransitionRouteGroupName
Formats a string containing the fully-qualified path to represent a project_location_agent_flow_transition_route_group resource.
project
string
location
string
agent
string
flow
string
transitionRouteGroup
string
string
static::projectLocationAgentTransitionRouteGroupName
Formats a string containing the fully-qualified path to represent a project_location_agent_transition_route_group resource.
project
string
location
string
agent
string
transitionRouteGroup
string
string
static::testCaseName
Formats a string containing the fully-qualified path to represent a test_case resource.
project
string
location
string
agent
string
testCase
string
string
static::testCaseResultName
Formats a string containing the fully-qualified path to represent a test_case_result resource.
project
string
location
string
agent
string
testCase
string
result
string
string
static::transitionRouteGroupName
Formats a string containing the fully-qualified path to represent a transition_route_group resource.
project
string
location
string
agent
string
flow
string
transitionRouteGroup
string
string
static::webhookName
Formats a string containing the fully-qualified path to represent a webhook resource.
project
string
location
string
agent
string
webhook
string
string
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.
formattedName
string
The formatted name string
template
string
Optional name of template to match
array
Constants
SERVICE_NAME
Value: 'google.cloud.dialogflow.cx.v3.TestCases'
The name of the service.
SERVICE_ADDRESS
Value: 'dialogflow.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.