Google Cloud Eventarc V1 Client - Class EventarcClient (1.3.5)

Reference documentation and code samples for the Google Cloud Eventarc V1 Client class EventarcClient.

Service Description: Eventarc allows users to subscribe to various events that are provided by Google Cloud services and forward them to supported destinations.

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 \ Eventarc \ V1 \ Client

Methods

__construct

Constructor.

Parameters
Name Description
options array

Optional. Options for configuring the service API wrapper.

↳ apiEndpoint string

The address of the API remote host. May optionally include the port, formatted as "

↳ credentials string|array|FetchAuthTokenInterface|CredentialsWrapper

The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

↳ disableRetries bool

Determines whether or not retries defined by the client configuration should be disabled. Defaults to false.

↳ clientConfig string|array

Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.

↳ transport string|TransportInterface

The transport used for executing network requests. May be either the string rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ transportConfig array

Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.

↳ clientCertSource callable

A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.

createChannel

Create a new channel in a particular project and location.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::createChannelAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateChannelRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\CreateChannelRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent The parent collection in which to add this channel. Please see
 *                                {@see EventarcClient::locationName()} for help formatting this field.
 * @param string $channelName     The resource name of the channel. Must be unique within the
 *                                location on the project and must be in
 *                                `projects/{project}/locations/{location}/channels/{channel_id}` format.
 * @param string $channelId       The user-provided ID to be assigned to the channel.
 * @param bool   $validateOnly    If set, validate the request and preview the review, but do not
 *                                post it.
 */
