Skip to content

Commit

Permalink
remove snowflake details (#300)
Browse files Browse the repository at this point in the history
* remove snowflake details

* update docs

* bugfix

* change example to make pkgdown work

* fix snowflake

Co-authored-by: Konrad Pagacz <[email protected]>
Co-authored-by: Junlue Zhao <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2021
1 parent e52527e commit 0b4de1f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
18 changes: 14 additions & 4 deletions R/DataConnection.R
Original file line number Diff line number Diff line change
Expand Up @@ -904,18 +904,20 @@ teradata_connection <- function(open_args = list(), close_args = list(), ping_ar
#' @param server the `Snowflake`server to connect to.
#' @param port the port to connect to the `Snowflake` instance.
#' @param driver the driver to use to connect to the `Snowflake` instance.
#' @param token_provider location of the auth token provider needed to access `Snowflake`.
#' @export
snowflake_connection_function <- function(username = askpass::askpass("Please enter your username"),
password = askpass::askpass("Please enter your password"),
role,
database,
schema,
warehouse,
server = "roche_pd.eu-central-1.snowflakecomputing.com",
server,
port = 443,
driver = "SnowflakeDSIIDriver") {
driver = "SnowflakeDSIIDriver",
token_provider) {

res <- httr::POST("https://wam.roche.com/as/token.oauth2",
res <- httr::POST(token_provider,
body = list(
client_id = "snowflake",
grant_type = "password",
Expand Down Expand Up @@ -948,7 +950,7 @@ snowflake_connection_function <- function(username = askpass::askpass("Please en
Warehouse = warehouse,
role = role,
authenticator = \"oauth\",
token = token")),
token = token)")),
error = function(cond){
stop(paste("Unable to connect to snowflake. Error message:", cond$message), call. = FALSE)
}
Expand Down Expand Up @@ -988,6 +990,14 @@ snowflake_connection <- function(open_args = list(), close_args = list(), ping_a
stopifnot(is_fully_named_list(close_args))
stopifnot(is_fully_named_list(ping_args))

if (!all(c("server", "token_provider") %in% names(open_args))) {
stop("When using a snowflake connection function
you must give the location of the snowflake server and auth token provider.
See 'help(snowflake_data)' for an example.
Please consult your internal documentation/support team for your server and token provider locations.")
}


open_fun <- callable_function("teal::snowflake_connection_function")
open_fun$set_args(open_args)

Expand Down
5 changes: 5 additions & 0 deletions R/RelationalDataConnector_constructors.R
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,9 @@ teradata_data <- function(..., connection = teradata_connection()) {
#'
#' @return An object of class \code{RelationalDataConnector}
#'
#' @details Note the server location and token_provider must be provided as arguments to
#' the snowflake_connection function, see example below.
#'
#' @examples
#' \dontrun{
#' library(magrittr)
Expand All @@ -382,6 +385,8 @@ teradata_data <- function(..., connection = teradata_connection()) {
#' ) %>% mutate_dataset("any mutations required, e.g. to convert data types"),
#' connection = snowflake_connection(
#' open_args = list(
#' server = "<<server>>",
#' token_provider = "<<url>>",
#' role = "role",
#' database = "database",
#' schema = "schema",
Expand Down
7 changes: 5 additions & 2 deletions man/snowflake_connection_function.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions man/snowflake_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b4de1f

Please sign in to comment.