...
Code Block |
---|
whoHasAccess<-function(entityId) {
aas<-synRestGET(sprintf("/entity/%s/accessApproval?limit=999&offset=0", entityId))$results
ups<-list()
approvedUsers<-list()
cat(sprintf("There are %d access approvals for entity %s\n", length(aas), entityId))
for (aa in aas) {
# cat(sprintf("approval id=%s requirement id=%s, user id=%s\n", aa$id, aa$requirementId, aa$accessorId))
userId<-aa$accessorId
reqId<-aa$requirementId
if (!any(approvedUsers[[userId]]==reqId)) {
approvedUsers[[userId]]<-append(approvedUsers[[userId]], reqId)
}
if (is.null(ups[[userId]])) {
ups[[userId]]<-synRestGET(sprintf("/userProfile/%s", userId))
}
cat(".")
}
cat("\n")
for (userId in names(approvedUsers)) {
displayName<-ups[[userId]]$displayName
userName<-ups[[userId]]$userName
if (is.null(displayName)) {
cat(sprintf("%s (id=%s) is approved for access requirement(s) %s\n", userName, userId,
paste(approvedUsers[[userId]], collapse=",")))
} else {
cat(sprintf("%s (username=%s, id=%s) is approved for access requirement(s) %s\n", displayName, userName, userId,
paste(approvedUsers[[userId]], collapse=",")))
}
}
}
|
...
Code Block |
---|
doesUserHaveAccess<-function(entityId, principalId) {
aas<-synRestGET(sprintf("/entity/%s/accessApproval?limit=999&offset=0", entityId))$results
approvedRequirements<-list()
cat(sprintf("There are %d access approvals for entity %s\n", length(aas), entityId))
for (aa in aas) {
# cat(sprintf("approval id=%s requirement id=%s, user id=%s\n", aa$id, aa$requirementId, aa$accessorId))
userId<-aa$accessorId
reqId<-aa$requirementId
if (userId==principalId && !any(approvedRequirements==reqId)) {
approvedRequirements<-append(approvedRequirements, reqId)
cat(sprintf("\nuser %s was approved for requirement %s by %s on %s\n", principalId, reqId, aa$createdBy, aa$createdOn))
}
cat(".")
}
cat("\n")
allRequirements<-list()
ars<-synRestGET(sprintf("/entity/%s/accessRequirement", entityId))$results
for (ar in ars) {
allRequirements<-append(allRequirements, ar$id)
}
if (length(allRequirements)>0) allRequirements<-sort(unlist(allRequirements))
if (length(approvedRequirements)>0) approvedRequirements<-sort(unlist(approvedRequirements))
if (identical(allRequirements, approvedRequirements)) {
message(sprintf("User %s DOES have access approvals for ALL %d access requirement(s) on %s",
principalId, length(allRequirements), entityId))
} else {
if (length(approvedRequirements>0)) {
message(sprintf("User %s does NOT have access approvals for all the %d access requirement(s) on %s, only for %s",
principalId, length(allRequirements), entityId, paste(approvedRequirements, collapse=",")))
} else {
message(sprintf("User %s does NOT have access approvals for ANY of the %d access requirement(s) on %s",
principalId, length(allRequirements), entityId))
}
}
}
|
...
Code Block |
---|
removeAccess<-function(entityId, principalId) {
aas<-synRestGET(sprintf("/entity/%s/accessApproval?limit=999&offset=0", entityId))$results
cat(sprintf("There are %d access approvals for entity %s\n", length(aas), entityId))
for (aa in aas) {
# cat(sprintf("approval id=%s requirement id=%s, user id=%s\n", aa$id, aa$requirementId, aa$accessorId))
userId<-aa$accessorId
reqId<-aa$requirementId
if (userId==principalId) {
synRestDELETE(sprintf("/accessApproval/%s", aa$id))
cat(sprintf("\nRemoved access approval for access requirement %s.\n", reqId))
}
cat(".")
}
cat("\n")
}
|
...
Code Block |
---|
whoHasAccessToTeam<-function(teamId) {
aas<-synRestGET(sprintf("/team/%s/accessApproval?limit=999&offset=0", teamId))$results
ups<-list()
approvedUsers<-list()
cat(sprintf("There are %d access approvals for Team %s\n", length(aas), teamId))
for (aa in aas) {
userId<-aa$accessorId
reqId<-aa$requirementId
if (!any(approvedUsers[[userId]]==reqId)) {
approvedUsers[[userId]]<-append(approvedUsers[[userId]], reqId)
}
if (is.null(ups[[userId]])) {
ups[[userId]]<-synRestGET(sprintf("/userProfile/%s", userId))
}
cat(".")
}
cat("\n")
for (userId in names(approvedUsers)) {
displayName<-ups[[userId]]$displayName
userName<-ups[[userId]]$userName
if (is.null(displayName)) {
cat(sprintf("%s (id=%s) is approved for access requirement(s) %s\n", userName, userId,
paste(approvedUsers[[userId]], collapse=",")))
} else {
cat(sprintf("%s (username=%s, id=%s) is approved for access requirement(s) %s\n", displayName, userName, userId,
paste(approvedUsers[[userId]], collapse=",")))
}
}
}
|
...
Code Block |
---|
isUserApprovedToJoinTeam<-function(teamId, principalId) {
aas<-synRestGET(sprintf("/team/%s/accessApproval?limit=999&offset=0", teamId))$results
approvedRequirements<-list()
cat(sprintf("There are %d access approvals for team %s\n", length(aas), teamId))
for (aa in aas) {
userId<-aa$accessorId
reqId<-aa$requirementId
if (userId==principalId && !any(approvedRequirements==reqId)) {
approvedRequirements<-append(approvedRequirements, reqId)
cat(sprintf("\nuser %s was approved for requirement %s by %s on %s\n", principalId, reqId, aa$createdBy, aa$createdOn))
}
cat(".")
}
cat("\n")
allRequirements<-list()
ars<-synRestGET(sprintf("/team/%s/accessRequirement", teamId))$results
for (ar in ars) {
allRequirements<-append(allRequirements, ar$id)
}
if (length(allRequirements)>0) allRequirements<-sort(unlist(allRequirements))
if (length(approvedRequirements)>0) approvedRequirements<-sort(unlist(approvedRequirements))
if (identical(allRequirements, approvedRequirements)) {
message(sprintf("User %s DOES have access approvals for ALL %d access requirement(s) on %s",
principalId, length(allRequirements), teamId))
} else {
if (length(approvedRequirements>0)) {
message(sprintf("User %s does NOT have access approvals for all the %d access requirement(s) on %s, only for %s",
principalId, length(allRequirements), teamId, paste(approvedRequirements, collapse=",")))
} else {
message(sprintf("User %s does NOT have access approvals for ANY of the %d access requirement(s) on %s",
principalId, length(allRequirements), teamId))
}
}
}
|
...