Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class Iam.
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} 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();
Methods
__construct
connection
Google\Cloud\Core\Iam\IamConnectionInterface
resource
string
options
array
Configuration Options
↳ parent
string|null
The parent request parameter for the policy. If set, policy data will be sent as request.{$parent}
. Otherwise, policy will be sent in request root. Defaults to policy
.
↳ args
array
Arbitrary data to be sent with the request.
policy
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}.
Example:
$policy = $iam->policy();
options
array
Configuration Options
array
setPolicy
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);
policy
options
array
Configuration Options
array
testPermissions
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'
]);
permissions
array
A list of permissions to test
options
array
Configuration Options
array
reload
Refresh the IAM policy for this resource.
Example:
$policy = $iam->reload();
options
array
Configuration Options
array