Skip to content

Commit

Permalink
rename credentials -> config for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
jburos committed Oct 19, 2023
1 parent 38e17e7 commit e9ec3a1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(configure)
export(drop_configs)
export(extract_subsample_info)
export(fetch_association_state)
export(fetch_biomarker_params)
Expand All @@ -24,6 +25,7 @@ export(find_runs)
export(flog.logger)
export(format_quantiles_as_widths)
export(list_biomarker_names)
export(list_configs)
export(list_datasets)
export(list_models)
export(list_parameter_names)
Expand Down
30 changes: 19 additions & 11 deletions R/geco_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -145,31 +145,39 @@ configure <- function(user, password, host) {
}
}

#' List saved credentials
#' List saved configurations
#' @param host Host identifier, defaults to 'geco'
#' @export
list_credentials <- function(host='geco') {
list_configs <- function(host='geco') {
service <- .get_keyring_service(host)
key_list(service)
}

#' Drop saved credentials
#' Warning! this will remove all saved credentials from the host.
#' Drop saved configurations
#' Warning! this will remove all saved configurations from the host.
#' @param host Host identifier, defaults to 'geco'
#' @param user Optional username, provided as a string.
#' @seealso [list_configs()]
#' @export
drop_credentials <- function(user, host='geco') {
drop_configs <- function(user, host='geco') {
service <- .get_keyring_service(host)
keys <- key_list(service)
if (!missing(user)) {
keys <- keys %>%
filter(username == !!user)
}
cli::cli_alert_warning('This will drop _ALL_ saved credentials listed.')
keys
if (askYesNo("Do you want to drop these credentials from your keyring?")) {
keys %>%
pull(username) %>%
walk(~ key_delete(service=service, username = .))
if (nrow(keys) == 0) {
cli::cli_alert_info('No keys found.')
} else {
cli::cli_alert_warning('This will drop _ALL_ saved configs listed.')
print(keys)
confirm <- askYesNo("Do you want to drop these configs from your keyring?",
default = FALSE)
if (!is.na(confirm) && isTRUE(confirm)) {
keys %>%
pull(username) %>%
walk(~ key_delete(service=service, username = .))
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions man/drop_configs.Rd

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

14 changes: 14 additions & 0 deletions man/list_configs.Rd

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

0 comments on commit e9ec3a1

Please sign in to comment.