Google Cloud Ai Platform V1 Client - Class SessionServiceClient (1.52.0)

Reference documentation and code samples for the Google Cloud Ai Platform V1 Client class SessionServiceClient.

Service Description: The service that manages Vertex Session related resources.

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 \ AIPlatform \ V1 \ 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\AIPlatform\V1\SessionServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new SessionServiceClient(['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'.

appendEvent

Appends an event to a given session.

The async variant is SessionServiceClient::appendEventAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\AppendEventRequest

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\AIPlatform\V1\AppendEventResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\AppendEventRequest;
use Google\Cloud\AIPlatform\V1\AppendEventResponse;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\SessionEvent;
use Google\Protobuf\Timestamp;

/**
 * @param string $formattedName     The resource name of the session to append event to.
 *                                  Format:
 *                                  `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
 *                                  Please see {@see SessionServiceClient::sessionName()} for help formatting this field.
 * @param string $eventAuthor       The name of the agent that sent the event, or user.
 * @param string $eventInvocationId The invocation id of the event, multiple events can have the same
 *                                  invocation id.
 */
function append_event_sample(
    string $formattedName,
    string $eventAuthor,
    string $eventInvocationId
): void {
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $eventTimestamp = new Timestamp();
    $event = (new SessionEvent())
        ->setAuthor($eventAuthor)
        ->setInvocationId($eventInvocationId)
        ->setTimestamp($eventTimestamp);
    $request = (new AppendEventRequest())
        ->setName($formattedName)
        ->setEvent($event);

    // Call the API and handle any network failures.
    try {
        /** @var AppendEventResponse $response */
        $response = $sessionServiceClient->appendEvent($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 = SessionServiceClient::sessionName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]',
        '[SESSION]'
    );
    $eventAuthor = '[AUTHOR]';
    $eventInvocationId = '[INVOCATION_ID]';

    append_event_sample($formattedName, $eventAuthor, $eventInvocationId);
}

createSession

Creates a new Session.

The async variant is SessionServiceClient::createSessionAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\CreateSessionRequest

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\AIPlatform\V1\Session>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\CreateSessionRequest;
use Google\Cloud\AIPlatform\V1\Session;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The resource name of the location to create the session in.
 *                                Format:
 *                                `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`
 *                                Please see {@see SessionServiceClient::reasoningEngineName()} for help formatting this field.
 * @param string $sessionUserId   Immutable. String id provided by the user
 */
function create_session_sample(string $formattedParent, string $sessionUserId): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $session = (new Session())
        ->setUserId($sessionUserId);
    $request = (new CreateSessionRequest())
        ->setParent($formattedParent)
        ->setSession($session);

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

        if ($response->operationSucceeded()) {
            /** @var Session $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 = SessionServiceClient::reasoningEngineName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]'
    );
    $sessionUserId = '[USER_ID]';

    create_session_sample($formattedParent, $sessionUserId);
}

deleteSession

Deletes details of the specific Session.

The async variant is SessionServiceClient::deleteSessionAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\DeleteSessionRequest

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<null>
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\DeleteSessionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The resource name of the session.
 *                              Format:
 *                              `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
 *                              Please see {@see SessionServiceClient::sessionName()} for help formatting this field.
 */
function delete_session_sample(string $formattedName): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

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

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

        if ($response->operationSucceeded()) {
            printf('Operation completed successfully.' . PHP_EOL);
        } 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 = SessionServiceClient::sessionName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]',
        '[SESSION]'
    );

    delete_session_sample($formattedName);
}

getSession

Gets details of the specific Session.

The async variant is SessionServiceClient::getSessionAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\GetSessionRequest

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\AIPlatform\V1\Session
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\GetSessionRequest;
use Google\Cloud\AIPlatform\V1\Session;

/**
 * @param string $formattedName The resource name of the session.
 *                              Format:
 *                              `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
 *                              Please see {@see SessionServiceClient::sessionName()} for help formatting this field.
 */
function get_session_sample(string $formattedName): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Session $response */
        $response = $sessionServiceClient->getSession($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 = SessionServiceClient::sessionName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]',
        '[SESSION]'
    );

    get_session_sample($formattedName);
}

listEvents

Lists Events in a given session.

The async variant is SessionServiceClient::listEventsAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\ListEventsRequest

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\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\ListEventsRequest;
use Google\Cloud\AIPlatform\V1\SessionEvent;

/**
 * @param string $formattedParent The resource name of the session to list events from.
 *                                Format:
 *                                `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
 *                                Please see {@see SessionServiceClient::sessionName()} for help formatting this field.
 */
function list_events_sample(string $formattedParent): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

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

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

        /** @var SessionEvent $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 = SessionServiceClient::sessionName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]',
        '[SESSION]'
    );

    list_events_sample($formattedParent);
}

listSessions

Lists Sessions in a given reasoning engine.

The async variant is SessionServiceClient::listSessionsAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\ListSessionsRequest

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\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\ListSessionsRequest;
use Google\Cloud\AIPlatform\V1\Session;

/**
 * @param string $formattedParent The resource name of the location to list sessions from.
 *                                Format:
 *                                `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`
 *                                Please see {@see SessionServiceClient::reasoningEngineName()} for help formatting this field.
 */
