Skip to content

Commit

Permalink
update documentation for CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
leeper committed Jul 1, 2017
1 parent f6ca50c commit 414d39a
Show file tree
Hide file tree
Showing 18 changed files with 407 additions and 120 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: aws.iam
Type: Package
Title: AWS IAM Client Package
Version: 0.1.6
Date: 2017-06-30
Version: 0.1.7
Date: 2017-07-01
Author: Thomas J. Leeper
Maintainer: Thomas J. Leeper <[email protected]>
Description: A simple client package for the Amazon Web Services (AWS) Identity
and Access Management (IAM) API.
Description: A simple client for the Amazon Web Services ('AWS') Identity
and Access Management ('IAM') 'API' <https://aws.amazon.com/iam/>.
License: GPL (>= 2)
Imports:
utils,
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Generated by roxygen2: do not edit by hand

S3method(print,iam_alias)
S3method(print,iam_group)
S3method(print,iam_instance_profile)
S3method(print,iam_key)
S3method(print,iam_policy)
S3method(print,iam_role)
S3method(print,iam_user)
export(add_policy)
export(add_profile_role)
export(add_user)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# CHANGES TO aws.iam 0.1.6

* Expanded documentation.

# CHANGES TO aws.iam 0.1.5

* Bump **aws.signature** dependency to 0.3.4.
Expand Down
18 changes: 18 additions & 0 deletions R/accesskey.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
#' @template marker
#' @template dots
#' @return \code{create_user} and \code{get_user} return objects of class \dQuote{iam_user}. \code{update_user} and \code{delete_user} return a logical \code{TRUE} (if successful) or an error. \code{list_users} returns a list of IAM user objects.
#' @examples
#' \dontrun{
#' # list access keys
#' list_keys()
#'
#' # create a user key
#' u <- create_user("example-user")
#' str(k <- create_key(u))
#'
#' # toggle key status to inactive
#' update_key(k, u, "Inactive")
#' list_keys(u)
#'
#' # cleanup
#' delete_key(k)
#' delete_user(u)
#' }
#' @seealso \code{\link{create_user}}
#' @export
create_key <- function(user, ...) {
query <- list(Action = "CreateAccessKey")
Expand Down
8 changes: 8 additions & 0 deletions R/get_account.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
#' @template dots
#' @return A list containing various account details.
#' @details \code{get_account} returns a list of account details. \code{credential_report} generates and/or retrieves a credential report. \code{auth_details} returns a list of group, user, role, and policy details.
#' @examples
#' \dontrun{
#' # account details
#' get_aaccount()
#'
#' # big list of authorizations
#' auth_details()
#' }
#' @export
get_account <- function(...) {
query <- list(Action = "GetAccountSummary")
Expand Down
24 changes: 24 additions & 0 deletions R/groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@
#' @template marker
#' @template dots
#' @return \code{create_group} and \code{get_group} return objects of class \dQuote{iam_group}. \code{update_group} and \code{delete_group}, \code{add_user}, and \code{remove_user} return a logical \code{TRUE} (if successful) or an error. \code{list_groups} returns a list of IAM group objects. \code{get_group_users} returns a list of objects of class \dQuote{iam_user}, with a \dQuote{iam_group} attribute.
#' @examples
#' \dontrun{
#' list_groups()
#'
#' # create group
#' (g <- create_group("example"))
#' # rename
#' update_group(g, "example2")
#' list_groups()
#'
#' # create example user
#' u <- create_user("example-user")
#' # add user to group
#' add_user(u, "example2")
#'
#' get_group_users("example2")
#'
#' # cleanup
#' remove_user(u, "example2")
#' delete_user(u)
#' delete_group("example2")
#' }
#' @seealso \code{\link{create_user}}, \code{\link{create_role}},
#' @export
create_group <- function(group, path, ...){
query <- list(Action = "CreateGroup")
Expand Down Expand Up @@ -107,6 +130,7 @@ get_group_users <- function(group, n, marker, ...) {
#' @export
list_groups <- function(user, n, marker, path, ...) {
if (!missing(user)) {
user <- get_username(user)
query <- list(Action = "ListGroupsForUsers", UserName = user)
} else {
user <- NULL
Expand Down
2 changes: 1 addition & 1 deletion R/http.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ iamHTTP <- function(query,
} else if (verb == "POST") {
r <- POST(paste0("https://iam.amazonaws.com"), H, query = query, body = body, ...)
}
if (http_status(r)$category == "Client error") {
if (http_error(r)) {
x <- try(as_list(read_xml(content(r, "text", encoding = "UTF-8"))), silent = TRUE)
if (inherits(x, "try-error")) {
x <- try(fromJSON(content(r, "text", encoding = "UTF-8"))$Error, silent = TRUE)
Expand Down
119 changes: 119 additions & 0 deletions R/print.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#' @export
print.iam_alias <- function(x, ...) {
if (!is.null(x[["AliasName"]])) {
cat("AliasName:", x[["AliasName"]], "\n")
}
invisible(x)
}

#' @export
print.iam_group <- function(x, ...) {
if (!is.null(x[["GroupId"]])) {
cat("GroupId: ", x[["GroupId"]], "\n")
}
if (!is.null(x[["GroupName"]])) {
cat("GroupName: ", paste0(x[["Path"]], x[["GroupName"]]), "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
invisible(x)
}

#' @export
print.iam_key <- function(x, ...) {
if (!is.null(x[["AccessKeyId"]])) {
cat("AccessKeyId:", x[["AccessKeyId"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate: ", x[["CreateDate"]], "\n")
}
if (!is.null(x[["Status"]])) {
cat("Status: ", x[["Status"]], "\n")
}
if (!is.null(x[["UserName"]])) {
cat("UserName: ", x[["UserName"]], "\n")
}
invisible(x)
}

#' @export
print.iam_policy <- function(x, ...) {
if (!is.null(x[["PolicyName"]])) {
cat("PolicyName:", x[["PolicyName"]], "\n")
}
if (!is.null(x[["RoleName"]])) {
cat("RoleName: ", x[["RoleName"]], "\n")
}
if (!is.null(x[["UserName"]])) {
cat("UserName: ", x[["UserName"]], "\n")
}
if (!is.null(x[["GroupName"]])) {
cat("GroupName: ", x[["GroupName"]], "\n")
}
if (!is.null(x[["PolicyDocument"]])) {
cat("policy: ", x[["PolicyDocument"]], "\n")
}
invisible(x)
}

#' @export
print.iam_instance_profile <- function(x, ...) {
if (!is.null(x[["InstanceProfileName"]])) {
cat("InstanceProfileName: ", paste0(x[["Path"]], x[["InstanceProfileName"]]), "\n")
}
if (!is.null(x[["InstanceProfileId"]])) {
cat("InstanceProfileId: ", x[["InstanceProfileId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate: ", x[["CreateDate"]], "\n")
}
if (!is.null(x[["Roles"]])) {
cat("Roles:\n")
print(x[["Roles"]])
}
invisible(x)
}

#' @export
print.iam_role <- function(x, ...) {
if (!is.null(x[["RoleName"]])) {
cat("RoleName: ", paste0(x[["Path"]], x[["RoleName"]]), "\n")
}
if (!is.null(x[["RoleId"]])) {
cat("RoleId: ", x[["RoleId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
if (!is.null(x[["AssumeRolePolicyDocument"]])) {
cat("policy: ", x[["AssumeRolePolicyDocument"]], "\n")
}
invisible(x)
}

#' @export
print.iam_user <- function(x, ...) {
if (!is.null(x[["UserName"]])) {
cat("UserName: ", paste0(x[["Path"]], x[["UserName"]]), "\n")
}
if (!is.null(x[["UserId"]])) {
cat("UserId: ", x[["UserId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
invisible(x)
}
1 change: 1 addition & 0 deletions R/roles.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @template marker
#' @template dots
#' @return \code{create_role} and \code{get_role} return objects of class \dQuote{iam_role}. \code{update_role} and \code{delete_role} return a logical \code{TRUE} (if successful) or an error. \code{list_roles} returns a list of IAM role objects.
#' @seealso \code{\link{create_user}}, \code{\link{create_group}},
#' @export
create_role <- function(role, policy, path, ...){
query <- list(Action = "CreateRole")
Expand Down
11 changes: 11 additions & 0 deletions R/user.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#' @template marker
#' @template dots
#' @return \code{create_user} and \code{get_user} return objects of class \dQuote{iam_user}. \code{update_user} and \code{delete_user} return a logical \code{TRUE} (if successful) or an error. \code{list_users} returns a list of IAM user objects.
#' @examples
#' \dontrun{
#' list_users()
#'
#' # create example user
#' u <- create_user("example-user")
#'
#' # cleanup
#' delete_user(u)
#' }
#' @export
create_user <- function(user, path, ...) {
query <- list(Action = "CreateUser")
Expand Down Expand Up @@ -79,6 +89,7 @@ get_user <- function(user, ...) {
#' @export
delete_user <- function(user, ...) {
query <- list(Action = "DeleteUser")
user <- get_username(user)
if (!missing(user)) {
if (nchar(user) < 1 | nchar(user) > 128) {
stop("'user' must be between 1 and 128 characters")
Expand Down
113 changes: 0 additions & 113 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,116 +67,3 @@ get_rolename <- function(x) {
x
}
}

print.iam_alias <- function(x, ...) {
if (!is.null(x[["AliasName"]])) {
cat("AliasName:", x[["AliasName"]], "\n")
}
invisible(x)
}

print.iam_group <- function(x, ...) {
if (!is.null(x[["GroupId"]])) {
cat("GroupId: ", x[["GroupId"]], "\n")
}
if (!is.null(x[["GroupName"]])) {
cat("GroupName: ", paste0(x[["Path"]], x[["GroupName"]]), "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
invisible(x)
}

print.iam_key <- function(x, ...) {
if (!is.null(x[["AccessKeyId"]])) {
cat("AccessKeyId:", x[["AccessKeyId"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate: ", x[["CreateDate"]], "\n")
}
if (!is.null(x[["Status"]])) {
cat("Status: ", x[["Status"]], "\n")
}
if (!is.null(x[["UserName"]])) {
cat("UserName: ", x[["UserName"]], "\n")
}
invisible(x)
}

print.iam_policy <- function(x, ...) {
if (!is.null(x[["PolicyName"]])) {
cat("PolicyName:", x[["PolicyName"]], "\n")
}
if (!is.null(x[["RoleName"]])) {
cat("RoleName: ", x[["RoleName"]], "\n")
}
if (!is.null(x[["UserName"]])) {
cat("UserName: ", x[["UserName"]], "\n")
}
if (!is.null(x[["GroupName"]])) {
cat("GroupName: ", x[["GroupName"]], "\n")
}
if (!is.null(x[["PolicyDocument"]])) {
cat("policy: ", x[["PolicyDocument"]], "\n")
}
invisible(x)
}

print.iam_instance_profile <- function(x, ...) {
if (!is.null(x[["InstanceProfileName"]])) {
cat("InstanceProfileName: ", paste0(x[["Path"]], x[["InstanceProfileName"]]), "\n")
}
if (!is.null(x[["InstanceProfileId"]])) {
cat("InstanceProfileId: ", x[["InstanceProfileId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate: ", x[["CreateDate"]], "\n")
}
if (!is.null(x[["Roles"]])) {
cat("Roles:\n")
print(x[["Roles"]])
}
invisible(x)
}

print.iam_role <- function(x, ...) {
if (!is.null(x[["RoleName"]])) {
cat("RoleName: ", paste0(x[["Path"]], x[["RoleName"]]), "\n")
}
if (!is.null(x[["RoleId"]])) {
cat("RoleId: ", x[["RoleId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
if (!is.null(x[["AssumeRolePolicyDocument"]])) {
cat("policy: ", x[["AssumeRolePolicyDocument"]], "\n")
}
invisible(x)
}

print.iam_user <- function(x, ...) {
if (!is.null(x[["UserName"]])) {
cat("UserName: ", paste0(x[["Path"]], x[["UserName"]]), "\n")
}
if (!is.null(x[["UserId"]])) {
cat("UserId: ", x[["UserId"]], "\n")
}
if (!is.null(x[["Arn"]])) {
cat("Arn: ", x[["Arn"]], "\n")
}
if (!is.null(x[["CreateDate"]])) {
cat("CreateDate:", x[["CreateDate"]], "\n")
}
invisible(x)
}
Loading

0 comments on commit 414d39a

Please sign in to comment.