# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' The Profiles API is a user directory service for the Agave Platform. Users
#' may query it for their own profile and search for the profile(s) of other
#' users. Depending on the configuration of your tenant, additional features
#' such as profile editing, profile creation, and password reset may be enabled
#' as well.
#'
#' @title Agave Profiles API operations
#' @description
#' ProfilesApi Class
#'
#' The Profiles API is a user directory service for the Agave Platform.
#'
#' @usage
#' profiles <- ProfilesApi$new(apiClient, cache, responseType="list")
#'
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' `$addProfile(body)` Create a new user profile. This may be disabled depending
#' on the configuration of your specific tenant.
#'
#' **Usage**
#'
#' ```
#' profile <- Profile$new(username="username",
#' password="password",
#' email="email@email.com")
#' api$profiles$addProfile(body=profile)
#' ```
#'
#' `$deleteProfile(username=username)` deletes a user profile. The user's data and history is
#' maintained. Depending on the backend identity provider, the user account
#' may or may not be avaialble for reuse/reactivation.
#'
#' **Usage**
#'
#' ```
#' api$profiles$deleteProfile(username="username")
#' ```
#'
#' `$getProfile(username)` get the full profile of a given user.
#'
#' **Usage**
#'
#' ```
#' api$profiles$getProfile()
#' api$profiles$getProfile(username="username")
#' ```
#'
#'
#' `$listProfiles(username, name, email)` list user profiles, filtering by
#' partial match on username, full name, or email address.
#'
#' **Usage**
#'
#' ```
#' api$profiles$listProfiles()
#' api$profiles$listProfiles(username="test")
#' api$profiles$listProfiles(name="Test")
#' api$profiles$listProfiles(email="test@")
#' ```
#'
#'
#' `$updateProfile` Update an existing user profile. This may be disabled
#' depending on the configuration of your specific tenant.
#'
#' **Usage**
#'
#' ```
#' profile <- Profile$new(username="username",
#' password="newpassword",
#' email="email@email.com")
#' api$profiles$updateProfile(username="username", body=profile)
#' ```
#'
#' }
#'
#' @importFrom R6 R6Class
#' @name ProfilesApi
#' @seealso [rAgave::Profile] [rAgave::ClientsApi] [rAgave::Client] [rAgave::ApiClient] [rAgave::Agave]
#' @export
ProfilesApi <- R6::R6Class(
'ProfilesApi',
private = list(
userAgent = "Agave-SDK/0.2.0/r",
apiClient = NULL,
responseType = "list",
formatResponse = function(resp, args=list()) {
# read the args from the unnamed request args
if ("responseType" %in% names(args)) {
responseType = args$responseType
}
else {
responseType = NULL
}
if (is.null(responseType) || nchar(responseType) == 0) {
responseType = private$responseType
}
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
logger.debug(jsonlite::toJSON(httr::content(resp,stringsAsFactors = FALSE), auto_unbox=TRUE, null="null", na="null"))
if (responseType == "raw") {
# check for the undeclared pretty attibute to pretty-print the json response
prettyPrint <- ("pretty" %in% names(args) && isTRUE(args$pretty))
jsonlite::toJSON(httr::content(resp, stringsAsFactors = FALSE), auto_unbox=TRUE, null="null", na="null", pretty=prettyPrint)
}
else {
jsonResp <- httr::content(resp)
if ("result" %in% names(jsonResp)) {
jsonResp <- jsonResp$result
}
if (responseType == "df" && length(jsonResp) > 0) {
# lookup properties of object. if null, it's a list. if not null, it's an object
colNames <- names(jsonResp)
if (is.null(colNames)) {
# convert to a list of dataframes
do.call("rbind", lapply(jsonResp, as.data.frame, col.names=factor(names(jsonResp[[1]]))))
}
else {
# convert object to single data frame
as.data.frame(jsonResp)
}
}
else {
jsonResp
}
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
logger.warn(jsonlite::toJSON(httr::content(resp, "text", encoding="UTF-8"), auto_unbox=TRUE, null="null", na="null"))
httr::content(resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
logger.warn(jsonlite::toJSON(httr::content(resp, "text", encoding="UTF-8"), auto_unbox=TRUE, null="null", na="null"))
httr::content(resp)
}
}
),
public = list(
initialize = function(apiClient, responseType){
if (!missing(apiClient)) {
private$apiClient <- apiClient
}
else {
private$apiClient <- ApiClient$new()
}
# user can override the global representation in which resources
# responses from this API are returned in when calling methods of
# this class. The same responseType attribute may be passed to any
# public method to override individual calls as well.
if (missing(responseType) || is.null(responseType) || nchar(responseType) == 0) {
# we ignore and use the default
}
else if (responseType != "raw" && responseType != "list" && responseType != "df") {
stop("Invalid responseType. Please specify one of: raw, list, df")
}
else {
# set the response type to the class default to be used
# whenever it is not explicitly set on a request
private$responseType = responseType
}
},
addProfile = function(body, naked, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
if (!missing(`naked`)) {
queryParams['naked'] <- naked
}
if (!missing(`body`)) {
if (!is.list(`body`)) {
body <- `body`$toJSON()
}
} else {
body <- NULL
}
urlPath <- "/profiles/v2"
resp <- private$apiClient$callApi(url = paste0(private$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
private$formatResponse(resp, args)
},
deleteProfile = function(username, naked, filter, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
if (!missing(`filter`)) {
queryParams['filter'] <- filter
}
if (!missing(`naked`)) {
queryParams['naked'] <- naked
}
urlPath <- "/profiles/v2/{apiUsername}"
if (!missing(`username`)) {
urlPath <- gsub(paste0("\\{", "apiUsername", "\\}"), `username`, urlPath)
}
resp <- private$apiClient$callApi(url = paste0(private$apiClient$basePath, urlPath),
method = "DELETE",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
private$formatResponse(resp, args)
},
getProfile = function(username="me", naked, filter, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
if (!missing(`filter`)) {
queryParams['filter'] <- filter
}
if (!missing(`naked`)) {
queryParams['naked'] <- naked
}
if (missing(username) || is.null(username) || nchar(username) == 0) {
username <- "me"
}
urlPath <- "/profiles/v2/{apiUsername}"
if (!missing(`username`)) {
urlPath <- gsub(paste0("\\{", "apiUsername", "\\}"), `username`, urlPath)
}
resp <- private$apiClient$callApi(url = paste0(private$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
private$formatResponse(resp, args)
},
listProfiles = function(naked, username, name, email, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
if ("limit" %in% names(args)) {
queryParams['limit'] <- args$limit
}
if ("offset" %in% names(args)) {
queryParams['offset'] <- args$offset
}
if (!missing(`username`)) {
queryParams['username'] <- username
}
if (!missing(`name`)) {
queryParams['name'] <- name
}
if (!missing(`email`)) {
queryParams['email'] <- email
}
if (!missing(`naked`)) {
queryParams['naked'] <- naked
}
urlPath <- "/profiles/v2"
resp <- private$apiClient$callApi(url = paste0(private$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
private$formatResponse(resp, args)
},
updateProfile = function(username, body, naked, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
if (!missing(`naked`)) {
queryParams['naked'] <- naked
}
if (!missing(`body`)) {
if (!is.list(`body`)) {
body <- `body`$toJSON()
}
} else {
body <- NULL
}
urlPath <- "/profiles/v2/{apiUsername}"
if (!missing(`username`)) {
urlPath <- gsub(paste0("\\{", "apiUsername", "\\}"), `username`, urlPath)
}
resp <- private$apiClient$callApi(url = paste0(private$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
private$formatResponse(resp, args)
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.