英文:
How to create a Google Cloud project with service management API enabled?
问题
我们正在代表用户在Google Cloud上部署我们的软件(OAuth2)。我们已经成功自动化了大部分过程,但还有一个缺失的部分。
- 使用https://godoc.org/google.golang.org/api/cloudresourcemanager/v1#ProjectsService.Create来创建项目。
- 使用google.golang.org/api/servicemanagement/v1#ServicesService.Enable来启用所需的API(计算、存储等)(由于SO的限制,无法作为完整链接发布)。
- 使用google.golang.org/api/compute/v1#InstancesService.Insert来创建实例。
缺失的部分在第1步和第2步之间:为了使用“服务管理API来启用所需的API”,我们需要在项目上启用服务管理API本身(多么讽刺)。我希望有一种方法可以在创建时或创建后立即启用一些特定的Google Cloud API,也许可以使用cloudresourcemanager,或者使用https://godoc.org/google.golang.org/api/deploymentmanager/v2,但我目前还没有找到。
因此,重新说明一下:有人知道是否可能(使用Go语言)在创建时或创建后立即启用一些特定的Google Cloud API来创建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.
- 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
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.
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?
答案1
得分: 0
Google Cloud Resource Manager API在允许的操作方面非常有限。
虽然它有一个projects.update方法,但不支持启用API。您需要手动编辑项目。
英文:
The Google Cloud Resource Manager API is very limited in what it will allow you to do.
while it does have a projects.update method it does not support enabling APIs. Your going to have to manually edit the project.
答案2
得分: 0
使用Service Usage API:
https://cloud.google.com/service-usage/docs/reference/rest/
(已更新)
英文:
Use the Service Usage API:
https://cloud.google.com/service-usage/docs/reference/rest/
(updated)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论