#' Jaqpot API
#'
#' A modern RESTful API for model management and prediction services, built using Spring Boot and Kotlin. Supports seamless integration with machine learning workflows.
#'
#' The version of the OpenAPI document: 1.0.0
#' Contact: upci.ntua@gmail.com
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title Dataset operations
#' @description DatasetApi
#' @format An \code{R6Class} generator object
#' @field api_client Handles the client-server communication.
#'
#' @examples
#' \dontrun{
#' #################### GetDatasetById ####################
#'
#' library(openapi)
#' var_id <- 0 # integer | The ID of the dataset to retrieve
#'
#' #Get a Dataset
#' api_instance <- DatasetApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$GetDatasetById(var_iddata_file = "result.txt")
#' result <- api_instance$GetDatasetById(var_id)
#' dput(result)
#'
#'
#' #################### GetDatasets ####################
#'
#' library(openapi)
#' var_page <- 0 # integer | (Optional)
#' var_size <- 10 # integer | (Optional)
#' var_sort <- c("inner_example") # array[character] | (Optional)
#'
#' #Get Datasets by User ID
#' api_instance <- DatasetApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$GetDatasets(page = var_page, size = var_size, sort = var_sortdata_file = "result.txt")
#' result <- api_instance$GetDatasets(page = var_page, size = var_size, sort = var_sort)
#' dput(result)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @keywords internal
DatasetApi <- R6::R6Class(
"DatasetApi",
public = list(
api_client = NULL,
#' @description
#' Initialize a new DatasetApi.
#'
#' @param api_client An instance of API client.
initialize = function(api_client) {
if (!missing(api_client)) {
self$api_client <- api_client
} else {
self$api_client <- ApiClient$new()
}
},
#' @description
#' Get a Dataset
#'
#' @param id The ID of the dataset to retrieve
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return Dataset
GetDatasetById = function(id, data_file = NULL, ...) {
local_var_response <- self$GetDatasetByIdWithHttpInfo(id, data_file = data_file, ...)
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
return(local_var_response)
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
return(local_var_response)
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
return(local_var_response)
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
return(local_var_response)
}
},
#' @description
#' Get a Dataset
#'
#' @param id The ID of the dataset to retrieve
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return API response (Dataset) with additional information such as HTTP status code, headers
GetDatasetByIdWithHttpInfo = function(id, data_file = NULL, ...) {
args <- list(...)
query_params <- list()
header_params <- c()
form_params <- list()
file_params <- list()
local_var_body <- NULL
oauth_scopes <- NULL
is_oauth <- FALSE
if (missing(`id`)) {
stop("Missing required parameter `id`.")
}
local_var_url_path <- "/v1/datasets/{id}"
if (!missing(`id`)) {
local_var_url_path <- gsub("\\{id\\}", URLencode(as.character(`id`), reserved = TRUE), local_var_url_path)
}
# Bearer token
if (!is.null(self$api_client$bearer_token)) {
header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
}
# The Accept request HTTP header
local_var_accepts <- list("application/json")
# The Content-Type representation header
local_var_content_types <- list()
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
method = "GET",
query_params = query_params,
header_params = header_params,
form_params = form_params,
file_params = file_params,
accepts = local_var_accepts,
content_types = local_var_content_types,
body = local_var_body,
is_oauth = is_oauth,
oauth_scopes = oauth_scopes,
...)
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
# save response in a file
if (!is.null(data_file)) {
write(local_var_resp$response, data_file)
}
# deserialized_resp_obj <- tryCatch(
# self$api_client$deserialize(local_var_resp$response_as_text(), "Dataset", loadNamespace("openapi")),
# error = function(e) {
# stop("Failed to deserialize response")
# }
# )
local_var_resp$content <- jsonlite::fromJSON(local_var_resp$response_as_text())
return(local_var_resp)
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
print(paste0("Error, status code ", local_var_resp$status_code))
return(local_var_resp)
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
ApiResponse$new("API client error", local_var_resp)
print(paste0("API client error, status code ", local_var_resp$status_code))
return(local_var_resp)
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
local_var_resp$response <- "API server error"
}
print(paste0("API server error, status code ", local_var_resp$status_code))
return(local_var_resp)
}
},
#' @description
#' Get Datasets by User ID
#'
#' @param page (optional) No description (default value: 0)
#' @param size (optional) No description (default value: 10)
#' @param sort (optional) No description
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return GetDatasets200Response
GetDatasets = function(page = 0, size = 10, sort = NULL, data_file = NULL, ...) {
local_var_response <- self$GetDatasetsWithHttpInfo(page, size, sort, data_file = data_file, ...)
if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
local_var_response$content
} else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
local_var_response
} else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
local_var_response
} else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
local_var_response
}
},
#' @description
#' Get Datasets by User ID
#'
#' @param page (optional) No description (default value: 0)
#' @param size (optional) No description (default value: 10)
#' @param sort (optional) No description
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return API response (GetDatasets200Response) with additional information such as HTTP status code, headers
GetDatasetsWithHttpInfo = function(page = 0, size = 10, sort = NULL, data_file = NULL, ...) {
args <- list(...)
query_params <- list()
header_params <- c()
form_params <- list()
file_params <- list()
local_var_body <- NULL
oauth_scopes <- NULL
is_oauth <- FALSE
query_params[["page"]] <- `page`
query_params[["size"]] <- `size`
# explore
for (query_item in `sort`) {
query_params[["sort"]] <- c(query_params[["sort"]], list(`sort` = query_item))
}
local_var_url_path <- "/v1/user/datasets"
# Bearer token
if (!is.null(self$api_client$bearer_token)) {
header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
}
# The Accept request HTTP header
local_var_accepts <- list("application/json")
# The Content-Type representation header
local_var_content_types <- list()
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
method = "GET",
query_params = query_params,
header_params = header_params,
form_params = form_params,
file_params = file_params,
accepts = local_var_accepts,
content_types = local_var_content_types,
body = local_var_body,
is_oauth = is_oauth,
oauth_scopes = oauth_scopes,
...)
if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
# save response in a file
if (!is.null(data_file)) {
write(local_var_resp$response, data_file)
}
deserialized_resp_obj <- tryCatch(
self$api_client$deserialize(local_var_resp$response_as_text(), "GetDatasets200Response", loadNamespace("openapi")),
error = function(e) {
stop("Failed to deserialize response")
}
)
local_var_resp$content <- deserialized_resp_obj
local_var_resp
} else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
} else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
ApiResponse$new("API client error", local_var_resp)
} else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
if (is.null(local_var_resp$response) || local_var_resp$response == "") {
local_var_resp$response <- "API server error"
}
local_var_resp
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.