Skip to content

Commit

Permalink
feat!: deprecate service_version argument, set version to 2.0.0 always (
Browse files Browse the repository at this point in the history
  • Loading branch information
maelle authored Feb 7, 2023
1 parent 9424494 commit 3865bea
Show file tree
Hide file tree
Showing 24 changed files with 82 additions and 46 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Imports:
curl,
httr,
janitor,
lifecycle,
magrittr,
memoise,
ows4R (>= 0.3),
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions R/EMODnetWFS-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom lifecycle deprecated
## usethis namespace: end
NULL

Expand Down
11 changes: 7 additions & 4 deletions R/client.R
Original file line number Diff line number Diff line change
Expand Up @@ -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).
#'
Expand All @@ -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)

Expand All @@ -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
)
Expand Down
10 changes: 10 additions & 0 deletions R/deprecate-service-version.R
Original file line number Diff line number Diff line change
@@ -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."
)
}
}
7 changes: 5 additions & 2 deletions R/info.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand Down
36 changes: 25 additions & 11 deletions R/layer_attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}
Expand All @@ -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)
Expand All @@ -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
}
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions R/layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions man/emodnet_get_layers.Rd

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

12 changes: 6 additions & 6 deletions man/emodnet_get_wfs_info.Rd

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

4 changes: 2 additions & 2 deletions man/emodnet_init_wfs_client.Rd

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

1 change: 1 addition & 0 deletions man/figures/lifecycle-archived.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-defunct.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-deprecated.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-experimental.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-maturing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-questioning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-stable.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions man/figures/lifecycle-superseded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions man/layer_attribute_descriptions.Rd

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

4 changes: 2 additions & 2 deletions man/layer_attribute_inspect.Rd

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

Loading

0 comments on commit 3865bea

Please sign in to comment.