-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
feat: add Azure endpoints
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#' Get NIXTLA_API_KEY from options or from .Renviron | ||
#' This is a private function of 'nixtlar' | ||
#' | ||
#' @return If available, the NIXTLA_API_KEY. Otherwise it returns an error and a message asking the user to set the 'API' key. | ||
#' @export | ||
#' @keywords internal | ||
#' @examples | ||
#' \dontrun{ | ||
#' .get_api_key() | ||
#' } | ||
#' | ||
.get_client_steup <- function(){ | ||
|
||
# Get setup from .Renviron | ||
base_url <- Sys.getenv("NIXTLA_BASE_URL", unset = NA) | ||
api_key <- Sys.getenv("NIXTLA_API_KEY", unset = NA) | ||
|
||
# If not available, get it from options | ||
if(is.na(base_url)){ | ||
base_url <- getOption("NIXTLA_BASE_URL", default = NA) | ||
} | ||
if(is.na(base_url)){ | ||
base_url <- "https://api.nixtla.io/" | ||
} | ||
|
||
if(is.na(api_key)) { | ||
api_key <- getOption("NIXTLA_API_KEY", default = NA) | ||
} | ||
if(is.na(api_key)){ | ||
stop("Please set your NIXTLA_API_KEY. Use nixtla_client_setup() or set it as an environment variable in .Renviron") | ||
} | ||
|
||
setup <- list( | ||
base_url = base_url, | ||
api_key = api_key | ||
) | ||
|
||
return(setup) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#' Set base 'ULR' and 'API' key in global environment | ||
#' | ||
#' @param base_url Custom base 'URL'. If NULL, defaults to "https://api.nixtla.io/". | ||
#' @param api_key The user's 'API' key. Get yours here: https://dashboard.nixtla.io/ | ||
#' | ||
#' @return A message indicating the configuration status. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' nixtlar::nixtla_client_setup( | ||
#' base_url = "Base URL", | ||
#' api_key = "Your API key" | ||
#' ) | ||
#' } | ||
#' | ||
nixtla_client_setup <- function(base_url = NULL, api_key = NULL) { | ||
if (is.null(base_url)) { | ||
base_url <- "https://api.nixtla.io/" | ||
} else { | ||
message("Base URL has been set to: ", base_url) | ||
} | ||
options("NIXTLA_BASE_URL" = base_url) | ||
|
||
if (is.null(api_key)) { | ||
stop("API key must be provided. Get yours at https://dashboard.nixtla.io/") | ||
} else { | ||
options("NIXTLA_API_KEY" = api_key) | ||
message("API key has been set for the current session.") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
#' Set 'API' key in global environment | ||
#' | ||
#' This function will be deprecated in future versions. Please use `nixtla_client_setup` instead. | ||
#' | ||
#' @param api_key The user's 'API' key. Get yours here: https://dashboard.nixtla.io/ | ||
#' | ||
#' @return A message indicating the 'API' key has been set in the global environment. | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' nixtlar::nixtla_set_api_key("YOUR_API_KEY") | ||
#' nixtlar::nixtla_set_api_key("Your API key") | ||
#' } | ||
#' | ||
nixtla_set_api_key <- function(api_key) { | ||
options("NIXTLA_API_KEY"=api_key) | ||
message("API key has been set for the current session.") | ||
nixtla_client_setup(base_url = NULL, api_key = api_key) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.