【问题标题】:How to disable gcp services by using python (client library files)?如何使用 python(客户端库文件)禁用 gcp 服务?
【发布时间】:2022-01-05 15:41:00
【问题描述】:

我可以使用 gcloud services disable storage.googleapis.com 通过 gcloud 禁用 GCP 服务。但我需要通过 python 客户端库文件 (reference) 来实现,我搜索但没有运气。对于身份验证,我有 credentials.json 文件。我们有什么办法吗?任何人都可以建议我的代码或参考文档或网站吗?

【问题讨论】:

标签: python google-cloud-platform google-api google-oauth google-api-python-client


【解决方案1】:

我相信您引用了错误的文档,这里是您应该查看的 Python SDK 文档:https://googleapis.github.io/google-api-python-client/docs/dyn/serviceusage_v1.services.html#disable

类似如下(未测试):

client = discovery.build('serviceusage', 'v1', credentials=credentials)
svc_name = "projects/123/services/serviceusage.googleapis.com"
operation = client.services().disable(name=svc_name).execute()

【讨论】:

  • 它工作得很好,谢谢兄弟
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-13
  • 1970-01-01
  • 2012-07-28
  • 1970-01-01
  • 1970-01-01
  • 2022-07-08
  • 1970-01-01
相关资源
最近更新 更多