# Google Cloud Essential Contacts V1 Client - Class EssentialContactsServiceClient (1.1.3)

1.1.3 (latest) 1.1.2 1.0.5 0.4.5 0.3.4 0.2.13 Reference documentation and code samples for the Google Cloud Essential Contacts V1 Client class EssentialContactsServiceClient.

Service Description: Manages contacts for important Google Cloud notifications.

This class provides the ability to make remote calls to the backing service through method
calls that map to API methods.

Many parameters require resource names to be formatted in a particular way. To
assist with these names, this class includes a format method for each type of
name, and additionally a parseName method to extract the individual identifiers
contained within formatted names that are returned by the API.

## Namespace

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

### computeContacts

Lists all contacts for the resource that are subscribed to the
specified notification categories, including contacts inherited from
any parent resources.

The async variant is
[EssentialContactsServiceClient::computeContactsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__computeContactsAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.ComputeContactsRequest` 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\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\ComputeContactsRequest;
    use Google\Cloud\EssentialContacts\V1\Contact;

    /**
     * @param string $formattedParent The name of the resource to compute contacts for.
     *                                Format: organizations/{organization_id},
     *                                folders/{folder_id} or projects/{project_id}
     *                                Please see {@see EssentialContactsServiceClient::projectName()} for help formatting this field.
     */
    function compute_contacts_sample(string $formattedParent): void
    {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

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

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

            /** @var Contact $element */
            foreach ($response as $element) {
                printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
            }
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

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

        compute_contacts_sample($formattedParent);
    }

### createContact

Adds a new contact for a resource.

The async variant is [EssentialContactsServiceClient::createContactAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__createContactAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.CreateContactRequest` 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/cloud-essential-contacts/latest/V1.Contact` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\Contact;
    use Google\Cloud\EssentialContacts\V1\CreateContactRequest;
    use Google\Cloud\EssentialContacts\V1\NotificationCategory;

    /**
     * @param string $formattedParent                                 The resource to save this contact for.
     *                                                                Format: organizations/{organization_id}, folders/{folder_id} or
     *                                                                projects/{project_id}
     *                                                                Please see {@see EssentialContactsServiceClient::projectName()} for help formatting this field.
     * @param string $contactEmail                                    The email address to send notifications to. The email address
     *                                                                does not need to be a Google Account.
     * @param int    $contactNotificationCategorySubscriptionsElement The categories of notifications that the contact will receive
     *                                                                communications for.
     * @param string $contactLanguageTag                              The preferred language for notifications, as a ISO 639-1 language
     *                                                                code. See [Supported
     *                                                                languages](https://cloud.google.com/resource-manager/docs/managing-notification-contacts#supported-languages)
     *                                                                for a list of supported languages.
     */
    function create_contact_sample(
        string $formattedParent,
        string $contactEmail,
        int $contactNotificationCategorySubscriptionsElement,
        string $contactLanguageTag
    ): void {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

        // Prepare the request message.
        $contactNotificationCategorySubscriptions = [$contactNotificationCategorySubscriptionsElement,];
        $contact = (new Contact())
            ->setEmail($contactEmail)
            ->setNotificationCategorySubscriptions($contactNotificationCategorySubscriptions)
            ->setLanguageTag($contactLanguageTag);
        $request = (new CreateContactRequest())
            ->setParent($formattedParent)
            ->setContact($contact);

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

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

        create_contact_sample(
            $formattedParent,
            $contactEmail,
            $contactNotificationCategorySubscriptionsElement,
            $contactLanguageTag
        );
    }

### deleteContact

Deletes a contact.

The async variant is [EssentialContactsServiceClient::deleteContactAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__deleteContactAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.DeleteContactRequest` 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. |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\DeleteContactRequest;

    /**
     * @param string $formattedName The name of the contact to delete.
     *                              Format: organizations/{organization_id}/contacts/{contact_id},
     *                              folders/{folder_id}/contacts/{contact_id} or
     *                              projects/{project_id}/contacts/{contact_id}
     *                              Please see {@see EssentialContactsServiceClient::contactName()} for help formatting this field.
     */
    function delete_contact_sample(string $formattedName): void
    {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

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

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

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

        delete_contact_sample($formattedName);
    }

### getContact

Gets a single contact.

The async variant is [EssentialContactsServiceClient::getContactAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__getContactAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.GetContactRequest` 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/cloud-essential-contacts/latest/V1.Contact` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\Contact;
    use Google\Cloud\EssentialContacts\V1\GetContactRequest;

    /**
     * @param string $formattedName The name of the contact to retrieve.
     *                              Format: organizations/{organization_id}/contacts/{contact_id},
     *                              folders/{folder_id}/contacts/{contact_id} or
     *                              projects/{project_id}/contacts/{contact_id}
     *                              Please see {@see EssentialContactsServiceClient::contactName()} for help formatting this field.
     */
    function get_contact_sample(string $formattedName): void
    {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

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

        // Call the API and handle any network failures.
        try {
            /** @var Contact $response */
            $response = $essentialContactsServiceClient->getContact($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 = EssentialContactsServiceClient::contactName('[PROJECT]', '[CONTACT]');

        get_contact_sample($formattedName);
    }

### listContacts

Lists the contacts that have been set on a resource.

The async variant is [EssentialContactsServiceClient::listContactsAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__listContactsAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.ListContactsRequest` 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\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\Contact;
    use Google\Cloud\EssentialContacts\V1\ListContactsRequest;

    /**
     * @param string $formattedParent The parent resource name.
     *                                Format: organizations/{organization_id}, folders/{folder_id} or
     *                                projects/{project_id}
     *                                Please see {@see EssentialContactsServiceClient::projectName()} for help formatting this field.
     */
    function list_contacts_sample(string $formattedParent): void
    {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

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

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

            /** @var Contact $element */
            foreach ($response as $element) {
                printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
            }
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    }

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

        list_contacts_sample($formattedParent);
    }

### sendTestMessage

Allows a contact admin to send a test message to contact to verify that it
has been configured correctly.

The async variant is
[EssentialContactsServiceClient::sendTestMessageAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__sendTestMessageAsync__) .

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.SendTestMessageRequest` 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. |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\NotificationCategory;
    use Google\Cloud\EssentialContacts\V1\SendTestMessageRequest;

    /**
     * @param string $formattedContactsElement The list of names of the contacts to send a test message to.
     *                                         Format: organizations/{organization_id}/contacts/{contact_id},
     *                                         folders/{folder_id}/contacts/{contact_id} or
     *                                         projects/{project_id}/contacts/{contact_id}
     *                                         Please see {@see EssentialContactsServiceClient::contactName()} for help formatting this field.
     * @param string $formattedResource        The name of the resource to send the test message for. All
     *                                         contacts must either be set directly on this resource or inherited from
     *                                         another resource that is an ancestor of this one. Format:
     *                                         organizations/{organization_id}, folders/{folder_id} or
     *                                         projects/{project_id}
     *                                         Please see {@see EssentialContactsServiceClient::projectName()} for help formatting this field.
     * @param int    $notificationCategory     The notification category to send the test message for. All
     *                                         contacts must be subscribed to this category.
     */
    function send_test_message_sample(
        string $formattedContactsElement,
        string $formattedResource,
        int $notificationCategory
    ): void {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

        // Prepare the request message.
        $formattedContacts = [$formattedContactsElement,];
        $request = (new SendTestMessageRequest())
            ->setContacts($formattedContacts)
            ->setResource($formattedResource)
            ->setNotificationCategory($notificationCategory);

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

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

        send_test_message_sample($formattedContactsElement, $formattedResource, $notificationCategory);
    }

### updateContact

Updates a contact.

Note: A contact's email address cannot be changed.

The async variant is [EssentialContactsServiceClient::updateContactAsync()](https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.Client.EssentialContactsServiceClient#_Google_Cloud_EssentialContacts_V1_Client_EssentialContactsServiceClient__updateContactAsync__)
.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.UpdateContactRequest` 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/cloud-essential-contacts/latest/V1.Contact` |   |

**Example**

    use Google\ApiCore\ApiException;
    use Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient;
    use Google\Cloud\EssentialContacts\V1\Contact;
    use Google\Cloud\EssentialContacts\V1\NotificationCategory;
    use Google\Cloud\EssentialContacts\V1\UpdateContactRequest;

    /**
     * @param string $contactEmail                                    The email address to send notifications to. The email address
     *                                                                does not need to be a Google Account.
     * @param int    $contactNotificationCategorySubscriptionsElement The categories of notifications that the contact will receive
     *                                                                communications for.
     * @param string $contactLanguageTag                              The preferred language for notifications, as a ISO 639-1 language
     *                                                                code. See [Supported
     *                                                                languages](https://cloud.google.com/resource-manager/docs/managing-notification-contacts#supported-languages)
     *                                                                for a list of supported languages.
     */
    function update_contact_sample(
        string $contactEmail,
        int $contactNotificationCategorySubscriptionsElement,
        string $contactLanguageTag
    ): void {
        // Create a client.
        $essentialContactsServiceClient = new EssentialContactsServiceClient();

        // Prepare the request message.
        $contactNotificationCategorySubscriptions = [$contactNotificationCategorySubscriptionsElement,];
        $contact = (new Contact())
            ->setEmail($contactEmail)
            ->setNotificationCategorySubscriptions($contactNotificationCategorySubscriptions)
            ->setLanguageTag($contactLanguageTag);
        $request = (new UpdateContactRequest())
            ->setContact($contact);

        // Call the API and handle any network failures.
        try {
            /** @var Contact $response */
            $response = $essentialContactsServiceClient->updateContact($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
    {
        $contactEmail = '[EMAIL]';
        $contactNotificationCategorySubscriptionsElement = NotificationCategory::NOTIFICATION_CATEGORY_UNSPECIFIED;
        $contactLanguageTag = '[LANGUAGE_TAG]';

        update_contact_sample(
            $contactEmail,
            $contactNotificationCategorySubscriptionsElement,
            $contactLanguageTag
        );
    }

### computeContactsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.ComputeContactsRequest` |
| `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>` |   |

### createContactAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.CreateContactRequest` |
| `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/cloud-essential-contacts/latest/V1.Contact>` |   |

### deleteContactAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.DeleteContactRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<void>` |   |

### getContactAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.GetContactRequest` |
| `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/cloud-essential-contacts/latest/V1.Contact>` |   |

### listContactsAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.ListContactsRequest` |
| `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>` |   |

### sendTestMessageAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.SendTestMessageRequest` |
| `optionalArgs` | `array` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.aws.amazon.com/aws-sdk-php/v3/api/class-GuzzleHttp.Promise.Promise.html<void>` |   |

### updateContactAsync

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `request` | `https://docs.cloud.google.com/php/docs/reference/cloud-essential-contacts/latest/V1.UpdateContactRequest` |
| `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/cloud-essential-contacts/latest/V1.Contact>` |   |

### static::contactName

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

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

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

### static::folderName

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

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

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

### static::folderContactName

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `folder` | `string` |
| `contact` | `string` |

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

### static::organizationName

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

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

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

### static::organizationContactName

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

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `organization` | `string` |
| `contact` | `string` |

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

### static::projectName

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

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

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

### static::projectContactName

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

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

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

- contact: projects/{project}/contacts/{contact}
- folder: folders/{folder}
- folderContact: folders/{folder}/contacts/{contact}
- organization: organizations/{organization}
- organizationContact: organizations/{organization}/contacts/{contact}
- project: projects/{project}
- projectContact: projects/{project}/contacts/{contact}

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