# Google Apps Events Subscriptions V1 Client - Class SubscriptionsServiceClient (0.4.4)

0.4.4 (latest) 0.4.3 0.3.1 0.2.1 0.1.6 Reference documentation and code samples for the Google Apps Events Subscriptions V1 Client class SubscriptionsServiceClient.

Service Description: A service that manages subscriptions to Google Workspace events.

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 \\ Apps \\ Events \\ Subscriptions \\ V1 \\ Client

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `options` | `array|https://docs.cloud.google.com/php/docs/reference/gax/latest/Options.ClientOptions.html` 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` | `https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html|https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html` This option should only be used with a pre-constructed [Google\\Auth\\FetchAuthTokenInterface](https://docs.cloud.google.com/php/docs/reference/auth/latest/FetchAuthTokenInterface.html) or [Google\\ApiCore\\CredentialsWrapper](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html) object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. **Important** : If you are providing a path to a credentials file, or a decoded credentials file as a PHP array, this usage is now DEPRECATED. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. It is recommended to create the credentials explicitly `use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Apps\Events\Subscriptions\V1\SubscriptionsServiceClient; $creds = new ServiceAccountCredentials($scopes, $json); $options = new SubscriptionsServiceClient(['credentials' => $creds]);` <https://cloud.google.com/docs/authentication/external/externally-sourced-credentials> |
| `↳ credentialsConfig` | `array` Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see [Google\\ApiCore\\CredentialsWrapper::build()](https://docs.cloud.google.com/php/docs/reference/gax/latest/CredentialsWrapper.html#_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|https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html` 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](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.TransportInterface.html) 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()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.GrpcTransport.html#_Google_ApiCore_Transport_GrpcTransport__build__) and [Google\\ApiCore\\Transport\\RestTransport::build()](https://docs.cloud.google.com/php/docs/reference/gax/latest/Transport.RestTransport.html#_Google_ApiCore_Transport_RestTransport__build__) methods for the supported options. |
| `↳ clientCertSource` | `callable` A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
| `↳ logger` | `false|Psr\Log\LoggerInterface` A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag |
| `↳ universeDomain` | `string` The service domain for the client. Defaults to 'googleapis.com'. |

### createSubscription