function list_sessions_sample(string $formattedParent): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

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

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

        /** @var Session $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 = SessionServiceClient::reasoningEngineName(
        '[PROJECT]',
        '[LOCATION]',
        '[REASONING_ENGINE]'
    );

    list_sessions_sample($formattedParent);
}

updateSession

Updates the specific Session.

The async variant is SessionServiceClient::updateSessionAsync() .

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\UpdateSessionRequest

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\AIPlatform\V1\Session
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\AIPlatform\V1\Session;
use Google\Cloud\AIPlatform\V1\UpdateSessionRequest;

/**
 * @param string $sessionUserId Immutable. String id provided by the user
 */
function update_session_sample(string $sessionUserId): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $session = (new Session())
        ->setUserId($sessionUserId);
    $request = (new UpdateSessionRequest())
        ->setSession($session);

    // Call the API and handle any network failures.
    try {
        /** @var Session $response */
        $response = $sessionServiceClient->updateSession($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
{
    $sessionUserId = '[USER_ID]';

    update_session_sample($sessionUserId);
}

getLocation

Gets information about a location.

The async variant is SessionServiceClient::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\AIPlatform\V1\Client\SessionServiceClient;
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.
    $sessionServiceClient = new SessionServiceClient();

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

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

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

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

getIamPolicy

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

The async variant is SessionServiceClient::getIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\Iam\V1\GetIamPolicyRequest;
use Google\Cloud\Iam\V1\Policy;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being requested.
 *                         See the operation documentation for the appropriate value for this field.
 */
function get_iam_policy_sample(string $resource): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $request = (new GetIamPolicyRequest())
        ->setResource($resource);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $sessionServiceClient->getIamPolicy($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
{
    $resource = '[RESOURCE]';

    get_iam_policy_sample($resource);
}

setIamPolicy

Sets the access control policy on the specified resource. Replaces any existing policy.

Can return NOT_FOUND, INVALID_ARGUMENT, and PERMISSION_DENIED errors.

The async variant is SessionServiceClient::setIamPolicyAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest

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\Iam\V1\Policy
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\Iam\V1\Policy;
use Google\Cloud\Iam\V1\SetIamPolicyRequest;

/**
 * @param string $resource REQUIRED: The resource for which the policy is being specified.
 *                         See the operation documentation for the appropriate value for this field.
 */
function set_iam_policy_sample(string $resource): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $policy = new Policy();
    $request = (new SetIamPolicyRequest())
        ->setResource($resource)
        ->setPolicy($policy);

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $sessionServiceClient->setIamPolicy($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
{
    $resource = '[RESOURCE]';

    set_iam_policy_sample($resource);
}

testIamPermissions

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.

The async variant is SessionServiceClient::testIamPermissionsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest

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\Iam\V1\TestIamPermissionsResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\AIPlatform\V1\Client\SessionServiceClient;
use Google\Cloud\Iam\V1\TestIamPermissionsRequest;
use Google\Cloud\Iam\V1\TestIamPermissionsResponse;

/**
 * @param string $resource           REQUIRED: The resource for which the policy detail is being requested.
 *                                   See the operation documentation for the appropriate value for this field.
 * @param string $permissionsElement The set of permissions to check for the `resource`. Permissions with
 *                                   wildcards (such as '*' or 'storage.*') are not allowed. For more
 *                                   information see
 *                                   [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
 */
function test_iam_permissions_sample(string $resource, string $permissionsElement): void
{
    // Create a client.
    $sessionServiceClient = new SessionServiceClient();

    // Prepare the request message.
    $permissions = [$permissionsElement,];
    $request = (new TestIamPermissionsRequest())
        ->setResource($resource)
        ->setPermissions($permissions);

    // Call the API and handle any network failures.
    try {
        /** @var TestIamPermissionsResponse $response */
        $response = $sessionServiceClient->testIamPermissions($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
{
    $resource = '[RESOURCE]';
    $permissionsElement = '[PERMISSIONS]';

    test_iam_permissions_sample($resource, $permissionsElement);
}

appendEventAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\AppendEventRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AIPlatform\V1\AppendEventResponse>

createSessionAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\CreateSessionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deleteSessionAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\DeleteSessionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getSessionAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\GetSessionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AIPlatform\V1\Session>

listEventsAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\ListEventsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

listSessionsAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\ListSessionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updateSessionAsync

Parameters
Name Description
request Google\Cloud\AIPlatform\V1\UpdateSessionRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\AIPlatform\V1\Session>

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>

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\Policy>

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V1\TestIamPermissionsResponse>

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

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

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

static::sessionName

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

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

static::sessionEventName

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

Parameters
Name Description
project string
location string
reasoningEngine string
session string
event string
Returns
Type Description
string The formatted session_event 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

  • reasoningEngine: projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}
  • session: projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}
  • sessionEvent: projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}/events/{event}

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.