Google Cloud Iam V3 Client - Class PolicyBindingsClient (1.1.1)

Reference documentation and code samples for the Google Cloud Iam V3 Client class PolicyBindingsClient.

Service Description: An interface for managing Identity and Access Management (IAM) policy bindings.

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 \ Iam \ V3 \ 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. Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information https://cloud.google.com/docs/authentication/external/externally-sourced-credentials

↳ credentialsConfig array

Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() .

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

↳ logger false|LoggerInterface

A PSR-3 compliant logger. If set to false, logging is disabled, ignoring the 'GOOGLE_SDK_PHP_LOGGING' environment flag

createPolicyBinding

Creates a policy binding and returns a long-running operation.

Callers will need the IAM permissions on both the policy and target. Once the binding is created, the policy is applied to the target.

The async variant is PolicyBindingsClient::createPolicyBindingAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\CreatePolicyBindingRequest

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\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\CreatePolicyBindingRequest;
use Google\Cloud\Iam\V3\PolicyBinding;
use Google\Cloud\Iam\V3\PolicyBinding\Target;
use Google\Rpc\Status;

/**
 * @param string $formattedParent     The parent resource where this policy binding will be created.
 *                                    The binding parent is the closest Resource Manager resource (project,
 *                                    folder or organization) to the binding target.
 *
 *                                    Format:
 *
 *                                    * `projects/{project_id}/locations/{location}`
 *                                    * `projects/{project_number}/locations/{location}`
 *                                    * `folders/{folder_id}/locations/{location}`
 *                                    * `organizations/{organization_id}/locations/{location}`
 *                                    Please see {@see PolicyBindingsClient::organizationLocationName()} for help formatting this field.
 * @param string $policyBindingId     The ID to use for the policy binding, which will become the final
 *                                    component of the policy binding's resource name.
 *
 *                                    This value must start with a lowercase letter followed by up to 62
 *                                    lowercase letters, numbers, hyphens, or dots. Pattern,
 *                                    /[a-z][a-z0-9-\.]{2,62}/.
 * @param string $policyBindingPolicy Immutable. The resource name of the policy to be bound. The
 *                                    binding parent and policy must belong to the same organization.
 */
