diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 15a0359..24ebf08 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -24,10 +24,8 @@ jobs: config: - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - # use 4.1 to check with rtools40's older compiler - - {os: windows-latest, r: '4.1'} - - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} env: diff --git a/DESCRIPTION b/DESCRIPTION index bb9c7a6..e3f2597 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: arcgislayers Type: Package Title: An Interface to ArcGIS Data Services -Version: 0.2.0 +Version: 0.2.1 Authors@R: c( person("Josiah", "Parry", , "josiah.parry@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9910-865X")), diff --git a/NEWS.md b/NEWS.md index 7e04873..4ff9602 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# arcgislayers (development) +# arcgislayers 0.3.0 - New `query_layer_attachments()` and `download_attachments()` help you access and download attachments to a layer - `arc_raster()` now downloads the exported image to a temp file instead of creating a connection to the url returned. This fixes an issue where rasters would stop working after the url had been removed. diff --git a/R/attachments.R b/R/attachments.R index e631f97..c35eedd 100644 --- a/R/attachments.R +++ b/R/attachments.R @@ -6,10 +6,13 @@ #' #' @inheritParams arc_select #' @param definition_expression default `1 = 1`. A SQL where clause that is applied to the layer. Only those records that conform to this expression will be returned. This parameter is required if neither `object_ids` or `global_ids` have been defined. +#' @param attachments_definition_expression default `NULL`. A SQL where calsue that is applied to the attachment metadata. +#' only attachments that conform to this expression will be returned. #' @param object_ids mutually exclusive with `definition_expression` and `global_ids`. The object IDs of the features to query attachments of. #' @param global_ids mutally exclusive with `definition_expression` and `object_ids`. The global IDs of the features to query attachments of. #' @param keywords default `NULL`. A character vector of the keywords to filter on. #' @param attachment_types default `NULL`. A character vector of attachment types to filter on. +#' @param overwrite default `FALSE`. A #' @rdname attachments #' @references [ArcGIS REST API Documentation](https://developers.arcgis.com/rest/services-reference/enterprise/query-attachments-feature-service-layer/) #' @export @@ -61,8 +64,6 @@ query_layer_attachments <- function( cli::cli_abort("{.arg layer} does not support attachments.") } - b_req <- arc_base_req(x[["url"]], token = token, path = "queryAttachments") - # check that only one of definition_expression, object_ids, and global_ids is provided rlang::check_exclusive(definition_expression, object_ids, global_ids, .require = FALSE) @@ -79,18 +80,15 @@ query_layer_attachments <- function( keywords <- paste(keywords, collapse = ",") } + # create the base request + b_req <- arc_base_req(x[["url"]], token = token, path = "queryAttachments") + + # Fill the body of the request req <- httr2::req_body_form( b_req, - # TODO test these why aren't these working?!! objectIds = paste(object_ids, collapse = ","), - # TODO create a test for this globalIds = paste(global_ids, collapse = ","), attachmentTypes = attachment_types, - # TODO document common examples: - # filter based on - # - date - # - common prefix - # - numeric value definitionExpression = definition_expression, attachmentsDefinitionExpression = attachments_definition_expression, keywords = keywords, @@ -99,10 +97,12 @@ query_layer_attachments <- function( f = "json" ) + # send request resp <- httr2::req_perform(req) + # parse response res <- RcppSimdJson::fparse(httr2::resp_body_string(resp)) + # throw an error if they are there arcgisutils::detect_errors(res) - # TODO assert that attachmentGroups are present # TODO consider importing {heck} for name cleaning later unnest_attachment_groups(res$attachmentGroups) } @@ -157,6 +157,8 @@ download_attachments <- function( # df, col ~ check_character, col ~ check_numeric # ) check_data_frame(attachments) + check_bool(overwrite) + check_bool(.progress) if (is.null(attachments[["name"]])) { cli::cli_abort( diff --git a/cran-comments.md b/cran-comments.md index 27df3bd..5cb7034 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,7 +2,11 @@ 0 errors | 0 warnings | 1 note -* This is a new release. +* This is a new release with small bug fixes and 2 minor new functions. + +----- + +Previous notes: * ArcGIS is a brand name and not a software name which is why it is unquoted some places in the DESCRIPTION's. These being the `Title` field and in the `Description` where it says "ArcGIS location services." * REST is not a software but an architecture so it is not quoted. diff --git a/dev/attachments-demo.R b/dev/attachments-demo.R index a90e187..d29f9c5 100644 --- a/dev/attachments-demo.R +++ b/dev/attachments-demo.R @@ -1,6 +1,7 @@ # install the development version # install.packages("pak") # pak::pak("r-arcgis/arcgislayers") +library(pillar) # for authorizing to your portal library(arcgisutils) @@ -53,7 +54,6 @@ query_layer_attachments( attachments_definition_expression = "att_name like '%20221005%'" ) - # to download the attachments: # res <- download_attachments( # att, diff --git a/man/attachments.Rd b/man/attachments.Rd index f7ced46..5885803 100644 --- a/man/attachments.Rd +++ b/man/attachments.Rd @@ -8,6 +8,7 @@ query_layer_attachments( x, definition_expression = "1=1", + attachments_definition_expression = NULL, object_ids = NULL, global_ids = NULL, attachment_types = NULL, @@ -20,6 +21,7 @@ download_attachments( attachments, out_dir, ..., + overwrite = FALSE, .progress = TRUE, token = arc_token() ) @@ -29,6 +31,9 @@ download_attachments( \item{definition_expression}{default \code{1 = 1}. A SQL where clause that is applied to the layer. Only those records that conform to this expression will be returned. This parameter is required if neither \code{object_ids} or \code{global_ids} have been defined.} +\item{attachments_definition_expression}{default \code{NULL}. A SQL where calsue that is applied to the attachment metadata. +only attachments that conform to this expression will be returned.} + \item{object_ids}{mutually exclusive with \code{definition_expression} and \code{global_ids}. The object IDs of the features to query attachments of.} \item{global_ids}{mutally exclusive with \code{definition_expression} and \code{object_ids}. The global IDs of the features to query attachments of.} @@ -45,6 +50,8 @@ download_attachments( \item{out_dir}{the path to the folder to download the file} +\item{overwrite}{default \code{FALSE}. A} + \item{.progress}{default \code{TRUE.} Whether a progress bar should be provided.} } \value{