Creates a Google Workspace subscription. To learn how to use this
method, see [Create a Google Workspace
subscription](https://developers.google.com/workspace/events/guides/create-subscription).

The async variant is
[SubscriptionsServiceClient::createSubscriptionAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__createSubscriptionAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.CreateSubscriptionRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html<https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Subscription>` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\OperationResponse;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\CreateSubscriptionRequest;
    use Google\Apps\Events\Subscriptions\V1\NotificationEndpoint;
    use Google\Apps\Events\Subscriptions\V1\Subscription;
    use Google\Rpc\Status;

    /**
     * @param string $subscriptionTargetResource    Immutable. The Google Workspace resource that's monitored for
     *                                              events, formatted as the [full resource
     *                                              name](https://google.aip.dev/122#full-resource-names). To learn about
     *                                              target resources and the events that they support, see [Supported Google
     *                                              Workspace
     *                                              events](https://developers.google.com/workspace/events#supported-events).
     *
     *                                              A user can only authorize your app to create one subscription for a given
     *                                              target resource. If your app tries to create another subscription with the
     *                                              same user credentials, the request returns an `ALREADY_EXISTS` error.
     * @param string $subscriptionEventTypesElement Immutable. Unordered list. Input for creating a subscription.
     *                                              Otherwise, output only. One or more types of events to receive about the
     *                                              target resource. Formatted according to the CloudEvents specification.
     *
     *                                              The supported event types depend on the target resource of your
     *                                              subscription. For details, see [Supported Google Workspace
     *                                              events](https://developers.google.com/workspace/events/guides#supported-events).
     *
     *                                              By default, you also receive events about the [lifecycle of your
     *                                              subscription](https://developers.google.com/workspace/events/guides/events-lifecycle).
     *                                              You don't need to specify lifecycle events for this field.
     *
     *                                              If you specify an event type that doesn't exist for the target resource,
     *                                              the request returns an HTTP `400 Bad Request` status code.
     */
    function create_subscription_sample(
        string $subscriptionTargetResource,
        string $subscriptionEventTypesElement
    ): void {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

        // Prepare the request message.
        $subscriptionEventTypes = [$subscriptionEventTypesElement,];
        $subscriptionNotificationEndpoint = new NotificationEndpoint();
        $subscription = (new Subscription())
            ->setTargetResource($subscriptionTargetResource)
            ->setEventTypes($subscriptionEventTypes)
            ->setNotificationEndpoint($subscriptionNotificationEndpoint);
        $request = (new CreateSubscriptionRequest())
            ->setSubscription($subscription);

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

            if ($response->operationSucceeded()) {
                /** @var Subscription $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
    {
        $subscriptionTargetResource = '[TARGET_RESOURCE]';
        $subscriptionEventTypesElement = '[EVENT_TYPES]';

        create_subscription_sample($subscriptionTargetResource, $subscriptionEventTypesElement);
    }

### deleteSubscription

Deletes a Google Workspace subscription.

To learn how to use this method, see [Delete a Google Workspace
subscription](https://developers.google.com/workspace/events/guides/delete-subscription).

The async variant is
[SubscriptionsServiceClient::deleteSubscriptionAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__deleteSubscriptionAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.DeleteSubscriptionRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html<null>` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\OperationResponse;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\DeleteSubscriptionRequest;
    use Google\Rpc\Status;

    /**
     * @param string $formattedName Resource name of the subscription to delete.
     *
     *                              Format: `subscriptions/{subscription}`
     *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
     */
    function delete_subscription_sample(string $formattedName): void
    {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

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

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

            if ($response->operationSucceeded()) {
                printf('Operation completed successfully.' . PHP_EOL);
            } else {
                /** @var Status $error */
                $error = $response->getError();
                printf('Operation failed with error data: %s' . PHP_EOL, $error->serializeToJsonString());
            }
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

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

        delete_subscription_sample($formattedName);
    }

### getSubscription

Gets details about a Google Workspace subscription. To learn how to use
this method, see [Get details about a Google Workspace
subscription](https://developers.google.com/workspace/events/guides/get-subscription).

The async variant is [SubscriptionsServiceClient::getSubscriptionAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__getSubscriptionAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.GetSubscriptionRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Subscription` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\GetSubscriptionRequest;
    use Google\Apps\Events\Subscriptions\V1\Subscription;

    /**
     * @param string $formattedName Resource name of the subscription.
     *
     *                              Format: `subscriptions/{subscription}`
     *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
     */
    function get_subscription_sample(string $formattedName): void
    {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

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

        // Call the API and handle any network failures.
        try {
            /** @var Subscription $response */
            $response = $subscriptionsServiceClient->getSubscription($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 = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');

        get_subscription_sample($formattedName);
    }

### listSubscriptions

Lists Google Workspace subscriptions. To learn how to use this method, see
[List Google Workspace
subscriptions](https://developers.google.com/workspace/events/guides/list-subscriptions).

The async variant is [SubscriptionsServiceClient::listSubscriptionsAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__listSubscriptionsAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.ListSubscriptionsRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\PagedListResponse;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\ListSubscriptionsRequest;
    use Google\Apps\Events\Subscriptions\V1\Subscription;

    /**
     * @param string $filter A query filter.
     *
     *                       You can filter subscriptions by event type (`event_types`)
     *                       and target resource (`target_resource`).
     *
     *                       You must specify at least one event type in your query. To filter for
     *                       multiple event types, use the `OR` operator.
     *
     *                       To filter by both event type and target resource, use the `AND` operator
     *                       and specify the full resource name, such as
     *                       `//chat.googleapis.com/spaces/{space}`.
     *
     *                       For example, the following queries are valid:
     *
     *                       ```
     *                       event_types:"google.workspace.chat.membership.v1.updated" OR
     *                       event_types:"google.workspace.chat.message.v1.created"
     *
     *                       event_types:"google.workspace.chat.message.v1.created" AND
     *                       target_resource="//chat.googleapis.com/spaces/{space}"
     *
     *                       ( event_types:"google.workspace.chat.membership.v1.updated" OR
     *                       event_types:"google.workspace.chat.message.v1.created" ) AND
     *                       target_resource="//chat.googleapis.com/spaces/{space}"
     *                       ```
     *
     *                       The server rejects invalid queries with an `INVALID_ARGUMENT`
     *                       error.
     */
    function list_subscriptions_sample(string $filter): void
    {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

        // Prepare the request message.
        $request = (new ListSubscriptionsRequest())
            ->setFilter($filter);

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

            /** @var Subscription $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
    {
        $filter = '[FILTER]';

        list_subscriptions_sample($filter);
    }

### reactivateSubscription

Reactivates a suspended Google Workspace subscription.

This method resets your subscription's `State` field to `ACTIVE`. Before
you use this method, you must fix the error that suspended the
subscription. To learn how to use this method, see [Reactivate a Google
Workspace
subscription](https://developers.google.com/workspace/events/guides/reactivate-subscription).

The async variant is
[SubscriptionsServiceClient::reactivateSubscriptionAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__reactivateSubscriptionAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.ReactivateSubscriptionRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html<https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Subscription>` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\OperationResponse;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\ReactivateSubscriptionRequest;
    use Google\Apps\Events\Subscriptions\V1\Subscription;
    use Google\Rpc\Status;

    /**
     * @param string $formattedName Resource name of the subscription.
     *
     *                              Format: `subscriptions/{subscription}`
     *                              Please see {@see SubscriptionsServiceClient::subscriptionName()} for help formatting this field.
     */
    function reactivate_subscription_sample(string $formattedName): void
    {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

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

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

            if ($response->operationSucceeded()) {
                /** @var Subscription $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 = SubscriptionsServiceClient::subscriptionName('[SUBSCRIPTION]');

        reactivate_subscription_sample($formattedName);
    }

### updateSubscription

Updates or renews a Google Workspace subscription. To learn how to use this
method, see [Update or renew a Google Workspace
subscription](https://developers.google.com/workspace/events/guides/update-subscription).

The async variant is
[SubscriptionsServiceClient::updateSubscriptionAsync()](https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Client.SubscriptionsServiceClient#_Google_Apps_Events_Subscriptions_V1_Client_SubscriptionsServiceClient__updateSubscriptionAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.UpdateSubscriptionRequest` A request to house fields associated with the call. |
| `callOptions` | `array` Optional. |
| `↳ retrySettings` | `https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html|array` Retry settings to use for this call. Can be a [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) object, or an associative array of retry settings parameters. See the documentation on [Google\\ApiCore\\RetrySettings](https://docs.cloud.google.com/php/docs/reference/gax/latest/RetrySettings.html) for example usage. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html<https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Subscription>` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\ApiCore\OperationResponse;
    use Google\Apps\Events\Subscriptions\V1\Client\SubscriptionsServiceClient;
    use Google\Apps\Events\Subscriptions\V1\NotificationEndpoint;
    use Google\Apps\Events\Subscriptions\V1\Subscription;
    use Google\Apps\Events\Subscriptions\V1\UpdateSubscriptionRequest;
    use Google\Rpc\Status;

    /**
     * @param string $subscriptionTargetResource    Immutable. The Google Workspace resource that's monitored for
     *                                              events, formatted as the [full resource
     *                                              name](https://google.aip.dev/122#full-resource-names). To learn about
     *                                              target resources and the events that they support, see [Supported Google
     *                                              Workspace
     *                                              events](https://developers.google.com/workspace/events#supported-events).
     *
     *                                              A user can only authorize your app to create one subscription for a given
     *                                              target resource. If your app tries to create another subscription with the
     *                                              same user credentials, the request returns an `ALREADY_EXISTS` error.
     * @param string $subscriptionEventTypesElement Immutable. Unordered list. Input for creating a subscription.
     *                                              Otherwise, output only. One or more types of events to receive about the
     *                                              target resource. Formatted according to the CloudEvents specification.
     *
     *                                              The supported event types depend on the target resource of your
     *                                              subscription. For details, see [Supported Google Workspace
     *                                              events](https://developers.google.com/workspace/events/guides#supported-events).
     *
     *                                              By default, you also receive events about the [lifecycle of your
     *                                              subscription](https://developers.google.com/workspace/events/guides/events-lifecycle).
     *                                              You don't need to specify lifecycle events for this field.
     *
     *                                              If you specify an event type that doesn't exist for the target resource,
     *                                              the request returns an HTTP `400 Bad Request` status code.
     */
    function update_subscription_sample(
        string $subscriptionTargetResource,
        string $subscriptionEventTypesElement
    ): void {
        // Create a client.
        $subscriptionsServiceClient = new SubscriptionsServiceClient();

        // Prepare the request message.
        $subscriptionEventTypes = [$subscriptionEventTypesElement,];
        $subscriptionNotificationEndpoint = new NotificationEndpoint();
        $subscription = (new Subscription())
            ->setTargetResource($subscriptionTargetResource)
            ->setEventTypes($subscriptionEventTypes)
            ->setNotificationEndpoint($subscriptionNotificationEndpoint);
        $request = (new UpdateSubscriptionRequest())
            ->setSubscription($subscription);

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

            if ($response->operationSucceeded()) {
                /** @var Subscription $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
    {
        $subscriptionTargetResource = '[TARGET_RESOURCE]';
        $subscriptionEventTypesElement = '[EVENT_TYPES]';

        update_subscription_sample($subscriptionTargetResource, $subscriptionEventTypesElement);
    }

### createSubscriptionAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.CreateSubscriptionRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html>` |   |

### deleteSubscriptionAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.DeleteSubscriptionRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html>` |   |

### getSubscriptionAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.GetSubscriptionRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.Subscription>` |   |

### listSubscriptionsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.ListSubscriptionsRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/PagedListResponse.html>` |   |

### reactivateSubscriptionAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.ReactivateSubscriptionRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html>` |   |

### updateSubscriptionAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/apps-events-subscriptions/latest/V1.UpdateSubscriptionRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html>` |   |

### getOperationsClient

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Google\LongRunning\Client\OperationsClient` |   |

### resumeOperation

Resume an existing long running operation that was previously started by a long
running API method. If $methodName is not provided, or does not match a long
running API method, then the operation can still be resumed, but the
OperationResponse object will not deserialize the final response.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `operationName` | `string` The name of the long running operation |
| `methodName` | `string` The name of the method used to start the operation |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/gax/latest/OperationResponse.html` |   |

### static::subscriptionName

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `subscription` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted subscription resource. |

### static::topicName

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `project` | `string` |
| `topic` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted topic resource. |

### static::userName

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

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `user` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` | The formatted user 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

- subscription: subscriptions/{subscription}
- topic: projects/{project}/topics/{topic}
- user: users/{user}

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. |