I am trying to create a gcp function in python which can simply check the project id and display as a starting point. Below is my code
import os
from google.cloud import resource_manager_v3
import subprocess
import csv
def list_projects_ids(request):
try:
gcloud_command = ["gcloud", "projects", "list", "--format=value(projectId)"]
project_id_output = subprocess.check_output(gcloud_command, universal_newlines=True, stderr=subprocess.STDOUT)
project_ids = project_id_output.strip().split("\n")
return {"project_id: project_ids"}
except subprocess.CalledProcessError as e:
return {"error: {e}"}
I am getting below error when i am trying to test it before deploying (looks like its automatically trying to test in cloud shell).
4:35:34 PM] - spec.loader.exec_module(source_module)
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/workspace/main.py", line 3, in <module>
from google.cloud import resource_manager_v3
ImportError: cannot import name 'resource_manager_v3' from 'google.cloud' (unknown location)
Can you please let me know what is missing in the code, any specific package that i need to add in code or requirement.txt file ? or in cloud shell anything needs to install?