Google Cloud Privileged Access Manager V1 Client - Class PrivilegedAccessManagerClient (0.1.1)

Reference documentation and code samples for the Google Cloud Privileged Access Manager V1 Client class PrivilegedAccessManagerClient.

Service Description: This API allows customers to manage temporary, request based privileged access to their resources.

It defines the following resource model:

  • A collection of Entitlement resources. An entitlement allows configuring (among other things):

  • Some kind of privileged access that users can request.

  • A set of users called requesters who can request this access.
  • A maximum duration for which the access can be requested.
  • An optional approval workflow which must be satisfied before access is granted.

  • A collection of Grant resources. A grant is a request by a requester to get the privileged access specified in an entitlement for some duration.

After the approval workflow as specified in the entitlement is satisfied, the specified access is given to the requester. The access is automatically taken back after the requested duration is over.

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

Methods

__construct

Constructor.

Parameters
Name Description
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.

approveGrant

ApproveGrant is used to approve a grant. This method can only be called on a grant when it's in the APPROVAL_AWAITED state. This operation can't be undone.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::approveGrantAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\ApproveGrantRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\Grant
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\ApproveGrantRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;

/**
 * @param string $formattedName Name of the grant resource which is being approved. Please see
 *                              {@see PrivilegedAccessManagerClient::grantName()} for help formatting this field.
 */
function approve_grant_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Grant $response */
        $response = $privilegedAccessManagerClient->approveGrant($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 = PrivilegedAccessManagerClient::grantName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]',
        '[GRANT]'
    );

    approve_grant_sample($formattedName);
}

checkOnboardingStatus

CheckOnboardingStatus reports the onboarding status for a project/folder/organization. Any findings reported by this API need to be fixed before PAM can be used on the resource.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::checkOnboardingStatusAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\CheckOnboardingStatusRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\CheckOnboardingStatusResponse
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\CheckOnboardingStatusRequest;
use Google\Cloud\PrivilegedAccessManager\V1\CheckOnboardingStatusResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;

/**
 * @param string $formattedParent The resource for which the onboarding status should be checked.
 *                                Should be in one of the following formats:
 *
 *                                * `projects/{project-number|project-id}/locations/{region}`
 *                                * `folders/{folder-number}/locations/{region}`
 *                                * `organizations/{organization-number}/locations/{region}`
 *                                Please see {@see PrivilegedAccessManagerClient::organizationLocationName()} for help formatting this field.
 */
function check_onboarding_status_sample(string $formattedParent): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var CheckOnboardingStatusResponse $response */
        $response = $privilegedAccessManagerClient->checkOnboardingStatus($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 = PrivilegedAccessManagerClient::organizationLocationName(
        '[ORGANIZATION]',
        '[LOCATION]'
    );

    check_onboarding_status_sample($formattedParent);
}

createEntitlement

Creates a new entitlement in a given project/folder/organization and location.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::createEntitlementAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\CreateEntitlementRequest

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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\CreateEntitlementRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement\RequesterJustificationConfig;
use Google\Protobuf\Duration;
use Google\Rpc\Status;

/**
 * @param string $formattedParent Name of the parent resource for the entitlement.
 *                                Possible formats:
 *
 *                                * `organizations/{organization-number}/locations/{region}`
 *                                * `folders/{folder-number}/locations/{region}`
 *                                * `projects/{project-id|project-number}/locations/{region}`
 *                                Please see {@see PrivilegedAccessManagerClient::organizationLocationName()} for help formatting this field.
 * @param string $entitlementId   The ID to use for this entitlement. This becomes the last part of
 *                                the resource name.
 *
 *                                This value should be 4-63 characters in length, and valid characters are
 *                                "[a-z]", "[0-9]", and "-". The first character should be from [a-z].
 *
 *                                This value should be unique among all other entitlements under the
 *                                specified `parent`.
 */
