diff --git a/NEWS.md b/NEWS.md index 7a65001..b5752bb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,7 @@ - **Breaking**: - `token` arguments are required to be a valid `httr2_token` object (strings are not supported). - all `host` arguments are removed. Instead, the host is fetched from the `token`. + - all `user` arguments are removed. Instead, the username is fetched from the `token`. If it is not found, an error is thrown. - Add support for `GroupLayer`s - Add `arc_read()` with support for `name_repair` argument using `{vctrs}` (#108) - Add `get_layer_estimates()` to retrieve estimate info such as the number of features and the extent of the layer diff --git a/R/add_item.R b/R/add_item.R index 5c39715..269edb5 100644 --- a/R/add_item.R +++ b/R/add_item.R @@ -32,8 +32,6 @@ #' `add_item()`. #' #' @inheritParams arcgisutils::as_layer -#' @param user default environment variable `Sys.getenv("ARCGIS_USER")`. -#' The username to publish the item under. #' @param description a length 1 character vector containing the description of #' the item that is being added. Note that the value cannot be larger than 64kb. #' @param tags a character vector of tags to add to the item. @@ -61,7 +59,6 @@ add_item <- function( x, title, - user = Sys.getenv("ARCGIS_USER"), description = "", tags = character(0), snippet = "", @@ -75,6 +72,12 @@ add_item <- function( # validate the token obj_check_token(token) + # check that there is a user associated with the token + check_token_has_user(token) + + # extract username + user <- token[["username"]] + # fetch the host from the token host <- token[["arcgis_host"]] @@ -175,7 +178,6 @@ add_item <- function( #' @rdname publish publish_item <- function( item_id, - user = Sys.getenv("ARCGIS_USER"), publish_params = .publish_params(), file_type = "featureCollection", token = arc_token() @@ -184,6 +186,12 @@ publish_item <- function( # validate the token obj_check_token(token) + # check that there is a user associated with the token + check_token_has_user(token) + + # extract username + user <- token[["username"]] + # fetch the host host <- token[["arcgis_host"]] @@ -221,7 +229,6 @@ publish_layer <- function( x, title, ..., - user = Sys.getenv("ARCGIS_USER"), publish_params = .publish_params(title, target_crs = sf::st_crs(x)), token = arc_token() ) { @@ -232,7 +239,6 @@ publish_layer <- function( add_item( x, title, - user = user, token = token, !!!adtl_args ) @@ -244,7 +250,6 @@ publish_layer <- function( published_item <- publish_item( item_id, - user = user, publish_params = publish_params, token = token ) diff --git a/R/create-service.R b/R/create-service.R index 76e3473..6a3d827 100644 --- a/R/create-service.R +++ b/R/create-service.R @@ -3,7 +3,6 @@ #' Creates an empty FeatureServer with no additional layers. #' #' @param service_name Feature Service name. -#' @param user default `Sys.getenv("ARCGIS_USER")`. Your account's username. #' @param description default blank. The description of the feature server. #' @param crs default `3857`. A coordinate reference system to set for the feature server. #' Must be compatible with `sf::st_crs()`. @@ -30,13 +29,14 @@ #' #' @export #' @examples +#' \donttest{ #' if (interactive()) { #' set_arc_token(auth_code()) #' create_feature_server("My empty feature server") #' } +#' } create_feature_server <- function( service_name, - user = Sys.getenv("ARCGIS_USER"), description = "", crs = 3857, capabilities = c("create", "delete", "query", "update", "editing"), @@ -57,6 +57,12 @@ create_feature_server <- function( # validate the token obj_check_token(token) + # check that there is a user associated with the token + check_token_has_user(token) + + # extract username + user <- token[["username"]] + # fetch the host host <- token[["arcgis_host"]] diff --git a/man/create_feature_server.Rd b/man/create_feature_server.Rd index 17f1ba8..4fa5569 100644 --- a/man/create_feature_server.Rd +++ b/man/create_feature_server.Rd @@ -7,7 +7,6 @@ \usage{ create_feature_server( service_name, - user = Sys.getenv("ARCGIS_USER"), description = "", crs = 3857, capabilities = c("create", "delete", "query", "update", "editing"), @@ -26,8 +25,6 @@ xss_defaults() \arguments{ \item{service_name}{Feature Service name.} -\item{user}{default \code{Sys.getenv("ARCGIS_USER")}. Your account's username.} - \item{description}{default blank. The description of the feature server.} \item{crs}{default \code{3857}. A coordinate reference system to set for the feature server. @@ -65,8 +62,10 @@ Creates an empty FeatureServer with no additional layers. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \examples{ +\donttest{ if (interactive()) { set_arc_token(auth_code()) create_feature_server("My empty feature server") } } +} diff --git a/man/publish.Rd b/man/publish.Rd index 79f1158..c5fe79e 100644 --- a/man/publish.Rd +++ b/man/publish.Rd @@ -10,7 +10,6 @@ add_item( x, title, - user = Sys.getenv("ARCGIS_USER"), description = "", tags = character(0), snippet = "", @@ -22,7 +21,6 @@ add_item( publish_item( item_id, - user = Sys.getenv("ARCGIS_USER"), publish_params = .publish_params(), file_type = "featureCollection", token = arc_token() @@ -32,7 +30,6 @@ publish_layer( x, title, ..., - user = Sys.getenv("ARCGIS_USER"), publish_params = .publish_params(title, target_crs = sf::st_crs(x)), token = arc_token() ) @@ -52,9 +49,6 @@ any other subclass of \code{data.frame}.} \item{title}{A user-friendly string title for the layer that can be used in a table of contents.} -\item{user}{default environment variable \code{Sys.getenv("ARCGIS_USER")}. -The username to publish the item under.} - \item{description}{a length 1 character vector containing the description of the item that is being added. Note that the value cannot be larger than 64kb.}