Google Cloud Dialogflow Cx V3 Client - Class PlaybooksClient (0.10.1)

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

Service Description: Service for managing Playbooks.

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|Google\ApiCore\Options\ClientOptions

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 FetchAuthTokenInterface|CredentialsWrapper

This option should only be used with a pre-constructed Google\Auth\FetchAuthTokenInterface or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. Important: If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Cloud\Dialogflow\Cx\V3\PlaybooksClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new PlaybooksClient(['credentials' => $creds]); 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

↳ universeDomain string

The service domain for the client. Defaults to 'googleapis.com'.

createPlaybook

Creates a playbook in a specified agent.

The async variant is PlaybooksClient::createPlaybookAsync() .

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

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\Playbook
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\CreatePlaybookRequest;
use Google\Cloud\Dialogflow\Cx\V3\Playbook;

/**
 * @param string $formattedParent     The agent to create a playbook for.
 *                                    Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Please see
 *                                    {@see PlaybooksClient::agentName()} for help formatting this field.
 * @param string $playbookDisplayName The human-readable name of the playbook, unique within an agent.
 * @param string $playbookGoal        High level description of the goal the playbook intend to
 *                                    accomplish. A goal should be concise since it's visible to other playbooks
 *                                    that may reference this playbook.
 */
function create_playbook_sample(
    string $formattedParent,
    string $playbookDisplayName,
    string $playbookGoal
): void {
    // Create a client.
    $playbooksClient = new PlaybooksClient();

    // Prepare the request message.
    $playbook = (new Playbook())
        ->setDisplayName($playbookDisplayName)
        ->setGoal($playbookGoal);
    $request = (new CreatePlaybookRequest())
        ->setParent($formattedParent)
        ->setPlaybook($playbook);

    // Call the API and handle any network failures.
    try {
        /** @var Playbook $response */
        $response = $playbooksClient->createPlaybook($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 = PlaybooksClient::agentName('[PROJECT]', '[LOCATION]', '[AGENT]');
    $playbookDisplayName = '[DISPLAY_NAME]';
    $playbookGoal = '[GOAL]';

    create_playbook_sample($formattedParent, $playbookDisplayName, $playbookGoal);
}

createPlaybookVersion

Creates a version for the specified Playbook.

The async variant is PlaybooksClient::createPlaybookVersionAsync() .

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

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\PlaybookVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\CreatePlaybookVersionRequest;
use Google\Cloud\Dialogflow\Cx\V3\PlaybookVersion;

/**
 * @param string $formattedParent The playbook to create a version for.
 *                                Format:
 *                                `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. Please see
 *                                {@see PlaybooksClient::playbookName()} for help formatting this field.
 */
function create_playbook_version_sample(string $formattedParent): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

    // Prepare the request message.
    $playbookVersion = new PlaybookVersion();
    $request = (new CreatePlaybookVersionRequest())
        ->setParent($formattedParent)
        ->setPlaybookVersion($playbookVersion);

    // Call the API and handle any network failures.
    try {
        /** @var PlaybookVersion $response */
        $response = $playbooksClient->createPlaybookVersion($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 = PlaybooksClient::playbookName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[PLAYBOOK]'
    );

    create_playbook_version_sample($formattedParent);
}

deletePlaybook

Deletes a specified playbook.

The async variant is PlaybooksClient::deletePlaybookAsync() .

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

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

/**
 * @param string $formattedName The name of the playbook to delete.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. Please see
 *                              {@see PlaybooksClient::playbookName()} for help formatting this field.
 */
function delete_playbook_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

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

    delete_playbook_sample($formattedName);
}

deletePlaybookVersion

Deletes the specified version of the Playbook.

The async variant is PlaybooksClient::deletePlaybookVersionAsync() .

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

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

/**
 * @param string $formattedName The name of the playbook version to delete.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/versions/<VersionID>`. Please see
 *                              {@see PlaybooksClient::playbookVersionName()} for help formatting this field.
 */
function delete_playbook_version_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

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

    delete_playbook_version_sample($formattedName);
}

exportPlaybook

Exports the specified playbook to a binary file.

Note that resources (e.g. examples, tools) that the playbook references will also be exported.

