|
| 1 | +#' List Schemas (Unity Catalog) |
| 2 | +#' |
| 3 | +#' @param catalog Parent catalog for schemas of interest. |
| 4 | +#' @param max_results Maximum number of schemas to return (default: 1000). |
| 5 | +#' @inheritParams auth_params |
| 6 | +#' @inheritParams db_sql_query_history |
| 7 | +#' @inheritParams db_sql_warehouse_create |
| 8 | +#' |
| 9 | +#' @family Unity Catalog Management |
| 10 | +#' |
| 11 | +#' @returns List |
| 12 | +#' @export |
| 13 | +db_uc_schemas_list <- function(catalog, |
| 14 | + max_results = 1000, |
| 15 | + page_token = NULL, |
| 16 | + host = db_host(), token = db_token(), |
| 17 | + perform_request = TRUE) { |
| 18 | + |
| 19 | + stopifnot(max_results <= 1000) |
| 20 | + |
| 21 | + body <- list( |
| 22 | + max_results = max_results, |
| 23 | + page_token = page_token |
| 24 | + ) |
| 25 | + |
| 26 | + req <- db_request( |
| 27 | + endpoint = "unity-catalog/schemas", |
| 28 | + method = "GET", |
| 29 | + version = "2.1", |
| 30 | + host = host, |
| 31 | + token = token, |
| 32 | + body = body |
| 33 | + ) |> |
| 34 | + httr2::req_url_query(catalog_name = catalog) |
| 35 | + |
| 36 | + if (perform_request) { |
| 37 | + db_perform_request(req)$schemas |
| 38 | + } else { |
| 39 | + req |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +#' Get Schema (Unity Catalog) |
| 45 | +#' |
| 46 | +#' @param catalog Parent catalog for schema of interest. |
| 47 | +#' @param schema Schema of interest. |
| 48 | +#' @inheritParams auth_params |
| 49 | +#' @inheritParams db_sql_query_history |
| 50 | +#' @inheritParams db_uc_catalogs_list |
| 51 | +#' |
| 52 | +#' @family Unity Catalog Management |
| 53 | +#' |
| 54 | +#' @returns List |
| 55 | +#' @export |
| 56 | +db_uc_schemas_get <- function(catalog, schema, |
| 57 | + include_browse = TRUE, |
| 58 | + host = db_host(), token = db_token(), |
| 59 | + perform_request = TRUE) { |
| 60 | + |
| 61 | + body <- list( |
| 62 | + include_browse = include_browse |
| 63 | + ) |
| 64 | + |
| 65 | + req <- db_request( |
| 66 | + endpoint = "unity-catalog/schemas/", |
| 67 | + method = "GET", |
| 68 | + version = "2.1", |
| 69 | + host = host, |
| 70 | + token = token, |
| 71 | + body = body |
| 72 | + ) |> |
| 73 | + httr2::req_url_path_append(paste(catalog, schema, sep = ".")) |
| 74 | + |
| 75 | + if (perform_request) { |
| 76 | + db_perform_request(req) |
| 77 | + } else { |
| 78 | + req |
| 79 | + } |
| 80 | +} |
| 81 | + |
0 commit comments