IAM Manager

This class is not meant to be used directly. It should be accessed
through other objects which support IAM.

Policies can be created using the {@see \Google\Cloud\Core\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 policies are managed.

use Google\Cloud\PubSub\PubSubClient;

$pubsub = new PubSubClient();
$topic = $pubsub->topic('my-new-topic');

$iam = $topic->iam();
CloneableInstantiable
Methods
public __construct(Google\Cloud\Core\Iam\IamConnectionInterface $connection, $resource, array $options = [])
 
  • access private
public policy(array $options = [])
 

Get the existing IAM policy for this resource.

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\Core\Iam\Iam::reload()}.

Example:

$policy = $iam->policy();
  • return array An array of policy data
public reload(array $options = [])
 

Refresh the IAM policy for this resource.

Example:

$policy = $iam->reload();
  • return array An array of policy data
public setPolicy( $policy, array $options = [])
 

Set the IAM policy for this resource.

Bindings with invalid roles, or non-existent members will raise a server
error.

Example:

$oldPolicy = $iam->policy();
$oldPolicy['bindings'][0]['members'] = 'user:test@example.com';

$policy = $iam->setPolicy($oldPolicy);
  • return array An array of policy data
  • throws InvalidArgumentException If the given policy is not an array or PolicyBuilder.
public testPermissions(array $permissions, array $options = [])
 

Test if the current user has the given permissions on this resource.

Invalid permissions will raise a BadRequestException.

Example:

$allowedPermissions = $iam->testPermissions([
    'pubsub.topics.publish',
    'pubsub.topics.attachSubscription'
]);
  • return array A subset of $permissions, with only those allowed included.
Properties
private $args
 
  • var array
private $connection
private $options
 
  • var array
private $policy
 
  • var array
private $resource
 
  • var string
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only