Search code examples
pythongoogle-cloud-platformgoogle-apigoogle-oauthgoogle-api-python-client

How to disable gcp services by using python (client library files)?


I can able to disable GCP services via gcloud by using gcloud services disable storage.googleapis.com. but i need to achieve via python client library files (reference), I searched but no luck. For Authentication i have credentials.json file. do we have any way ? can any one suggest me the code or reference document or site pl?


Solution

  • I believe you referenced the wrong documentation, here is the Python SDK documentation you should look at: https://googleapis.github.io/google-api-python-client/docs/dyn/serviceusage_v1.services.html#disable

    Something similar as below (haven't tested it):

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