Title: | A Client for the 'Consibio Cloud' API |
---|---|
Description: | Enable seamless interaction with 'Consibio Cloud' <https://consibio.cloud> 'API' <https://api.v2.consibio.com/api-docs/>. This package provides tools to query data from resources like projects, elements, devices, and datalogs. |
Authors: | Tobias Nordahl [aut, cre], Consibio ApS [cph, fnd] |
Maintainer: | Tobias Nordahl <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-10-30 05:16:24 UTC |
Source: | https://github.com/cran/consibiocloudclient |
This function retrieves the API URL from the environment variable named "CONSIBIO_API_HOST", if it is set. If the environment variable is not set, it set and returns a default URL. Optionally, it can append a path to the URL.
get_api_url(path = NULL)
get_api_url(path = NULL)
path |
A character string representing the API URL. |
A character string representing the API URL.
## Not run: get_api_url("/users/me") ## End(Not run)
## Not run: get_api_url("/users/me") ## End(Not run)
Get the datalog for multiple elements in a project from Consibio APIs.
get_datalog( element_ids_to_fetch = NULL, from_time = NULL, to_time = NULL, interval = NULL, raw = FALSE )
get_datalog( element_ids_to_fetch = NULL, from_time = NULL, to_time = NULL, interval = NULL, raw = FALSE )
element_ids_to_fetch |
The element ids to fetch ( |
from_time |
The from date ( |
to_time |
The to date ( |
interval |
The interval (optional, in seconds). |
raw |
If TRUE, return the raw JSON response. |
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__datalog
A data frame with the datalog information.
## Not run: get_datalog( element_ids_to_fetch = c("{element_id}"), from_time = as.POSIXct("2021-01-01"), to_time = as.POSIXct("2021-01-02") ) ## End(Not run)
## Not run: get_datalog( element_ids_to_fetch = c("{element_id}"), from_time = as.POSIXct("2021-01-01"), to_time = as.POSIXct("2021-01-02") ) ## End(Not run)
Get the project device in Consibio APIs.
get_device(device_id = NULL)
get_device(device_id = NULL)
device_id |
The device id. |
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__devices__device_id_
A matrix with the device information.
## Not run: get_device(device_id = "{device_id}") ## End(Not run)
## Not run: get_device(device_id = "{device_id}") ## End(Not run)
Get the project devices in Consibio APIs.
get_devices()
get_devices()
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__devices
A matrix with the devices information.
## Not run: get_devices() ## End(Not run)
## Not run: get_devices() ## End(Not run)
Get the element information from Consibio APIs.
get_element(element_id = NULL)
get_element(element_id = NULL)
element_id |
The element id. |
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__elements__entity_id_
A matrix with the element information.
## Not run: get_element(element_id = "{element_id}") ## End(Not run)
## Not run: get_element(element_id = "{element_id}") ## End(Not run)
Get the projects elements to the user from Consibio APIs.
get_elements()
get_elements()
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__elements
A matrix with the project information.
## Not run: get_elements() ## End(Not run)
## Not run: get_elements() ## End(Not run)
Get the project information from Consibio APIs.
get_project(project_id = NULL)
get_project(project_id = NULL)
project_id |
The project id (optional). |
See details in https://api.v2.consibio.com/api-docs/#/default/get_project
A matrix with the project information.
## Not run: get_project(project_id = "{project_id}") ## End(Not run)
## Not run: get_project(project_id = "{project_id}") ## End(Not run)
This function retrieves the Consibio project ID from the options. If the project ID is not set or is an empty string, an error is thrown.
get_project_id()
get_project_id()
The Consibio project ID
# Set the Consibio project ID # Alternatively, you can use the set_project_id('PROJECT_ID') function options(consibio.project_id = "PROJECT_ID") # Get the Consibio project ID get_project_id()
# Set the Consibio project ID # Alternatively, you can use the set_project_id('PROJECT_ID') function options(consibio.project_id = "PROJECT_ID") # Get the Consibio project ID get_project_id()
Get the projects accessible to the user from Consibio APIs.
get_projects()
get_projects()
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects
A matrix with the project information.
## Not run: get_projects() ## End(Not run)
## Not run: get_projects() ## End(Not run)
Get the status of requests directly at Consibio APIs. Does not require authentication.
get_test()
get_test()
See details in https://api.v2.consibio.com/api-docs/#/default/get_test
A list with the status of the API and the time of the request.
## Not run: c_get_test() ## End(Not run)
## Not run: c_get_test() ## End(Not run)
Get the user information from Consibio APIs.
get_users_me()
get_users_me()
See details in https://api.v2.consibio.com/api-docs/#/default/get_users_me
A matrix with the user information.
## Not run: get_users_me() ## End(Not run)
## Not run: get_users_me() ## End(Not run)
Is valid entity ID
is_valid_entity_id(entity_id = NULL, type = NULL)
is_valid_entity_id(entity_id = NULL, type = NULL)
entity_id |
The entity ID |
type |
The type of the entity ID. Default is 'project' (will just change the halt error message) |
TRUE if the entity ID is valid, FALSE otherwise
## Not run: is_valid_entity_id("123456", "project") ## End(Not run)
## Not run: is_valid_entity_id("123456", "project") ## End(Not run)
By using regular expressions, this function checks if a username is a valid email address.
is_valid_username(username = NULL)
is_valid_username(username = NULL)
username |
The username to be checked. |
TRUE if the username is valid, otherwise an error is thrown.
is_valid_username("[email protected]") ## Not run: is_valid_username("invalid_username") is_valid_username("") is_valid_username(NULL) ## End(Not run)
is_valid_username("[email protected]") ## Not run: is_valid_username("invalid_username") is_valid_username("") is_valid_username(NULL) ## End(Not run)
Use username to login to the Consibio API. Password will be requested interactively, now and once the token expires. It sets the default username for authenticated requests.
login(username = NULL)
login(username = NULL)
username |
A character string representing the username. |
A character string representing the logged-in username.
## Not run: login("[email protected]") ## End(Not run)
## Not run: login("[email protected]") ## End(Not run)
Logout by removing the username and cached token
logout()
logout()
TRUE
logout()
logout()
This function sets the API URL in the environment variable named "CONSIBIO_API_HOST".
set_api_url(url = NULL)
set_api_url(url = NULL)
url |
A character string representing the API URL. |
A character string representing the API URL.
## Not run: set_api_url("https://api.v2.consibio.com") ## End(Not run)
## Not run: set_api_url("https://api.v2.consibio.com") ## End(Not run)
Set the Consibio project ID option
set_project_id(project_id)
set_project_id(project_id)
project_id |
The project ID to set. |
The project ID that was set.
set_project_id("PROJECT_ID")
set_project_id("PROJECT_ID")