55
66# datastore API base URL:
77assign(" ds_public_api" ,
8- " https://irmaservices.nps.gov/datastore/v7 /rest" ,
8+ " https://irmaservices.nps.gov/datastore/v8 /rest" ,
99 envir = .pkgglobalenv
1010)
1111
1212# datastore secure API base URL:
1313assign(" ds_secure_api" ,
14- " https://irmaservices.nps.gov/datastore-secure/v7 /rest" ,
14+ " https://irmaservices.nps.gov/datastore-secure/v8 /rest" ,
1515 envir = .pkgglobalenv
1616)
1717
1818# datastore secure dev api
1919assign(" ds_dev_secure_api" ,
20- " https://irmadevservices.nps.gov/datastore-secure/v7 /rest" ,
20+ " https://irmadevservices.nps.gov/datastore-secure/v8 /rest" ,
2121 envir = .pkgglobalenv
2222)
2323
2424# datastore dev API
2525assign(" ds_dev_public_api" ,
26- " https://irmadevservices.nps.gov/datastore/v7 /rest" ,
26+ " https://irmadevservices.nps.gov/datastore/v8 /rest" ,
2727 envir = .pkgglobalenv
2828)
2929
@@ -62,7 +62,9 @@ globalVariables(c("public_refs",
6262 " mimeType" ,
6363 " downloadLink" ,
6464 " is508Compliant" ,
65- " fileSize_kb" ))
65+ " fileSize_kb" ,
66+ " extensionAttribute2" ,
67+ " orcid" ))
6668
6769
6870# ' Get the right base URL for the DataStore API
@@ -71,6 +73,7 @@ globalVariables(c("public_refs",
7173# ' @param is_dev Retrieve the dev version of the API base URL?
7274# '
7375# ' @returns One of four base URLs for the DataStore API (public, secure, public+dev, secure+dev)
76+ # ' @keywords internal
7477# '
7578.get_base_url <- function (is_secure , is_dev ) {
7679 datastore_url <- dplyr :: case_when(
@@ -89,6 +92,7 @@ globalVariables(c("public_refs",
8992# ' @inheritParams .get_base_url
9093# '
9194# ' @returns The url to the reference profile page
95+ # ' @keywords internal
9296# '
9397.get_ref_profile_url <- function (ref_id , is_dev ) {
9498 ref_profile_url <- dplyr :: case_when(
@@ -106,6 +110,7 @@ globalVariables(c("public_refs",
106110# ' @param suppress_errors Suppress HTTP errors? Set to TRUE if using `.validate_resp()`
107111# '
108112# ' @returns A httr2 request object with curl options set to allow authentication for NPS users (if using secure API)
113+ # ' @keywords internal
109114# '
110115.datastore_request <- function (is_secure , is_dev , suppress_errors = TRUE ) {
111116 base_url <- .get_base_url(is_secure = is_secure , is_dev = is_dev )
@@ -132,6 +137,7 @@ globalVariables(c("public_refs",
132137# ' @inheritParams .get_base_url
133138# '
134139# ' @returns List of reference profiles
140+ # ' @keywords internal
135141# '
136142.get_reference_profiles <- function (reference_ids , is_secure , is_dev ) {
137143 request <- .datastore_request(is_secure = is_secure , is_dev = is_dev ) | >
@@ -169,6 +175,7 @@ globalVariables(c("public_refs",
169175# ' @param child_list_names The elements of the reference profile that should be converted to vectors
170176# '
171177# ' @returns The tidied reference profile
178+ # ' @keywords internal
172179# '
173180.lists2vectors <- function (parent_list , child_list_names ) {
174181 for (child_list in child_list_names ) {
@@ -188,6 +195,7 @@ globalVariables(c("public_refs",
188195# ' @param child_list_names The elements of the reference profile that should be converted to tibbles
189196# '
190197# ' @returns The tidied reference profile
198+ # ' @keywords internal
191199# '
192200.lists2tibbles <- function (parent_list , child_list_names ) {
193201 for (child_list in child_list_names ) {
@@ -245,6 +253,7 @@ example_ref_ids <- function(visibility = c("public", "internal", "both"), n, see
245253# ' @param multiple_ok Can ref_id be a vector of multiple IDs?
246254# ' @param arg Used to get the actual name of the argument in the calling function. See `?rlang::`topic-error-call``
247255# ' @param call The caller environment, for more helpful error messages. See `?rlang::`topic-error-call``
256+ # ' @keywords internal
248257# '
249258.validate_ref_id <- function (ref_id , multiple_ok = FALSE ,
250259 arg = rlang :: caller_arg(ref_id ),
@@ -271,6 +280,22 @@ example_ref_ids <- function(visibility = c("public", "internal", "both"), n, see
271280
272281}
273282
283+ .validate_lifecycle <- function (ref_id , expected_lifecycle = c(" Draft" , " Active" ), is_dev ,
284+ call = rlang :: caller_env()) {
285+
286+ expected_lifecycle <- match.arg(expected_lifecycle , several.ok = FALSE )
287+
288+ # Get actual lifecycle
289+ actual_lifecycle <- get_lifecycle_info(reference_id = ref_id , dev = is_dev )
290+ actual_lifecycle <- actual_lifecycle $ lifecycle
291+
292+ # Enforce is file, not folder
293+ if (actual_lifecycle != expected_lifecycle ) {
294+ cli :: cli_abort(" Lifecycle for reference {ref_id} must be set to {expected_lifecycle}. It is currently set to {actual_lifecycle}." ,
295+ call = call )
296+ }
297+ }
298+
274299.validate_file_path <- function (file_path ,
275300 arg = rlang :: caller_arg(file_path ),
276301 call = rlang :: caller_env()) {
@@ -286,6 +311,25 @@ example_ref_ids <- function(visibility = c("public", "internal", "both"), n, see
286311 }
287312}
288313
314+ # ' Validate TRUE/FALSE arguments
315+ # '
316+ # ' @param bool Value to check
317+ # ' @param arg Used to get the actual name of the argument in the calling function. See `?rlang::`topic-error-call``
318+ # ' @param call The caller environment, for more helpful error messages. See `?rlang::`topic-error-call``
319+ # ' @keywords internal
320+ # '
321+ .validate_truefalse <- function (bool ,
322+ arg = rlang :: caller_arg(bool ),
323+ call = rlang :: caller_env()) {
324+
325+ # Enforce a TRUE/FALSE value
326+ if (! is.logical(bool ) || is.na(bool )) {
327+ cli :: cli_abort(" {.arg {arg}} is invalid. Must be logical (`TRUE` or `FALSE`)." ,
328+ call = call )
329+ }
330+
331+ }
332+
289333.validate_retry <- function (retry ,
290334 arg = rlang :: caller_arg(retry ),
291335 call = rlang :: caller_env()) {
0 commit comments