#' 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 ApiKeys operations
#' @description ApiKeysApi
#' @format An \code{R6Class} generator object
#' @field api_client Handles the client-server communication.
#'
#' @examples
#' \dontrun{
#' #################### CreateApiKey ####################
#'
#' library(openapi)
#' var_api_key <- ApiKey$new("THREE_MONTHS", "clientKey_example", "note_example", "userId_example", "expiresAt_example", "lastUsed_example", "lastUsedIp_example", "enabled_example") # ApiKey | Payload to create a new API key
#'
#' #Create an API Key for the User
#' api_instance <- ApiKeysApi$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$CreateApiKey(var_api_keydata_file = "result.txt")
#' result <- api_instance$CreateApiKey(var_api_key)
#' dput(result)
#'
#'
#' #################### DeleteApiKey ####################
#'
#' library(openapi)
#' var_key <- "jq_abcd1234efgh5678ijkl" # character | The API key to delete
#'
#' #Delete an API Key
#' api_instance <- ApiKeysApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' api_instance$DeleteApiKey(var_key)
#'
#'
#' #################### GetAllApiKeysForUser ####################
#'
#' library(openapi)
#'
#' #Get All API Keys for the User
#' api_instance <- ApiKeysApi$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$GetAllApiKeysForUser(data_file = "result.txt")
#' result <- api_instance$GetAllApiKeysForUser()
#' dput(result)
#'
#'
#' #################### UpdateApiKey ####################
#'
#' library(openapi)
#' var_key <- "jq_abcd1234efgh5678ijkl" # character | The API key to update
#' var_update_api_key_request <- updateApiKey_request$new("note_example", "enabled_example") # UpdateApiKeyRequest | Payload to update API key metadata
#'
#' #Update API Key
#' api_instance <- ApiKeysApi$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$UpdateApiKey(var_key, var_update_api_key_requestdata_file = "result.txt")
#' result <- api_instance$UpdateApiKey(var_key, var_update_api_key_request)
#' dput(result)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @keywords internal
ApiKeysApi <- R6::R6Class(
"ApiKeysApi",
public = list(
api_client = NULL,
#' @description
#' Initialize a new ApiKeysApi.
#'
#' @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
#' Create an API Key for the User
#'
#' @param api_key Payload to create a new API key
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return CreateApiKey201Response
CreateApiKey = function(api_key, data_file = NULL, ...) {
local_var_response <- self$CreateApiKeyWithHttpInfo(api_key, 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
#' Create an API Key for the User
#'
#' @param api_key Payload to create a new API key
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return API response (CreateApiKey201Response) with additional information such as HTTP status code, headers
CreateApiKeyWithHttpInfo = function(api_key, 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(`api_key`)) {
stop("Missing required parameter `api_key`.")
}
if (!is.null(`api_key`)) {
local_var_body <- `api_key`$toJSONString()
} else {
body <- NULL
}
local_var_url_path <- "/v1/user/api-keys"
# 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("application/json")
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
method = "POST",
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(), "CreateApiKey201Response", 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
}
},
#' @description
#' Delete an API Key
#'
#' @param key The API key to delete
#' @param ... Other optional arguments
#'
#' @return void
DeleteApiKey = function(key, ...) {
local_var_response <- self$DeleteApiKeyWithHttpInfo(key, ...)
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
#' Delete an API Key
#'
#' @param key The API key to delete
#' @param ... Other optional arguments
#'
#' @return API response (void) with additional information such as HTTP status code, headers
DeleteApiKeyWithHttpInfo = function(key, ...) {
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(`key`)) {
stop("Missing required parameter `key`.")
}
local_var_url_path <- "/v1/user/api-keys/{key}"
if (!missing(`key`)) {
local_var_url_path <- gsub("\\{key\\}", URLencode(as.character(`key`), 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()
# 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 = "DELETE",
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) {
local_var_resp$content <- NULL
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
}
},
#' @description
#' Get All API Keys for the User
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return array[GetAllApiKeysForUser200ResponseInner]
GetAllApiKeysForUser = function(data_file = NULL, ...) {
local_var_response <- self$GetAllApiKeysForUserWithHttpInfo(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 All API Keys for the User
#'
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return API response (array[GetAllApiKeysForUser200ResponseInner]) with additional information such as HTTP status code, headers
GetAllApiKeysForUserWithHttpInfo = function(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
local_var_url_path <- "/v1/user/api-keys"
# 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(), "array[GetAllApiKeysForUser200ResponseInner]", 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
}
},
#' @description
#' Update API Key
#'
#' @param key The API key to update
#' @param update_api_key_request Payload to update API key metadata
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return UpdateApiKey200Response
UpdateApiKey = function(key, update_api_key_request, data_file = NULL, ...) {
local_var_response <- self$UpdateApiKeyWithHttpInfo(key, update_api_key_request, 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
#' Update API Key
#'
#' @param key The API key to update
#' @param update_api_key_request Payload to update API key metadata
#' @param data_file (optional) name of the data file to save the result
#' @param ... Other optional arguments
#'
#' @return API response (UpdateApiKey200Response) with additional information such as HTTP status code, headers
UpdateApiKeyWithHttpInfo = function(key, update_api_key_request, 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(`key`)) {
stop("Missing required parameter `key`.")
}
if (missing(`update_api_key_request`)) {
stop("Missing required parameter `update_api_key_request`.")
}
if (!is.null(`update_api_key_request`)) {
local_var_body <- `update_api_key_request`$toJSONString()
} else {
body <- NULL
}
local_var_url_path <- "/v1/user/api-keys/{key}"
if (!missing(`key`)) {
local_var_url_path <- gsub("\\{key\\}", URLencode(as.character(`key`), 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("application/json")
local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
method = "PATCH",
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(), "UpdateApiKey200Response", 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.