Java Code Examples for com.google.api.services.cloudresourcemanager.model.Project#getParent()
The following examples show how to use
com.google.api.services.cloudresourcemanager.model.Project#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LiveProjectSource.java From policyscanner with Apache License 2.0 | 5 votes |
private boolean refreshProjects(String nextPageToken) throws IOException { ListProjectsResponse projectListResponse; Projects.List projectsList; try { projectsList = GCPProject.getProjectsApiStub().list(); if (nextPageToken != null) { projectsList = projectsList.setPageToken(nextPageToken); } if (source.getOrgId() != null) { projectsList = projectsList .setFilter("parent.type:organization parent.id:" + source.getOrgId()); } projectListResponse = projectsList.execute(); } catch (GeneralSecurityException gse) { throw new IOException("Cannot get projects. Access denied"); } List<Project> projects = projectListResponse.getProjects(); for (Project project : projects) { String orgId = null; if (project.getParent() != null) { orgId = project.getParent().getId(); } if (project.getLifecycleState() == null || project.getLifecycleState().startsWith(DELETE_PREFIX)) { continue; } this.projects.add(new GCPProject(project.getProjectId(), orgId, project.getName())); } this.nextPageToken = projectListResponse.getNextPageToken(); return !this.projects.isEmpty(); }
Example 2
Source File: Authenticator.java From styx with Apache License 2.0 | 5 votes |
private boolean resolveProject(Project project) throws IOException { final ResourceId resourceId = resourceId(project); if (isWhitelisted(resourceId)) { return true; } if (project.getParent() != null && isWhitelisted(project.getParent())) { return true; } return resolveProjectAccess(project.getProjectId()); }