function create_channel_sample(
    string $formattedParent,
    string $channelName,
    string $channelId,
    bool $validateOnly
): void {
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $channel = (new Channel())
        ->setName($channelName);
    $request = (new CreateChannelRequest())
        ->setParent($formattedParent)
        ->setChannel($channel)
        ->setChannelId($channelId)
        ->setValidateOnly($validateOnly);

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

        if ($response->operationSucceeded()) {
            /** @var Channel $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');
    $channelName = '[NAME]';
    $channelId = '[CHANNEL_ID]';
    $validateOnly = false;

    create_channel_sample($formattedParent, $channelName, $channelId, $validateOnly);
}

createChannelConnection

Create a new ChannelConnection in a particular project and location.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::createChannelConnectionAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateChannelConnectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\CreateChannelConnectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedParent                   The parent collection in which to add this channel connection. Please see
 *                                                  {@see EventarcClient::locationName()} for help formatting this field.
 * @param string $channelConnectionName             The name of the connection.
 * @param string $formattedChannelConnectionChannel The name of the connected subscriber Channel.
 *                                                  This is a weak reference to avoid cross project and cross accounts
 *                                                  references. This must be in
 *                                                  `projects/{project}/location/{location}/channels/{channel_id}` format. Please see
 *                                                  {@see EventarcClient::channelName()} for help formatting this field.
 * @param string $channelConnectionId               The user-provided ID to be assigned to the channel connection.
 */
function create_channel_connection_sample(
    string $formattedParent,
    string $channelConnectionName,
    string $formattedChannelConnectionChannel,
    string $channelConnectionId
): void {
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $channelConnection = (new ChannelConnection())
        ->setName($channelConnectionName)
        ->setChannel($formattedChannelConnectionChannel);
    $request = (new CreateChannelConnectionRequest())
        ->setParent($formattedParent)
        ->setChannelConnection($channelConnection)
        ->setChannelConnectionId($channelConnectionId);

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

        if ($response->operationSucceeded()) {
            /** @var ChannelConnection $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');
    $channelConnectionName = '[NAME]';
    $formattedChannelConnectionChannel = EventarcClient::channelName(
        '[PROJECT]',
        '[LOCATION]',
        '[CHANNEL]'
    );
    $channelConnectionId = '[CHANNEL_CONNECTION_ID]';

    create_channel_connection_sample(
        $formattedParent,
        $channelConnectionName,
        $formattedChannelConnectionChannel,
        $channelConnectionId
    );
}

createTrigger

Create a new trigger in a particular project and location.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::createTriggerAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateTriggerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\CreateTriggerRequest;
use Google\Cloud\Eventarc\V1\Destination;
use Google\Cloud\Eventarc\V1\EventFilter;
use Google\Cloud\Eventarc\V1\Trigger;
use Google\Rpc\Status;

/**
 * @param string $formattedParent              The parent collection in which to add this trigger. Please see
 *                                             {@see EventarcClient::locationName()} for help formatting this field.
 * @param string $triggerName                  The resource name of the trigger. Must be unique within the location of the
 *                                             project and must be in
 *                                             `projects/{project}/locations/{location}/triggers/{trigger}` format.
 * @param string $triggerEventFiltersAttribute The name of a CloudEvents attribute. Currently, only a subset of attributes
 *                                             are supported for filtering.
 *
 *                                             All triggers MUST provide a filter for the 'type' attribute.
 * @param string $triggerEventFiltersValue     The value for the attribute.
 * @param string $triggerId                    The user-provided ID to be assigned to the trigger.
 * @param bool   $validateOnly                 If set, validate the request and preview the review, but do not
 *                                             post it.
 */
function create_trigger_sample(
    string $formattedParent,
    string $triggerName,
    string $triggerEventFiltersAttribute,
    string $triggerEventFiltersValue,
    string $triggerId,
    bool $validateOnly
): void {
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $eventFilter = (new EventFilter())
        ->setAttribute($triggerEventFiltersAttribute)
        ->setValue($triggerEventFiltersValue);
    $triggerEventFilters = [$eventFilter,];
    $triggerDestination = new Destination();
    $trigger = (new Trigger())
        ->setName($triggerName)
        ->setEventFilters($triggerEventFilters)
        ->setDestination($triggerDestination);
    $request = (new CreateTriggerRequest())
        ->setParent($formattedParent)
        ->setTrigger($trigger)
        ->setTriggerId($triggerId)
        ->setValidateOnly($validateOnly);

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

        if ($response->operationSucceeded()) {
            /** @var Trigger $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');
    $triggerName = '[NAME]';
    $triggerEventFiltersAttribute = '[ATTRIBUTE]';
    $triggerEventFiltersValue = '[VALUE]';
    $triggerId = '[TRIGGER_ID]';
    $validateOnly = false;

    create_trigger_sample(
        $formattedParent,
        $triggerName,
        $triggerEventFiltersAttribute,
        $triggerEventFiltersValue,
        $triggerId,
        $validateOnly
    );
}

deleteChannel

Delete a single channel.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::deleteChannelAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteChannelRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\DeleteChannelRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the channel to be deleted. Please see
 *                              {@see EventarcClient::channelName()} for help formatting this field.
 * @param bool   $validateOnly  If set, validate the request and preview the review, but do not
 *                              post it.
 */
function delete_channel_sample(string $formattedName, bool $validateOnly): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Channel $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 = EventarcClient::channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]');
    $validateOnly = false;

    delete_channel_sample($formattedName, $validateOnly);
}

deleteChannelConnection

Delete a single ChannelConnection.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::deleteChannelConnectionAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteChannelConnectionRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\DeleteChannelConnectionRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the channel connection to delete. Please see
 *                              {@see EventarcClient::channelConnectionName()} for help formatting this field.
 */
function delete_channel_connection_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var ChannelConnection $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 = EventarcClient::channelConnectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CHANNEL_CONNECTION]'
    );

    delete_channel_connection_sample($formattedName);
}

deleteTrigger

Delete a single trigger.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::deleteTriggerAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteTriggerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\DeleteTriggerRequest;
use Google\Cloud\Eventarc\V1\Trigger;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the trigger to be deleted. Please see
 *                              {@see EventarcClient::triggerName()} for help formatting this field.
 * @param bool   $validateOnly  If set, validate the request and preview the review, but do not
 *                              post it.
 */
function delete_trigger_sample(string $formattedName, bool $validateOnly): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Trigger $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 = EventarcClient::triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]');
    $validateOnly = false;

    delete_trigger_sample($formattedName, $validateOnly);
}

getChannel

Get a single Channel.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::getChannelAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetChannelRequest

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\Eventarc\V1\Channel
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GetChannelRequest;

/**
 * @param string $formattedName The name of the channel to get. Please see
 *                              {@see EventarcClient::channelName()} for help formatting this field.
 */
function get_channel_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Channel $response */
        $response = $eventarcClient->getChannel($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 = EventarcClient::channelName('[PROJECT]', '[LOCATION]', '[CHANNEL]');

    get_channel_sample($formattedName);
}

getChannelConnection

Get a single ChannelConnection.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::getChannelConnectionAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetChannelConnectionRequest

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\Eventarc\V1\ChannelConnection
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GetChannelConnectionRequest;

/**
 * @param string $formattedName The name of the channel connection to get. Please see
 *                              {@see EventarcClient::channelConnectionName()} for help formatting this field.
 */
function get_channel_connection_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ChannelConnection $response */
        $response = $eventarcClient->getChannelConnection($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 = EventarcClient::channelConnectionName(
        '[PROJECT]',
        '[LOCATION]',
        '[CHANNEL_CONNECTION]'
    );

    get_channel_connection_sample($formattedName);
}

