| Title: | 'Lifebit' Platform 'API' Client |
|---|---|
| Description: | Interacts with the 'Lifebit' Platform Cohort Browser 'API' <https://cloudos.lifebit.ai>. Enables schema discovery, table exploration, and read-only 'SQL' query execution with policy-aware behavior and team-based access control for cohort data analysis. Requires bastion-enabled workspaces for 'API' access. |
| Authors: | Leila Mansouri [aut, cre] |
| Maintainer: | Leila Mansouri <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-06-02 08:58:33 UTC |
| Source: | https://github.com/cran/cloudosR |
Retrieves the list of available database schemas and tables for a cohort.
cloudos.cohort_tables(profilename = "", cohort_id = "")cloudos.cohort_tables(profilename = "", cohort_id = "")
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
cohort_id |
Character. ID of the cohort to query schemas for. |
List with schema information including databases, tables, and columns.
## Not run: # Get available schemas for a cohort schemas <- cloudos.cohort_tables( profilename = "production", cohort_id = "your-cohort-id" ) # Display databases cat("Available databases:\n") for (db in schemas) { cat(" -", db$database, "\n") } ## End(Not run)## Not run: # Get available schemas for a cohort schemas <- cloudos.cohort_tables( profilename = "production", cohort_id = "your-cohort-id" ) # Display databases cat("Available databases:\n") for (db in schemas) { cat(" -", db$database, "\n") } ## End(Not run)
Stores API credentials and workspace context for a named profile. This is the required first step before any API wrapper call.
cloudos.configure( profilename = "", apikey = "", workspace_id = "", base_url = "https://cloudos.lifebit.ai", set_default = FALSE )cloudos.configure( profilename = "", apikey = "", workspace_id = "", base_url = "https://cloudos.lifebit.ai", set_default = FALSE )
profilename |
Character. Name of the profile to create or update. |
apikey |
Character. API key for authentication. |
workspace_id |
Character. Workspace/team ID for API requests. |
base_url |
Character. Base URL for Lifebit Platform API (default: "https://cloudos.lifebit.ai"). |
set_default |
Logical. If TRUE, sets this profile as the default (default: FALSE). |
Invisible NULL. Prints a success message.
## Not run: cloudos.configure( profilename = "production", apikey = "your-api-key", workspace_id = "5c6d3e9bd954e800b23f8c62", set_default = TRUE ) ## End(Not run)## Not run: cloudos.configure( profilename = "production", apikey = "your-api-key", workspace_id = "5c6d3e9bd954e800b23f8c62", set_default = TRUE ) ## End(Not run)
Lists configured profiles so users can confirm available environments.
cloudos.profile_list()cloudos.profile_list()
Data frame with profile names and metadata (workspace_id, default, created_at, updated_at). Returns empty data frame if no profiles are configured.
## Not run: profiles <- cloudos.profile_list() print(profiles) ## End(Not run)## Not run: profiles <- cloudos.profile_list() print(profiles) ## End(Not run)
High-level function that orchestrates the full query lifecycle: submit -> poll status -> fetch results as dataframe.
cloudos.query( profilename = "", cohort_id = "", sql = "", poll_interval = 2, max_wait = 600, page_size = 1000, all_pages = TRUE )cloudos.query( profilename = "", cohort_id = "", sql = "", poll_interval = 2, max_wait = 600, page_size = 1000, all_pages = TRUE )
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
cohort_id |
Character. ID of the cohort to query. |
sql |
Character. SQL query to execute. |
poll_interval |
Integer. Seconds between status checks (default: 2). |
max_wait |
Integer. Maximum seconds to wait for completion (default: 600). |
page_size |
Integer. Number of rows per page (default: 1000). |
all_pages |
Logical. Fetch all result pages automatically (default: TRUE). When TRUE, submits multiple async tasks (one per page) to fetch complete results. |
IMPORTANT: Pagination works by submitting separate tasks for each page. When all_pages=TRUE, this function submits multiple async tasks (one per page), waits for all to complete, and combines the results. This may take longer for large result sets.
Data frame with query results.
## Not run: # Fetch all results results <- cloudos.query( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id, gender_concept_id FROM person LIMIT 500" ) # Fetch only first page results_page1 <- cloudos.query( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person", all_pages = FALSE, page_size = 100 ) ## End(Not run)## Not run: # Fetch all results results <- cloudos.query( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id, gender_concept_id FROM person LIMIT 500" ) # Fetch only first page results_page1 <- cloudos.query( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person", all_pages = FALSE, page_size = 100 ) ## End(Not run)
Fetches results from a completed async SQL task and returns as a dataframe.
cloudos.query_results(profilename = "", task_id = "")cloudos.query_results(profilename = "", task_id = "")
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
task_id |
Character. Task ID returned from cloudos.query_submit_async(). |
Note: Pagination is controlled when submitting the query via cloudos.query_submit_async(), not when fetching results. This function returns whatever page the task was configured for.
Data frame with query results from the page configured at submission time.
## Not run: # Fetch results for a task (returns the page configured when query was submitted) results <- cloudos.query_results( profilename = "production", task_id = "69a5c58d626fe626da0025ce" ) ## End(Not run)## Not run: # Fetch results for a task (returns the page configured when query was submitted) results <- cloudos.query_results( profilename = "production", task_id = "69a5c58d626fe626da0025ce" ) ## End(Not run)
Returns the current status and metadata for a submitted async SQL task.
cloudos.query_status(profilename = "", task_id = "")cloudos.query_status(profilename = "", task_id = "")
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
task_id |
Character. Task ID returned from cloudos.query_submit_async(). |
List with task status, count of results, and other metadata.
## Not run: status <- cloudos.query_status( profilename = "production", task_id = "69a5c58d626fe626da0025ce" ) print(status$status) print(status$count_of_results) ## End(Not run)## Not run: status <- cloudos.query_status( profilename = "production", task_id = "69a5c58d626fe626da0025ce" ) print(status$status) print(status$count_of_results) ## End(Not run)
Starts async SQL execution for a cohort and returns a task ID for tracking.
cloudos.query_submit_async( profilename = "", cohort_id = "", sql = "", pagination = NULL )cloudos.query_submit_async( profilename = "", cohort_id = "", sql = "", pagination = NULL )
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
cohort_id |
Character. ID of the cohort to query. |
sql |
Character. SQL query to execute. |
pagination |
List (optional). Pagination settings with pageNumber and pageSize. Example: list(pageNumber = 0, pageSize = 100). If NULL, API returns default page. |
List with task metadata including task_id, status, and full response.
## Not run: # Submit query without pagination task <- cloudos.query_submit_async( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person LIMIT 100" ) # Submit query with pagination for page 2 with 50 rows per page task <- cloudos.query_submit_async( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person", pagination = list(pageNumber = 2, pageSize = 50) ) print(task$task_id) ## End(Not run)## Not run: # Submit query without pagination task <- cloudos.query_submit_async( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person LIMIT 100" ) # Submit query with pagination for page 2 with 50 rows per page task <- cloudos.query_submit_async( profilename = "production", cohort_id = "699edb4380a6867895f0c9e1", sql = "SELECT person_id FROM person", pagination = list(pageNumber = 2, pageSize = 50) ) print(task$task_id) ## End(Not run)
Validates SQL syntax and references before execution.
cloudos.sql_validate(profilename = "", sql = "")cloudos.sql_validate(profilename = "", sql = "")
profilename |
Character. Name of the configured profile to use. If empty or NULL, uses the default profile. |
sql |
Character. SQL query to validate. |
List with validation results including isValid, tableReferences, and columnReferences.
## Not run: # Validate a SQL query validation <- cloudos.sql_validate( profilename = "production", sql = "SELECT person_id FROM person WHERE year_of_birth >= 1960" ) if (validation$isValid) { cat("SQL is valid\n") cat("Tables:", paste(validation$tableReferences, collapse = ", "), "\n") } else { cat("SQL is invalid:", validation$message, "\n") } ## End(Not run)## Not run: # Validate a SQL query validation <- cloudos.sql_validate( profilename = "production", sql = "SELECT person_id FROM person WHERE year_of_birth >= 1960" ) if (validation$isValid) { cat("SQL is valid\n") cat("Tables:", paste(validation$tableReferences, collapse = ", "), "\n") } else { cat("SQL is invalid:", validation$message, "\n") } ## End(Not run)
Print method for cloudos_tables
## S3 method for class 'cloudos_tables' print(x, ...)## S3 method for class 'cloudos_tables' print(x, ...)
x |
A cloudos_tables object |
... |
Additional arguments (unused) |
The cloudos_tables object x, returned invisibly.
Called primarily for its side effect of printing a formatted list of
schemas and tables to the console.