问题描述
我们正在代表用户(OAuth2)在Google Cloud上部署我们的软件.我们已经设法使其中的大多数自动化,但是缺少了一点.
We're deploying our software on behalf (OAuth2) of users on Google Cloud. We've managed to automate most of it, but there's one bit that's missing.
- 使用 https://godoc创建项目.org/google.golang.org/api/cloudresourcemanager/v1#ProjectsService.Create
- 启用所需的API(计算,存储等)是通过google.golang.org/api/servicemanagement/v1#ServicesService.Enable(由于SO的限制非常有限,无法发布为完整链接)
- 使用google.golang.org/api/compute/v1#InstancesService.Insert 创建实例
- Creating the project is done with https://godoc.org/google.golang.org/api/cloudresourcemanager/v1#ProjectsService.Create
- Enabling the required APIs (compute, storage, etc) is done with google.golang.org/api/servicemanagement/v1#ServicesService.Enable (can't post as full link thanks to the very bright SO limitations)
- Creating the instance is done with google.golang.org/api/compute/v1#InstancesService.Insert
步骤1和步骤2之间缺少位:为了利用Service Management API to enable the needed APIs
,我们需要在项目上启用服务管理API本身(具有讽刺意味的).我希望必须有一种方法可以从一开始就启用启用某些API的项目,或者使用cloudresourcemanager或使用 https://godoc.org/google.golang.org/api/deploymentmanager/v2 ,但到目前为止我还没有找到它.
The missing bit is between step 1 and step 2: in order to make use of the Service Management API to enable the needed APIs
, we need the Service Management API itself to be enabled on the project (how ironic). I'm hoping there must be a way to create a project with some APIs enabled from the start, maybe with cloudresourcemanager, or maybe with https://godoc.org/google.golang.org/api/deploymentmanager/v2, but I haven't found it so far.
因此,请重申一下:有没有人知道(在Go中)创建一个在创建后立即启用某些特定Google Cloud API的Google Cloud项目吗?
So, to restate: does anyone know if it's possible (in Go) to create a Google Cloud project with some specific Google Cloud APIs enabled right on/after creation?
推荐答案
使用服务使用API: https://cloud.google.com/service-usage/docs/reference /rest/
Use the Service Usage API:https://cloud.google.com/service-usage/docs/reference/rest/
(已更新)
这篇关于如何在启用了服务管理API的情况下创建Google Cloud项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!