getGoogleChannelConfig

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetGoogleChannelConfigRequest

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\Eventarc\V1\GoogleChannelConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GetGoogleChannelConfigRequest;
use Google\Cloud\Eventarc\V1\GoogleChannelConfig;

/**
 * @param string $formattedName The name of the config to get. Please see
 *                              {@see EventarcClient::googleChannelConfigName()} for help formatting this field.
 */
function get_google_channel_config_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var GoogleChannelConfig $response */
        $response = $eventarcClient->getGoogleChannelConfig($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 = EventarcClient::googleChannelConfigName('[PROJECT]', '[LOCATION]');

    get_google_channel_config_sample($formattedName);
}

getProvider

Get a single Provider.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::getProviderAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetProviderRequest

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\Eventarc\V1\Provider
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GetProviderRequest;
use Google\Cloud\Eventarc\V1\Provider;

/**
 * @param string $formattedName The name of the provider to get. Please see
 *                              {@see EventarcClient::providerName()} for help formatting this field.
 */
function get_provider_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Provider $response */
        $response = $eventarcClient->getProvider($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 = EventarcClient::providerName('[PROJECT]', '[LOCATION]', '[PROVIDER]');

    get_provider_sample($formattedName);
}

getTrigger

Get a single trigger.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::getTriggerAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetTriggerRequest

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\Eventarc\V1\Trigger
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GetTriggerRequest;
use Google\Cloud\Eventarc\V1\Trigger;

/**
 * @param string $formattedName The name of the trigger to get. Please see
 *                              {@see EventarcClient::triggerName()} for help formatting this field.
 */
