-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #639 from DyfanJones/config_flattern
- Loading branch information
Showing
20 changed files
with
684 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.param_not_used <- c( | ||
"expiration", | ||
"force_refresh", | ||
"endpoint_resolver", | ||
"enforce_should_retry_check", | ||
"disable_ssl", | ||
"max_retries", | ||
"retryer", | ||
"disable_param_validation", | ||
"disable_compute_checksums", | ||
"s3_disable_100_continue", | ||
"s3_use_accelerate", | ||
"s3_disable_content_md5_validation", | ||
"ec2_metadata_disable_timeout_override", | ||
"use_dual_stack", | ||
"sleep_delay", | ||
"disable_rest_protocol_uri_cleaning", | ||
"provider", | ||
"provider_name" | ||
) | ||
|
||
firstup <- function(x) { | ||
substr(x, 1, 1) <- toupper(substr(x, 1, 1)) | ||
return(x) | ||
} | ||
|
||
get_service_parameter <- function(param) { | ||
fn <- get(param, envir = getNamespace("paws.common")) | ||
elements <- as.list(formals(fn)) | ||
elements <- elements[!(names(elements) %in% .param_not_used)] | ||
|
||
for (nms in names(elements)) { | ||
if (is.list(elements[[nms]])) { | ||
elements[[nms]] <- get_service_parameter(firstup(nms)) | ||
} | ||
} | ||
return(elements) | ||
} | ||
|
||
build_service_parameter <- function(param) { | ||
return(do.call( | ||
paws.common:::struct, | ||
get_service_parameter(param) | ||
)) | ||
} | ||
|
||
#' @title Create paws serice helper functions | ||
#' @param dir directory of paws.common | ||
#' @export | ||
paws_service_param_fn <- function(dir = "../paws.common") { | ||
file <- system.file( | ||
file.path("templates","service_parameter_helper.R"), package = "make.paws" | ||
) | ||
r_file <- readLines(file) | ||
|
||
for (param in c("config", "credentials", "creds")) { | ||
line <- grep(sprintf("\\{\\{%s\\}\\}", param), r_file) | ||
fn_body <- deparse(build_service_parameter(firstup(param))) | ||
fn_body[[1]] <- sprintf("%s <- %s", param, fn_body[[1]]) | ||
r_file[[line]] <- paste(fn_body, collapse = "\n") | ||
} | ||
writeLines(r_file, file.path(dir, "R", "service_parameter_helper.R")) | ||
roxygen2::roxygenise(dir) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
################################################################ | ||
# Generated by make.paws: do not edit by hand | ||
# Please edit: make.paws/inst/templates/set_service_parameter.R | ||
################################################################ | ||
|
||
#' @title Set service parameters | ||
#' @description | ||
#' Help functions for setting the parameters for services | ||
#' | ||
#' @param credentials \code{credentials()} or \code{list} is same format. | ||
#' \itemize{ | ||
#' \item{\strong{creds}:} {\code{creds()} or \code{list} in same format. | ||
#' \itemize{ | ||
#' \item{\strong{access_key_id}:} {AWS access key ID} | ||
#' \item{\strong{secret_access_key}:} {AWS secret access key} | ||
#' \item{\strong{session_token}:} {AWS temporary session token} | ||
#' \item{\strong{access_token}:} {The token issued by the \code{CreateToken} API call. For more information, see | ||
#' \href{https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html}{CreateToken} | ||
#' in the `IAM Identity Center OIDC API Reference Guide`.} | ||
#' }} | ||
#' \item{\strong{profile}:} {The name of a profile to use. If not given, then the default profile is used.} | ||
#' \item{\strong{anonymous}:} {Set anonymous credentials.} | ||
#' } | ||
#' @param endpoint The complete URL to use for the constructed client. | ||
#' @param region The AWS Region used in instantiating the client. | ||
#' @param close_connection Immediately close all HTTP connections. | ||
#' @param connect_timeout The time in seconds till a timeout exception is thrown | ||
#' when attempting to make a connection. The default is 60 seconds. | ||
#' @param s3_force_path_style Set this to `true` to force the request to use path-style | ||
#' addressing, i.e. `http://s3.amazonaws.com/BUCKET/KEY`. | ||
#' @param sts_regional_endpoint Set sts regional endpoint resolver to regional or | ||
#' legacy \url{https://docs.aws.amazon.com/sdkref/latest/guide/feature-sts-regionalized-endpoints.html} | ||
#' @param creds \code{creds()} or \code{list} in same format. | ||
#' \itemize{ | ||
#' \item{\strong{access_key_id}:} {AWS access key ID} | ||
#' \item{\strong{secret_access_key}:} {AWS secret access key} | ||
#' \item{\strong{session_token}:} {AWS temporary session token} | ||
#' \item{\strong{access_token}:} {The token issued by the \code{CreateToken} API call. For more information, see | ||
#' \href{https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html}{CreateToken} | ||
#' in the `IAM Identity Center OIDC API Reference Guide`. | ||
#' }} | ||
#' @param profile The name of a profile to use. If not given, then the default profile is used. | ||
#' @param anonymous Set anonymous credentials. | ||
#' @param access_key_id AWS access key ID | ||
#' @param secret_access_key AWS secret access key | ||
#' @param session_token AWS temporary session token | ||
#' @param access_token The token issued by the \code{CreateToken} API call. For more information, see | ||
#' \href{https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html}{CreateToken} | ||
#' in the `IAM Identity Center OIDC API Reference Guide`. | ||
#' @return list set of parameter variables for paws services. | ||
#' @examples | ||
#' # set service parameter access_key_id and secret_access_key | ||
#' | ||
#' config(credentials(creds("dummy", "secret"))) | ||
#' | ||
#' # set service parameter access_key_id and secret_access_key using using lists | ||
#' config( | ||
#' credentials = list( | ||
#' creds = list( | ||
#' access_key_id = "dummy", | ||
#' secret_access_key = "secret" | ||
#' ) | ||
#' ) | ||
#' ) | ||
#' | ||
#' @name set_service_parameter | ||
#' @export | ||
{{config}} | ||
|
||
#' @rdname set_service_parameter | ||
#' @export | ||
{{credentials}} | ||
|
||
#' @rdname set_service_parameter | ||
#' @export | ||
{{creds}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.