Package 'cumulocityr'

Title: Client for the 'Cumulocity' API
Description: Access the 'Cumulocity' API and retrieve data on devices, measurements, and events. Documentation for the API can be found at <https://www.cumulocity.com/guides/reference/rest-implementation/>.
Authors: Dmitriy Bolotov [aut, cre], Software AG [cph]
Maintainer: Dmitriy Bolotov <[email protected]>
License: GPL-3
Version: 0.1.0.9000
Built: 2024-11-04 04:49:28 UTC
Source: https://github.com/cumulocity-iot/cumulocityr

Help Index


Get the devices or for a tenant.

Description

Get the devices or for a tenant.

Usage

get_devices(num_rows = NULL, parse_json = TRUE)

Arguments

num_rows

The number of records to return.

parse_json

If TRUE, parse the JSON object into a data frame.

Details

If num_rows = NULL (default), all devices are returned.

If parse_json is TRUE, the JSON object is parsed using jsonlite::fromJSON before being returned. The data is converted to a single flattened data frame.

If parse_json is FALSE, the JSON object is returned as a JSON string.

Value

A data.frame if parse_json = TRUE, and a character string otherwise.

Author(s)

Dmitriy Bolotov

References

Cumulocity Inventory API

Examples

## Not run: 
get_devices()

## End(Not run)

Get the events for a device.

Description

Get the events for a device.

Usage

get_events(
  device_id,
  date_from,
  date_to = NULL,
  num_rows = NULL,
  parse_json = TRUE
)

Arguments

device_id

The device id.

date_from

The starting datetime.

date_to

The ending datetime.

num_rows

The number of records to return.

parse_json

If TRUE, parse the JSON object into a data frame.

Details

The datetime fields date_from and date_from are expected to be strings in the format "YYYY-MM-DDTHH:MM:SSZ".

If date_to is null, it is set to the current time.

If num_rows and both dates are specified, the lesser of the two ranges is returned.

If parse_json is TRUE, the JSON object is parsed using jsonlite::fromJSON before being returned. The data is converted to a single flattened data frame. If a page does not contain any events, it does not get added to the data frame.

If parse_json is FALSE, the JSON object is returned as a JSON string. For queries with multiple pages, a list of such objects is returned. Each element in this list contains up to 2000 records.

Value

A data.frame if parse_json = TRUE, and a character string otherwise.

Author(s)

Dmitriy Bolotov

References

Cumulocity Events API

Examples

## Not run: 
get_events(device_id, date_from = "2019-09-30T20:00:00Z")

## End(Not run)

Get the measurements for a device.

Description

Get the measurements for a device.

Usage

get_measurements(
  device_id,
  date_from,
  date_to = NULL,
  num_rows = NULL,
  parse_json = TRUE
)

Arguments

device_id

The device id.

date_from

The starting datetime.

date_to

The ending datetime.

num_rows

The number of records to return.

parse_json

If TRUE, parse the JSON object into a data frame.

Details

The datetime fields date_from and date_from are expected to be strings in the format "YYYY-MM-DDTHH:MM:SSZ".

If date_to is null, it is set to the current time.

If num_rows and both dates are specified, the lesser of the two ranges is returned.

If parse_json is TRUE, the JSON object is parsed using jsonlite::fromJSON before being returned. The data is converted to a single flattened data frame. If a page does not contain any measurements, it does not get added to the data frame.

If parse_json is FALSE, the JSON object is returned as a JSON string. For queries with multiple pages, a list of such objects is returned. Each element in this list contains up to 2000 records.

Value

A data.frame if parse_json = TRUE, and a character string otherwise.

Author(s)

Dmitriy Bolotov

References

Cumulocity Measurements API

Examples

## Not run: 
get_measurements(device_id, date_from = "2019-09-30T20:00:00Z")

## End(Not run)