-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve entity_list: add parameter
deleted
- Loading branch information
Showing
7 changed files
with
58 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,18 +5,17 @@ | |
#' This function returns a list of the Entities of a kind (belonging to an | ||
#' Entity List or Dataset). | ||
#' Please note that this endpoint only returns metadata of the entities, not the | ||
#' data. If you want to get the data of all entities then please refer to OData | ||
#' Dataset Service | ||
#' data. If you want to get the data of all entities then please refer to the | ||
#' OData Dataset Service. | ||
#' | ||
#' You can provide ?deleted=true to get only deleted entities. | ||
#' | ||
#' `entity_list()` will fail with incorrect or missing authentication. | ||
#' | ||
#' This function is supported from ODK Central v2022.3 and will warn if the | ||
#' given odkc_version is lower. | ||
#' You can get only deleted entities with `deleted=TRUE`. | ||
#' | ||
#' @template tpl-auth-missing | ||
#' @template tpl-compat-2022-3 | ||
#' @template param-pid | ||
#' @template param-did | ||
#' @param deleted (bool) Whether to get only deleted entities (`TRUE`) or not | ||
#' (`FALSE`). Default: `FALSE`. | ||
#' @template param-url | ||
#' @template param-auth | ||
#' @template param-retries | ||
|
@@ -36,36 +35,37 @@ | |
#' # See vignette("setup") for setup and authentication options | ||
#' # ruODK::ru_setup(svc = "....svc", un = "[email protected]", pw = "...") | ||
#' | ||
#' el <- entitylist_list() | ||
#' el <- entitylist_list() | ||
#' | ||
#' # Entity List name (dataset ID) | ||
#' did <- el$name[1] | ||
#' # Entity List name (dataset ID) | ||
#' did <- el$name[1] | ||
#' | ||
#' # All Entities of Entity List | ||
#' en <- entity_list(did = el$name[1]) | ||
#' # All Entities of Entity List | ||
#' en <- entity_list(did = el$name[1]) | ||
#' | ||
#' # The UUID of the first Entity | ||
#' eid <- en$uuid[1] | ||
#' # The UUID of the first Entity | ||
#' eid <- en$uuid[1] | ||
#' | ||
#' # The current version of the first Entity | ||
#' ev <- en$current_version_version[1] | ||
#' # The current version of the first Entity | ||
#' ev <- en$current_version_version[1] | ||
#' } | ||
entity_list <- function(pid = get_default_pid(), | ||
did = NULL, | ||
url = get_default_url(), | ||
un = get_default_un(), | ||
pw = get_default_pw(), | ||
retries = get_retries(), | ||
odkc_version = get_default_odkc_version(), | ||
orders = c( | ||
"YmdHMS", | ||
"YmdHMSz", | ||
"Ymd HMS", | ||
"Ymd HMSz", | ||
"Ymd", | ||
"ymd" | ||
), | ||
tz = get_default_tz()) { | ||
did = NULL, | ||
deleted = FALSE, | ||
url = get_default_url(), | ||
un = get_default_un(), | ||
pw = get_default_pw(), | ||
retries = get_retries(), | ||
odkc_version = get_default_odkc_version(), | ||
orders = c( | ||
"YmdHMS", | ||
"YmdHMSz", | ||
"Ymd HMS", | ||
"Ymd HMSz", | ||
"Ymd", | ||
"ymd" | ||
), | ||
tz = get_default_tz()) { | ||
yell_if_missing(url, un, pw, pid = pid) | ||
|
||
if (is.null(did)) { | ||
|
@@ -80,6 +80,10 @@ entity_list <- function(pid = get_default_pid(), | |
"v1/projects/{pid}/datasets/{URLencode(did, reserved = TRUE)}/entities" | ||
) | ||
|
||
if (deleted == TRUE) { | ||
pth <- glue::glue("{pth}?deleted=true") | ||
} | ||
|
||
httr::RETRY( | ||
"GET", | ||
httr::modify_url(url, path = pth), | ||
|
@@ -101,4 +105,4 @@ entity_list <- function(pid = get_default_pid(), | |
) | ||
} | ||
|
||
# usethis::use_test("entity_list") # nolint | ||
# usethis::use_test("entity_list") # nolint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters