Google Cloud Managed Identities V1 Client - Class ManagedIdentitiesServiceClient (1.3.0)

Reference documentation and code samples for the Google Cloud Managed Identities V1 Client class ManagedIdentitiesServiceClient.

Service Description: API Overview

The managedidentites.googleapis.com service implements the Google Cloud Managed Identites API for identity services (e.g. Microsoft Active Directory).

The Managed Identities service provides methods to manage (create/read/update/delete) domains, reset managed identities admin password, add/remove domain controllers in GCP regions and add/remove VPC peering.

Data Model

The Managed Identities service exposes the following resources:

  • Locations as global, named as follows: projects/{project_id}/locations/global.

  • Domains, named as follows: /projects/{project_id}/locations/global/domain/{domain_name}.

The {domain_name} refers to fully qualified domain name in the customer project e.g. mydomain.myorganization.com, with the following restrictions:

  • Must contain only lowercase letters, numbers, periods and hyphens.
  • Must start with a letter.
  • Must contain between 2-64 characters.
  • Must end with a number or a letter.
  • Must not start with period.
  • First segement length (mydomain form example above) shouldn't exceed 15 chars.
  • The last segment cannot be fully numeric.
  • Must be unique within the customer project.

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

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.

attachTrust

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\AttachTrustRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\AttachTrustRequest;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\Trust;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustDirection;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustType;
use Google\Rpc\Status;

/**
 * @param string $formattedName                    The resource domain name, project name and location using the form:
 *                                                 `projects/{project_id}/locations/global/domains/{domain_name}`
 *                                                 Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 * @param string $trustTargetDomainName            The fully qualified target domain name which will be in trust with the
 *                                                 current domain.
 * @param int    $trustTrustType                   The type of trust represented by the trust resource.
 * @param int    $trustTrustDirection              The trust direction, which decides if the current domain is trusted,
 *                                                 trusting, or both.
 * @param string $trustTargetDnsIpAddressesElement The target DNS server IP addresses which can resolve the remote domain
 *                                                 involved in the trust.
 * @param string $trustTrustHandshakeSecret        The trust secret used for the handshake with the target domain. This will
 *                                                 not be stored.
 */