The async variant is PlaybooksClient::exportPlaybookAsync() .

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

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<Google\Cloud\Dialogflow\Cx\V3\ExportPlaybookResponse>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\ExportPlaybookRequest;
use Google\Cloud\Dialogflow\Cx\V3\ExportPlaybookResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the playbook to export.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. Please see
 *                              {@see PlaybooksClient::playbookName()} for help formatting this field.
 */
function export_playbook_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

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

    export_playbook_sample($formattedName);
}

getPlaybook

Retrieves the specified Playbook.

The async variant is PlaybooksClient::getPlaybookAsync() .

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

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\Playbook
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\GetPlaybookRequest;
use Google\Cloud\Dialogflow\Cx\V3\Playbook;

/**
 * @param string $formattedName The name of the playbook.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. Please see
 *                              {@see PlaybooksClient::playbookName()} for help formatting this field.
 */
function get_playbook_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Playbook $response */
        $response = $playbooksClient->getPlaybook($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 = PlaybooksClient::playbookName('[PROJECT]', '[LOCATION]', '[AGENT]', '[PLAYBOOK]');

    get_playbook_sample($formattedName);
}

getPlaybookVersion

Retrieves the specified version of the Playbook.

The async variant is PlaybooksClient::getPlaybookVersionAsync() .

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

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\PlaybookVersion
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\GetPlaybookVersionRequest;
use Google\Cloud\Dialogflow\Cx\V3\PlaybookVersion;

/**
 * @param string $formattedName The name of the playbook version.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/versions/<VersionID>`. Please see
 *                              {@see PlaybooksClient::playbookVersionName()} for help formatting this field.
 */
function get_playbook_version_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PlaybookVersion $response */
        $response = $playbooksClient->getPlaybookVersion($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 = PlaybooksClient::playbookVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[PLAYBOOK]',
        '[VERSION]'
    );

    get_playbook_version_sample($formattedName);
}

importPlaybook

Imports the specified playbook to the specified agent from a binary file.

The async variant is PlaybooksClient::importPlaybookAsync() .

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

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<Google\Cloud\Dialogflow\Cx\V3\ImportPlaybookResponse>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\ImportPlaybookRequest;
use Google\Cloud\Dialogflow\Cx\V3\ImportPlaybookResponse;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The agent to import the playbook into.
 *                                Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Please see
 *                                {@see PlaybooksClient::agentName()} for help formatting this field.
 */
function import_playbook_sample(string $formattedParent): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

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

    import_playbook_sample($formattedParent);
}

listPlaybookVersions

Lists versions for the specified Playbook.

The async variant is PlaybooksClient::listPlaybookVersionsAsync() .

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

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\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\ListPlaybookVersionsRequest;
use Google\Cloud\Dialogflow\Cx\V3\PlaybookVersion;

/**
 * @param string $formattedParent The playbook to list versions for.
 *                                Format:
 *                                `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>`. Please see
 *                                {@see PlaybooksClient::playbookName()} for help formatting this field.
 */
function list_playbook_versions_sample(string $formattedParent): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

        /** @var PlaybookVersion $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 = PlaybooksClient::playbookName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[PLAYBOOK]'
    );

    list_playbook_versions_sample($formattedParent);
}

listPlaybooks

Returns a list of playbooks in the specified agent.

The async variant is PlaybooksClient::listPlaybooksAsync() .

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

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\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\ListPlaybooksRequest;
use Google\Cloud\Dialogflow\Cx\V3\Playbook;

/**
 * @param string $formattedParent The agent to list playbooks from.
 *                                Format: `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>`. Please see
 *                                {@see PlaybooksClient::agentName()} for help formatting this field.
 */
function list_playbooks_sample(string $formattedParent): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

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

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

    list_playbooks_sample($formattedParent);
}

restorePlaybookVersion

Retrieves the specified version of the Playbook and stores it as the current playbook draft, returning the playbook with resources updated.

The async variant is PlaybooksClient::restorePlaybookVersionAsync() .

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

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\RestorePlaybookVersionResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\RestorePlaybookVersionRequest;
use Google\Cloud\Dialogflow\Cx\V3\RestorePlaybookVersionResponse;

