|
7 | 7 | # nolint end |
8 | 8 | #' |
9 | 9 | #' @param workspace_uuid UUID of workspace |
10 | | -#' @param type List of asset types to return. Default returns all types; |
11 | | -#' "document", "folder" and "link". |
12 | | -#' |
13 | | -#' List must be empty (default, returns all asset types), or length 1 (e.g. |
14 | | -#' `list("document")`). This is a temporary measure while a bug in the |
15 | | -#' underlying API is outstanding (see |
16 | | -#' [objr#53](https://github.com/ScotGovAnalysis/objr/issues/53)). |
17 | | -#' |
| 10 | +#' @param type Asset type to filter results by. Either "document", "folder" or |
| 11 | +#' "link". Default returns all asset types. |
18 | 12 | #' @inheritParams objr |
19 | 13 | #' @inheritParams workspaces |
20 | 14 | #' |
|
25 | 19 | #' @export |
26 | 20 |
|
27 | 21 | assets <- function(workspace_uuid, |
28 | | - type = list(), |
| 22 | + type = NULL, |
29 | 23 | page = NULL, |
30 | 24 | size = NULL, |
31 | 25 | use_proxy = FALSE) { |
32 | 26 |
|
33 | | - check_list(type) |
34 | | - |
35 | | - if (length(type) > 1) { |
36 | | - cli::cli_abort(c( |
37 | | - "x" = "{.arg type} must be a list of length 0 or 1, not {length(type)}.", |
38 | | - "i" = paste( |
39 | | - "There is currently a bug in the underlying API preventing", |
40 | | - "users from selecting more than one asset type. See", |
41 | | - "{.href [objr#53](https://github.com/ScotGovAnalysis/objr/issues/53)}", |
42 | | - "for more information." |
43 | | - ), |
44 | | - "i" = paste("To return all assets, use `type = list()` (default)."), |
45 | | - "i" = paste("To return one asset type only, e.g. documents, use", |
46 | | - "`type = list(\"document\")`. See `?assets` for all", |
47 | | - "options.") |
48 | | - )) |
| 27 | + if (rlang::is_list(type)) { |
| 28 | + lifecycle::deprecate_warn( |
| 29 | + when = "0.2.0", |
| 30 | + what = "assets(type = 'must be a character string')", |
| 31 | + details = "All asset types are returned.", |
| 32 | + always = TRUE |
| 33 | + ) |
| 34 | + type <- NULL |
49 | 35 | } |
50 | 36 |
|
51 | | - type <- paste(toupper(type), collapse = "|") |
| 37 | + if (!is.null(type)) { |
| 38 | + if (!rlang::is_string(type)) { |
| 39 | + cli::cli_abort( |
| 40 | + "`type` must be a string, length 1." |
| 41 | + ) |
| 42 | + } |
| 43 | + if (!type %in% c("document", "folder", "link")) { |
| 44 | + cli::cli_abort( |
| 45 | + "`type` must be one of {.str document}, {.str folder} or {.str link}." |
| 46 | + ) |
| 47 | + } |
| 48 | + } |
52 | 49 |
|
53 | 50 | response <- objr( |
54 | 51 | endpoint = "assets", |
55 | 52 | url_query = list(workspaceUuid = workspace_uuid, |
56 | | - type = type, |
| 53 | + type = toupper(type), |
57 | 54 | page = page, |
58 | 55 | size = size), |
59 | 56 | use_proxy = use_proxy |
|
0 commit comments