function attach_trust_sample(
    string $formattedName,
    string $trustTargetDomainName,
    int $trustTrustType,
    int $trustTrustDirection,
    string $trustTargetDnsIpAddressesElement,
    string $trustTrustHandshakeSecret
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $trustTargetDnsIpAddresses = [$trustTargetDnsIpAddressesElement,];
    $trust = (new Trust())
        ->setTargetDomainName($trustTargetDomainName)
        ->setTrustType($trustTrustType)
        ->setTrustDirection($trustTrustDirection)
        ->setTargetDnsIpAddresses($trustTargetDnsIpAddresses)
        ->setTrustHandshakeSecret($trustTrustHandshakeSecret);
    $request = (new AttachTrustRequest())
        ->setName($formattedName)
        ->setTrust($trust);

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

        if ($response->operationSucceeded()) {
            /** @var Domain $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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');
    $trustTargetDomainName = '[TARGET_DOMAIN_NAME]';
    $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED;
    $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED;
    $trustTargetDnsIpAddressesElement = '[TARGET_DNS_IP_ADDRESSES]';
    $trustTrustHandshakeSecret = '[TRUST_HANDSHAKE_SECRET]';

    attach_trust_sample(
        $formattedName,
        $trustTargetDomainName,
        $trustTrustType,
        $trustTrustDirection,
        $trustTargetDnsIpAddressesElement,
        $trustTrustHandshakeSecret
    );
}

createMicrosoftAdDomain

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\CreateMicrosoftAdDomainRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\CreateMicrosoftAdDomainRequest;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Rpc\Status;

/**
 * @param string $formattedParent        The resource project name and location using the form:
 *                                       `projects/{project_id}/locations/global`
 *                                       Please see {@see ManagedIdentitiesServiceClient::locationName()} for help formatting this field.
 * @param string $domainName             The fully qualified domain name.
 *                                       e.g. mydomain.myorganization.com, with the following restrictions:
 *
 *                                       * Must contain only lowercase letters, numbers, periods and hyphens.
 *                                       * Must start with a letter.
 *                                       * Must contain between 2-64 characters.
 *                                       * Must end with a number or a letter.
 *                                       * Must not start with period.
 *                                       * First segement length (mydomain form example above) shouldn't exceed
 *                                       15 chars.
 *                                       * The last segment cannot be fully numeric.
 *                                       * Must be unique within the customer project.
 * @param string $domainName             The unique name of the domain using the form:
 *                                       `projects/{project_id}/locations/global/domains/{domain_name}`.
 * @param string $domainReservedIpRange  The CIDR range of internal addresses that are reserved for this
 *                                       domain. Reserved networks must be /24 or larger. Ranges must be
 *                                       unique and non-overlapping with existing subnets in
 *                                       [Domain].[authorized_networks].
 * @param string $domainLocationsElement Locations where domain needs to be provisioned.
 *                                       [regions][compute/docs/regions-zones/]
 *                                       e.g. us-west1 or us-east4
 *                                       Service supports up to 4 locations at once. Each location will use a /26
 *                                       block.
 */
function create_microsoft_ad_domain_sample(
    string $formattedParent,
    string $domainName,
    string $domainName,
    string $domainReservedIpRange,
    string $domainLocationsElement
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $domainLocations = [$domainLocationsElement,];
    $domain = (new Domain())
        ->setName($domainName)
        ->setReservedIpRange($domainReservedIpRange)
        ->setLocations($domainLocations);
    $request = (new CreateMicrosoftAdDomainRequest())
        ->setParent($formattedParent)
        ->setDomainName($domainName)
        ->setDomain($domain);

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

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

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

    create_microsoft_ad_domain_sample(
        $formattedParent,
        $domainName,
        $domainName,
        $domainReservedIpRange,
        $domainLocationsElement
    );
}

deleteDomain

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\DeleteDomainRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\DeleteDomainRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The domain resource name using the form:
 *                              `projects/{project_id}/locations/global/domains/{domain_name}`
 *                              Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 */
function delete_domain_sample(string $formattedName): void
{
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $managedIdentitiesServiceClient->deleteDomain($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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    delete_domain_sample($formattedName);
}

detachTrust

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\DetachTrustRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\DetachTrustRequest;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\Trust;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustDirection;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustType;
use Google\Rpc\Status;

/**
 * @param string $formattedName                    The resource domain name, project name, and location using the form:
 *                                                 `projects/{project_id}/locations/global/domains/{domain_name}`
 *                                                 Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 * @param string $trustTargetDomainName            The fully qualified target domain name which will be in trust with the
 *                                                 current domain.
 * @param int    $trustTrustType                   The type of trust represented by the trust resource.
 * @param int    $trustTrustDirection              The trust direction, which decides if the current domain is trusted,
 *                                                 trusting, or both.
 * @param string $trustTargetDnsIpAddressesElement The target DNS server IP addresses which can resolve the remote domain
 *                                                 involved in the trust.
 * @param string $trustTrustHandshakeSecret        The trust secret used for the handshake with the target domain. This will
 *                                                 not be stored.
 */
function detach_trust_sample(
    string $formattedName,
    string $trustTargetDomainName,
    int $trustTrustType,
    int $trustTrustDirection,
    string $trustTargetDnsIpAddressesElement,
    string $trustTrustHandshakeSecret
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $trustTargetDnsIpAddresses = [$trustTargetDnsIpAddressesElement,];
    $trust = (new Trust())
        ->setTargetDomainName($trustTargetDomainName)
        ->setTrustType($trustTrustType)
        ->setTrustDirection($trustTrustDirection)
        ->setTargetDnsIpAddresses($trustTargetDnsIpAddresses)
        ->setTrustHandshakeSecret($trustTrustHandshakeSecret);
    $request = (new DetachTrustRequest())
        ->setName($formattedName)
        ->setTrust($trust);

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

        if ($response->operationSucceeded()) {
            /** @var Domain $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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');
    $trustTargetDomainName = '[TARGET_DOMAIN_NAME]';
    $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED;
    $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED;
    $trustTargetDnsIpAddressesElement = '[TARGET_DNS_IP_ADDRESSES]';
    $trustTrustHandshakeSecret = '[TRUST_HANDSHAKE_SECRET]';

    detach_trust_sample(
        $formattedName,
        $trustTargetDomainName,
        $trustTrustType,
        $trustTrustDirection,
        $trustTargetDnsIpAddressesElement,
        $trustTrustHandshakeSecret
    );
}

getDomain

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\GetDomainRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\Cloud\ManagedIdentities\V1\Domain
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\GetDomainRequest;

/**
 * @param string $formattedName The domain resource name using the form:
 *                              `projects/{project_id}/locations/global/domains/{domain_name}`
 *                              Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 */
function get_domain_sample(string $formattedName): void
{
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Domain $response */
        $response = $managedIdentitiesServiceClient->getDomain($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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    get_domain_sample($formattedName);
}

listDomains

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ListDomainsRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\ListDomainsRequest;

/**
 * @param string $formattedParent The resource name of the domain location using the form:
 *                                `projects/{project_id}/locations/global`
 *                                Please see {@see ManagedIdentitiesServiceClient::locationName()} for help formatting this field.
 */
function list_domains_sample(string $formattedParent): void
{
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

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

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

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

    list_domains_sample($formattedParent);
}

reconfigureTrust

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ReconfigureTrustRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\ReconfigureTrustRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName               The resource domain name, project name and location using the form:
 *                                            `projects/{project_id}/locations/global/domains/{domain_name}`
 *                                            Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 * @param string $targetDomainName            The fully-qualified target domain name which will be in trust with current
 *                                            domain.
 * @param string $targetDnsIpAddressesElement The target DNS server IP addresses to resolve the remote domain involved
 *                                            in the trust.
 */
function reconfigure_trust_sample(
    string $formattedName,
    string $targetDomainName,
    string $targetDnsIpAddressesElement
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $targetDnsIpAddresses = [$targetDnsIpAddressesElement,];
    $request = (new ReconfigureTrustRequest())
        ->setName($formattedName)
        ->setTargetDomainName($targetDomainName)
        ->setTargetDnsIpAddresses($targetDnsIpAddresses);

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

        if ($response->operationSucceeded()) {
            /** @var Domain $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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');
    $targetDomainName = '[TARGET_DOMAIN_NAME]';
    $targetDnsIpAddressesElement = '[TARGET_DNS_IP_ADDRESSES]';

    reconfigure_trust_sample($formattedName, $targetDomainName, $targetDnsIpAddressesElement);
}

resetAdminPassword

Resets a domain's administrator password.

The async variant is Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient::resetAdminPasswordAsync() .

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordRequest;
use Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordResponse;

/**
 * @param string $formattedName The domain resource name using the form:
 *                              `projects/{project_id}/locations/global/domains/{domain_name}`
 *                              Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 */
function reset_admin_password_sample(string $formattedName): void
{
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var ResetAdminPasswordResponse $response */
        $response = $managedIdentitiesServiceClient->resetAdminPassword($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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');

    reset_admin_password_sample($formattedName);
}

updateDomain

Updates the metadata and configuration of a domain.

The async variant is Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient::updateDomainAsync() .

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\UpdateDomainRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\UpdateDomainRequest;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * @param string $domainName             The unique name of the domain using the form:
 *                                       `projects/{project_id}/locations/global/domains/{domain_name}`.
 * @param string $domainReservedIpRange  The CIDR range of internal addresses that are reserved for this
 *                                       domain. Reserved networks must be /24 or larger. Ranges must be
 *                                       unique and non-overlapping with existing subnets in
 *                                       [Domain].[authorized_networks].
 * @param string $domainLocationsElement Locations where domain needs to be provisioned.
 *                                       [regions][compute/docs/regions-zones/]
 *                                       e.g. us-west1 or us-east4
 *                                       Service supports up to 4 locations at once. Each location will use a /26
 *                                       block.
 */
function update_domain_sample(
    string $domainName,
    string $domainReservedIpRange,
    string $domainLocationsElement
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $updateMask = new FieldMask();
    $domainLocations = [$domainLocationsElement,];
    $domain = (new Domain())
        ->setName($domainName)
        ->setReservedIpRange($domainReservedIpRange)
        ->setLocations($domainLocations);
    $request = (new UpdateDomainRequest())
        ->setUpdateMask($updateMask)
        ->setDomain($domain);

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

        if ($response->operationSucceeded()) {
            /** @var Domain $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
{
    $domainName = '[NAME]';
    $domainReservedIpRange = '[RESERVED_IP_RANGE]';
    $domainLocationsElement = '[LOCATIONS]';

    update_domain_sample($domainName, $domainReservedIpRange, $domainLocationsElement);
}

validateTrust

Validates a trust state, that the target domain is reachable, and that the target domain is able to accept incoming trust requests.

The async variant is Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient::validateTrustAsync() .

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ValidateTrustRequest

A request to house fields associated with the call.

callOptions array

Optional.

↳ retrySettings RetrySettings|array

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

Returns
TypeDescription
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\ManagedIdentities\V1\Client\ManagedIdentitiesServiceClient;
use Google\Cloud\ManagedIdentities\V1\Domain;
use Google\Cloud\ManagedIdentities\V1\Trust;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustDirection;
use Google\Cloud\ManagedIdentities\V1\Trust\TrustType;
use Google\Cloud\ManagedIdentities\V1\ValidateTrustRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName                    The resource domain name, project name, and location using the form:
 *                                                 `projects/{project_id}/locations/global/domains/{domain_name}`
 *                                                 Please see {@see ManagedIdentitiesServiceClient::domainName()} for help formatting this field.
 * @param string $trustTargetDomainName            The fully qualified target domain name which will be in trust with the
 *                                                 current domain.
 * @param int    $trustTrustType                   The type of trust represented by the trust resource.
 * @param int    $trustTrustDirection              The trust direction, which decides if the current domain is trusted,
 *                                                 trusting, or both.
 * @param string $trustTargetDnsIpAddressesElement The target DNS server IP addresses which can resolve the remote domain
 *                                                 involved in the trust.
 * @param string $trustTrustHandshakeSecret        The trust secret used for the handshake with the target domain. This will
 *                                                 not be stored.
 */
function validate_trust_sample(
    string $formattedName,
    string $trustTargetDomainName,
    int $trustTrustType,
    int $trustTrustDirection,
    string $trustTargetDnsIpAddressesElement,
    string $trustTrustHandshakeSecret
): void {
    // Create a client.
    $managedIdentitiesServiceClient = new ManagedIdentitiesServiceClient();

    // Prepare the request message.
    $trustTargetDnsIpAddresses = [$trustTargetDnsIpAddressesElement,];
    $trust = (new Trust())
        ->setTargetDomainName($trustTargetDomainName)
        ->setTrustType($trustTrustType)
        ->setTrustDirection($trustTrustDirection)
        ->setTargetDnsIpAddresses($trustTargetDnsIpAddresses)
        ->setTrustHandshakeSecret($trustTrustHandshakeSecret);
    $request = (new ValidateTrustRequest())
        ->setName($formattedName)
        ->setTrust($trust);

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

        if ($response->operationSucceeded()) {
            /** @var Domain $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 = ManagedIdentitiesServiceClient::domainName('[PROJECT]', '[LOCATION]', '[DOMAIN]');
    $trustTargetDomainName = '[TARGET_DOMAIN_NAME]';
    $trustTrustType = TrustType::TRUST_TYPE_UNSPECIFIED;
    $trustTrustDirection = TrustDirection::TRUST_DIRECTION_UNSPECIFIED;
    $trustTargetDnsIpAddressesElement = '[TARGET_DNS_IP_ADDRESSES]';
    $trustTrustHandshakeSecret = '[TRUST_HANDSHAKE_SECRET]';

    validate_trust_sample(
        $formattedName,
        $trustTargetDomainName,
        $trustTrustType,
        $trustTrustDirection,
        $trustTargetDnsIpAddressesElement,
        $trustTrustHandshakeSecret
    );
}

attachTrustAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\AttachTrustRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

createMicrosoftAdDomainAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\CreateMicrosoftAdDomainRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

deleteDomainAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\DeleteDomainRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

detachTrustAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\DetachTrustRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getDomainAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\GetDomainRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

listDomainsAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ListDomainsRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

reconfigureTrustAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ReconfigureTrustRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

resetAdminPasswordAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ResetAdminPasswordRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

updateDomainAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\UpdateDomainRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

validateTrustAsync

Parameters
NameDescription
request Google\Cloud\ManagedIdentities\V1\ValidateTrustRequest
optionalArgs = [] array
Returns
TypeDescription
GuzzleHttp\Promise\PromiseInterface

getOperationsClient

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

Returns
TypeDescription
Google\ApiCore\LongRunning\OperationsClient

resumeOperation

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

Parameters
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

static::domainName

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

Parameters
NameDescription
project string
location string
domain string
Returns
TypeDescription
stringThe formatted domain resource.

static::locationName

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

Parameters
NameDescription
project string
location string
Returns
TypeDescription
stringThe formatted location 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

  • domain: projects/{project}/locations/{location}/domains/{domain}
  • location: projects/{project}/locations/{location}

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.