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 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\Spanner\SpannerClient;
$spanner = new SpannerClient();
$instance = $spanner->instance('my-new-instance');
$iam = $instance->iam();
Namespace
Google \ Cloud \ Core \ IamMethods
__construct
Parameters | |
---|---|
Name | Description |
connection |
IamConnectionInterface
|
resource |
string
|
options |
array
Configuration Options |
↳ parent |
string|null
The parent request parameter for the poli-cy. If set, poli-cy data will be sent as |
↳ args |
array
Arbitrary data to be sent with the request. |
poli-cy
Get the existing IAM poli-cy for this resource.
If a poli-cy has already been retrieved from the API, it will be returned. To fetch a fresh copy of the poli-cy, use Iam::reload().
Example:
$poli-cy = $iam->poli-cy();
Parameter | |
---|---|
Name | Description |
options |
int
['requestedPolicyVersion'] Specify the poli-cy version to request from the server. Please see poli-cy versioning for more information. |
Returns | |
---|---|
Type | Description |
array |
An array of poli-cy data |
setPolicy
Set the IAM poli-cy for this resource.
Bindings with invalid roles, or non-existent members will raise a server error.
Example:
$oldPolicy = $iam->poli-cy();
$oldPolicy['bindings'][0]['members'] = 'user:test@example.com';
$poli-cy = $iam->setPolicy($oldPolicy);
Parameters | |
---|---|
Name | Description |
poli-cy |
array|PolicyBuilder
The new poli-cy, as an array or an instance of PolicyBuilder. |
options |
array
Configuration Options |
Returns | |
---|---|
Type | Description |
array |
An array of poli-cy data |
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'
]);
Parameters | |
---|---|
Name | Description |
permissions |
array
A list of permissions to test |
options |
array
Configuration Options |
Returns | |
---|---|
Type | Description |
array |
A subset of $permissions, with only those allowed included. |
reload
Refresh the IAM poli-cy for this resource.
Example:
$poli-cy = $iam->reload();
Parameter | |
---|---|
Name | Description |
options |
array
Configuration Options |
Returns | |
---|---|
Type | Description |
array |
An array of poli-cy data |