Google Cloud Essential Contacts V1 Client - Class EssentialContactsServiceClient (0.3.4)

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. Sample code to get started:

$essentialContactsServiceClient = new EssentialContactsServiceClient();
try {
    $formattedParent = $essentialContactsServiceClient->projectName('[PROJECT]');
    // Iterate over pages of elements
    $pagedResponse = $essentialContactsServiceClient->computeContacts($formattedParent);
    foreach ($pagedResponse->iteratePages() as $page) {
        foreach ($page as $element) {
            // doSomethingWith($element);
        }
    }
    // Alternatively:
    // Iterate through all elements
    $pagedResponse = $essentialContactsServiceClient->computeContacts($formattedParent);
    foreach ($pagedResponse->iterateAllElements() as $element) {
        // doSomethingWith($element);
    }
} finally {
    $essentialContactsServiceClient->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.

This service has a new (beta) implementation. See Google\Cloud\EssentialContacts\V1\Client\EssentialContactsServiceClient to use the new surface.

Namespace

Google \ Cloud \ EssentialContacts \ V1

Methods

__construct

Constructor.

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

computeContacts

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

Parameters
NameDescription
parent string

Required. The name of the resource to compute contacts for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}

optionalArgs array

Optional.

↳ notificationCategories int[]

The categories of notifications to compute contacts for. If ALL is included in this list, contacts subscribed to any notification category will be returned. For allowed values, use constants defined on Google\Cloud\EssentialContacts\V1\NotificationCategory

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

Returns
TypeDescription
Google\ApiCore\PagedListResponse
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.

Parameters
NameDescription
parent string

Required. The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}

contact Google\Cloud\EssentialContacts\V1\Contact

Required. The contact to create. Must specify an email address and language tag.

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.

Returns
TypeDescription
Google\Cloud\EssentialContacts\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.

Parameters
NameDescription
name string

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

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.

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.

Parameters
NameDescription
name string

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

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.

Returns
TypeDescription
Google\Cloud\EssentialContacts\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.

Parameters
NameDescription
parent string

Required. The parent resource name. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}

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.

Returns
TypeDescription
Google\ApiCore\PagedListResponse
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.

Parameters
NameDescription
contacts string[]

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

resource string

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

notificationCategory int

Required. The notification category to send the test message for. All contacts must be subscribed to this category. For allowed values, use constants defined on Google\Cloud\EssentialContacts\V1\NotificationCategory

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.

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.

Parameters
NameDescription
contact Google\Cloud\EssentialContacts\V1\Contact

Required. The contact resource to replace the existing saved contact. Note: the email address of the contact cannot be modified.

optionalArgs array

Optional.

↳ updateMask FieldMask

Optional. The update mask applied to the resource. For the FieldMask definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\Cloud\EssentialContacts\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
    );
}

static::contactName

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

Parameters
NameDescription
project string
contact string
Returns
TypeDescription
stringThe formatted contact resource.

static::folderName

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

Parameter
NameDescription
folder string
Returns
TypeDescription
stringThe formatted folder resource.

static::folderContactName

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

Parameters
NameDescription
folder string
contact string
Returns
TypeDescription
stringThe formatted folder_contact resource.

static::organizationName

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

Parameter
NameDescription
organization string
Returns
TypeDescription
stringThe formatted organization resource.

static::organizationContactName

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

Parameters
NameDescription
organization string
contact string
Returns
TypeDescription
stringThe formatted organization_contact resource.

static::projectName

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

Parameter
NameDescription
project string
Returns
TypeDescription
stringThe formatted project resource.

static::projectContactName

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

Parameters
NameDescription
project string
contact string
Returns
TypeDescription
stringThe 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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

Constants

SERVICE_NAME

Value: 'google.cloud.essentialcontacts.v1.EssentialContactsService'

The name of the service.

SERVICE_ADDRESS

Value: 'essentialcontacts.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.