Title: | R Client for 'Via Foundry' API |
---|---|
Description: | 'Via Foundry' API provides streamlined tools for interacting with and extracting data from structured responses, particularly for use cases involving hierarchical data from Foundry's API. It includes functions to fetch and parse process-level and file-level metadata, allowing users to efficiently query and manipulate nested data structures. Key features include the ability to list all unique process names, retrieve file metadata for specific or all processes, and dynamically load or download files based on their type. With built-in support for handling various file formats (e.g., tabular and non-tabular files) and seamless integration with API through authentication, this package is designed to enhance workflows involving large-scale data management and analysis. Robust error handling and flexible configuration ensure reliable performance across diverse data environments. Please consult the documentation for the API endpoint for your installation. |
Authors: | Alper Kucukural [aut, cre], Via Scientific [aut, cph] |
Maintainer: | Alper Kucukural <[email protected]> |
License: | Apache License 2.0 |
Version: | 1.0.0 |
Built: | 2025-01-14 06:08:31 UTC |
Source: | https://github.com/viascientific/viafoundry-r-sdk |
Authenticates the user with the 'Via Foundry' API using their username and password. Retrieves a bearer token and saves it along with the hostname to a configuration file.
authenticate( hostname, username = NULL, password = NULL, identity_type = 1, redirect_uri = "http://localhost", config_path = DEFAULT_CONFIG_PATH, overwrite = FALSE )
authenticate( hostname, username = NULL, password = NULL, identity_type = 1, redirect_uri = "http://localhost", config_path = DEFAULT_CONFIG_PATH, overwrite = FALSE )
hostname |
The API 'hostname' (e.g., 'https://your_viafoundry'). |
username |
The login username. |
password |
The login password (optional; will prompt if not provided). |
identity_type |
The identity type (default is 1). |
redirect_uri |
The redirect 'URI' (default is 'http://your_viafoundry/redirect'). |
config_path |
Path to save the configuration file (default is '~/.viaenv'). |
overwrite |
Logical flag to overwrite the existing configuration file (default is FALSE). |
None. Saves the bearer token to the configuration file and sets the global config path.
Calculate expiration date (30 days from now)
calculate_expiration_date()
calculate_expiration_date()
The expiration date as a string.
Sends an HTTP request to a specified API endpoint using the stored bearer token for authentication.
call_endpoint(method, endpoint, params = list(), data = NULL)
call_endpoint(method, endpoint, params = list(), data = NULL)
method |
The HTTP method (e.g., "GET", "POST", "PUT", "DELETE"). |
endpoint |
The API endpoint (e.g., '/api/projects'). |
params |
A named list of query parameters (optional). |
data |
A named list or 'JSON' object to include in the request body (optional). |
A list containing the API response.
## Not run: response <- call_endpoint("GET", "/api/projects") print(response) ## End(Not run)
## Not run: response <- call_endpoint("GET", "/api/projects") print(response) ## End(Not run)
Fetches and lists all available API endpoints from the Swagger documentation.
discover()
discover()
A character vector of available endpoints.
## Not run: discover() ## End(Not run)
## Not run: discover() ## End(Not run)
Fetch the 'JSON' data for a report
fetchReportData(reportID)
fetchReportData(reportID)
reportID |
The ID of the report to fetch data for. |
The 'JSON' object containing the report data.
Sends a simple GET request to check the status of the API.
get_api_status()
get_api_status()
A character vector with the API status.
## Not run: status <- get_api_status() print(status) ## End(Not run)
## Not run: status <- get_api_status() print(status) ## End(Not run)
Get bearer token using the cookie token
get_bearer_token(hostname, cookie_token, name = "token")
get_bearer_token(hostname, cookie_token, name = "token")
hostname |
The API hostname. |
cookie_token |
The cookie token. |
name |
The name of the token (default is "token"). |
The bearer token.
Get headers for API requests
get_headers()
get_headers()
A list of headers with the bearer token.
Extract children names across all processes
getAllFileNames(json_data)
getAllFileNames(json_data)
json_data |
The 'JSON' object containing the report data. |
A data frame containing 'id', 'processName', 'name', 'extension', 'fileSize', and 'routePath'.
Get file names for a specific process
getFileNames(json_data, processName)
getFileNames(json_data, processName)
json_data |
The 'JSON' object containing the report data. |
processName |
The name of the process to filter by. |
A data frame containing 'id', 'name', 'extension', 'fileSize', and 'routePath'.
Get unique process names
getProcessNames(json_data)
getProcessNames(json_data)
json_data |
The 'JSON' object containing the report data. |
A character vector of unique process names.
Loads the configuration file or triggers authentication if the file is missing.
load_config()
load_config()
A list containing the hostname and bearer token.
Load or download a file from a process and file name
loadFile(json_data, processName, fileName, sep = "\t", download_dir = getwd())
loadFile(json_data, processName, fileName, sep = "\t", download_dir = getwd())
json_data |
The 'JSON' object containing the report data. |
processName |
The name of the process. |
fileName |
The name of the file to load or download. |
sep |
The separator for tabular files. Default is tab-separated. |
download_dir |
The directory where non-tabular files will be downloaded. |
A data frame with the file contents if the file is tabular; otherwise, NULL after downloading the file.
Login and retrieve the cookie token
login( hostname, username, password, identity_type = 1, redirect_uri = "http://localhost" )
login( hostname, username, password, identity_type = 1, redirect_uri = "http://localhost" )
hostname |
The API hostname. |
username |
The login username. |
password |
The login password. |
identity_type |
The identity type. |
redirect_uri |
The redirect URI. |
The cookie token.