function create_policy_binding_sample(
    string $formattedParent,
    string $policyBindingId,
    string $policyBindingPolicy
): void {
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

    // Prepare the request message.
    $policyBindingTarget = new Target();
    $policyBinding = (new PolicyBinding())
        ->setTarget($policyBindingTarget)
        ->setPolicy($policyBindingPolicy);
    $request = (new CreatePolicyBindingRequest())
        ->setParent($formattedParent)
        ->setPolicyBindingId($policyBindingId)
        ->setPolicyBinding($policyBinding);

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

        if ($response->operationSucceeded()) {
            /** @var PolicyBinding $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 = PolicyBindingsClient::organizationLocationName('[ORGANIZATION]', '[LOCATION]');
    $policyBindingId = '[POLICY_BINDING_ID]';
    $policyBindingPolicy = '[POLICY]';

    create_policy_binding_sample($formattedParent, $policyBindingId, $policyBindingPolicy);
}

deletePolicyBinding

Deletes a policy binding and returns a long-running operation.

Callers will need the IAM permissions on both the policy and target. Once the binding is deleted, the policy no longer applies to the target.

The async variant is PolicyBindingsClient::deletePolicyBindingAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\DeletePolicyBindingRequest

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\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\DeletePolicyBindingRequest;
use Google\Rpc\Status;

/**
 * @param string $formattedName The name of the policy binding to delete.
 *
 *                              Format:
 *
 *                              * `projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              Please see {@see PolicyBindingsClient::policyBindingName()} for help formatting this field.
 */
function delete_policy_binding_sample(string $formattedName): void
{
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var OperationResponse $response */
        $response = $policyBindingsClient->deletePolicyBinding($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 = PolicyBindingsClient::policyBindingName(
        '[ORGANIZATION]',
        '[LOCATION]',
        '[POLICY_BINDING]'
    );

    delete_policy_binding_sample($formattedName);
}

getPolicyBinding

Gets a policy binding.

The async variant is PolicyBindingsClient::getPolicyBindingAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\GetPolicyBindingRequest

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\Iam\V3\PolicyBinding
Example
use Google\ApiCore\ApiException;
use Google\Cloud\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\GetPolicyBindingRequest;
use Google\Cloud\Iam\V3\PolicyBinding;

/**
 * @param string $formattedName The name of the policy binding to retrieve.
 *
 *                              Format:
 *
 *                              * `projects/{project_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `projects/{project_number}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `folders/{folder_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              * `organizations/{organization_id}/locations/{location}/policyBindings/{policy_binding_id}`
 *                              Please see {@see PolicyBindingsClient::policyBindingName()} for help formatting this field.
 */
function get_policy_binding_sample(string $formattedName): void
{
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

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

    // Call the API and handle any network failures.
    try {
        /** @var PolicyBinding $response */
        $response = $policyBindingsClient->getPolicyBinding($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 = PolicyBindingsClient::policyBindingName(
        '[ORGANIZATION]',
        '[LOCATION]',
        '[POLICY_BINDING]'
    );

    get_policy_binding_sample($formattedName);
}

listPolicyBindings

Lists policy bindings.

The async variant is PolicyBindingsClient::listPolicyBindingsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\ListPolicyBindingsRequest

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\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\ListPolicyBindingsRequest;
use Google\Cloud\Iam\V3\PolicyBinding;

/**
 * @param string $formattedParent The parent resource, which owns the collection of policy
 *                                bindings.
 *
 *                                Format:
 *
 *                                * `projects/{project_id}/locations/{location}`
 *                                * `projects/{project_number}/locations/{location}`
 *                                * `folders/{folder_id}/locations/{location}`
 *                                * `organizations/{organization_id}/locations/{location}`
 *                                Please see {@see PolicyBindingsClient::organizationLocationName()} for help formatting this field.
 */
function list_policy_bindings_sample(string $formattedParent): void
{
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

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

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

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

    list_policy_bindings_sample($formattedParent);
}

searchTargetPolicyBindings

Search policy bindings by target. Returns all policy binding objects bound directly to target.

The async variant is PolicyBindingsClient::searchTargetPolicyBindingsAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\SearchTargetPolicyBindingsRequest

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\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\PolicyBinding;
use Google\Cloud\Iam\V3\SearchTargetPolicyBindingsRequest;

/**
 * @param string $target          The target resource, which is bound to the policy in the binding.
 *
 *                                Format:
 *
 *                                * `//iam.googleapis.com/locations/global/workforcePools/POOL_ID`
 *                                * `//iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID`
 *                                * `//iam.googleapis.com/locations/global/workspace/WORKSPACE_ID`
 *                                * `//cloudresourcemanager.googleapis.com/projects/{project_number}`
 *                                * `//cloudresourcemanager.googleapis.com/folders/{folder_id}`
 *                                * `//cloudresourcemanager.googleapis.com/organizations/{organization_id}`
 * @param string $formattedParent The parent resource where this search will be performed. This
 *                                should be the nearest Resource Manager resource (project, folder, or
 *                                organization) to the target.
 *
 *                                Format:
 *
 *                                * `projects/{project_id}/locations/{location}`
 *                                * `projects/{project_number}/locations/{location}`
 *                                * `folders/{folder_id}/locations/{location}`
 *                                * `organizations/{organization_id}/locations/{location}`
 *                                Please see {@see PolicyBindingsClient::organizationLocationName()} for help formatting this field.
 */
function search_target_policy_bindings_sample(string $target, string $formattedParent): void
{
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

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

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

        /** @var PolicyBinding $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
{
    $target = '[TARGET]';
    $formattedParent = PolicyBindingsClient::organizationLocationName('[ORGANIZATION]', '[LOCATION]');

    search_target_policy_bindings_sample($target, $formattedParent);
}

updatePolicyBinding

Updates a policy binding and returns a long-running operation.

Callers will need the IAM permissions on the policy and target in the binding to update, and the IAM permission to remove the existing policy from the binding. Target is immutable and cannot be updated. Once the binding is updated, the new policy is applied to the target.

The async variant is PolicyBindingsClient::updatePolicyBindingAsync() .

Parameters
Name Description
request Google\Cloud\Iam\V3\UpdatePolicyBindingRequest

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\Iam\V3\Client\PolicyBindingsClient;
use Google\Cloud\Iam\V3\PolicyBinding;
use Google\Cloud\Iam\V3\PolicyBinding\Target;
use Google\Cloud\Iam\V3\UpdatePolicyBindingRequest;
use Google\Rpc\Status;

/**
 * @param string $policyBindingPolicy Immutable. The resource name of the policy to be bound. The
 *                                    binding parent and policy must belong to the same organization.
 */
function update_policy_binding_sample(string $policyBindingPolicy): void
{
    // Create a client.
    $policyBindingsClient = new PolicyBindingsClient();

    // Prepare the request message.
    $policyBindingTarget = new Target();
    $policyBinding = (new PolicyBinding())
        ->setTarget($policyBindingTarget)
        ->setPolicy($policyBindingPolicy);
    $request = (new UpdatePolicyBindingRequest())
        ->setPolicyBinding($policyBinding);

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

        if ($response->operationSucceeded()) {
            /** @var PolicyBinding $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
{
    $policyBindingPolicy = '[POLICY]';

    update_policy_binding_sample($policyBindingPolicy);
}

createPolicyBindingAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\CreatePolicyBindingRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

deletePolicyBindingAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\DeletePolicyBindingRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

getPolicyBindingAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\GetPolicyBindingRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\Cloud\Iam\V3\PolicyBinding>

listPolicyBindingsAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\ListPolicyBindingsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

searchTargetPolicyBindingsAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\SearchTargetPolicyBindingsRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\PagedListResponse>

updatePolicyBindingAsync

Parameters
Name Description
request Google\Cloud\Iam\V3\UpdatePolicyBindingRequest
optionalArgs array
Returns
Type Description
GuzzleHttp\Promise\PromiseInterface<Google\ApiCore\OperationResponse>

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::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::folderLocationPolicyBindingName

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

Parameters
Name Description
folder string
location string
policyBinding string
Returns
Type Description
string The formatted folder_location_policy_binding 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::organizationLocationPolicyBindingName

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

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

static::policyBindingName

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

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

static::projectLocationPolicyBindingName

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

Parameters
Name Description
project string
location string
policyBinding string
Returns
Type Description
string The formatted project_location_policy_binding 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

  • folderLocation: folders/{folder}/locations/{location}
  • folderLocationPolicyBinding: folders/{folder}/locations/{location}/policyBindings/{policy_binding}
  • location: projects/{project}/locations/{location}
  • organizationLocation: organizations/{organization}/locations/{location}
  • organizationLocationPolicyBinding: organizations/{organization}/locations/{location}/policyBindings/{policy_binding}
  • policyBinding: organizations/{organization}/locations/{location}/policyBindings/{policy_binding}
  • projectLocationPolicyBinding: projects/{project}/locations/{location}/policyBindings/{policy_binding}

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.