Problem in GCP setIamPolicy API reference under PHP example

穿精又带淫゛_ 提交于 2019-12-13 03:24:18

问题


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:


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!



来源:https://stackoverflow.com/questions/58126932/problem-in-gcp-setiampolicy-api-reference-under-php-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!