Hi,
I am trying to use the API library list_projects to list my projects. But in V3 it seems the parents are no longer optional. I can confirm the same from https://cloud.google.com/resource-manager/reference/rest/v3/projects/list?apix_params=%7B%22parent%2....
Now, can anyone suggest, how to use this API for projects not under any organization structure?
Hello Mus,
As per Cloudkollectiv from Stackoverflow,
"According to the documentation you should be able to use filters to check whether a project belongs to a parent (organization). Through the cli this works:
gcloud projects list --filter="parent.id.yesno(yes='Yes', no='No')=No"
This would also work:
gcloud projects list --filter="parent.id:None"
The python equivalent would then be:
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('cloudresourcemanager', 'v1beta1', credentials=credentials)
filter = "parent.id:None"
projects = service.projects().list(filter=filter).execute()
"