Skip to contents

The server assigns ids, and a deployment references a device and an individual by id rather than by serial number or nickname. This turns a create or read result into the named vector that bridges the two: your key on the names, the API's id on the values.

Usage

build_lookup(data, key, value = "id")

Arguments

data

A tibble from a telem_create_*() or telem_read_*() call. A batch-create result is flattened to its successful records first, so the ids inside its data list-column do not have to be unpacked by hand.

key

Character. The column to use as names, such as "serial_number" for devices or "nickname" for individuals.

value

Character. The column to use as values. Defaults to "id".

Value

A named integer vector, keys on the names and ids on the values. Errors if every record in a batch failed, since there is then nothing to map and a later call would fail more obscurely.

Examples

if (FALSE) { # \dontrun{
created <- telem_create_devices(devices)
dev <- build_lookup(created, "serial_number")
dev
#> 103633 103635
#>     20     22

# That vector is how a serial becomes the device_id a deployment needs.
telem_create_deployments(tibble::tibble(
  device_id     = unname(dev[c("103633", "103635")]),
  individual_id = unname(ind[c("EF01", "EM01")]),
  start_at      = "2026-02-04T00:00:00Z"
))
} # }