function create_entitlement_sample(string $formattedParent, string $entitlementId): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

    // Prepare the request message.
    $entitlementMaxRequestDuration = new Duration();
    $entitlementRequesterJustificationConfig = new RequesterJustificationConfig();
    $entitlement = (new Entitlement())
        ->setMaxRequestDuration($entitlementMaxRequestDuration)
        ->setRequesterJustificationConfig($entitlementRequesterJustificationConfig);
    $request = (new CreateEntitlementRequest())
        ->setParent($formattedParent)
        ->setEntitlementId($entitlementId)
        ->setEntitlement($entitlement);

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

        if ($response->operationSucceeded()) {
            /** @var Entitlement $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 = PrivilegedAccessManagerClient::organizationLocationName(
        '[ORGANIZATION]',
        '[LOCATION]'
    );
    $entitlementId = '[ENTITLEMENT_ID]';

    create_entitlement_sample($formattedParent, $entitlementId);
}

createGrant

Creates a new grant in a given project and location.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::createGrantAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\CreateGrantRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\Grant
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\CreateGrantRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;
use Google\Protobuf\Duration;

/**
 * @param string $formattedParent Name of the parent entitlement for which this grant is being
 *                                requested. Please see
 *                                {@see PrivilegedAccessManagerClient::entitlementName()} for help formatting this field.
 */
function create_grant_sample(string $formattedParent): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

    // Prepare the request message.
    $grantRequestedDuration = new Duration();
    $grant = (new Grant())
        ->setRequestedDuration($grantRequestedDuration);
    $request = (new CreateGrantRequest())
        ->setParent($formattedParent)
        ->setGrant($grant);

    // Call the API and handle any network failures.
    try {
        /** @var Grant $response */
        $response = $privilegedAccessManagerClient->createGrant($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 = PrivilegedAccessManagerClient::entitlementName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]'
    );

    create_grant_sample($formattedParent);
}

deleteEntitlement

Deletes a single entitlement. This method can only be called when there are no in-progress (ACTIVE/ACTIVATING/REVOKING) grants under the entitlement.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::deleteEntitlementAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\DeleteEntitlementRequest

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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\DeleteEntitlementRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see PrivilegedAccessManagerClient::entitlementName()} for help formatting this field.
 */
function delete_entitlement_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Entitlement $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 = PrivilegedAccessManagerClient::entitlementName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]'
    );

    delete_entitlement_sample($formattedName);
}

denyGrant

DenyGrant is used to deny a grant. This method can only be called on a grant when it's in the APPROVAL_AWAITED state. This operation can't be undone.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::denyGrantAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\DenyGrantRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\Grant
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\DenyGrantRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;

/**
 * @param string $formattedName Name of the grant resource which is being denied. Please see
 *                              {@see PrivilegedAccessManagerClient::grantName()} for help formatting this field.
 */
function deny_grant_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Grant $response */
        $response = $privilegedAccessManagerClient->denyGrant($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 = PrivilegedAccessManagerClient::grantName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]',
        '[GRANT]'
    );

    deny_grant_sample($formattedName);
}

getEntitlement

Gets details of a single entitlement.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::getEntitlementAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\GetEntitlementRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\Entitlement
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Cloud\PrivilegedAccessManager\V1\GetEntitlementRequest;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see PrivilegedAccessManagerClient::entitlementName()} for help formatting this field.
 */
function get_entitlement_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Entitlement $response */
        $response = $privilegedAccessManagerClient->getEntitlement($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 = PrivilegedAccessManagerClient::entitlementName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]'
    );

    get_entitlement_sample($formattedName);
}

getGrant

Get details of a single grant.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::getGrantAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\GetGrantRequest

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
Type Description
Google\Cloud\PrivilegedAccessManager\V1\Grant
Example
use Google\ApiCore\ApiException;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\GetGrantRequest;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;

/**
 * @param string $formattedName Name of the resource. Please see
 *                              {@see PrivilegedAccessManagerClient::grantName()} for help formatting this field.
 */
function get_grant_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var Grant $response */
        $response = $privilegedAccessManagerClient->getGrant($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 = PrivilegedAccessManagerClient::grantName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]',
        '[GRANT]'
    );

    get_grant_sample($formattedName);
}

listEntitlements

Lists entitlements in a given project/folder/organization and location.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::listEntitlementsAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\ListEntitlementsRequest

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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Cloud\PrivilegedAccessManager\V1\ListEntitlementsRequest;

/**
 * @param string $formattedParent The parent which owns the entitlement resources. Please see
 *                                {@see PrivilegedAccessManagerClient::organizationLocationName()} for help formatting this field.
 */
function list_entitlements_sample(string $formattedParent): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        /** @var Entitlement $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 = PrivilegedAccessManagerClient::organizationLocationName(
        '[ORGANIZATION]',
        '[LOCATION]'
    );

    list_entitlements_sample($formattedParent);
}

listGrants

Lists grants for a given entitlement.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::listGrantsAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\ListGrantsRequest

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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;
use Google\Cloud\PrivilegedAccessManager\V1\ListGrantsRequest;

/**
 * @param string $formattedParent The parent resource which owns the grants. Please see
 *                                {@see PrivilegedAccessManagerClient::entitlementName()} for help formatting this field.
 */
