php - PHP示例下GCP setIamPolicy API参考中的问题
问题描述
在此页面上https://cloud.google.com/resource-manager/reference/rest/v1/projects/setIamPolicy
底部是代码示例。PHP 代码如下。问题是线路
$response = $service->projects->setIamPolicy($resource, $requestBody);
没有定义的“项目”属性。我猜这已经过时了。任何人都可以描述应该如何使用它,或者提供更正吗?
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";
解决方案
我不认为该示例已经过时,我认为它假设您已经查看了其他文档:
https://cloud.google.com/resource-manager/reference/rest/v1/projects/get
不过,如果您认为信息丢失,您可以按文档右上角的“发送反馈”。
祝你好运!
推荐阅读
- javascript - CKEditor 4.6 有时会在不进行配置的情况下剥离属性
- java - 如何使用 Groovy 在 Outlook 中创建“免费”条目?
- node.js - 如何显示完整的属性路径 Joi 验证
- laravel - 通过修剪函数将输入名称变量转换为在数据库中搜索
- elasticsearch - 在logstash中分离键值对
- javascript - 如何在 switch 语句中传递按钮 ID 以执行该按钮应该执行的任何功能?
- xamarin - Xamarin Forms:IOS 上的 Webview 自动打开 IFrame
- angular - “可观察”类型上不存在属性“distinctUntilChanged”
' - java - 如何在 java 中使用 REST/SOAP 获取联邦快递的跟踪详细信息?
- database - 在 laravel 5.4 中更新列值