Skip to content

put examples back in for internal fxns #131

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ export(figure_out_policy_arn)
export(group_policies)
export(instance_details)
export(ip_permissions_generator)
export(path_as_s3)
export(path_from)
export(path_s3_build)
export(path_s3_parse)
export(random_bucket)
export(random_role)
export(random_string)
Expand Down
8 changes: 8 additions & 0 deletions R/ui_fetch_secret.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
#' to use. If you choose none of them this function returns NULL for
#' both user and password
#' @keywords internal
#' @examples \dontrun{
#' # user,pwd supplied, return them right away at top of fxn
#' ui_fetch_secret(engine = "mariadb", user = "jane", password = "apple")
#'
#' # user,pwd null
#' ui_fetch_secret(engine = "redshift")
#' ui_fetch_secret(engine = "mariadb")
#' }
ui_fetch_secret <- function(
user = NULL,
password = NULL,
Expand Down
37 changes: 37 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,28 @@ check_for_pkg <- function(x) {

#' Parse s3 paths
#'
#' @export
#' @keywords internal
#' @param paths (character) one or more s3 paths
#' @return an unnamed list with each slot a named list with bucket, path,
#' and file
#' @examples
#' path_s3_parse("s3://s64-test-2/DESCRIPTION")
#' path_s3_parse("s3://s64-test-2/some/other/path/things.csv")
#' paths <- c(
#' "s3://s64-test-2/DESCRIPTION",
#' "s3://s64-test-2/stuff.txt",
#' "s3://s64-test-2/some/other/path/things.csv"
#' )
#' path_s3_parse(paths)
#'
#' # if a path is not an s3 path
#' paths <- c(
#' "s3://s64-test-2/DESCRIPTION",
#' "s3://s64-test-2/stuff.txt",
#' "s64-test-2/some/other/path/things.csv"
#' )
#' try(path_s3_parse(paths))
path_s3_parse <- function(paths) {
list_names <- c("bucket", "path", "file")
stopifnot("One or more paths are not s3 paths" = all(grepl("^s3://", paths)))
Expand All @@ -87,8 +105,17 @@ path_s3_parse <- function(paths) {

#' Build s3 paths
#'
#' @export
#' @keywords internal
#' @param x unnamed list of parsed paths, from [path_s3_parse()]
#' @examples
#' paths <- c(
#' "s3://s64-test-2/DESCRIPTION",
#' "s3://s64-test-2/stuff.txt",
#' "s3://s64-test-2/some/other/path/things.csv"
#' )
#' x <- path_s3_parse(paths)
#' path_s3_build(x)
path_s3_build <- function(x) {
purrr::map_vec(x, function(w) {
path <- if (nzchar(w$path)) paste0(w$path, "/") else ""
Expand All @@ -100,10 +127,19 @@ path_s3_build <- function(x) {

#' Convert a s3 like path to a single format
#'
#' @export
#' @keywords internal
#' @inheritParams path_s3_parse
#' @return vector of s3 paths (character), Of the form:
#' `s3://<bucket>/<path>/<file>`
#' @examples
#' path_as_s3("http://s64-test-3.s3.amazonaws.com/")
#' path_as_s3("https://s64-test-3.s3.amazonaws.com/")
#' path_as_s3(c(
#' "https://s64-test-3.s3.amazonaws.com/",
#' "https://mybucket.s3.amazonaws.com/"
#' ))
#' path_as_s3(c("apple", "banana", "pear", "pineapple"))
path_as_s3 <- function(paths) {
paths <- gsub("https?://", "", paths)
paths <- gsub("\\.s3.+", "", paths)
Expand Down Expand Up @@ -146,6 +182,7 @@ paginate_aws_marker <- function(fun, target, ...) {
#' @importFrom rlang is_empty
#' @inheritParams paginate_aws_marker
#' @keywords internal
#' @note `paginate_aws_token(fun=con_sm()$list_secrets, target="SecretList")`
paginate_aws_token <- function(fun, target, ...) {
con <- con_sm()
res <- con[[fun]](...)
Expand Down
6 changes: 6 additions & 0 deletions R/wait.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ wait_until <- function(fun, message) {
#' @return nothing, exits if there's an error, or if the while
#' loop completes
#' @keywords internal
#' @examples \dontrun{
#' wait_for_cluster(id = "scotts-test-cluster-456")
#' }
wait_for_cluster <- wait_until(
aws_db_cluster_status,
"Redshift cluster initializing"
Expand All @@ -49,6 +52,9 @@ wait_for_cluster <- wait_until(
#' @return nothing, exits if there's an error, or if the while
#' loop completes
#' @keywords internal
#' @examples \dontrun{
#' wait_for_instance(id = "scotts-test-cluster-456")
#' }
wait_for_instance <- wait_until(
aws_db_instance_status,
"RDS instance initializing"
Expand Down
3 changes: 3 additions & 0 deletions man/paginate_aws_token.Rd

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

9 changes: 9 additions & 0 deletions man/path_as_s3.Rd

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

9 changes: 9 additions & 0 deletions man/path_s3_build.Rd

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

18 changes: 18 additions & 0 deletions man/path_s3_parse.Rd

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

10 changes: 10 additions & 0 deletions man/ui_fetch_secret.Rd

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

5 changes: 5 additions & 0 deletions man/wait_for_cluster.Rd

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

5 changes: 5 additions & 0 deletions man/wait_for_instance.Rd

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