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 \ ClientMethods
__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. Important : If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials
↳ 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.
↳ logger
false|LoggerInterface
A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag
batchDeleteTestCases
Batch deletes test cases.
The async variant is TestCasesClient::batchDeleteTestCasesAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Please see
* {@see TestCasesClient::agentName()} for help formatting this field.
* @param string $formattedNamesElement Format of test case names:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>`. 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:
-
metadata
: BatchRunTestCasesMetadata -
response
: BatchRunTestCasesResponse
The async variant is TestCasesClient::batchRunTestCasesAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Please see
* {@see TestCasesClient::agentName()} for help formatting this field.
* @param string $formattedTestCasesElement Format:
* `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>`. 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 TestCasesClient::calculateCoverageAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. 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 TestCasesClient::createTestCaseAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. 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:
-
metadata
: ExportTestCasesMetadata -
response
: ExportTestCasesResponse
The async variant is TestCasesClient::exportTestCasesAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. 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
Gets a test case.
The async variant is TestCasesClient::getTestCaseAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>`. 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
Gets a test case result.
The async variant is TestCasesClient::getTestCaseResultAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>/results/<TestCaseResultID>`. 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:
-
metadata
: ImportTestCasesMetadata -
response
: ImportTestCasesResponse
The async variant is TestCasesClient::importTestCasesAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. 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 TestCasesClient::listTestCaseResultsAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>`.
* 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 TestCasesClient::listTestCasesAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. 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:
-
metadata
: RunTestCaseMetadata -
response
: RunTestCaseResponse
The async variant is TestCasesClient::runTestCaseAsync() .
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.
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/<ProjectID>/locations/<LocationID>/agents/<AgentID>/testCases/<TestCaseID>`. 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 TestCasesClient::updateTestCaseAsync() .
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.
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 TestCasesClient::getLocationAsync() .
request
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.
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 TestCasesClient::listLocationsAsync() .
request
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.
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
optionalArgs
array
batchRunTestCasesAsync
optionalArgs
array
calculateCoverageAsync
optionalArgs
array
createTestCaseAsync
optionalArgs
array
exportTestCasesAsync
optionalArgs
array
getTestCaseAsync
optionalArgs
array
getTestCaseResultAsync
optionalArgs
array
importTestCasesAsync
optionalArgs
array
listTestCaseResultsAsync
optionalArgs
array
listTestCasesAsync
optionalArgs
array
runTestCaseAsync
optionalArgs
array
updateTestCaseAsync
optionalArgs
array
getLocationAsync
listLocationsAsync
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
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.
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