function get_trigger_sample(string $formattedName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Trigger $response */
        $response = $eventarcClient->getTrigger($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 = EventarcClient::triggerName('[PROJECT]', '[LOCATION]', '[TRIGGER]');

    get_trigger_sample($formattedName);
}

listChannelConnections

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListChannelConnectionsRequest

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\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\ListChannelConnectionsRequest;

/**
 * @param string $formattedParent The parent collection from which to list channel connections. Please see
 *                                {@see EventarcClient::locationName()} for help formatting this field.
 */
function list_channel_connections_sample(string $formattedParent): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        /** @var ChannelConnection $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');

    list_channel_connections_sample($formattedParent);
}

listChannels

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListChannelsRequest

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\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\ListChannelsRequest;

/**
 * @param string $formattedParent The parent collection to list channels on. Please see
 *                                {@see EventarcClient::locationName()} for help formatting this field.
 */
function list_channels_sample(string $formattedParent): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        /** @var Channel $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');

    list_channels_sample($formattedParent);
}

listProviders

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListProvidersRequest

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\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\ListProvidersRequest;
use Google\Cloud\Eventarc\V1\Provider;

/**
 * @param string $formattedParent The parent of the provider to get. Please see
 *                                {@see EventarcClient::locationName()} for help formatting this field.
 */
function list_providers_sample(string $formattedParent): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        /** @var Provider $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');

    list_providers_sample($formattedParent);
}

listTriggers

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListTriggersRequest

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\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\ListTriggersRequest;
use Google\Cloud\Eventarc\V1\Trigger;

/**
 * @param string $formattedParent The parent collection to list triggers on. Please see
 *                                {@see EventarcClient::locationName()} for help formatting this field.
 */
function list_triggers_sample(string $formattedParent): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

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

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

        /** @var Trigger $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 = EventarcClient::locationName('[PROJECT]', '[LOCATION]');

    list_triggers_sample($formattedParent);
}

updateChannel

Update a single channel.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::updateChannelAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateChannelRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\UpdateChannelRequest;
use Google\Rpc\Status;

/**
 * @param bool $validateOnly If set, validate the request and preview the review, but do not
 *                           post it.
 */
function update_channel_sample(bool $validateOnly): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $request = (new UpdateChannelRequest())
        ->setValidateOnly($validateOnly);

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

        if ($response->operationSucceeded()) {
            /** @var Channel $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
{
    $validateOnly = false;

    update_channel_sample($validateOnly);
}

updateGoogleChannelConfig

Update a single GoogleChannelConfig

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::updateGoogleChannelConfigAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateGoogleChannelConfigRequest

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\Eventarc\V1\GoogleChannelConfig
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\GoogleChannelConfig;
use Google\Cloud\Eventarc\V1\UpdateGoogleChannelConfigRequest;

/**
 * @param string $googleChannelConfigName The resource name of the config. Must be in the format of,
 *                                        `projects/{project}/locations/{location}/googleChannelConfig`.
 */
function update_google_channel_config_sample(string $googleChannelConfigName): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $googleChannelConfig = (new GoogleChannelConfig())
        ->setName($googleChannelConfigName);
    $request = (new UpdateGoogleChannelConfigRequest())
        ->setGoogleChannelConfig($googleChannelConfig);

    // Call the API and handle any network failures.
    try {
        /** @var GoogleChannelConfig $response */
        $response = $eventarcClient->updateGoogleChannelConfig($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
{
    $googleChannelConfigName = '[NAME]';

    update_google_channel_config_sample($googleChannelConfigName);
}

updateTrigger

Update a single trigger.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::updateTriggerAsync() .

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateTriggerRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.

Returns
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Client\EventarcClient;
use Google\Cloud\Eventarc\V1\Trigger;
use Google\Cloud\Eventarc\V1\UpdateTriggerRequest;
use Google\Rpc\Status;

/**
 * @param bool $validateOnly If set, validate the request and preview the review, but do not
 *                           post it.
 */
function update_trigger_sample(bool $validateOnly): void
{
    // Create a client.
    $eventarcClient = new EventarcClient();

    // Prepare the request message.
    $request = (new UpdateTriggerRequest())
        ->setValidateOnly($validateOnly);

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

        if ($response->operationSucceeded()) {
            /** @var Trigger $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
{
    $validateOnly = false;

    update_trigger_sample($validateOnly);
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::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\Eventarc\V1\Client\EventarcClient;
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.
    $eventarcClient = new EventarcClient();

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

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

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\Eventarc\V1\Client\EventarcClient::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\Eventarc\V1\Client\EventarcClient;
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.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $eventarcClient->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 Google\Cloud\Eventarc\V1\Client\EventarcClient::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\Eventarc\V1\Client\EventarcClient;
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.
    $eventarcClient = new EventarcClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Policy $response */
        $response = $eventarcClient->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 Google\Cloud\Eventarc\V1\Client\EventarcClient::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\Eventarc\V1\Client\EventarcClient;
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.
    $eventarcClient = new EventarcClient();

    // 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 = $eventarcClient->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 Google\Cloud\Eventarc\V1\Client\EventarcClient::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\Eventarc\V1\Client\EventarcClient;
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.
    $eventarcClient = new EventarcClient();

    // 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 = $eventarcClient->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);
}

createChannelAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateChannelRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createChannelConnectionAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateChannelConnectionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

createTriggerAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\CreateTriggerRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteChannelAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteChannelRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteChannelConnectionAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteChannelConnectionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

deleteTriggerAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\DeleteTriggerRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getChannelAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetChannelRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getChannelConnectionAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetChannelConnectionRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getGoogleChannelConfigAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetGoogleChannelConfigRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getProviderAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetProviderRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getTriggerAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\GetTriggerRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listChannelConnectionsAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListChannelConnectionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listChannelsAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListChannelsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listProvidersAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListProvidersRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

listTriggersAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\ListTriggersRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateChannelAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateChannelRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateGoogleChannelConfigAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateGoogleChannelConfigRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

updateTriggerAsync

Parameters
Name Description
request Google\Cloud\Eventarc\V1\UpdateTriggerRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getLocationAsync

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

listLocationsAsync

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

getIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\GetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

setIamPolicyAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\SetIamPolicyRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

testIamPermissionsAsync

Parameters
Name Description
request Google\Cloud\Iam\V1\TestIamPermissionsRequest
optionalArgs = [] array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
Type Description
Google\ApiCore\LongRunning\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::channelName

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

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

static::channelConnectionName

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

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

static::cloudFunctionName

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

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

static::cryptoKeyName

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

Parameters
Name Description
project string
location string
keyRing string
cryptoKey string
Returns
Type Description
string The formatted crypto_key resource.

static::googleChannelConfigName

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

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

static::locationName

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

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

static::providerName

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

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

static::serviceAccountName

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

Parameters
Name Description
project string
serviceAccount string
Returns
Type Description
string The formatted service_account resource.

static::triggerName

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

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

static::workflowName

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

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

  • channel: projects/{project}/locations/{location}/channels/{channel}
  • channelConnection: projects/{project}/locations/{location}/channelConnections/{channel_connection}
  • cloudFunction: projects/{project}/locations/{location}/functions/{function}
  • cryptoKey: projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}
  • googleChannelConfig: projects/{project}/locations/{location}/googleChannelConfig
  • location: projects/{project}/locations/{location}
  • provider: projects/{project}/locations/{location}/providers/{provider}
  • serviceAccount: projects/{project}/serviceAccounts/{service_account}
  • trigger: projects/{project}/locations/{location}/triggers/{trigger}
  • workflow: projects/{project}/locations/{location}/workflows/{workflow}

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.