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. Sample code to get started:
$eventarcClient = new EventarcClient();
try {
$formattedParent = $eventarcClient->locationName('[PROJECT]', '[LOCATION]');
$channel = new Channel();
$channelId = 'channel_id';
$validateOnly = false;
$operationResponse = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $eventarcClient->resumeOperation($operationName, 'createChannel');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$eventarcClient->close();
}
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Methods
channelName
Formats a string containing the fully-qualified path to represent a channel resource.
project
string
location
string
channel
string
string
channelConnectionName
Formats a string containing the fully-qualified path to represent a channel_connection resource.
project
string
location
string
channelConnection
string
string
cloudFunctionName
Formats a string containing the fully-qualified path to represent a cloud_function resource.
project
string
location
string
function
string
string
cryptoKeyName
Formats a string containing the fully-qualified path to represent a crypto_key resource.
project
string
location
string
keyRing
string
cryptoKey
string
string
googleChannelConfigName
Formats a string containing the fully-qualified path to represent a google_channel_config resource.
project
string
location
string
string
locationName
Formats a string containing the fully-qualified path to represent a location resource.
project
string
location
string
string
providerName
Formats a string containing the fully-qualified path to represent a provider resource.
project
string
location
string
provider
string
string
serviceAccountName
Formats a string containing the fully-qualified path to represent a service_account resource.
project
string
serviceAccount
string
string
triggerName
Formats a string containing the fully-qualified path to represent a trigger resource.
project
string
location
string
trigger
string
string
workflowName
Formats a string containing the fully-qualified path to represent a workflow resource.
project
string
location
string
workflow
string
string
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.
formattedName
string
The formatted name string
template
string
Optional name of template to match
array
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
resumeOperation
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.
operationName
string
The name of the long running operation
methodName
string
The name of the method used to start the operation
__construct
Constructor.
options
array
Optional. Options for configuring the service API wrapper.
↳ apiEndpoint
string
The address of the API remote host. May optionally include the port, formatted as "
↳ credentials
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage : In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored.
↳ credentialsConfig
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .
↳ disableRetries
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to false
.
↳ clientConfig
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder.
↳ transport
string|TransportInterface
The transport used for executing network requests. May be either the string rest
or grpc
. Defaults to grpc
if gRPC support is detected on the system. Advanced usage
: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface
object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.
↳ transportConfig
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options.
↳ clientCertSource
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS.
createChannel
Create a new channel in a particular project and location.
parent
string
Required. The parent collection in which to add this channel.
channel
channelId
string
Required. The user-provided ID to be assigned to the channel.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\EventarcClient;
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 any non-scalar elements to be passed along with the request.
$channel = (new Channel())
->setName($channelName);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->createChannel($formattedParent, $channel, $channelId, $validateOnly);
$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());
}
}
/**
* 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.
parent
string
Required. The parent collection in which to add this channel connection.
channelConnection
channelConnectionId
string
Required. The user-provided ID to be assigned to the channel connection.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\EventarcClient;
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 any non-scalar elements to be passed along with the request.
$channelConnection = (new ChannelConnection())
->setName($channelConnectionName)
->setChannel($formattedChannelConnectionChannel);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->createChannelConnection(
$formattedParent,
$channelConnection,
$channelConnectionId
);
$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());
}
}
/**
* 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.
parent
string
Required. The parent collection in which to add this trigger.
trigger
triggerId
string
Required. The user-provided ID to be assigned to the trigger.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Destination;
use Google\Cloud\Eventarc\V1\EventFilter;
use Google\Cloud\Eventarc\V1\EventarcClient;
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 any non-scalar elements to be passed along with the request.
$eventFilter = (new EventFilter())
->setAttribute($triggerEventFiltersAttribute)
->setValue($triggerEventFiltersValue);
$triggerEventFilters = [$eventFilter,];
$triggerDestination = new Destination();
$trigger = (new Trigger())
->setName($triggerName)
->setEventFilters($triggerEventFilters)
->setDestination($triggerDestination);
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->createTrigger($formattedParent, $trigger, $triggerId, $validateOnly);
$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());
}
}
/**
* 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.
name
string
Required. The name of the channel to be deleted.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->deleteChannel($formattedName, $validateOnly);
$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());
}
}
/**
* 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.
name
string
Required. The name of the channel connection to delete.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->deleteChannelConnection($formattedName);
$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());
}
}
/**
* 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.
name
string
Required. The name of the trigger to be deleted.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ etag
string
If provided, the trigger will only be deleted if the etag matches the current etag on the resource.
↳ allowMissing
bool
If set to true, and the trigger is not found, the request will succeed but no action will be taken on the server.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->deleteTrigger($formattedName, $validateOnly);
$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());
}
}
/**
* 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.
name
string
Required. The name of the channel to get.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\EventarcClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var Channel $response */
$response = $eventarcClient->getChannel($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
name
string
Required. The name of the channel connection to get.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\EventarcClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var ChannelConnection $response */
$response = $eventarcClient->getChannelConnection($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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
Get a GoogleChannelConfig
name
string
Required. The name of the config to get.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var GoogleChannelConfig $response */
$response = $eventarcClient->getGoogleChannelConfig($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
name
string
Required. The name of the provider to get.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var Provider $response */
$response = $eventarcClient->getProvider($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
name
string
Required. The name of the trigger to get.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var Trigger $response */
$response = $eventarcClient->getTrigger($formattedName);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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
List channel connections.
parent
string
Required. The parent collection from which to list channel connections.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Eventarc\V1\ChannelConnection;
use Google\Cloud\Eventarc\V1\EventarcClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $eventarcClient->listChannelConnections($formattedParent);
/** @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());
}
}
/**
* 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
List channels.
parent
string
Required. The parent collection to list channels on.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ orderBy
string
The sorting order of the resources returned. Value should be a comma-separated list of fields. The default sorting order is ascending. To specify descending order for a field, append a desc
suffix; for example: name desc, channel_id
.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\EventarcClient;
/**
* @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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $eventarcClient->listChannels($formattedParent);
/** @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());
}
}
/**
* 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
List providers.
parent
string
Required. The parent of the provider to get.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ orderBy
string
The sorting order of the resources returned. Value should be a comma-separated list of fields. The default sorting oder is ascending. To specify descending order for a field, append a desc
suffix; for example: name desc, _id
.
↳ filter
string
The filter field that the list request will filter on.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $eventarcClient->listProviders($formattedParent);
/** @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());
}
}
/**
* 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
List triggers.
parent
string
Required. The parent collection to list triggers on.
optionalArgs
array
Optional.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ orderBy
string
The sorting order of the resources returned. Value should be a comma-separated list of fields. The default sorting order is ascending. To specify descending order for a field, append a desc
suffix; for example: name desc, trigger_id
.
↳ filter
string
Filter field. Used to filter the Triggers to be listed. Possible filters are described in https://google.aip.dev/160 . For example, using "?filter=destination:gke" would list only Triggers with a gke destination.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $eventarcClient->listTriggers($formattedParent);
/** @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());
}
}
/**
* 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.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ channel
Channel
The channel to be updated.
↳ updateMask
FieldMask
The fields to be updated; only fields explicitly provided are updated. If no field mask is provided, all provided fields in the request are updated. To update all fields, provide a field mask of "*".
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\Channel;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->updateChannel($validateOnly);
$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());
}
}
/**
* 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
googleChannelConfig
optionalArgs
array
Optional.
↳ updateMask
FieldMask
The fields to be updated; only fields explicitly provided are updated. If no field mask is provided, all provided fields in the request are updated. To update all fields, provide a field mask of "*".
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
use Google\Cloud\Eventarc\V1\GoogleChannelConfig;
/**
* @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 any non-scalar elements to be passed along with the request.
$googleChannelConfig = (new GoogleChannelConfig())
->setName($googleChannelConfigName);
// Call the API and handle any network failures.
try {
/** @var GoogleChannelConfig $response */
$response = $eventarcClient->updateGoogleChannelConfig($googleChannelConfig);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
validateOnly
bool
Required. If set, validate the request and preview the review, but do not post it.
optionalArgs
array
Optional.
↳ trigger
Trigger
The trigger to be updated.
↳ updateMask
FieldMask
The fields to be updated; only fields explicitly provided are updated. If no field mask is provided, all provided fields in the request are updated. To update all fields, provide a field mask of "*".
↳ allowMissing
bool
If set to true, and the trigger is not found, a new trigger will be created. In this situation, update_mask
is ignored.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\Eventarc\V1\EventarcClient;
use Google\Cloud\Eventarc\V1\Trigger;
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();
// Call the API and handle any network failures.
try {
/** @var OperationResponse $response */
$response = $eventarcClient->updateTrigger($validateOnly);
$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());
}
}
/**
* 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.
optionalArgs
array
Optional.
↳ name
string
Resource name for the location.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $eventarcClient->getLocation();
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
listLocations
Lists information about the supported locations for this service.
optionalArgs
array
Optional.
↳ name
string
The resource that owns the locations collection, if applicable.
↳ filter
string
The standard list filter.
↳ pageSize
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved.
↳ pageToken
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $eventarcClient->listLocations();
/** @var Location $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
getIamPolicy
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
resource
string
REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
optionalArgs
array
Optional.
↳ options
GetPolicyOptions
OPTIONAL: A GetPolicyOptions
object for specifying options to GetIamPolicy
.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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();
// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $eventarcClient->getIamPolicy($resource);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
resource
string
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
policy
Google\Cloud\Iam\V1\Policy
REQUIRED: The complete policy to be applied to the resource
. The size of
the policy is limited to a few 10s of KB. An empty policy is a
valid policy but certain Cloud Platform services (such as Projects)
might reject them.
optionalArgs
array
Optional.
↳ updateMask
FieldMask
OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: paths: "bindings, etag"
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
use Google\Cloud\Iam\V1\Policy;
/**
* @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 any non-scalar elements to be passed along with the request.
$policy = new Policy();
// Call the API and handle any network failures.
try {
/** @var Policy $response */
$response = $eventarcClient->setIamPolicy($resource, $policy);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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.
resource
string
REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
permissions
string[]
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
.
optionalArgs
array
Optional.
↳ retrySettings
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage.
use Google\ApiCore\ApiException;
use Google\Cloud\Eventarc\V1\EventarcClient;
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 any non-scalar elements to be passed along with the request.
$permissions = [$permissionsElement,];
// Call the API and handle any network failures.
try {
/** @var TestIamPermissionsResponse $response */
$response = $eventarcClient->testIamPermissions($resource, $permissions);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* 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);
}
Constants
SERVICE_NAME
Value: 'google.cloud.eventarc.v1.Eventarc'
The name of the service.
SERVICE_ADDRESS
Value: 'eventarc.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.