diff --git a/DESCRIPTION b/DESCRIPTION index 53fe0e8..f746c8b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,7 +42,6 @@ Imports: dplyr, DSMolgenisArmadillo, jsonlite, - methods, opalr, purrr, RcppTOML, @@ -55,34 +54,5 @@ Imports: Depends: R (>= 4.1.0) VignetteBuilder: knitr -Collate: - 'ArmadilloCredentials-class.R' - 'audit.R' - 'audit_engine.R' - 'dsROCrate-package.R' - 'dsROCrate.R' - 'print.R' - 'report.R' - 'safe_data.R' - 'safe_output.R' - 'safe_people.R' - 'safe_project.R' - 'safe_setting.R' - 'utils-armadillo.R' - 'utils-audit.R' - 'utils-connection.R' - 'utils-cr8tor.R' - 'utils-date.R' - 'utils-digest.R' - 'utils-opal.R' - 'utils-rocrate.R' - 'utils-rocrateR.R' - 'utils-safe_data.R' - 'utils-safe_output.R' - 'utils-safe_people.R' - 'utils-safe_project.R' - 'utils-safe_setting.R' - 'utils-show.R' - 'utils-tibble.R' URL: https://github.com/FederatedMethods/dsROCrate BugReports: https://github.com/FederatedMethods/dsROCrate/issues diff --git a/NAMESPACE b/NAMESPACE index 80e8b6d..b8a79c3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,6 @@ # Generated by roxygen2: do not edit by hand -S3method(audit,armadillo) +S3method(audit,ArmadilloCredentials) S3method(audit,character) S3method(audit,cr8tor) S3method(audit,list) @@ -30,9 +30,9 @@ S3method(flatten_safe_setting,default) S3method(flatten_safe_setting,rocrate) S3method(init,opal) S3method(init,rocrate) -S3method(parse_user_profiles,armadillo) +S3method(parse_user_profiles,ArmadilloCredentials) S3method(print,cr8tor_bundle) -S3method(project_exists,armadillo) +S3method(project_exists,ArmadilloCredentials) S3method(report,character) S3method(report,default) S3method(report,list) @@ -49,7 +49,7 @@ S3method(safe_people,character) S3method(safe_people,default) S3method(safe_people,opal) S3method(safe_people,rocrate) -S3method(safe_project,armadillo) +S3method(safe_project,ArmadilloCredentials) S3method(safe_project,character) S3method(safe_project,default) S3method(safe_project,opal) @@ -68,8 +68,5 @@ export(safe_output) export(safe_people) export(safe_project) export(safe_setting) -exportMethods(safe_project) -import(methods) -importClassesFrom(DSMolgenisArmadillo,ArmadilloCredentials) importFrom(rocrateR,get_entity) importFrom(utils,write.csv) diff --git a/R/ArmadilloCredentials-class.R b/R/ArmadilloCredentials-class.R deleted file mode 100644 index 2b69a51..0000000 --- a/R/ArmadilloCredentials-class.R +++ /dev/null @@ -1,21 +0,0 @@ -# define virtual S4 class `armadillo` -setClass("armadillo", contains = "VIRTUAL") - -# declare inheritance from existing class -setIs("ArmadilloCredentials", "armadillo") -# setIs("DSMolgenisArmadillo::ArmadilloCredentials", "armadillo") - -# # define S4 class `ArmadilloCredentials` -# setClass( -# "ArmadilloCredentials", -# contains = "armadillo", -# slots = list( -# access_token = "character", -# id_token = "character", -# refresh_token = "character", -# token_type = "character", -# auth_type = "character", -# expires_in = "integer", -# expires_at = "POSIXct" -# ) -# ) diff --git a/R/audit.R b/R/audit.R index 1e58e4f..69ecea9 100644 --- a/R/audit.R +++ b/R/audit.R @@ -39,7 +39,7 @@ audit <- function(x, ...) { #' @rdname audit #' @export -audit.armadillo <- function(x, ..., intent = NULL) { +audit.ArmadilloCredentials <- function(x, ..., intent = NULL) { stop( "The audit for Armadillo backend is not currently implemented!", call. = FALSE diff --git a/R/dsROCrate-package.R b/R/dsROCrate-package.R index 858a878..aff741d 100644 --- a/R/dsROCrate-package.R +++ b/R/dsROCrate-package.R @@ -2,7 +2,7 @@ "_PACKAGE" ## usethis namespace: start -#' @import methods -#' @importClassesFrom DSMolgenisArmadillo ArmadilloCredentials +# @import methods +# @importClassesFrom DSMolgenisArmadillo ArmadilloCredentials ## usethis namespace: end NULL diff --git a/R/safe_project.R b/R/safe_project.R index 7411df7..2676bb0 100644 --- a/R/safe_project.R +++ b/R/safe_project.R @@ -251,38 +251,27 @@ safe_project.rocrate <- function( } # S4 methods ---- -# Bridge method for your S4 class -#' @method safe_project armadillo +#' @method safe_project ArmadilloCredentials #' @rdname safe_project #' @export -safe_project.armadillo <- function(x, ...) { - methods::callGeneric(x, ...) -} - -#' @aliases safe_project,armadillo-method -#' @export -setMethod( - "safe_project", - signature(x = "armadillo"), - function( - x, - ..., - profile = "default", - project = NULL, - rocrate = rocrateR::rocrate_5s(), - asset_id_suffix = "#asset:", - project_id_suffix = "#project:", - path = NULL, - resources = NULL, - tables = NULL, - user = NULL - ) { - # check if the given `project` exists - project_exists(x, project = project) +safe_project.ArmadilloCredentials <- function( + x, + ..., + profile = "default", + project = NULL, + rocrate = rocrateR::rocrate_5s(), + asset_id_suffix = "#asset:", + project_id_suffix = "#project:", + path = NULL, + resources = NULL, + tables = NULL, + user = NULL +) { + # check if the given `project` exists + project_exists(x, project = project) - # retrieve details associated to `project` - project_details_tbl <- MolgenisArmadillo::armadillo.get_projects_info() |> - purrr::list_c() |> - tibble::as_tibble() - } -) + # retrieve details associated to `project` + project_details_tbl <- MolgenisArmadillo::armadillo.get_projects_info() |> + purrr::list_c() |> + tibble::as_tibble() +} diff --git a/R/utils-connection.R b/R/utils-connection.R index 014cbc3..ce4a464 100644 --- a/R/utils-connection.R +++ b/R/utils-connection.R @@ -45,24 +45,13 @@ parse_user_profiles.opal <- function(x, ..., user) { } # S4 methods ---- -# Bridge method for your S4 class -#' @method parse_user_profiles armadillo +#' @method parse_user_profiles ArmadilloCredentials #' @rdname parse_user_profiles #' @export -parse_user_profiles.armadillo <- function(x, ...) { - methods::callGeneric(x, ...) +parse_user_profiles.ArmadilloCredentials <- function(x, ..., user) { + message("PLACEHOLDER!") } -#' @aliases parse_user_profiles,armadillo-method -#' @family Armadillo -setMethod( - "parse_user_profiles", - signature(x = "armadillo"), - function(x, ..., user) { - message("PLACEHOLDER!") - } -) - #' Verify if project exists #' #' Wrapper for the [opalr::opal.project_exists()] and @@ -104,19 +93,11 @@ project_exists.opal <- function(x, ..., project) { } # S4 methods ---- -# Bridge method for your S4 class -#' @method project_exists armadillo +#' @method project_exists ArmadilloCredentials #' @rdname project_exists #' @export -project_exists.armadillo <- function(x, ...) { - methods::callGeneric(x, ...) -} - -#' @aliases project_exists,armadillo-method #' @family Armadillo -setMethod( - "project_exists", - signature(x = "armadillo"), +project_exists.ArmadilloCredentials <- function( x, ..., @@ -132,4 +113,3 @@ setMethod( ) } } -) diff --git a/R/utils-show.R b/R/utils-show.R deleted file mode 100644 index 02f7aa1..0000000 --- a/R/utils-show.R +++ /dev/null @@ -1,21 +0,0 @@ -#' @include ArmadilloCredentials-class.R -NULL - -setMethod( - "show", - "ArmadilloCredentials", - function(object) { - expiration_timestamp <- object@expires_at - is_expired <- Sys.time() > expiration_timestamp - cat("\n") - if (is_expired) { - cat(" Connection expired!\n") - cat("\nYou must login again:\n") - cat(" `dsROCrate::armadillo_login(SERVER)`\n") - } else { - cat(" auth type: ", object@auth_type, "\n", sep = "") - cat(" token type:", object@token_type, "\n") - cat(" expires at:", format(object@expires_at, tz = "UTC"), "\n") - } - } -) diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..67d4658 --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,3 @@ +.onLoad <- function(libname, pkgname) { + # methods::setOldClass("ArmadilloCredentials") +} diff --git a/man/audit.Rd b/man/audit.Rd index c92afb4..6d1e009 100644 --- a/man/audit.Rd +++ b/man/audit.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/audit.R \name{audit} \alias{audit} -\alias{audit.armadillo} +\alias{audit.ArmadilloCredentials} \alias{audit.character} \alias{audit.cr8tor} \alias{audit.list} @@ -12,7 +12,7 @@ \usage{ audit(x, ...) -\method{audit}{armadillo}(x, ..., intent = NULL) +\method{audit}{ArmadilloCredentials}(x, ..., intent = NULL) \method{audit}{character}(x, ..., intent = NULL) diff --git a/man/parse_user_profiles.Rd b/man/parse_user_profiles.Rd index d0d7478..2611227 100644 --- a/man/parse_user_profiles.Rd +++ b/man/parse_user_profiles.Rd @@ -4,14 +4,14 @@ \alias{parse_user_profiles} \alias{parse_user_profiles,armadillo-method} \alias{parse_user_profiles.opal} -\alias{parse_user_profiles.armadillo} +\alias{parse_user_profiles.ArmadilloCredentials} \title{Parse user profiles} \usage{ \S4method{parse_user_profiles}{armadillo}(x, ..., user) -parse_user_profiles.opal(x, ..., user) +\method{parse_user_profiles}{opal}(x, ..., user) -\method{parse_user_profiles}{armadillo}(x, ...) +\method{parse_user_profiles}{ArmadilloCredentials}(x, ..., user) } \arguments{ \item{x}{Connection object to backend for DataSHIELD server (e.g., Opal).} diff --git a/man/project_exists.Rd b/man/project_exists.Rd index 6fba252..f3d537f 100644 --- a/man/project_exists.Rd +++ b/man/project_exists.Rd @@ -4,7 +4,7 @@ \alias{project_exists} \alias{project_exists,armadillo-method} \alias{project_exists.opal} -\alias{project_exists.armadillo} +\alias{project_exists.ArmadilloCredentials} \title{Verify if project exists} \usage{ \S4method{project_exists}{armadillo}( @@ -13,9 +13,9 @@ project ) -project_exists.opal(x, ..., project) +\method{project_exists}{opal}(x, ..., project) -\method{project_exists}{armadillo}(x, ...) +\method{project_exists}{ArmadilloCredentials}(x, ..., project) } \arguments{ \item{x}{Connection object to backend for DataSHIELD server (e.g., Opal).} @@ -41,6 +41,9 @@ Other Opal: \code{\link{get_project_tables}()}, \code{\link{get_table_permissions}()}, \code{\link{parse_user_profiles}()} + +Other Armadillo: +\code{\link{parse_user_profiles}()} } \concept{Armadillo} \concept{Opal} diff --git a/man/safe_project.Rd b/man/safe_project.Rd index a6e2978..3321e50 100644 --- a/man/safe_project.Rd +++ b/man/safe_project.Rd @@ -6,7 +6,7 @@ \alias{safe_project.character} \alias{safe_project.opal} \alias{safe_project.rocrate} -\alias{safe_project.armadillo} +\alias{safe_project.ArmadilloCredentials} \title{Safe Project details} \source{ \itemize{ @@ -71,7 +71,19 @@ user = attr(x, "user") ) -\method{safe_project}{armadillo}(x, ...) +\method{safe_project}{ArmadilloCredentials}( + x, + ..., + profile = "default", + project = NULL, + rocrate = rocrateR::rocrate_5s(), + asset_id_suffix = "#asset:", + project_id_suffix = "#project:", + path = NULL, + resources = NULL, + tables = NULL, + user = NULL +) } \arguments{ \item{x}{This can be a connection to a 'DataSHIELD' server (e.g., object with diff --git a/tests/testthat/test-utils-show.R b/tests/testthat/test-utils-show.R deleted file mode 100644 index 55c1799..0000000 --- a/tests/testthat/test-utils-show.R +++ /dev/null @@ -1,47 +0,0 @@ -test_that("show() prints expired credentials message", { - obj <- new( - "ArmadilloCredentials", - auth_type = "bearer", - token_type = "JWT", - expires_at = Sys.time() - 3600 - ) - - expect_output( - show(obj), - "Connection expired!" - ) -}) - -test_that("show() prints credential details when not expired", { - expires_at <- as.POSIXct("2030-01-01 00:00:00", tz = "UTC") - - obj <- new( - "ArmadilloCredentials", - auth_type = "bearer", - token_type = "JWT", - expires_at = expires_at - ) - - expect_output(show(obj), "") - expect_output(show(obj), "auth type: bearer") - expect_output(show(obj), "token type: JWT") - expect_output( - show(obj), - format(expires_at, tz = "UTC") - ) -}) - -test_that("show() output is correct for expired credentials", { - obj <- new( - "ArmadilloCredentials", - auth_type = "bearer", - token_type = "JWT", - expires_at = Sys.time() - 1 - ) - - out <- paste(capture.output(show(obj)), collapse = "\n") - - expect_true(grepl("", out)) - expect_true(grepl("Connection expired!", out)) - expect_true(grepl("armadillo_login", out)) -})