Skip to content

Commit

Permalink
remove user argument. Use arcgisutils check_token_has_user()
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Feb 9, 2024
1 parent 0edd537 commit 975653c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions R/add_item.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
add_item <- function(
x,
title,
user = Sys.getenv("ARCGIS_USER"),
description = "",
tags = character(0),
snippet = "",
Expand All @@ -75,6 +74,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"]]

Expand Down Expand Up @@ -175,7 +180,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()
Expand All @@ -184,6 +188,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"]]

Expand Down Expand Up @@ -221,7 +231,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()
) {
Expand All @@ -232,7 +241,6 @@ publish_layer <- function(
add_item(
x,
title,
user = user,
token = token,
!!!adtl_args
)
Expand All @@ -244,7 +252,6 @@ publish_layer <- function(

published_item <- publish_item(
item_id,
user = user,
publish_params = publish_params,
token = token
)
Expand Down
9 changes: 7 additions & 2 deletions R/create-service.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
#'
#' @export
#' @examples
#' if (interactive()) {
#' \donttest{
#' 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"),
Expand All @@ -57,6 +56,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"]]

Expand Down
7 changes: 3 additions & 4 deletions man/create_feature_server.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions man/publish.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 975653c

Please sign in to comment.