From 3865beaf7e4026ec537e7c12c118948e464ad9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 7 Feb 2023 15:56:13 +0100 Subject: [PATCH] feat!: deprecate service_version argument, set version to 2.0.0 always (#132) --- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/EMODnetWFS-package.R | 1 + R/client.R | 11 +++++--- R/deprecate-service-version.R | 10 +++++++ R/info.R | 7 +++-- R/layer_attributes.R | 36 ++++++++++++++++++-------- R/layers.R | 6 ++--- man/emodnet_get_layers.Rd | 4 +-- man/emodnet_get_wfs_info.Rd | 12 ++++----- man/emodnet_init_wfs_client.Rd | 4 +-- man/figures/lifecycle-archived.svg | 1 + man/figures/lifecycle-defunct.svg | 1 + man/figures/lifecycle-deprecated.svg | 1 + man/figures/lifecycle-experimental.svg | 1 + man/figures/lifecycle-maturing.svg | 1 + man/figures/lifecycle-questioning.svg | 1 + man/figures/lifecycle-stable.svg | 1 + man/figures/lifecycle-superseded.svg | 1 + man/layer_attribute_descriptions.Rd | 4 +-- man/layer_attribute_inspect.Rd | 4 +-- man/layer_attributes_get_names.Rd | 4 +-- man/layer_attributes_summarise.Rd | 4 +-- man/layer_attributes_tbl.Rd | 9 ++----- 24 files changed, 82 insertions(+), 46 deletions(-) create mode 100644 R/deprecate-service-version.R create mode 100644 man/figures/lifecycle-archived.svg create mode 100644 man/figures/lifecycle-defunct.svg create mode 100644 man/figures/lifecycle-deprecated.svg create mode 100644 man/figures/lifecycle-experimental.svg create mode 100644 man/figures/lifecycle-maturing.svg create mode 100644 man/figures/lifecycle-questioning.svg create mode 100644 man/figures/lifecycle-stable.svg create mode 100644 man/figures/lifecycle-superseded.svg diff --git a/DESCRIPTION b/DESCRIPTION index 98c21e6..f1b0dde 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,7 @@ Imports: curl, httr, janitor, + lifecycle, magrittr, memoise, ows4R (>= 0.3), @@ -56,6 +57,6 @@ Encoding: UTF-8 LazyData: true VignetteBuilder: knitr Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.3 SystemRequirements: C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0) diff --git a/NAMESPACE b/NAMESPACE index d8603a9..595bf2d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ export(layer_attribute_inspect) export(layer_attributes_get_names) export(layer_attributes_summarise) export(layer_attributes_tbl) +importFrom(lifecycle,deprecated) importFrom(magrittr,"%>%") importFrom(memoise,memoise) importFrom(rlang,.data) diff --git a/R/EMODnetWFS-package.R b/R/EMODnetWFS-package.R index 21f41ea..8b30c30 100644 --- a/R/EMODnetWFS-package.R +++ b/R/EMODnetWFS-package.R @@ -3,6 +3,7 @@ "_PACKAGE" ## usethis namespace: start +#' @importFrom lifecycle deprecated ## usethis namespace: end NULL diff --git a/R/client.R b/R/client.R index 6b01a77..db80f1d 100644 --- a/R/client.R +++ b/R/client.R @@ -2,7 +2,7 @@ #' #' @param service the EMODnet OGC WFS service name. #' For available services, see [`emodnet_wfs()`]. -#' @param service_version the WFS service version. Defaults to "2.0.0". +#' @param service_version `r lifecycle::badge('deprecated')` the WFS service version. Now always "2.0.0". #' @param logger the logger. Either `NULL` (no logging info), `"INFO"` (log about ows4R requests) #' or `"DEBUG"` (including curl details). #' @@ -14,8 +14,11 @@ #' \dontrun{ #' wfs <- emodnet_init_wfs_client(service = "bathymetry") #' } -emodnet_init_wfs_client <- function(service, service_version = "2.0.0", logger = NULL) { - check_service_name(service) +emodnet_init_wfs_client <- function(service, service_version = NULL, logger = NULL) { + + deprecate_message_service_version(service_version, "deprecate_message_service_version") + + check_service_name(service) service_url <- get_service_url(service) @@ -24,7 +27,7 @@ emodnet_init_wfs_client <- function(service, service_version = "2.0.0", logger = wfs <- suppressWarnings( ows4R::WFSClient$new( service_url, - serviceVersion = service_version, + serviceVersion = "2.0.0", headers = c("User-Agent" = emodnetwfs_user_agent()), logger = logger ) diff --git a/R/deprecate-service-version.R b/R/deprecate-service-version.R new file mode 100644 index 0000000..fc735ed --- /dev/null +++ b/R/deprecate-service-version.R @@ -0,0 +1,10 @@ +deprecate_message_service_version <- function(service_version, function_name) { + if (!is.null(service_version)) { + lifecycle::deprecate_soft( + sprintf("%s(service_version)", function_name), + when = "2.0.1", + details = "All calls are made with service version 2.0.0. + For more control, consider using {ows4r} directly." + ) + } +} diff --git a/R/info.R b/R/info.R index 87fb022..9f19b28 100644 --- a/R/info.R +++ b/R/info.R @@ -36,7 +36,10 @@ #' @export emodnet_get_layer_info <- memoise::memoise(.emodnet_get_layer_info) -.emodnet_get_wfs_info <- function(wfs = NULL, service = NULL, service_version = "2.0.0") { +.emodnet_get_wfs_info <- function(wfs = NULL, service = NULL, service_version = NULL) { + + deprecate_message_service_version(service_version, "emodnet_get_wfs_info") + if (is.null(wfs) && is.null(service)) { cli::cli_abort( c( @@ -46,7 +49,7 @@ emodnet_get_layer_info <- memoise::memoise(.emodnet_get_layer_info) ) } - wfs <- wfs %||% emodnet_init_wfs_client(service, service_version) + wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) capabilities <- wfs$getCapabilities() diff --git a/R/layer_attributes.R b/R/layer_attributes.R index c04cc0b..81dd07d 100644 --- a/R/layer_attributes.R +++ b/R/layer_attributes.R @@ -14,13 +14,15 @@ #' } layer_attributes_summarise <- function(wfs = NULL, service = NULL, - service_version = "2.0.0", layer) { + service_version = NULL, + layer) { + + deprecate_message_service_version(service_version, "layer_attributes_summarise") summary( layer_attributes_tbl( wfs = wfs, service = service, - service_version = service_version, - layer + layer = layer ) ) } @@ -40,8 +42,11 @@ layer_attributes_summarise <- function(wfs = NULL, #' } layer_attribute_descriptions <- function(wfs = NULL, service = NULL, - service_version = "2.0.0", layer) { - wfs <- wfs %||% emodnet_init_wfs_client(service, service_version) + service_version = NULL, layer) { + + deprecate_message_service_version(service_version, "layer_attribute_descriptions") + + wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) get_layer_metadata(layer, wfs)$getDescription(pretty = TRUE) @@ -63,11 +68,14 @@ layer_attribute_descriptions <- function(wfs = NULL, #' } layer_attributes_get_names <- function(wfs = NULL, service = NULL, - service_version = "2.0.0", layer) { + service_version = NULL, + layer) { + + deprecate_message_service_version(service_version, "layer_attributes_get_names") + layer_attribute_descriptions( wfs = wfs, service = service, - service_version = service_version, layer = layer )$name } @@ -92,9 +100,12 @@ layer_attributes_get_names <- function(wfs = NULL, #' } layer_attribute_inspect <- function(wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layer, attribute) { - wfs <- wfs %||% emodnet_init_wfs_client(service, service_version) + + deprecate_message_service_version(service_version, "layer_attribute_inspect") + + wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) layer <- match.arg(layer, @@ -147,8 +158,11 @@ layer_attribute_inspect <- function(wfs = NULL, #' } layer_attributes_tbl <- function(wfs = NULL, service = NULL, - service_version = "2.0.0", layer) { - wfs <- wfs %||% emodnet_init_wfs_client(service, service_version) + service_version = NULL, layer) { + + deprecate_message_service_version(service_version, "layer_attributes_tbl") + + wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) layer <- match.arg(layer, diff --git a/R/layers.R b/R/layers.R index d4d962e..f74cbab 100644 --- a/R/layers.R +++ b/R/layers.R @@ -66,11 +66,11 @@ #' reduce_layers = TRUE #' ) #' } -emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = "2.0.0", +emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = NULL, layers, crs = NULL, cql_filter = NULL, reduce_layers = FALSE, suppress_warnings = FALSE, ...) { - + deprecate_message_service_version(service_version, "emodnet_get_layers") # check wfs ---------------------------------------------------------------- if (is.null(wfs) && is.null(service)) { @@ -82,7 +82,7 @@ emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = "2. ) } - wfs <- wfs %||% emodnet_init_wfs_client(service, service_version) + wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) diff --git a/man/emodnet_get_layers.Rd b/man/emodnet_get_layers.Rd index 037ceb7..b08fb3c 100644 --- a/man/emodnet_get_layers.Rd +++ b/man/emodnet_get_layers.Rd @@ -7,7 +7,7 @@ emodnet_get_layers( wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layers, crs = NULL, cql_filter = NULL, @@ -22,7 +22,7 @@ emodnet_get_layers( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layers}{a character vector of layer names. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} diff --git a/man/emodnet_get_wfs_info.Rd b/man/emodnet_get_wfs_info.Rd index de0e9d1..f9a7eeb 100644 --- a/man/emodnet_get_wfs_info.Rd +++ b/man/emodnet_get_wfs_info.Rd @@ -8,7 +8,7 @@ \usage{ emodnet_get_layer_info(wfs, layers) -emodnet_get_wfs_info(wfs = NULL, service = NULL, service_version = "2.0.0") +emodnet_get_wfs_info(wfs = NULL, service = NULL, service_version = NULL) emodnet_get_all_wfs_info() } @@ -21,7 +21,7 @@ emodnet_get_all_wfs_info() \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} } \value{ a tibble containing metadata on each layer available from the service. @@ -36,15 +36,15 @@ To clear the cache, re-start R or run \code{memoise::forget(emodnet_get_wfs_info } \section{Functions}{ \itemize{ -\item \code{emodnet_get_layer_info}: Get metadata for specific layers. Requires a +\item \code{emodnet_get_layer_info()}: Get metadata for specific layers. Requires a \code{wfs} object as input. -\item \code{emodnet_get_wfs_info}: Get info on all layers from am EMODnet WFS service. +\item \code{emodnet_get_wfs_info()}: Get info on all layers from am EMODnet WFS service. -\item \code{emodnet_get_all_wfs_info}: Get metadata on all layers and all available +\item \code{emodnet_get_all_wfs_info()}: Get metadata on all layers and all available services from server. -}} +}} \examples{ \dontrun{ emodnet_get_wfs_info(service = "bathymetry") diff --git a/man/emodnet_init_wfs_client.Rd b/man/emodnet_init_wfs_client.Rd index 8b093bd..8d03ef3 100644 --- a/man/emodnet_init_wfs_client.Rd +++ b/man/emodnet_init_wfs_client.Rd @@ -4,13 +4,13 @@ \alias{emodnet_init_wfs_client} \title{Initialise an EMODnet WFS client} \usage{ -emodnet_init_wfs_client(service, service_version = "2.0.0", logger = NULL) +emodnet_init_wfs_client(service, service_version = NULL, logger = NULL) } \arguments{ \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{logger}{the logger. Either \code{NULL} (no logging info), \code{"INFO"} (log about ows4R requests) or \code{"DEBUG"} (including curl details).} diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 0000000..48f72a6 --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1 @@ + lifecyclelifecyclearchivedarchived \ No newline at end of file diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 0000000..01452e5 --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1 @@ +lifecyclelifecycledefunctdefunct \ No newline at end of file diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 0000000..4baaee0 --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1 @@ +lifecyclelifecycledeprecateddeprecated \ No newline at end of file diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg new file mode 100644 index 0000000..d1d060e --- /dev/null +++ b/man/figures/lifecycle-experimental.svg @@ -0,0 +1 @@ +lifecyclelifecycleexperimentalexperimental \ No newline at end of file diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 0000000..df71310 --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1 @@ +lifecyclelifecyclematuringmaturing \ No newline at end of file diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 0000000..08ee0c9 --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1 @@ +lifecyclelifecyclequestioningquestioning \ No newline at end of file diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 0000000..e015dc8 --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1 @@ +lifecyclelifecyclestablestable \ No newline at end of file diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 0000000..75f24f5 --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1 @@ + lifecyclelifecyclesupersededsuperseded \ No newline at end of file diff --git a/man/layer_attribute_descriptions.Rd b/man/layer_attribute_descriptions.Rd index caeefec..a5b1ac7 100644 --- a/man/layer_attribute_descriptions.Rd +++ b/man/layer_attribute_descriptions.Rd @@ -7,7 +7,7 @@ layer_attribute_descriptions( wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layer ) } @@ -17,7 +17,7 @@ layer_attribute_descriptions( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} diff --git a/man/layer_attribute_inspect.Rd b/man/layer_attribute_inspect.Rd index cfb06ae..38e1d81 100644 --- a/man/layer_attribute_inspect.Rd +++ b/man/layer_attribute_inspect.Rd @@ -7,7 +7,7 @@ layer_attribute_inspect( wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layer, attribute ) @@ -18,7 +18,7 @@ layer_attribute_inspect( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} diff --git a/man/layer_attributes_get_names.Rd b/man/layer_attributes_get_names.Rd index dedc27e..14ba1f9 100644 --- a/man/layer_attributes_get_names.Rd +++ b/man/layer_attributes_get_names.Rd @@ -7,7 +7,7 @@ layer_attributes_get_names( wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layer ) } @@ -17,7 +17,7 @@ layer_attributes_get_names( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} diff --git a/man/layer_attributes_summarise.Rd b/man/layer_attributes_summarise.Rd index 060a3b1..40ca5a6 100644 --- a/man/layer_attributes_summarise.Rd +++ b/man/layer_attributes_summarise.Rd @@ -7,7 +7,7 @@ layer_attributes_summarise( wfs = NULL, service = NULL, - service_version = "2.0.0", + service_version = NULL, layer ) } @@ -17,7 +17,7 @@ layer_attributes_summarise( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} diff --git a/man/layer_attributes_tbl.Rd b/man/layer_attributes_tbl.Rd index 73e069b..7ca61f9 100644 --- a/man/layer_attributes_tbl.Rd +++ b/man/layer_attributes_tbl.Rd @@ -4,12 +4,7 @@ \alias{layer_attributes_tbl} \title{Get layer attribute values tibble} \usage{ -layer_attributes_tbl( - wfs = NULL, - service = NULL, - service_version = "2.0.0", - layer -) +layer_attributes_tbl(wfs = NULL, service = NULL, service_version = NULL, layer) } \arguments{ \item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} @@ -17,7 +12,7 @@ layer_attributes_tbl( \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{the WFS service version. Defaults to "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.}