| Title: | Tools for the ICES Regional DataBase and Estimation System |
|---|---|
| Description: | Tools to support the ICES Regional DataBase and Estimation System (RDBES) <https://sboxrdbesapi.ices.dk/rdbescatalogue/> to access, analyse, and process fisheries data collected under the EU Data Collection Framework. |
| Authors: | Ezaj Muhammad [aut], Colin Millar [aut, cre] |
| Maintainer: | Colin Millar <[email protected]> |
| License: | file LICENSE |
| Version: | 0.0.8 |
| Built: | 2026-06-03 13:16:36 UTC |
| Source: | https://github.com/ices-tools-prod/icesRDBES |
Tools to support the ICES Regional DataBase and Estimation System (RDBES), to access, analyse, and process fisheries data collected under the EU Data Collection Framework.
Ejaz Muhammad and Colin Millar.
ICES Regional DataBase and Estimation System: https://sboxshiny.ices.dk/rdbescatalogue/.
Useful links:
Decodes the token to allow inspection of claims
decode_token(token = rdbes_token())decode_token(token = rdbes_token())
token |
a javascript web token got by running 'rdbes_token()' |
list of claims
## Not run: decode_token() ## End(Not run)## Not run: decode_token() ## End(Not run)
This function returns the API URL based on whether the package is in development or production mode.
rdbes_api(production = getOption("rdbes.production"), type = c("upload", "download"))rdbes_api(production = getOption("rdbes.production"), type = c("upload", "download"))
production |
Logical. If TRUE, returns the production API URL. If FALSE, returns the development API URL. |
type |
Character. The type of API URL to return, either "upload" or "download". Defaults to "upload". |
A character string representing the API URL.
This function authenticates with Azure, creates an export job, polls for completion, and downloads the resulting ZIP file to the current working directory.
rdbes_download_data(payload, dest_dir = ".", production = getOption("rdbes.production"), verbose = FALSE)rdbes_download_data(payload, dest_dir = ".", production = getOption("rdbes.production"), verbose = FALSE)
payload |
List. The filter configuration including hierarchies, format, and filters. |
dest_dir |
Character. Optional. Directory to save the downloaded file. Defaults to the current working directory. |
production |
Logical. Optional. Whether to use the production API endpoint. Defaults to getOption("rdbes.production"). |
verbose |
Logical. Optional. Whether to print verbose HTTP request/response details. Defaults to FALSE. |
The payload should be a nested list. Example:
list(hierarchies = list("H1"), format = "SingleCsvFile", csFilters = list(...))
Character. The path to the downloaded ZIP file.
## Not run: my_filters <- list( dataType = "SL", format = "SingleCsvFile", hierarchies = list("HSL"), slFilters = list( slCountry = list("ZW"), slYear = list("2024") ) ) rdbes_download_data(my_filters) ## End(Not run)## Not run: my_filters <- list( dataType = "SL", format = "SingleCsvFile", hierarchies = list("HSL"), slFilters = list( slCountry = list("ZW"), slYear = list("2024") ) ) rdbes_download_data(my_filters) ## End(Not run)
This function authenticates with Azure using the tenant ID, client app ID, and resource specified in the package options to get an access token.
rdbes_token(invisible = TRUE, quiet = TRUE)rdbes_token(invisible = TRUE, quiet = TRUE)
invisible |
Logical. If TRUE (default), the token is returned invisibly to avoid printing it in the console. |
quiet |
Logical. If TRUE (default), suppresses the token inventory check messages. |
Character. The access token string.
## Not run: token <- rdbes_token() # Inspect claims (out of curiosity) decode_token(token) ## End(Not run)## Not run: token <- rdbes_token() # Inspect claims (out of curiosity) decode_token(token) ## End(Not run)
This function authenticates with Azure, uploads a file, starts a screening job, polls for completion, and downloads the resulting reordered file if available.
rdbes_upload_data(file_path, hierarchy, production = getOption("rdbes.production"), verbose = FALSE)rdbes_upload_data(file_path, hierarchy, production = getOption("rdbes.production"), verbose = FALSE)
file_path |
Character. The path to the file to upload. |
hierarchy |
Character. The hierarchy type for the upload. |
production |
Logical. Optional. Whether to use the production API endpoint. Defaults to getOption("rdbes.production"). |
verbose |
Logical. Optional. Whether to print verbose HTTP request/response details. Defaults to FALSE. |
Character. The path to the downloaded ZIP file.
## Not run: filename <- system.file("test_files/importtest_HNI.csv", package = "icesRDBES") result <- rdbes_upload_data(file_path = filename, hierarchy = "HNI") ## End(Not run)## Not run: filename <- system.file("test_files/importtest_HNI.csv", package = "icesRDBES") result <- rdbes_upload_data(file_path = filename, hierarchy = "HNI") ## End(Not run)
Type filters for different RDBES data types to facilitate data downloads.
type_filterstype_filters
A list containing type filters for different RDBES data types:
hierarchies |
hierarchy |
filters |
list of filters |
Each data type (e.g., Commercial Sampling, Commercial Landing) has its own set of filters that can be applied when requesting data from the RDBES API. These filters are pre-configured for the year 2024 and the country code "ZW" (Zimbabwe) as an example. Users can modify these filters as needed before making their API requests.
type_filters[["CS"]]type_filters[["CS"]]
This function allows users to switch between development and production modes for the icesRDBES package. In development mode, the package will use the sboxrdbes API endpoint (sandbox environment) for testing and development purposes, while in production mode, it will use the production API endpoint.
use_sboxrdbes(flag = TRUE)use_sboxrdbes(flag = TRUE)
flag |
Logical. If TRUE, sets the package to sandbox mode. If FALSE, sets it to production mode. Default is TRUE. |
When in sandbox mode, the package will use the API endpoint specified in the 'rdbes.api_sandbox_url' option. When in production mode, it will use the endpoint specified in the 'rdbes.api_prod_url' option. This allows for easy switching between testing and live environments without needing to change code.
## Not run: # Set to sandbox mode use_sboxrdbes(TRUE) rdbes_api() # Should return the sandbox API URL # Set to production mode use_sboxrdbes(FALSE) rdbes_api() # Should return the production API URL ## End(Not run)## Not run: # Set to sandbox mode use_sboxrdbes(TRUE) rdbes_api() # Should return the sandbox API URL # Set to production mode use_sboxrdbes(FALSE) rdbes_api() # Should return the production API URL ## End(Not run)