I am new to google cloud applications and so I was figuring out to use various methods to list all different services list in using GCP SDK in python.
I wrote following code to create a client instance for Compute services to list down all Firewalls present in the project in Python3.
from google.oauth2 import service_account
import googleapiclient.discovery
credentials = service_account.Credentials.from_service_account_file(filename='/path/to/cred/file.json')
client = googleapiclient.discovery.build(
'compute', 'v1', credentials=credentials)
def __test_firewall():
result = client.firewalls().list(project='project-id').execute()
return result['items'] if 'items' in result else None
This code returned me all the firewalls present in the project successfully as I wanted.
I want something similar that I can use to list down all Cloud Functions in GCP through SDK and I do not want to use CLI. I could not figure out the way to do it so posting here.
Any help is highly appreciated. Thanks in advance. ????