masus04
masus04

Reputation: 983

Importing & initializing GCP googleapis/google-cloud-python clients

As far as I understand, the suggested way to interact with GCP using python is to use the google-cloud-python client.

So far I have not been able to initialize or even import such a client in my project and was not able to find any documentation about it.

Can anyone help me figure out the import and init statements for the Resource Client as well as the Compute Engine Client?

From there on I assume I'll figure out the rest using the docs.

Upvotes: 2

Views: 549

Answers (1)

masus04
masus04

Reputation: 983

So I figured it out, primarily I had an issue with another google package that messed up my dependencies.

The import statement is as follows:

from google.cloud.resourcemanager_v3.services.projects.client import ProjectsClient

and the initialization is simply this:

client = ProjectsClient()

Note however, that this relies on an existing application default credentials file existing on the machine, which can be created by running the following command in the console:

gcloud auth application-default login

Upvotes: 3

Related Questions