/**
 * @param string $formattedName The name of the playbook version.
 *                              Format:
 *                              `projects/<ProjectID>/locations/<LocationID>/agents/<AgentID>/playbooks/<PlaybookID>/versions/<VersionID>`. Please see
 *                              {@see PlaybooksClient::playbookVersionName()} for help formatting this field.
 */
function restore_playbook_version_sample(string $formattedName): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var RestorePlaybookVersionResponse $response */
        $response = $playbooksClient->restorePlaybookVersion($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 = PlaybooksClient::playbookVersionName(
        '[PROJECT]',
        '[LOCATION]',
        '[AGENT]',
        '[PLAYBOOK]',
        '[VERSION]'
    );

    restore_playbook_version_sample($formattedName);
}

updatePlaybook

Updates the specified Playbook.

The async variant is PlaybooksClient::updatePlaybookAsync() .

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

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\Playbook
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Dialogflow\Cx\V3\Client\PlaybooksClient;
use Google\Cloud\Dialogflow\Cx\V3\Playbook;
use Google\Cloud\Dialogflow\Cx\V3\UpdatePlaybookRequest;

/**
 * @param string $playbookDisplayName The human-readable name of the playbook, unique within an agent.
 * @param string $playbookGoal        High level description of the goal the playbook intend to
 *                                    accomplish. A goal should be concise since it's visible to other playbooks
 *                                    that may reference this playbook.
 */
function update_playbook_sample(string $playbookDisplayName, string $playbookGoal): void
{
    // Create a client.
    $playbooksClient = new PlaybooksClient();

    // Prepare the request message.
    $playbook = (new Playbook())
        ->setDisplayName($playbookDisplayName)
        ->setGoal($playbookGoal);
    $request = (new UpdatePlaybookRequest())
        ->setPlaybook($playbook);

    // Call the API and handle any network failures.
    try {
        /** @var Playbook $response */
        $response = $playbooksClient->updatePlaybook($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
{
    $playbookDisplayName = '[DISPLAY_NAME]';
    $playbookGoal = '[GOAL]';

    update_playbook_sample($playbookDisplayName, $playbookGoal);
}

getLocation

Gets information about a location.

The async variant is PlaybooksClient::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\PlaybooksClient;
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.
    $playbooksClient = new PlaybooksClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Location $response */
        $response = $playbooksClient->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 PlaybooksClient::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\PlaybooksClient;
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.
    $playbooksClient = new PlaybooksClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $playbooksClient->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());
    }
}

createPlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreatePlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\Playbook>

createPlaybookVersionAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\CreatePlaybookVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\PlaybookVersion>

deletePlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\DeletePlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

deletePlaybookVersionAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\DeletePlaybookVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<void>

exportPlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ExportPlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getPlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetPlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\Playbook>

getPlaybookVersionAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\GetPlaybookVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\PlaybookVersion>

importPlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ImportPlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

listPlaybookVersionsAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListPlaybookVersionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listPlaybooksAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\ListPlaybooksRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

restorePlaybookVersionAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\RestorePlaybookVersionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\RestorePlaybookVersionResponse>

updatePlaybookAsync

Parameters
Name Description
request Google\Cloud\Dialogflow\Cx\V3\UpdatePlaybookRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Dialogflow\Cx\V3\Playbook>

getLocationAsync

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Location\Location>

listLocationsAsync

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

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::exampleName

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

Parameters
Name Description
project string
location string
agent string
playbook string
example string
Returns
Type Description
string The formatted example 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::generatorName

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

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

static::playbookName

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

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

static::playbookVersionName

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

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

static::toolName

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

Parameters
Name Description
project string
location string
agent string
tool string
Returns
Type Description
string The formatted tool 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}
  • example: projects/{project}/locations/{location}/agents/{agent}/playbooks/{playbook}/examples/{example}
  • flow: projects/{project}/locations/{location}/agents/{agent}/flows/{flow}
  • generator: projects/{project}/locations/{location}/agents/{agent}/generators/{generator}
  • playbook: projects/{project}/locations/{location}/agents/{agent}/playbooks/{playbook}
  • playbookVersion: projects/{project}/locations/{location}/agents/{agent}/playbooks/{playbook}/versions/{version}
  • tool: projects/{project}/locations/{location}/agents/{agent}/tools/{tool}
  • 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.