use of com.google.api.services.cloudresourcemanager.model.TestIamPermissionsRequest in project google-cloud-java by GoogleCloudPlatform.
the class HttpResourceManagerRpc method testPermissions.
@Override
public List<Boolean> testPermissions(String projectId, List<String> permissions) throws ResourceManagerException {
try {
TestIamPermissionsResponse response = resourceManager.projects().testIamPermissions(projectId, new TestIamPermissionsRequest().setPermissions(permissions)).execute();
Set<String> permissionsOwned = ImmutableSet.copyOf(firstNonNull(response.getPermissions(), ImmutableList.<String>of()));
ImmutableList.Builder<Boolean> answer = ImmutableList.builder();
for (String p : permissions) {
answer.add(permissionsOwned.contains(p));
}
return answer.build();
} catch (IOException ex) {
throw translate(ex);
}
}
Aggregations