简体   繁体   中英

How list available BigQuery projects without parent?

I am using Java client and I would like to list all projects that user has access to (as it appears in GCP console).

  1. As documentation says it is recommended to use ResourceManager library instead of BigQuery ( BigQuery library has no classes to retrieve projects - there is another one called Bigquery (small q) that has some api for calling project, but documentation claims it is using ResourceManager underneath.
  2. I tried using v3 library version of ResourceManager but apparently it always requires the parent id , but I don't want to give access for listing the folder above because in much more complicated architecture I would have to give access to all organisations and folders and prepare search of all projects. I would like only list projects that current user has access to.
  3. There is also possibility to use same library but with v1 api version which works like a charm... but it is deprecated and I am not sure how long it will be supported.
  4. I don't want to use any other clients than Java.

Do you know solution using ResourceManager but not with parent or without granting too many privileges?

Apparently the replacement for list is search method with empty query string:

ProjectsSettings projectsSettings = ProjectsSettings.newBuilder().build();
ProjectsClient projectsClient = ProjectsClient.create(projectsSettings);

ProjectsClient.SearchProjectsPagedResponse searchProjectsPagedResponse = projectsClient.searchProjects("");

for (Project project : searchProjectsPagedResponse.iterateAll()) {
        System.out.println(project.getDisplayName());
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM