Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove user argument. Use arcgisutils check_token_has_user() #144

Merged
merged 3 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 12 additions & 7 deletions R/add_item.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -61,7 +59,6 @@
add_item <- function(
x,
title,
user = Sys.getenv("ARCGIS_USER"),
description = "",
tags = character(0),
snippet = "",
Expand All @@ -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"]]

Expand Down Expand Up @@ -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()
Expand All @@ -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"]]

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

published_item <- publish_item(
item_id,
user = user,
publish_params = publish_params,
token = token
)
Expand Down
10 changes: 8 additions & 2 deletions R/create-service.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand All @@ -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"),
Expand All @@ -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"]]

Expand Down
5 changes: 2 additions & 3 deletions man/create_feature_server.Rd

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

6 changes: 0 additions & 6 deletions man/publish.Rd

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

Loading