0

I have used the documentation here https://cloud.google.com/endpoints/docs/frameworks/enable-api#gcloud to enable new APIs via the gcloud CLI tool. I have a service account with the owner role over my project, is it possible from within the python SDK, to enable APIs without using gcloud? Or, is it possible to call the gcloud CLI tool from the python SDK?

2 Answers 2

2

You can by using the discovery API client library for Service Usage API

You can also perform an authenticated call to the Service Usage API enable service endpoint

Let me know if you have issues and you want code example.

Sign up to request clarification or add additional context in comments.

Comments

1

According to the official documentation:

Enabling APIs

You can enable Cloud APIs for a project using the console

You can also enable and disable Cloud APIs using Cloud SDK and Service Usage API

Therefore I would recommend to make a HTTP request using python to this url :POST https://serviceusage.googleapis.com/v1/{name=*/*/services/*}:enable

This is the curl command I used to enable analytics.googleapis.com API

OAUTH_TOKEN=`gcloud auth print-access-token`

curl -X POST -H "Authorization: Bearer $OAUTH_TOKEN" -H "Content-Type: application/json" https://serviceusage.googleapis.com/v1/projects/your-project/services/analytics.googleapis.com:enable


Response body
.......
"state": "ENABLED",
      "parent": "projects/xxxxxxx"

.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.