function list_grants_sample(string $formattedParent): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        /** @var Grant $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 = PrivilegedAccessManagerClient::entitlementName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]'
    );

    list_grants_sample($formattedParent);
}

revokeGrant

RevokeGrant is used to immediately revoke access for a grant. This method can be called when the grant is in a non-terminal state.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::revokeGrantAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\RevokeGrantRequest

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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;
use Google\Cloud\PrivilegedAccessManager\V1\RevokeGrantRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName Name of the grant resource which is being revoked. Please see
 *                              {@see PrivilegedAccessManagerClient::grantName()} for help formatting this field.
 */
function revoke_grant_sample(string $formattedName): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        if ($response->operationSucceeded()) {
            /** @var Grant $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 = PrivilegedAccessManagerClient::grantName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]',
        '[GRANT]'
    );

    revoke_grant_sample($formattedName);
}

searchEntitlements

SearchEntitlements returns entitlements on which the caller has the specified access.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::searchEntitlementsAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\SearchEntitlementsRequest

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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Cloud\PrivilegedAccessManager\V1\SearchEntitlementsRequest;
use Google\Cloud\PrivilegedAccessManager\V1\SearchEntitlementsRequest\CallerAccessType;

/**
 * @param string $formattedParent  The parent which owns the entitlement resources. Please see
 *                                 {@see PrivilegedAccessManagerClient::organizationLocationName()} for help formatting this field.
 * @param int    $callerAccessType Only entitlements where the calling user has this access are
 *                                 returned.
 */
function search_entitlements_sample(string $formattedParent, int $callerAccessType): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        /** @var Entitlement $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 = PrivilegedAccessManagerClient::organizationLocationName(
        '[ORGANIZATION]',
        '[LOCATION]'
    );
    $callerAccessType = CallerAccessType::CALLER_ACCESS_TYPE_UNSPECIFIED;

    search_entitlements_sample($formattedParent, $callerAccessType);
}

searchGrants

SearchGrants returns grants that are related to the calling user in the specified way.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::searchGrantsAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\SearchGrantsRequest

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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Grant;
use Google\Cloud\PrivilegedAccessManager\V1\SearchGrantsRequest;
use Google\Cloud\PrivilegedAccessManager\V1\SearchGrantsRequest\CallerRelationshipType;

/**
 * @param string $formattedParent    The parent which owns the grant resources. Please see
 *                                   {@see PrivilegedAccessManagerClient::entitlementName()} for help formatting this field.
 * @param int    $callerRelationship Only grants which the caller is related to by this relationship
 *                                   are returned in the response.
 */
function search_grants_sample(string $formattedParent, int $callerRelationship): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

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

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

        /** @var Grant $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 = PrivilegedAccessManagerClient::entitlementName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTITLEMENT]'
    );
    $callerRelationship = CallerRelationshipType::CALLER_RELATIONSHIP_TYPE_UNSPECIFIED;

    search_grants_sample($formattedParent, $callerRelationship);
}

updateEntitlement

Updates the entitlement specified in the request. Updated fields in the entitlement need to be specified in an update mask. The changes made to an entitlement are applicable only on future grants of the entitlement.

However, if new approvers are added or existing approvers are removed from the approval workflow, the changes are effective on existing grants.

The following fields are not supported for updates:

  • All immutable fields
  • Entitlement name
  • Resource name
  • Resource type
  • Adding an approval workflow in an entitlement which previously had no approval workflow.
  • Deleting the approval workflow from an entitlement.
  • Adding or deleting a step in the approval workflow (only one step is supported)

Note that updates are allowed on the list of approvers in an approval workflow step.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::updateEntitlementAsync() .

Parameters
Name Description
request Google\Cloud\PrivilegedAccessManager\V1\UpdateEntitlementRequest

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
Type Description
Google\ApiCore\OperationResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\OperationResponse;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement;
use Google\Cloud\PrivilegedAccessManager\V1\Entitlement\RequesterJustificationConfig;
use Google\Cloud\PrivilegedAccessManager\V1\UpdateEntitlementRequest;
use Google\Protobuf\Duration;
use Google\Protobuf\FieldMask;
use Google\Rpc\Status;

/**
 * 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 update_entitlement_sample(): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

    // Prepare the request message.
    $entitlementMaxRequestDuration = new Duration();
    $entitlementRequesterJustificationConfig = new RequesterJustificationConfig();
    $entitlement = (new Entitlement())
        ->setMaxRequestDuration($entitlementMaxRequestDuration)
        ->setRequesterJustificationConfig($entitlementRequesterJustificationConfig);
    $updateMask = new FieldMask();
    $request = (new UpdateEntitlementRequest())
        ->setEntitlement($entitlement)
        ->setUpdateMask($updateMask);

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

        if ($response->operationSucceeded()) {
            /** @var Entitlement $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());
    }
}

getLocation

Gets information about a location.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::getLocationAsync() .

Parameters
Name Description
request Google\Cloud\Location\GetLocationRequest

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
Type Description
Google\Cloud\Location\Location
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function get_location_sample(): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

    // Prepare the request message.
    $request = new GetLocationRequest();

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

listLocations

Lists information about the supported locations for this service.

The async variant is Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient::listLocationsAsync() .

Parameters
Name Description
request Google\Cloud\Location\ListLocationsRequest

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
Type Description
Google\ApiCore\PagedListResponse
Example
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Location\ListLocationsRequest;
use Google\Cloud\Location\Location;
use Google\Cloud\PrivilegedAccessManager\V1\Client\PrivilegedAccessManagerClient;

/**
 * This sample has been automatically generated and should be regarded as a code
 * template only. It will require modifications to work:
 *  - It may require correct/in-range values for request initialization.
 *  - It may require specifying regional endpoints when creating the service client,
 *    please see the apiEndpoint client configuration option for more details.
 */
function list_locations_sample(): void
{
    // Create a client.
    $privilegedAccessManagerClient = new PrivilegedAccessManagerClient();

    // Prepare the request message.
    $request = new ListLocationsRequest();

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

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

PromiseInterface

Returns
Type Description
void

getOperationsClient

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

Returns
Type Description
Google\LongRunning\Client\OperationsClient

resumeOperation

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

Parameters
Name Description
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
Type Description
Google\ApiCore\OperationResponse

static::entitlementName

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

Parameters
Name Description
project string
location string
entitlement string
Returns
Type Description
string The formatted entitlement resource.

static::folderLocationName

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

Parameters
Name Description
folder string
location string
Returns
Type Description
string The formatted folder_location resource.

static::folderLocationEntitlementName

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

Parameters
Name Description
folder string
location string
entitlement string
Returns
Type Description
string The formatted folder_location_entitlement resource.

static::folderLocationEntitlementGrantName

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

Parameters
Name Description
folder string
location string
entitlement string
grant string
Returns
Type Description
string The formatted folder_location_entitlement_grant resource.

static::grantName

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

Parameters
Name Description
project string
location string
entitlement string
grant string
Returns
Type Description
string The formatted grant resource.

static::locationName

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

Parameters
Name Description
project string
location string
Returns
Type Description
string The formatted location resource.

static::organizationLocationName

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

Parameters
Name Description
organization string
location string
Returns
Type Description
string The formatted organization_location resource.

static::organizationLocationEntitlementName

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

Parameters
Name Description
organization string
location string
entitlement string
Returns
Type Description
string The formatted organization_location_entitlement resource.

static::organizationLocationEntitlementGrantName

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

Parameters
Name Description
organization string
location string
entitlement string
grant string
Returns
Type Description
string The formatted organization_location_entitlement_grant resource.

static::projectLocationEntitlementName

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

Parameters
Name Description
project string
location string
entitlement string
Returns
Type Description
string The formatted project_location_entitlement resource.

static::projectLocationEntitlementGrantName

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

Parameters
Name Description
project string
location string
entitlement string
grant string
Returns
Type Description
string The formatted project_location_entitlement_grant 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

  • entitlement: projects/{project}/locations/{location}/entitlements/{entitlement}
  • folderLocation: folders/{folder}/locations/{location}
  • folderLocationEntitlement: folders/{folder}/locations/{location}/entitlements/{entitlement}
  • folderLocationEntitlementGrant: folders/{folder}/locations/{location}/entitlements/{entitlement}/grants/{grant}
  • grant: projects/{project}/locations/{location}/entitlements/{entitlement}/grants/{grant}
  • location: projects/{project}/locations/{location}
  • organizationLocation: organizations/{organization}/locations/{location}
  • organizationLocationEntitlement: organizations/{organization}/locations/{location}/entitlements/{entitlement}
  • organizationLocationEntitlementGrant: organizations/{organization}/locations/{location}/entitlements/{entitlement}/grants/{grant}
  • projectLocationEntitlement: projects/{project}/locations/{location}/entitlements/{entitlement}
  • projectLocationEntitlementGrant: projects/{project}/locations/{location}/entitlements/{entitlement}/grants/{grant}

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.