Skip to content

Commit e803cd6

Browse files
authored
Bring this package back alive! (#11)
* Bring this package back alive! For now I just redocumented and rebuilt, with my name added as maintainer. We'll see how that goes. * Add NEWS.md * Updated travis to match aws.s3 * Cleanup with goodpractice package. * Verified functions.R Found and fixed a bug in delete_function (it was invoking delete_function_version instead of the main delete API). Manually tested all functions in this file to make sure they're invoking the proper APIs with proper query parameters. * Verified account.R * Update GPL-2 to GPL-3 Also cleaned DESCRIPTION. * Verified aliases.R Added warning for version == $LATEST (api bug). Changed order of parameters in create and made description optional. Logged missing update options in issue #12. * Verified http.R Started to streamline lambdaHTTP, but there's more to do in future PRs. * Verified invoke_function There are some issues here (logged), but no show stoppers. * Verified create_function And cleaned up references in docs. * Final cleanups pre-release. * Updated README. * Added cran comments.
1 parent 8181177 commit e803cd6

28 files changed

+1582
-671
lines changed

.Rbuildignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ knitreadme.sh
1010
^.*\.Rproj$
1111
^\.Rproj\.user$
1212
^\.github.?
13+
^LICENSE\.md$
14+
^README\.Rmd$
15+
^cran-comments\.md$

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.Rproj.user
33
.Rhistory
44
.RData
5-
aws.s3.Rproj
5+
aws.lambda.Rproj

.travis.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ matrix:
77
dist: trusty
88
sudo: required
99
env: DRAT_DEPLOY=true
10-
- os: osx
11-
osx_image: xcode9.2
12-
- os: osx
13-
osx_image: xcode7.3
14-
r_build_args: "--no-build-vignettes"
15-
r_check_args: "--ignore-vignettes --no-examples"
10+
# Travis is currently broken for macos R so disable
11+
# - os: osx
12+
# osx_image: xcode9.2
1613
r_packages:
1714
- covr
1815
- drat

DESCRIPTION

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
Package: aws.lambda
22
Type: Package
33
Title: AWS Lambda Client Package
4-
Version: 0.1.6
5-
Date: 2017-07-01
6-
Authors@R: c(person("Thomas J.", "Leeper", role = c("aut"),
4+
Version: 0.2.0
5+
Authors@R: c(
6+
person("Thomas J.", "Leeper", role = c("aut"),
77
email = "[email protected]",
8-
comment = c(ORCID = "0000-0003-4097-6326")))
9-
Maintainer: ORPHANED
10-
Description: A simple client package for the Amazon Web Services ('AWS') Lambda 'API' <https://aws.amazon.com/lambda/>.
11-
License: GPL (>= 2)
8+
comment = c(ORCID = "0000-0003-4097-6326")),
9+
person("Jon", "Harmon", role = c("ctb", "cre"),
10+
email = "[email protected]",
11+
comment = c(ORCID = "0000-0003-4781-4346"))
12+
)
13+
Description: A simple client package for the Amazon Web Services ('AWS') Lambda
14+
API <https://aws.amazon.com/lambda/>.
15+
Encoding: UTF-8
16+
LazyData: true
17+
Depends: R (>= 3.4)
18+
License: GPL-3
1219
Imports:
1320
utils,
1421
httr,
@@ -21,4 +28,4 @@ Suggests:
2128
aws.iam
2229
URL: https://github.com/cloudyr/aws.lambda
2330
BugReports: https://github.com/cloudyr/aws.lambda/issues
24-
RoxygenNote: 6.0.1
31+
RoxygenNote: 7.1.0

LICENSE.md

+595
Large diffs are not rendered by default.

NAMESPACE

+13-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ export(list_function_aliases)
1717
export(list_function_versions)
1818
export(list_functions)
1919
export(make_function_version)
20+
export(publish_function_version)
2021
export(update_function)
2122
export(update_function_alias)
22-
import(httr)
23+
export(update_function_code)
24+
export(update_function_config)
25+
importFrom(aws.signature,locate_credentials)
2326
importFrom(aws.signature,signature_v4_auth)
2427
importFrom(base64enc,base64encode)
25-
importFrom(jsonlite,fromJSON)
28+
importFrom(httr,DELETE)
29+
importFrom(httr,GET)
30+
importFrom(httr,POST)
31+
importFrom(httr,PUT)
32+
importFrom(httr,add_headers)
33+
importFrom(httr,content)
34+
importFrom(httr,headers)
35+
importFrom(httr,http_error)
36+
importFrom(httr,stop_for_status)
2637
importFrom(jsonlite,toJSON)
27-
importFrom(utils,str)
2838
importFrom(utils,zip)

NEWS.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
# CHANGES TO aws.lambda 0.1.6
1+
# aws.lambda 0.1.6.9000
2+
3+
* New maintainer (@jonthegeek).
4+
* Updated license to GPL-3.
5+
* Deprecated `update_function()` in favor of `update_function_code()` and `update_function_config()`.
6+
* Deprecated `make_function_version()` in favor of `publish_function_version()`.
7+
8+
# aws.lambda 0.1.6
29

310
* Change `get_account()` to `get_lambda_account()` to avoid namespace conflict with **aws.iam.**
411

5-
# CHANGES TO aws.lambda 0.1.4
12+
# aws.lambda 0.1.4
613

714
* Bump **aws.signature** dependency to 0.3.4.
815

9-
# CHANGES TO aws.lambda 0.1.3
16+
# aws.lambda 0.1.3
1017

1118
* Rename alias-related functions to avoid namespace clash with aws.iam.
1219

13-
# CHANGES TO aws.lambda 0.1.2
20+
# aws.lambda 0.1.2
1421

1522
* Update code and documentation.
1623

17-
# CHANGES TO aws.lambda 0.1.1
24+
# aws.lambda 0.1.1
1825

1926
* Initial release.

R/account.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#' @return A list.
55
#' @examples
66
#' \dontrun{
7-
#' get_lambda_account()
7+
#' get_lambda_account()
88
#' }
99
#' @export
1010
get_lambda_account <- function(...) {
11-
act <- paste0("/2016-08-19/account-settings")
12-
lambdaHTTP(verb = "GET", action = act, ...)
11+
act <- paste0("/2016-08-19/account-settings")
12+
lambdaHTTP(verb = "GET", action = act, ...)
1313
}

R/aliases.R

+70-33
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,100 @@
33
#' @description List, create, update, and delete function aliases
44
#' @template name
55
#' @param alias A character string specifying a function alias
6-
#' @param description Optionally, a max 256-character description of the function for your own use.
7-
#' @param version A character string specifying a function version
6+
#' @param version A character string specifying a function version to associate
7+
#' with this alias.
8+
#' @param description Optionally, a max 256-character description of the
9+
#' function for your own use.
810
#' @param marker A pagination marker from a previous request.
911
#' @param n An integer specifying the number of results to return.
1012
#' @template dots
1113
#' @return An object of class \dQuote{aws_lambda_function}.
12-
#' @details \code{list_functions} lists all functions. \code{get_function} retrieves a specific function and \code{get_function_versions} retrieves all versions of that function. \code{get_function_configuration} returns the configuration details used when creating or updating the function. \code{delete_function} deletes a function, if you have permission to do so.
14+
#' @details \code{create_function_alias} creates a new function alias for a
15+
#' given version of a function. \code{update_function_alias} updates the
16+
#' association between a function alias and the function version.
17+
#' \code{list_function_aliases} lists all function aliases.
18+
#' \code{get_function_alias} retrieves a specific function alias.
19+
#' \code{delete_function_alias} deletes a function alias, but not the
20+
#' associated function version.
1321
#' @references
14-
#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API Reference: GetAlias}
15-
#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API Reference: CreateAlias}
16-
#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API Reference: UpdateAlias}
17-
#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API Reference: DeleteAlias}
18-
#' \href{http://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API Reference: ListAliases}
22+
#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_GetAlias.html}{API
23+
#' Reference: GetAlias}
24+
#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html}{API
25+
#' Reference: CreateAlias}
26+
#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_UpdateAlias.html}{API
27+
#' Reference: UpdateAlias}
28+
#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_DeleteAlias.html}{API
29+
#' Reference: DeleteAlias}
30+
#' \href{https://docs.aws.amazon.com/lambda/latest/dg/API_ListAliases.html}{API
31+
#' Reference: ListAliases}
1932
#' @seealso \code{\link{create_function}}, \code{\link{list_functions}}
2033
#' @export
21-
create_function_alias <- function(name, alias, description, version, ...) {
22-
name <- get_function_name(name)
23-
act <- paste0("/2015-03-31/functions/", name, "/aliases")
24-
b <- list(Description = description, FunctionVersion = version, Name = alias)
25-
r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
26-
return(r)
34+
create_function_alias <- function(name, alias, version, description, ...) {
35+
name <- get_function_name(name)
36+
act <- paste0("/2015-03-31/functions/", name, "/aliases")
37+
b <- list(FunctionVersion = version, Name = alias)
38+
# Description is optional.
39+
if (!missing(description)) {
40+
b[["Description"]] <- description
41+
}
42+
r <- lambdaHTTP(verb = "POST", action = act, body = b, ...)
43+
return(r)
2744
}
2845

2946
#' @rdname alias
3047
#' @export
31-
update_function_alias <- function(name, alias, description, version, ...) {
32-
name <- get_function_name(name)
33-
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
34-
b <- list(Description = description, FunctionVersion = version)
35-
r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
36-
return(r)
48+
update_function_alias <- function(name, alias, version, description, ...) {
49+
name <- get_function_name(name)
50+
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
51+
b <- list()
52+
if (!missing(version)) {
53+
b[["FunctionVersion"]] <- version
54+
}
55+
if (!missing(description)) {
56+
b[["Description"]] <- description
57+
}
58+
r <- lambdaHTTP(verb = "PUT", action = act, body = b, ...)
59+
return(r)
3760
}
3861

3962
#' @rdname alias
4063
#' @export
4164
delete_function_alias <- function(name, alias, ...) {
42-
name <- get_function_name(name)
43-
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
44-
r <- lambdaHTTP(verb = "DELETE", action = act, ...)
45-
return(r)
65+
name <- get_function_name(name)
66+
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
67+
r <- lambdaHTTP(verb = "DELETE", action = act, ...)
68+
return(r)
4669
}
4770

4871
#' @rdname alias
4972
#' @export
5073
get_function_alias <- function(name, alias, ...) {
51-
name <- get_function_name(name)
52-
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
53-
r <- lambdaHTTP(verb = "GET", action = act, ...)
54-
return(r)
74+
name <- get_function_name(name)
75+
act <- paste0("/2015-03-31/functions/", name, "/aliases/", alias)
76+
r <- lambdaHTTP(verb = "GET", action = act, ...)
77+
return(r)
5578
}
5679

5780
#' @rdname alias
5881
#' @export
5982
list_function_aliases <- function(name, version, marker, n, ...) {
60-
name <- get_function_name(name)
61-
act <- paste0("/2015-03-31/functions/", name, "/aliases")
62-
query <- list(FunctionVersion = version, Marker = marker, MaxItems = n)
63-
r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
64-
return(r)
83+
name <- get_function_name(name)
84+
act <- paste0("/2015-03-31/functions/", name, "/aliases")
85+
query <- list()
86+
if (!missing(version)) {
87+
warning(
88+
"The AWS API erroneously returns an empty list when version is specified",
89+
" if you only have one alias.",
90+
"\n You may want to try again without specifying a version."
91+
)
92+
query[["FunctionVersion"]] <- version
93+
}
94+
if (!missing(marker)) {
95+
query[["Marker"]] <- marker
96+
}
97+
if (!missing(n)) {
98+
query[["MaxItems"]] <- n
99+
}
100+
r <- lambdaHTTP(verb = "GET", action = act, query = query, ...)
101+
return(r)
65102
}

0 commit comments

Comments
 (0)