[英]How to delete a GCP Resource Folder programatically?
I am trying to create a cron service that cleans up (removes billing and deletes) a bunch of projects and resource folders on GCP for a development team.我正在尝试创建一个 cron 服务,为开发团队清理(删除计费和删除)GCP 上的一堆项目和资源文件夹。 Ideally, I would like to use cloud functions to do this as its lightweight, however, I can't seem to find any client libraries that would allow for FOLDER deletion .
理想情况下,我想使用云功能来执行此操作,因为它是轻量级的,但是,我似乎找不到任何允许删除 FOLDER 的客户端库。 Has anyone been able to find any client libraries to do this?
有没有人能够找到任何客户端库来执行此操作?
The other options I am considering are:我正在考虑的其他选择是:
You can use the discovery API. We use it in production (only for search and then attach project to a folder)您可以使用发现 API。我们在生产中使用它(仅用于搜索,然后将项目附加到文件夹)
An example of our python code我们的 python 代码示例
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
#Use GCF Service Account credentials for all APIs call
CREDENTIALS = GoogleCredentials.get_application_default()
SERVICE_RESOURCE_MANAGER_FOLDER = discovery.build('cloudresourcemanager', 'v2',
credentials=CREDENTIALS)
# Example for a search
request = SERVICE_RESOURCE_MANAGER_FOLDER.folders().search(body=body)
response = request.execute()
Use the delete operation if you want to do this.如果要执行此操作,请使用删除操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.