use of org.broadinstitute.dsde.workbench.client.sam.model.ResourceAndAccessPolicy in project jade-data-repo by DataBiosphere.
the class SamIam method listAuthorizedResourcesInner.
private List<UUID> listAuthorizedResourcesInner(AuthenticatedUserRequest userReq, IamResourceType iamResourceType) throws ApiException {
ResourcesApi samResourceApi = samResourcesApi(userReq.getRequiredToken());
List<ResourceAndAccessPolicy> resources = samResourceApi.listResourcesAndPolicies(iamResourceType.toString());
return resources.stream().map(resource -> UUID.fromString(resource.getResourceId())).collect(Collectors.toList());
}
use of org.broadinstitute.dsde.workbench.client.sam.model.ResourceAndAccessPolicy in project terra-workspace-manager by DataBiosphere.
the class SamService method listWorkspaceIds.
/**
* List all workspace IDs in Sam this user has access to. Note that in environments shared with
* Rawls, some of these workspaces will be Rawls managed and WSM will not know about them.
*/
@Traced
public List<UUID> listWorkspaceIds(AuthenticatedUserRequest userRequest) throws InterruptedException {
ResourcesApi resourceApi = samResourcesApi(userRequest.getRequiredToken());
List<UUID> workspaceIds = new ArrayList<>();
try {
List<ResourceAndAccessPolicy> resourceAndPolicies = SamRetry.retry(() -> resourceApi.listResourcesAndPolicies(SamConstants.SamResource.WORKSPACE));
for (var resourceAndPolicy : resourceAndPolicies) {
try {
workspaceIds.add(UUID.fromString(resourceAndPolicy.getResourceId()));
} catch (IllegalArgumentException e) {
// ignored here.
continue;
}
}
} catch (ApiException apiException) {
throw SamExceptionFactory.create("Error listing Workspace Ids in Sam", apiException);
}
return workspaceIds;
}
Aggregations