Skip to content

Commit

Permalink
Merge pull request #82 from getwilds/egs-groups
Browse files Browse the repository at this point in the history
added egs for groups fxns; also reexporting magrittr pipe so its avai…
  • Loading branch information
sckott authored Jan 29, 2025
2 parents 131c9ea + e2318aa commit 58ab2e1
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:

- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-examples", "--no-manual", "--as-cran")'
upload-snapshots: true
env:
AWS_REGION: us-west-2
Expand Down
1 change: 1 addition & 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

S3method(print,sixtyfour_client)
export("%>%")
export(as_policy_arn)
export(aws_billing)
export(aws_billing_raw)
Expand Down
40 changes: 24 additions & 16 deletions R/groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ group_list_tidy <- function(x) {
#' if username is non-NULL, otherwise passed on to `list_users`
#' @return A tibble with information about groups
#' @family groups
#' @examples \dontrun{
#' @examplesIf aws_has_creds()
#' aws_groups()
#' aws_groups(username = aws_user_current())
#' }
aws_groups <- function(username = NULL, ...) {
if (is.null(username)) {
paginate_aws_marker("list_groups", "Groups", ...) %>%
Expand All @@ -48,9 +47,13 @@ aws_groups <- function(username = NULL, ...) {
#' @details see docs <https://www.paws-r-sdk.com/docs/iam_get_group/>
#' @autoglobal
#' @family groups
#' @examples \dontrun{
#' aws_group(name = "users")
#' }
#' @examplesIf aws_has_creds()
#' # create a group
#' aws_group_create("testing")
#' # get the group
#' aws_group(name = "testing")
#' # cleanup
#' aws_group_delete(name = "testing")
aws_group <- function(name) {
x <- con_iam()$get_group(name)
list(
Expand All @@ -63,18 +66,21 @@ aws_group <- function(name) {

#' Check if a group exists
#'
#' @importFrom purrr safely
#' @export
#' @param name (character) the group name
#' @return a single boolean
#' @details uses `aws_group` internally. see docs
#' <https://www.paws-r-sdk.com/docs/iam_get_group/>
#' @family groups
#' @examples \dontrun{
#' aws_group_exists(name = "users")
#' aws_group_exists(name = "apples")
#' }
#' @examplesIf aws_has_creds()
#' aws_group_create("apples")
#' aws_group_exists("apples")
#' aws_group_exists("doesnotexist")
#' # cleanup
#' aws_group_delete("apples")
aws_group_exists <- function(name) {
check_aws_group <- purrr::safely(aws_group, otherwise = FALSE)
check_aws_group <- safely(aws_group, otherwise = FALSE)
is.null(check_aws_group(name)$error)
}

Expand All @@ -88,9 +94,11 @@ aws_group_exists <- function(name) {
#' @details See <https://www.paws-r-sdk.com/docs/iam_create_group/>
#' docs for details on the parameters
#' @family groups
#' @examples \dontrun{
#' aws_group_create("testgroup")
#' }
#' @examplesIf aws_has_creds()
#' aws_group_create("testingagroup")
#' aws_group("testingagroup")
#' # cleanup
#' aws_group_delete("testingagroup")
aws_group_create <- function(name, path = NULL) {
con_iam()$create_group(Path = path, GroupName = name) %>%
group_list_tidy()
Expand All @@ -104,9 +112,9 @@ aws_group_create <- function(name, path = NULL) {
#' @details See <https://www.paws-r-sdk.com/docs/iam_delete_group/>
#' docs for more details
#' @family groups
#' @examples \dontrun{
#' aws_group_delete(name = "testgroup")
#' }
#' @examplesIf aws_has_creds()
#' aws_group_create("somegroup")
#' aws_group_delete("somegroup")
aws_group_delete <- function(name) {
con_iam()$delete_group(name)
}
3 changes: 3 additions & 0 deletions R/reexport-magrittr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#' @importFrom magrittr %>%
#' @export
magrittr::`%>%`
11 changes: 8 additions & 3 deletions man/aws_group.Rd

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

9 changes: 6 additions & 3 deletions man/aws_group_create.Rd

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

7 changes: 4 additions & 3 deletions man/aws_group_delete.Rd

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

11 changes: 7 additions & 4 deletions man/aws_group_exists.Rd

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

4 changes: 2 additions & 2 deletions man/aws_groups.Rd

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

5 changes: 4 additions & 1 deletion man/reexports.Rd

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

2 changes: 1 addition & 1 deletion man/sixtyfour-package.Rd

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

0 comments on commit 58ab2e1

Please sign in to comment.