Type: | Package |
Title: | A Client for the 'Consibio Cloud' API |
Version: | 1.0.0 |
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. |
License: | MIT + file LICENSE |
Depends: | R (≥ 3.5.0) |
Imports: | httr2 (≥ 1.0.2), magrittr, utils |
Suggests: | dotenv, httptest2, knitr, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
Language: | en-US |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2024-07-29 08:37:00 UTC; tobias |
Author: | Tobias Nordahl [aut, cre], Consibio ApS [cph, fnd] |
Maintainer: | Tobias Nordahl <tnk@consibio.com> |
Repository: | CRAN |
Date/Publication: | 2024-07-30 19:20:08 UTC |
Authenticate the request with the OAuth client
Description
Authenticate the request with the OAuth client
Usage
client_req_auth(req)
Arguments
req |
The request object to authenticate. |
Value
The authenticated request object.
Get API URL from environment variable
Description
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.
Usage
get_api_url(path = NULL)
Arguments
path |
A character string representing the API URL. |
Value
A character string representing the API URL.
Examples
## Not run:
get_api_url("/users/me")
## End(Not run)
Get datalog for elements in project
Description
Get the datalog for multiple elements in a project from Consibio APIs.
Usage
get_datalog(
element_ids_to_fetch = NULL,
from_time = NULL,
to_time = NULL,
interval = NULL,
raw = FALSE
)
Arguments
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. |
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__datalog
Value
A data frame with the datalog information.
Examples
## 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 device in project
Description
Get the project device in Consibio APIs.
Usage
get_device(device_id = NULL)
Arguments
device_id |
The device id. |
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__devices__device_id_
Value
A matrix with the device information.
Examples
## Not run:
get_device(device_id = "{device_id}")
## End(Not run)
Get devices in project
Description
Get the project devices in Consibio APIs.
Usage
get_devices()
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__devices
Value
A matrix with the devices information.
Examples
## Not run:
get_devices()
## End(Not run)
Get element information
Description
Get the element information from Consibio APIs.
Usage
get_element(element_id = NULL)
Arguments
element_id |
The element id. |
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__elements__entity_id_
Value
A matrix with the element information.
Examples
## Not run:
get_element(element_id = "{element_id}")
## End(Not run)
Get elements accessible to the user
Description
Get the projects elements to the user from Consibio APIs.
Usage
get_elements()
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects__project_id__elements
Value
A matrix with the project information.
Examples
## Not run:
get_elements()
## End(Not run)
Get project information
Description
Get the project information from Consibio APIs.
Usage
get_project(project_id = NULL)
Arguments
project_id |
The project id (optional). |
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_project
Value
A matrix with the project information.
Examples
## Not run:
get_project(project_id = "{project_id}")
## End(Not run)
Get the Consibio project ID
Description
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.
Usage
get_project_id()
Value
The Consibio project ID
Examples
# 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 projects accessible to the user
Description
Get the projects accessible to the user from Consibio APIs.
Usage
get_projects()
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_projects
Value
A matrix with the project information.
Examples
## Not run:
get_projects()
## End(Not run)
Consibio APIs status by calling the test endpoint
Description
Get the status of requests directly at Consibio APIs. Does not require authentication.
Usage
get_test()
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_test
Value
A list with the status of the API and the time of the request.
Examples
## Not run:
c_get_test()
## End(Not run)
Get the user information
Description
Get the user information from Consibio APIs.
Usage
get_users_me()
Details
See details in https://api.v2.consibio.com/api-docs/#/default/get_users_me
Value
A matrix with the user information.
Examples
## Not run:
get_users_me()
## End(Not run)
Is valid entity ID
Description
Is valid entity ID
Usage
is_valid_entity_id(entity_id = NULL, type = NULL)
Arguments
entity_id |
The entity ID |
type |
The type of the entity ID. Default is 'project' (will just change the halt error message) |
Value
TRUE if the entity ID is valid, FALSE otherwise
Examples
## Not run:
is_valid_entity_id("123456", "project")
## End(Not run)
Check if a username is valid.
Description
By using regular expressions, this function checks if a username is a valid email address.
Usage
is_valid_username(username = NULL)
Arguments
username |
The username to be checked. |
Value
TRUE if the username is valid, otherwise an error is thrown.
Examples
is_valid_username("john.doe@example.com")
## Not run:
is_valid_username("invalid_username")
is_valid_username("")
is_valid_username(NULL)
## End(Not run)
Login to Consibio API
Description
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.
Usage
login(username = NULL)
Arguments
username |
A character string representing the username. |
Value
A character string representing the logged-in username.
Examples
## Not run:
login("bob@helloworld.com")
## End(Not run)
Logout by removing the username and cached token
Description
Logout by removing the username and cached token
Usage
logout()
Value
TRUE
Examples
logout()
Set API URL in environment variable
Description
This function sets the API URL in the environment variable named "CONSIBIO_API_HOST".
Usage
set_api_url(url = NULL)
Arguments
url |
A character string representing the API URL. |
Value
A character string representing the API URL.
Examples
## Not run:
set_api_url("https://api.v2.consibio.com")
## End(Not run)
Set the Consibio project ID option
Description
Set the Consibio project ID option
Usage
set_project_id(project_id)
Arguments
project_id |
The project ID to set. |
Value
The project ID that was set.
Examples
set_project_id("PROJECT_ID")