-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CORE-40] Add cross-billing project spend report API #3107
Changes from 32 commits
c0ef330
1a396b9
3a4dc82
56cf2bc
cc2c3bd
2adf61b
775616e
414207c
c5c736a
81f843b
0895f80
a023bbb
0c6915b
9a8694b
554256b
9085110
8f52a84
b5fa11f
9fd6bc0
9ad4c7e
b07bbb1
a0e9897
9da40c0
6a03274
2200b62
e1e31a1
e4a13db
85ad0f2
c6d966f
0c4cbe1
7d9f379
20dfd8c
cdc0b53
a6b900f
e079f56
780974f
9dcfd0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,20 @@ import org.broadinstitute.dsde.rawls.model._ | |
import org.broadinstitute.dsde.rawls.util.{FutureSupport, Retry} | ||
import org.broadinstitute.dsde.workbench.client.sam | ||
import org.broadinstitute.dsde.workbench.client.sam.api._ | ||
import org.broadinstitute.dsde.workbench.client.sam.model.{ | ||
FilteredFlatResourcePolicy, | ||
FilteredHierarchicalResource, | ||
FilteredHierarchicalResourcePolicy, | ||
FilteredResourcesHierarchicalResponse, | ||
ListResourcesV2200Response | ||
} | ||
import org.broadinstitute.dsde.workbench.client.sam.{ApiCallback, ApiClient, ApiException} | ||
import org.broadinstitute.dsde.workbench.model.{WorkbenchEmail, WorkbenchGroupName} | ||
|
||
import java.time.Instant | ||
import java.time.temporal.ChronoUnit | ||
import java.util | ||
import java.util.List | ||
import scala.concurrent.duration.FiniteDuration | ||
import scala.concurrent.{ExecutionContext, Future, Promise} | ||
import scala.jdk.CollectionConverters._ | ||
|
@@ -513,6 +521,31 @@ class HttpSamDAO(baseSamServiceURL: String, rawlsCredential: RawlsCredential, ti | |
} | ||
} | ||
|
||
override def listResourcesWithActions(resourceTypeName: SamResourceTypeName, | ||
action: SamResourceAction, | ||
ctx: RawlsRequestContext | ||
): Future[Seq[FilteredHierarchicalResource]] = | ||
retry(when401or5xx) { () => | ||
val callback = new SamApiCallback[ListResourcesV2200Response]("listResourcesV2") | ||
|
||
resourcesApi(ctx).listResourcesV2Async( | ||
/* format = */ "hierarchical", | ||
/* resourceTypes = */ util.List.of(resourceTypeName.value), | ||
/* policies = */ util.List.of(), | ||
/* roles = */ util.List.of(), | ||
/* actions = */ util.List.of(action.value), | ||
/* includePublic = */ false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I'll change it to true. |
||
callback | ||
) | ||
|
||
callback.future.map { resourcesResponse => | ||
resourcesResponse.getFilteredResourcesHierarchicalResponse | ||
.getResources() | ||
.asScala | ||
.toSeq | ||
} | ||
} | ||
|
||
private def toSamRolesAndActions(rolesAndActions: sam.model.RolesAndActions) = | ||
SamRolesAndActions( | ||
rolesAndActions.getRoles.asScala.map(SamResourceRole).toSet, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hierarchical
will not return actions that are included in rolesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, with hierarchical I get a
policies
object like so:but with
flat
it's just:Looks like I want hierarchical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, this does not seem right, I will look at what sam is doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a full resource in the response for
flat
looks likeThe actions are not included in the policies. The is probably what it means to be flat.
The full resource for a hierarchical response looks like
The actions are both at policy and role level. Also note there could be multiple policies that contain the action. Flat is really what you want because it hides all the details about how user has the action on the resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this further, flat vs hierarchical does not matter because nothing is used of the response other than the resource id. But hierarchical is much harder to use correctly. So I would either have this
listResourcesWithActions
function return only a list of resource ids or switch to flat