0

on this page https://cloud.google.com/resource-manager/reference/rest/v1/projects/setIamPolicy

Way down at the bottom are come code examples. The PHP code follows. The problem is the line

$response = $service->projects->setIamPolicy($resource, $requestBody);

There is no defined 'projects' property. I'm guessing this is out of date. Can anyone describe how this should be used, or offer a correction?

require_once __DIR__ . '/vendor/autoload.php';

$client = new Google_Client();
$client->setApplicationName('Google-CloudResourceManagerSample/0.1');
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/cloud-platform');

$service = new Google_Service_CloudResourceManager($client);

// REQUIRED: The resource for which the policy is being specified.
// See the operation documentation for the appropriate value for this field.
$resource = 'my-resource';  // TODO: Update placeholder value.

// TODO: Assign values to desired properties of `requestBody`:
$requestBody = new Google_Service_CloudResourceManager_SetIamPolicyRequest();

$response = $service->projects->setIamPolicy($resource, $requestBody);

// TODO: Change code below to process the `response` object:
echo '<pre>', var_export($response, true), '</pre>', "\n";

1 Answer 1

1

I don’t think that the example is out-dated, I think that it assumes you have reviewed this other Document:

https://cloud.google.com/resource-manager/reference/rest/v1/projects/get

Nevertheless, if you think that the info is missing, you could press “send feedback” on the top-right on the document.

Good Luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.