Package 'icesRDBES'

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

Help Index


Tools for the ICES Regional DataBase and Estimation System

Description

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.

Author(s)

Ejaz Muhammad and Colin Millar.

References

ICES Regional DataBase and Estimation System: https://sboxshiny.ices.dk/rdbescatalogue/.

See Also

Useful links:


Decode token

Description

Decodes the token to allow inspection of claims

Usage

decode_token(token = rdbes_token())

Arguments

token

a javascript web token got by running 'rdbes_token()'

Value

list of claims

Examples

## Not run: 
decode_token()

## End(Not run)

Get the current API URL based on the environment

Description

This function returns the API URL based on whether the package is in development or production mode.

Usage

rdbes_api(production = getOption("rdbes.production"), type = c("upload",
  "download"))

Arguments

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".

Value

A character string representing the API URL.


Download RDBES Data

Description

This function authenticates with Azure, creates an export job, polls for completion, and downloads the resulting ZIP file to the current working directory.

Usage

rdbes_download_data(payload, dest_dir = ".",
  production = getOption("rdbes.production"), verbose = FALSE)

Arguments

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.

Details

The payload should be a nested list. Example: list(hierarchies = list("H1"), format = "SingleCsvFile", csFilters = list(...))

Value

Character. The path to the downloaded ZIP file.

Examples

## 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)

Get a Token to Download RDBES Data

Description

This function authenticates with Azure using the tenant ID, client app ID, and resource specified in the package options to get an access token.

Usage

rdbes_token(invisible = TRUE, quiet = TRUE)

Arguments

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.

Value

Character. The access token string.

Examples

## Not run: 
  token <- rdbes_token()
  # Inspect claims (out of curiosity)
  decode_token(token)

## End(Not run)

Upload RDBES Data

Description

This function authenticates with Azure, uploads a file, starts a screening job, polls for completion, and downloads the resulting reordered file if available.

Usage

rdbes_upload_data(file_path, hierarchy,
  production = getOption("rdbes.production"), verbose = FALSE)

Arguments

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.

Value

Character. The path to the downloaded ZIP file.

Examples

## 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 RDBES Data downloads

Description

Type filters for different RDBES data types to facilitate data downloads.

Usage

type_filters

Format

A list containing type filters for different RDBES data types:

hierarchies hierarchy
filters list of filters

Details

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.

Examples

type_filters[["CS"]]

Set development mode for icesRDBES

Description

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.

Usage

use_sboxrdbes(flag = TRUE)

Arguments

flag

Logical. If TRUE, sets the package to sandbox mode. If FALSE, sets it to production mode. Default is TRUE.

Details

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.

Examples

## 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)