4

How can I enable/disable APIs/Services in Google Cloud Project via Restful APIs or python?

For example, I want to enable following API/Service in a project.

https://console.developers.google.com/apis/api/iam.googleapis.com/overview?project=

A_K
  • 81
  • 8
  • Have you looked at; https://cloud.google.com/service-management/enable-disable ? or https://cloud.google.com/compute/docs/api/how-tos/api-requests-responses – user3788685 Jul 01 '17 at 14:33
  • In the first link it just shows option to enable and disable services via gcloud and curl. I am not sure how I can integrate this in python script. The other link is for compute resource creation. – A_K Jul 01 '17 at 18:24
  • You can execute a bash command using python, but first setup gcloud CLI or you have curl which is just another way to make a HTTP request, search for a python library for same, I'm sure there would be many available. https://stackoverflow.com/questions/4256107/running-bash-commands-in-python – Bhavay Anand Jul 19 '19 at 06:30

1 Answers1

1

You can programmatically enable or disable a GCP service using the Service Usage API. There are also methods for batch operations and querying service state. See the link below to the documentation.

https://cloud.google.com/service-usage/docs/reference/rest/v1/services

Eric Aya
  • 69,473
  • 35
  • 181
  • 253