Skip to content
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

add config helper functions to credential doc #644

Merged
merged 3 commits into from
Jul 6, 2023
Merged
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
45 changes: 45 additions & 0 deletions docs/credentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ svc <- paws::svc(
)
```

As of `paws.common (>= 0.5.8)` 3 new helper functions have been added to help
set credentials for an individual service (`config`, `credentials` and `creds`).
These new helper functions aim to provide auto-complete functionality to aid
the construction of config list.

```r
# paws.common (>= 0.5.8)
library(paws.common)
svc <- paws::svc(
config(
credentials(
creds(
access_key_id = "your AWS access key",
secret_access_key = "your AWS secret key"
)
)
)
)
```

In this example, `paws::svc` is a placeholder for an AWS service. Use a
specific service instead, for example, `paws::s3`. Paws supports having
multiple service objects with different credentials.
Expand All @@ -128,13 +148,38 @@ svc <- paws::svc(
)
```

Alternatively:
```r
# paws.common (>= 0.5.8)
library(paws.common)
svc <- paws::svc(
config(
credentials(
creds(
access_key_id = "your AWS access key",
secret_access_key = "your AWS secret key",
session_token = "your session token",
expiration = as.POSIXct("2001-02-03 04:05:06")
)
)
)
)
```

`expiration` must be a `POSIXct` date-time or able to be compared with them.

Additionally, anonymous credentials may be used (e.g., before calling `assume_role_with_web_identity()` on an STS service)
``` r
svc <- paws::svc(config = list(credentials = list(anonymous = TRUE)))
```

Alternatively:
```r
# paws.common (>= 0.5.8)
library(paws.common)
svc <- paws::svc(config(credentials(anonymous = TRUE)))
```

---


Expand Down
2 changes: 1 addition & 1 deletion make.paws/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: make.paws
Type: Package
Title: Generate Paws AWS SDKs for R
Version: 0.5.2
Version: 0.5.3
Authors@R: c(
person("David", "Kretch", email = "david.kretch@gmail.com", role = "aut"),
person("Adam", "Banker", email = "adam.banker39@gmail.com", role = "aut"),
Expand Down
1 change: 0 additions & 1 deletion make.paws/R/paws_helper_fun.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.param_not_used <- c(
"expiration",
"force_refresh",
"endpoint_resolver",
"enforce_should_retry_check",
Expand Down
10 changes: 8 additions & 2 deletions make.paws/inst/templates/service_parameter_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#' \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{expiration}:} {The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.}
#' }}
#' \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.}
Expand All @@ -37,8 +39,10 @@
#' \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`.
#' }}
#' in the `IAM Identity Center OIDC API Reference Guide`.}
#' \item{\strong{expiration}:} {The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.}
#' }
#' @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
Expand All @@ -47,6 +51,8 @@
#' @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`.
#' @param expiration The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.
#' @return list set of parameter variables for paws services.
#' @examples
#' # set service parameter access_key_id and secret_access_key
Expand Down
2 changes: 1 addition & 1 deletion paws.common/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: paws.common
Type: Package
Title: Paws Low-Level Amazon Web Services API
Version: 0.5.8
Version: 0.5.9
Authors@R: c(
person("David", "Kretch", email = "david.kretch@gmail.com", role = "aut"),
person("Adam", "Banker", email = "adam.banker39@gmail.com", role = "aut"),
Expand Down
5 changes: 4 additions & 1 deletion paws.common/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# paws.common 0.5.9
* add expiration parameter to creds

# paws.common 0.5.8
* fix mismatch apparent method as.list.struct (#634)
* split timeout and connecttimeout in http call (#610). Thanks to @stuart-storypark for identifying issue, and @joakibo for extra insight and testing.
* add STS regional endpoint support (#631). Thanks to @daniepi for identifying issue, and @joakibo for implementing solution.
* fix windows root path by adding HOMEDRIVE environmental variable (#640). Thanks to @karen5780 for identifying issue and proposing solution.
* enhancements to service construction, export helper functions for parameter auto-complete (#421).
* enhancements to service construction, export helper functions for parameter auto-complete (#421). Thanks to @hadley for suggestion and recommendation.

# paws.common 0.5.7
* skip network unit test on cran (#632)
Expand Down
23 changes: 15 additions & 8 deletions paws.common/R/service_parameter_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#' \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{expiration}:} {The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.}
#' }}
#' \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.}
Expand All @@ -37,8 +39,10 @@
#' \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`.
#' }}
#' in the `IAM Identity Center OIDC API Reference Guide`.}
#' \item{\strong{expiration}:} {The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.}
#' }
#' @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
Expand All @@ -47,6 +51,8 @@
#' @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`.
#' @param expiration The date and time when the temporary credentials expire.
#' `expiration` must be a `POSIXct` date-time or able to be compared with them.
#' @return list set of parameter variables for paws services.
#' @examples
#' # set service parameter access_key_id and secret_access_key
Expand All @@ -66,10 +72,10 @@
#' @name set_service_parameter
#' @export
config <- function (credentials = list(creds = list(access_key_id = "",
secret_access_key = "", session_token = "", access_token = ""),
profile = "", anonymous = FALSE), endpoint = "", region = "",
close_connection = FALSE, connect_timeout = 60, s3_force_path_style = FALSE,
sts_regional_endpoint = "")
secret_access_key = "", session_token = "", access_token = "",
expiration = Inf), profile = "", anonymous = FALSE), endpoint = "",
region = "", close_connection = FALSE, connect_timeout = 60,
s3_force_path_style = FALSE, sts_regional_endpoint = "")
{
.args <- as.list(environment(), all.names = TRUE)
class(.args) <- "struct"
Expand All @@ -79,7 +85,8 @@ config <- function (credentials = list(creds = list(access_key_id = "",
#' @rdname set_service_parameter
#' @export
credentials <- function (creds = list(access_key_id = "", secret_access_key = "",
session_token = "", access_token = ""), profile = "", anonymous = FALSE)
session_token = "", access_token = "", expiration = Inf),
profile = "", anonymous = FALSE)
{
.args <- as.list(environment(), all.names = TRUE)
class(.args) <- "struct"
Expand All @@ -89,7 +96,7 @@ credentials <- function (creds = list(access_key_id = "", secret_access_key = ""
#' @rdname set_service_parameter
#' @export
creds <- function (access_key_id = "", secret_access_key = "", session_token = "",
access_token = "")
access_token = "", expiration = Inf)
{
.args <- as.list(environment(), all.names = TRUE)
class(.args) <- "struct"
Expand Down
19 changes: 14 additions & 5 deletions paws.common/man/set_service_parameter.Rd

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