# sunagriAPI
#
# An instance of OpenSILEX WebService
#
# OpenAPI spec version: 3.3.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' @title Experiments operations
#' @description phisWSClientRTools.Experiments
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#' @field userAgent Set the user agent of the request.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' get_experiment_data_search Get data corresponding to the search parameters given.
#'
#'
#' get_experiment_detail Get an experiment
#'
#'
#' get_experiments_by_search Get all experiments corresponding to the searched params given
#'
#'
#' post_experiment Post a experiment
#'
#'
#' put_experiment Update experiment
#'
#'
#' put_sensors Update the sensors which participates in an experiment
#'
#'
#' put_variables Update the observed variables of an experiment
#'
#' }
#'
#' @export
ExperimentsApi <- R6::R6Class(
'ExperimentsApi',
public = list(
userAgent = "Swagger-Codegen/3.3.0/r",
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
get_experiment_data_search = function(uri,page_size,page,variable_uri,start_date,end_date,object_uri,object_label,provenance_uri,provenance_label,date_sort_asc,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`page_size`)) {
queryParams['pageSize'] <- page_size
}
if (!missing(`page`)) {
queryParams['page'] <- page
}
if (!missing(`variable_uri`)) {
queryParams['variableUri'] <- variable_uri
}
if (!missing(`start_date`)) {
queryParams['startDate'] <- start_date
}
if (!missing(`end_date`)) {
queryParams['endDate'] <- end_date
}
if (!missing(`object_uri`)) {
queryParams['objectUri'] <- object_uri
}
if (!missing(`object_label`)) {
queryParams['objectLabel'] <- object_label
}
if (!missing(`provenance_uri`)) {
queryParams['provenanceUri'] <- provenance_uri
}
if (!missing(`provenance_label`)) {
queryParams['provenanceLabel'] <- provenance_label
}
if (!missing(`date_sort_asc`)) {
queryParams['dateSortAsc'] <- date_sort_asc
}
urlPath <- "/experiments/{uri}/data"
if (!missing(`uri`)) {
urlPath <- gsub(paste0("\\{", "uri", "\\}"), `uri`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- Data$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
get_experiment_detail = function(experiment,page_size,page,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`page_size`)) {
queryParams['pageSize'] <- page_size
}
if (!missing(`page`)) {
queryParams['page'] <- page
}
urlPath <- "/experiments/{experiment}"
if (!missing(`experiment`)) {
urlPath <- gsub(paste0("\\{", "experiment", "\\}"), `experiment`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- Experiment$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
get_experiments_by_search = function(page_size,page,uri,project_uri,start_date,end_date,field,campaign,place,alias,keywords,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`page_size`)) {
queryParams['pageSize'] <- page_size
}
if (!missing(`page`)) {
queryParams['page'] <- page
}
if (!missing(`uri`)) {
queryParams['uri'] <- uri
}
if (!missing(`project_uri`)) {
queryParams['projectUri'] <- project_uri
}
if (!missing(`start_date`)) {
queryParams['startDate'] <- start_date
}
if (!missing(`end_date`)) {
queryParams['endDate'] <- end_date
}
if (!missing(`field`)) {
queryParams['field'] <- field
}
if (!missing(`campaign`)) {
queryParams['campaign'] <- campaign
}
if (!missing(`place`)) {
queryParams['place'] <- place
}
if (!missing(`alias`)) {
queryParams['alias'] <- alias
}
if (!missing(`keywords`)) {
queryParams['keywords'] <- keywords
}
urlPath <- "/experiments"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "GET"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- Experiment$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
post_experiment = function(body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/experiments"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "POST"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
put_experiment = function(body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/experiments"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "PUT",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "PUT"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
put_sensors = function(uri,body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/experiments/{uri}/sensors"
if (!missing(`uri`)) {
urlPath <- gsub(paste0("\\{", "uri", "\\}"), `uri`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "PUT",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "PUT"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
},
put_variables = function(uri,body,...){
args <- list(...)
queryParams <- list()
headerParams <- character()
self$apiClient$basePath = sub("/$", "",get("BASE_PATH",opensilexWSClientR:::configWS))
if(self$apiClient$basePath == ""){
stop("Wrong you must first connect with connectToPHISWS")
}
#if (!missing(`authorization`)) {
# headerParams['Authorization'] <- authorization
#}
if (!missing(`body`)) {
if(is.list(`body`)){
bodyList <- lapply(`body`, function(x){x$toJSONString()})
bodyListPaste <- paste(bodyList, collapse=', ' )
body <- paste('[',bodyListPaste,']')
}else{
body <- paste('[',`body`$toJSONString(),']')
}
} else {
body <- NULL
}
urlPath <- "/experiments/{uri}/variables"
if (!missing(`uri`)) {
urlPath <- gsub(paste0("\\{", "uri", "\\}"), `uri`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "PUT",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
method = "PUT"
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
if(method == "GET"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
data <- json$result$data
returnedOjects = list()
for(i in 1:nrow(data)){
row <- data[i,]
returnObject <- ResponseFormPOST$new()
returnObject$fromJSONObject(row)
returnedOjects = c(returnedOjects,returnObject)
}
return(Response$new(json$metadata,returnedOjects, resp, TRUE))
}
if(method == "POST" || method == "PUT"){
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json$result$datafiles, resp, TRUE))
}
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
json <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
return(Response$new(json$metadata, json, resp, FALSE))
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.