|
3 | 3 | #' @description List, create, update, and delete function aliases
|
4 | 4 | #' @template name
|
5 | 5 | #' @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. |
8 | 10 | #' @param marker A pagination marker from a previous request.
|
9 | 11 | #' @param n An integer specifying the number of results to return.
|
10 | 12 | #' @template dots
|
11 | 13 | #' @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. |
13 | 21 | #' @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} |
19 | 32 | #' @seealso \code{\link{create_function}}, \code{\link{list_functions}}
|
20 | 33 | #' @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) |
27 | 44 | }
|
28 | 45 |
|
29 | 46 | #' @rdname alias
|
30 | 47 | #' @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) |
37 | 60 | }
|
38 | 61 |
|
39 | 62 | #' @rdname alias
|
40 | 63 | #' @export
|
41 | 64 | 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) |
46 | 69 | }
|
47 | 70 |
|
48 | 71 | #' @rdname alias
|
49 | 72 | #' @export
|
50 | 73 | 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) |
55 | 78 | }
|
56 | 79 |
|
57 | 80 | #' @rdname alias
|
58 | 81 | #' @export
|
59 | 82 | 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) |
65 | 102 | }
|
0 commit comments