2 years ago

#33283

test-img

mini_developer

How to disable GCP services via python client library files?

here is reference doc1 , doc2

import google.auth
from google.cloud import servicemanagement_v1,service_usage_v1


credentials,project = google.auth.default()
req = {
    'name' : 'projects/123/services/monitoring.googleapis.com',
    'disable_dependent_services': True,
    # 'check_if_service_has_usage': service_usage_v1.types.DisableServiceRequest.check_if_service_has_usage
}
ok = service_usage_v1.ServiceUsageClient().disable_service(request=req)
print('disabled succesfuly')

If i enabled check_if_service_has_usage its througing error like (AttributeError: type object 'DisableServiceRequest' has no attribute 'check_if_service_has_usage' )

I need to know how to handle check_if_service_has_usage in my code is like bool? then i also need to know when to use True/False for disable_dependent_services

python

google-cloud-platform

google-oauth

google-api-client

google-api-python-client

0 Answers

Your Answer

Accepted video resources