From dc343ab2da51a9af1b5d377f2d95d21f25593bdc Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Fri, 16 Jun 2023 15:28:16 +0530 Subject: [PATCH 1/4] Create connectHost.R --- R/connectHost.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 R/connectHost.R diff --git a/R/connectHost.R b/R/connectHost.R new file mode 100644 index 0000000..379d1b9 --- /dev/null +++ b/R/connectHost.R @@ -0,0 +1,22 @@ +##' Creates a server object containing the base URL of the PEcAn API server, +##' the username & password, which can be simply passed into other functions +##' to make requests to the PEcAn API. +##' Currently, there is no validation. In future, we may validate the username-password +##' pair by hitting the appropriate API endpoint +##' +##' @name connect +##' @title Creates a server object that can be passed into other functions for making requests to the PEcAn API +##' @param url Base URL of the PEcAn API Server +##' @param username Username +##' @param password Password corresponding to the username +##' @return A server object that can be passed into other functions for making requests to the PEcAn API +##' @export +##' @examples +##' server <- connect(url="http://localhost:8000", username="carya", password="illinois") + +connectHost <- function(url, username=NULL, password=NULL, host=NULL){ + header <- add_headers(Host = host) + + res <- list(url=sub('^/|/$','',url), username=username, password=password, headers = header) + return(res) +} From 1ecba15c6b8f72fb162cc0a2518a7f658e432197 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Sat, 17 Jun 2023 18:26:58 +0530 Subject: [PATCH 2/4] Update connectHost.R to keep header field as required --- R/connectHost.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/connectHost.R b/R/connectHost.R index 379d1b9..38e9972 100644 --- a/R/connectHost.R +++ b/R/connectHost.R @@ -14,7 +14,7 @@ ##' @examples ##' server <- connect(url="http://localhost:8000", username="carya", password="illinois") -connectHost <- function(url, username=NULL, password=NULL, host=NULL){ +connectHost <- function(url, username=NULL, password=NULL, host){ header <- add_headers(Host = host) res <- list(url=sub('^/|/$','',url), username=username, password=password, headers = header) From ae1cf9a5b966b00fdf2e97260b1a815116ed7f0e Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Mon, 19 Jun 2023 13:10:07 +0530 Subject: [PATCH 3/4] Update connectHost.R --- R/connectHost.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/connectHost.R b/R/connectHost.R index 38e9972..8373b34 100644 --- a/R/connectHost.R +++ b/R/connectHost.R @@ -9,10 +9,11 @@ ##' @param url Base URL of the PEcAn API Server ##' @param username Username ##' @param password Password corresponding to the username +##' @param host host corresponds to host runner machine ##' @return A server object that can be passed into other functions for making requests to the PEcAn API ##' @export ##' @examples -##' server <- connect(url="http://localhost:8000", username="carya", password="illinois") +##' server <- connect(url="http://localhost:8000", username="carya", password="illinois", host="pecan.localhost") connectHost <- function(url, username=NULL, password=NULL, host){ header <- add_headers(Host = host) From cfe9e9d02e402eed0d94884dc05208162b86f0f0 Mon Sep 17 00:00:00 2001 From: Rohan Sasne Date: Fri, 23 Jun 2023 02:51:12 +0530 Subject: [PATCH 4/4] fix typo --- R/connectHost.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/connectHost.R b/R/connectHost.R index 8373b34..acb2b49 100644 --- a/R/connectHost.R +++ b/R/connectHost.R @@ -13,7 +13,7 @@ ##' @return A server object that can be passed into other functions for making requests to the PEcAn API ##' @export ##' @examples -##' server <- connect(url="http://localhost:8000", username="carya", password="illinois", host="pecan.localhost") +##' server <- connectHost(url="http://localhost:8000", username="carya", password="illinois", host="pecan.localhost") connectHost <- function(url, username=NULL, password=NULL, host){ header <- add_headers(Host = host)