PHP Class Google\Cloud\Iam\Iam

This class is not meant to be used directly. It should be accessed through other objects which support IAM. Note that examples make use of the PubSub API, and the {@see \Google\Cloud\PubSub\Topic} class. Policies can be created using the {@see \Google\Cloud\Iam\PolicyBuilder} to help ensure their validity. Example: IAM policies are obtained via resources which implement IAM. In this example, we'll use PubSub topics to demonstrate how IAM politices are managed. use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder; $pubsub = $cloud->pubsub(); $topic = $pubsub->topic('my-new-topic'); $iam = $topic->iam();
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php Class Usage Examples

Protected Properties

Property Type Description
$connection Google\Cloud\Iam\IamConnectionInterface

Public Methods

Method Description
__construct ( Google\Cloud\Iam\IamConnectionInterface $connection, string $resource )
policy ( array $options = [] ) : array Get the existing IAM policy for this resource.
reload ( array $options = [] ) : array Refresh the IAM policy for this resource.
setPolicy ( array $policy, array $options = [] ) : array Set the IAM policy for this resource.
testPermissions ( array $permissions, array $options = [] ) : array Test if the current user has the given permissions on this resource.

Method Details

__construct() public method

public __construct ( Google\Cloud\Iam\IamConnectionInterface $connection, string $resource )
$connection Google\Cloud\Iam\IamConnectionInterface
$resource string

policy() public method

If a policy has already been retrieved from the API, it will be returned. To fetch a fresh copy of the policy, use {@see \Google\Cloud\Iam\Iam::reload()}. Example: $policy = $iam->policy();
public policy ( array $options = [] ) : array
$options array Configuration Options
return array An array of policy data

reload() public method

Example: $policy = $iam->reload();
public reload ( array $options = [] ) : array
$options array Configuration Options
return array An array of policy data

setPolicy() public method

Bindings with invalid roles, or non-existent members will raise a server error. Example: $oldPolicy = $iam->policy(); $oldPolicy['bindings'][0]['members'] = 'user:[email protected]'; $policy = $iam->setPolicy($oldPolicy);
public setPolicy ( array $policy, array $options = [] ) : array
$policy array A new policy array
$options array Configuration Options
return array An array of policy data

testPermissions() public method

Invalid permissions will raise a BadRequestException. A list of allowed permissions can be found in the access control documentation. Example: $allowedPermissions = $iam->testPermissions([ 'pubsub.topics.publish', 'pubsub.topics.attachSubscription' ]);
public testPermissions ( array $permissions, array $options = [] ) : array
$permissions array A list of permissions to test
$options array Configuration Options
return array A subset of $permissions, with only those allowed included.

Property Details

$connection protected_oe property

protected IamConnectionInterface,Google\Cloud\Iam $connection
return Google\Cloud\Iam\IamConnectionInterface