Skip to content
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

FDS-1881 Write function to access Synapse API permissions endpoint #51

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export(storage_projects)
export(style_dashboard)
export(synapse_access)
export(synapse_annotations)
export(synapse_permissions)
export(true_false_icon)
export(update_data_flow_manifest)
export(verbose_message)
Expand Down
29 changes: 29 additions & 0 deletions R/synapse_rest_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,35 @@ synapse_access <- function(url = "https://repo-prod.prod.sagebase.org/repo/v1/en
cont$result
}

#' @title Gets user permissions
#'
#' @param id Synapse ID
#' @param auth Synapse authentication token
#' @param url Synapse API endpoint URL
#'
#' @export

synapse_permissions <- function(id,
auth,
url = "https://repo-prod.prod.sagebase.org/repo/v1/entity") {

if (is.null(id)) stop("id cannot be NULL")

# query permissions endpoint
req_url <- file.path(url, id, "permissions")
req <- httr::GET(
req_url,
httr::add_headers(Authorization = paste0("Bearer ", auth))
)

# send error if unsuccessful query
status <- httr::http_status(req)
if (status$category != "Success") stop(status$message)

cont <- httr::content(req)
return(cont)
}

#' @title Gets annotations for a given entity ID
#' @description wrapper for https://rest-docs.synapse.org/rest/GET/entity/id/annotations2.html
#'
Expand Down
22 changes: 22 additions & 0 deletions man/synapse_permissions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading