R/tasks_api.R

# TileDB Storage Platform API
#
# TileDB Storage Platform REST API
#
# The version of the OpenAPI document: 2.2.19
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Tasks operations
#' @description tiledbcloud.Tasks
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ RunSQL } \emph{  }
#' Run a sql query
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } sql \link{SQLParameters}
#' \item \emph{ @param } accept.encoding character
#'
#'
#' \item status code : 200 | JSON results in array of objects form, if the query returns results
#'
#' \item return type : array[object] 
#' \item response headers :
#'
#' \tabular{ll}{
#' X-TILEDB-CLOUD-TASK-ID \tab Task ID for just completed request \cr
#' }
#' \item status code : 204 | SQL executed successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' X-TILEDB-CLOUD-TASK-ID \tab Task ID for just completed request \cr
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ TaskIdGet } \emph{  }
#' Fetch an array task
#'
#' \itemize{
#' \item \emph{ @param } id character
#' \item \emph{ @returnType } \link{ArrayTask} \cr
#'
#'
#' \item status code : 200 | Array task
#'
#' \item return type : ArrayTask 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ TaskIdResultGet } \emph{  }
#' Retrieve results of an array task
#'
#' \itemize{
#' \item \emph{ @param } id character
#' \item \emph{ @param } accept.encoding character
#'
#'
#' \item status code : 200 | output and format of originating request
#'
#' \item return type : character 
#' \item response headers :
#'
#' \tabular{ll}{
#' Content-Type \tab format results are delivered in \cr
#' }
#' \item status code : 202 | task is still executing
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | results were not saved, or results have expored
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ TasksGet } \emph{  }
#' Fetch a list of all array tasks a user has access to
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } created.by character
#' \item \emph{ @param } array character
#' \item \emph{ @param } start integer
#' \item \emph{ @param } end integer
#' \item \emph{ @param } page integer
#' \item \emph{ @param } per.page integer
#' \item \emph{ @param } type character
#' \item \emph{ @param } exclude.type list( character )
#' \item \emph{ @param } file.type list( character )
#' \item \emph{ @param } exclude.file.type list( character )
#' \item \emph{ @param } status character
#' \item \emph{ @param } search character
#' \item \emph{ @param } orderby character
#' \item \emph{ @returnType } \link{ArrayTaskData} \cr
#'
#'
#' \item status code : 200 | Array of all tasks user has access too
#'
#' \item return type : ArrayTaskData 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  RunSQL  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace to run task under is in (an organization name or user's username)
#' var.sql <- SQLParameters$new() # SQLParameters | sql being submitted
#' var.accept.encoding <- 'accept.encoding_example' # character | Encoding to use
#'
#' api.instance <- TasksApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-TILEDB-REST-API-KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure HTTP basic authorization: BasicAuth
#' # provide your username in the user-serial format
#' api.instance$apiClient$username <- '<user-serial>'; 
#' # provide your api key generated using the developer portal
#' api.instance$apiClient$password <- '<api_key>';
#'
#' result <- api.instance$RunSQL(var.namespace, var.sql, accept.encoding=var.accept.encoding)
#'
#'
#' ####################  TaskIdGet  ####################
#'
#' library(tiledbcloud)
#' var.id <- 'id_example' # character | task ID to fetch
#'
#' api.instance <- TasksApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-TILEDB-REST-API-KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure HTTP basic authorization: BasicAuth
#' # provide your username in the user-serial format
#' api.instance$apiClient$username <- '<user-serial>'; 
#' # provide your api key generated using the developer portal
#' api.instance$apiClient$password <- '<api_key>';
#'
#' result <- api.instance$TaskIdGet(var.id)
#'
#'
#' ####################  TaskIdResultGet  ####################
#'
#' library(tiledbcloud)
#' var.id <- 'id_example' # character | task ID to retrieve stored results
#' var.accept.encoding <- 'accept.encoding_example' # character | Encoding to use
#'
#' api.instance <- TasksApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-TILEDB-REST-API-KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure HTTP basic authorization: BasicAuth
#' # provide your username in the user-serial format
#' api.instance$apiClient$username <- '<user-serial>'; 
#' # provide your api key generated using the developer portal
#' api.instance$apiClient$password <- '<api_key>';
#'
#' result <- api.instance$TaskIdResultGet(var.id, accept.encoding=var.accept.encoding)
#'
#'
#' ####################  TasksGet  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace to filter
#' var.created.by <- 'created.by_example' # character | username to filter
#' var.array <- 'array_example' # character | name/uri of array that is url-encoded to filter
#' var.start <- 56 # integer | start time for tasks to filter by
#' var.end <- 56 # integer | end time for tasks to filter by
#' var.page <- 56 # integer | pagination offset
#' var.per.page <- 56 # integer | pagination limit
#' var.type <- 'type_example' # character | task type, \"QUERY\", \"SQL\", \"UDF\", \"GENERIC_UDF\"
#' var.exclude.type <- ['exclude.type_example'] # array[character] | task_type to exclude matching array in results, more than one can be included
#' var.file.type <- ['file.type_example'] # array[character] | match file_type of task array, more than one can be included
#' var.exclude.file.type <- ['exclude.file.type_example'] # array[character] | exclude file_type of task arrays, more than one can be included
#' var.status <- 'status_example' # character | Filter to only return these statuses
#' var.search <- 'search_example' # character | search string that will look at name, namespace or description fields
#' var.orderby <- 'orderby_example' # character | sort by which field valid values include start_time, name
#'
#' api.instance <- TasksApi$new()
#'
#' #Configure API key authorization: ApiKeyAuth
#' api.instance$apiClient$apiKeys['X-TILEDB-REST-API-KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure HTTP basic authorization: BasicAuth
#' # provide your username in the user-serial format
#' api.instance$apiClient$username <- '<user-serial>'; 
#' # provide your api key generated using the developer portal
#' api.instance$apiClient$password <- '<api_key>';
#'
#' result <- api.instance$TasksGet(namespace=var.namespace, created.by=var.created.by, array=var.array, start=var.start, end=var.end, page=var.page, per.page=var.per.page, type=var.type, exclude.type=var.exclude.type, file.type=var.file.type, exclude.file.type=var.exclude.file.type, status=var.status, search=var.search, orderby=var.orderby)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
TasksApi <- R6::R6Class(
  'TasksApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    RunSQL = function(namespace, sql, accept.encoding=NULL, ...){
      apiResponse <- self$RunSQLWithHttpInfo(namespace, sql, accept.encoding, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    RunSQLWithHttpInfo = function(namespace, sql, accept.encoding=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`namespace`)) {
        stop("Missing required parameter `namespace`.")
      }

      if (missing(`sql`)) {
        stop("Missing required parameter `sql`.")
      }

      headerParams['Accept-Encoding'] <- `accept.encoding`

      if (!missing(`sql`)) {
        body <- `sql`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/sql/{namespace}"
      if (!missing(`namespace`)) {
        urlPath <- gsub(paste0("\\{", "namespace", "\\}"), URLencode(as.character(`namespace`), reserved = TRUE), urlPath)
      }

      # API key authentication
      if ("X-TILEDB-REST-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]) > 0) {
        headerParams['X-TILEDB-REST-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]), collapse='')
      }
      # HTTP basic auth
      headerParams['Authorization'] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$apiClient$username, self$apiClient$password, sep=":"))))

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[object]", loadNamespace("tiledbcloud")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    TaskIdGet = function(id, ...){
      apiResponse <- self$TaskIdGetWithHttpInfo(id, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    TaskIdGetWithHttpInfo = function(id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`id`)) {
        stop("Missing required parameter `id`.")
      }

      body <- NULL
      urlPath <- "/task/{id}"
      if (!missing(`id`)) {
        urlPath <- gsub(paste0("\\{", "id", "\\}"), URLencode(as.character(`id`), reserved = TRUE), urlPath)
      }

      # API key authentication
      if ("X-TILEDB-REST-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]) > 0) {
        headerParams['X-TILEDB-REST-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]), collapse='')
      }
      # HTTP basic auth
      headerParams['Authorization'] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$apiClient$username, self$apiClient$password, sep=":"))))

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "ArrayTask", loadNamespace("tiledbcloud")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    TaskIdResultGet = function(id, accept.encoding=NULL, ...){
      apiResponse <- self$TaskIdResultGetWithHttpInfo(id, accept.encoding, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    TaskIdResultGetWithHttpInfo = function(id, accept.encoding=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`id`)) {
        stop("Missing required parameter `id`.")
      }

      headerParams['Accept-Encoding'] <- `accept.encoding`

      body <- NULL
      urlPath <- "/task/{id}/result"
      if (!missing(`id`)) {
        urlPath <- gsub(paste0("\\{", "id", "\\}"), URLencode(as.character(`id`), reserved = TRUE), urlPath)
      }

      # API key authentication
      if ("X-TILEDB-REST-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]) > 0) {
        headerParams['X-TILEDB-REST-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]), collapse='')
      }
      # HTTP basic auth
      headerParams['Authorization'] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$apiClient$username, self$apiClient$password, sep=":"))))

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "character", loadNamespace("tiledbcloud")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    TasksGet = function(namespace=NULL, created.by=NULL, array=NULL, start=NULL, end=NULL, page=NULL, per.page=NULL, type=NULL, exclude.type=NULL, file.type=NULL, exclude.file.type=NULL, status=NULL, search=NULL, orderby=NULL, ...){
      apiResponse <- self$TasksGetWithHttpInfo(namespace, created.by, array, start, end, page, per.page, type, exclude.type, file.type, exclude.file.type, status, search, orderby, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    TasksGetWithHttpInfo = function(namespace=NULL, created.by=NULL, array=NULL, start=NULL, end=NULL, page=NULL, per.page=NULL, type=NULL, exclude.type=NULL, file.type=NULL, exclude.file.type=NULL, status=NULL, search=NULL, orderby=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['namespace'] <- namespace

      queryParams['created_by'] <- created.by

      queryParams['array'] <- array

      queryParams['start'] <- start

      queryParams['end'] <- end

      queryParams['page'] <- page

      queryParams['per_page'] <- per.page

      queryParams['type'] <- type

      queryParams['exclude_type'] <- exclude.type

      queryParams['file_type'] <- file.type

      queryParams['exclude_file_type'] <- exclude.file.type

      queryParams['status'] <- status

      queryParams['search'] <- search

      queryParams['orderby'] <- orderby

      body <- NULL
      urlPath <- "/tasks"
      # API key authentication
      if ("X-TILEDB-REST-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]) > 0) {
        headerParams['X-TILEDB-REST-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-TILEDB-REST-API-KEY"]), collapse='')
      }
      # HTTP basic auth
      headerParams['Authorization'] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$apiClient$username, self$apiClient$password, sep=":"))))

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "ArrayTaskData", loadNamespace("tiledbcloud")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.