R/udf_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 Udf operations
#' @description tiledbcloud.Udf
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ DeleteUDFInfo } \emph{  }
#' delete a registered UDF -- this will remove all sharing and can not be undone
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#'
#'
#' \item status code : 202 | UDF delete successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetUDFInfo } \emph{  }
#' get a specific UDF in the given namespace
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#' \item \emph{ @returnType } \link{UDFInfo} \cr
#'
#'
#' \item status code : 200 | UDFInfo was retrieved successfully
#'
#' \item return type : UDFInfo 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | UDF not found
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetUDFInfoSharingPolicies } \emph{  }
#' Get all sharing details of the UDF
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#' \item \emph{ @returnType } list( \link{UDFSharing} ) \cr
#'
#'
#' \item status code : 200 | List of all specific sharing policies
#'
#' \item return type : array[UDFSharing] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | UDF does not exist or user does not have permissions to view array-sharing policies
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ RegisterUDFInfo } \emph{  }
#' register a UDF in the given namespace
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#' \item \emph{ @param } udf \link{UDFInfoUpdate}
#'
#'
#' \item status code : 204 | UDF registered successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ShareUDFInfo } \emph{  }
#' Share a UDF with a user
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#' \item \emph{ @param } udf.sharing \link{UDFSharing}
#'
#'
#' \item status code : 204 | UDF shared successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | UDF does not exist or user does not have permissions to share UDF
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ SubmitGenericUDF } \emph{  }
#' submit a generic UDF in the given namespace
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } udf \link{GenericUDF}
#' \item \emph{ @param } accept.encoding character
#'
#'
#' \item status code : 200 | UDF completed and the UDF-type specific result is returned
#'
#' \item return type : data.frame 
#' \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}{
#' X-TILEDB-CLOUD-TASK-ID \tab Task ID for just completed request \cr
#' }
#' }
#'
#' \strong{ SubmitMultiArrayUDF } \emph{  }
#' submit a multi-array UDF in the given namespace
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } udf \link{MultiArrayUDF}
#' \item \emph{ @param } accept.encoding character
#'
#'
#' \item status code : 200 | UDF completed and the UDF-type specific result is returned
#'
#' \item return type : data.frame 
#' \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}{
#' X-TILEDB-CLOUD-TASK-ID \tab Task ID for just completed request \cr
#' }
#' }
#'
#' \strong{ SubmitUDF } \emph{  }
#' send a UDF to run against a specified array/URI registered to a group/project
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } array character
#' \item \emph{ @param } udf \link{MultiArrayUDF}
#' \item \emph{ @param } x.payer character
#' \item \emph{ @param } accept.encoding character
#' \item \emph{ @param } v2 character
#'
#'
#' \item status code : 200 | UDF completed and the UDF-type specific result is returned
#'
#' \item return type : data.frame 
#' \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}{
#' X-TILEDB-CLOUD-TASK-ID \tab Task ID for just completed request \cr
#' }
#' }
#'
#' \strong{ UdfNamespaceArrayEndTimestampsGet } \emph{  }
#' retrieve a list of timestamps from the array fragment info listing in milliseconds, paginated
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } array character
#' \item \emph{ @param } page integer
#' \item \emph{ @param } per.page integer
#' \item \emph{ @returnType } \link{ArrayEndTimestampData} \cr
#'
#'
#' \item status code : 200 | list of timestamps in milliseconds, paginated
#'
#' \item return type : ArrayEndTimestampData 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ UpdateUDFInfo } \emph{  }
#' update an existing registered UDF in the given namespace
#'
#' \itemize{
#' \item \emph{ @param } namespace character
#' \item \emph{ @param } name character
#' \item \emph{ @param } udf \link{UDFInfoUpdate}
#'
#'
#' \item status code : 204 | UDF updated successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 0 | error response
#'
#' \item return type : Error 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  DeleteUDFInfo  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name to register UDF under
#'
#' api.instance <- UdfApi$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$DeleteUDFInfo(var.namespace, var.name)
#'
#'
#' ####################  GetUDFInfo  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name to register UDF under
#'
#' api.instance <- UdfApi$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$GetUDFInfo(var.namespace, var.name)
#'
#'
#' ####################  GetUDFInfoSharingPolicies  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name of UDFInfo
#'
#' api.instance <- UdfApi$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$GetUDFInfoSharingPolicies(var.namespace, var.name)
#'
#'
#' ####################  RegisterUDFInfo  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name to register UDF under
#' var.udf <- UDFInfoUpdate$new() # UDFInfoUpdate | UDF to register
#'
#' api.instance <- UdfApi$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$RegisterUDFInfo(var.namespace, var.name, var.udf)
#'
#'
#' ####################  ShareUDFInfo  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name of UDFInfo
#' var.udf.sharing <- UDFSharing$new() # UDFSharing | Namespace and list of permissions to share with. An empty list of permissions will remove the namespace; if permissions already exist they will be deleted then new ones added. In the event of a failure, the new policies will be rolled back to prevent partial policies, and it's likely the UDF will not be shared with the namespace at all.
#'
#' api.instance <- UdfApi$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$ShareUDFInfo(var.namespace, var.name, var.udf.sharing)
#'
#'
#' ####################  SubmitGenericUDF  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.udf <- GenericUDF$new() # GenericUDF | UDF to run
#' var.accept.encoding <- 'accept.encoding_example' # character | Encoding to use
#'
#' api.instance <- UdfApi$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$SubmitGenericUDF(var.namespace, var.udf, accept.encoding=var.accept.encoding)
#'
#'
#' ####################  SubmitMultiArrayUDF  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.udf <- MultiArrayUDF$new() # MultiArrayUDF | UDF to run
#' var.accept.encoding <- 'accept.encoding_example' # character | Encoding to use
#'
#' api.instance <- UdfApi$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$SubmitMultiArrayUDF(var.namespace, var.udf, accept.encoding=var.accept.encoding)
#'
#'
#' ####################  SubmitUDF  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.array <- 'array_example' # character | name/uri of array that is url-encoded
#' var.udf <- MultiArrayUDF$new() # MultiArrayUDF | UDF to run
#' var.x.payer <- 'x.payer_example' # character | Name of organization or user who should be charged for this request
#' var.accept.encoding <- 'accept.encoding_example' # character | Encoding to use
#' var.v2 <- 'v2_example' # character | flag to indicate if v2 array UDFs should be used, currently in beta testing. Setting any value will enable v2 array UDFs.
#'
#' api.instance <- UdfApi$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$SubmitUDF(var.namespace, var.array, var.udf, x.payer=var.x.payer, accept.encoding=var.accept.encoding, v2=var.v2)
#'
#'
#' ####################  UdfNamespaceArrayEndTimestampsGet  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.array <- 'array_example' # character | name/uri of array that is url-encoded
#' var.page <- 56 # integer | pagination offset
#' var.per.page <- 56 # integer | pagination limit
#'
#' api.instance <- UdfApi$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$UdfNamespaceArrayEndTimestampsGet(var.namespace, var.array, page=var.page, per.page=var.per.page)
#'
#'
#' ####################  UpdateUDFInfo  ####################
#'
#' library(tiledbcloud)
#' var.namespace <- 'namespace_example' # character | namespace array is in (an organization name or user's username)
#' var.name <- 'name_example' # character | name to register UDF under
#' var.udf <- UDFInfoUpdate$new() # UDFInfoUpdate | UDF to update
#'
#' api.instance <- UdfApi$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$UpdateUDFInfo(var.namespace, var.name, var.udf)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
UdfApi <- R6::R6Class(
  'UdfApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    DeleteUDFInfo = function(namespace, name, ...){
      apiResponse <- self$DeleteUDFInfoWithHttpInfo(namespace, name, ...)
      resp <- apiResponse$response
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

    DeleteUDFInfoWithHttpInfo = function(namespace, name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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 = "DELETE",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },
    GetUDFInfo = function(namespace, name, ...){
      apiResponse <- self$GetUDFInfoWithHttpInfo(namespace, name, ...)
      resp <- apiResponse$response
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

    GetUDFInfoWithHttpInfo = function(namespace, name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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,
                                 ...)

      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },
    GetUDFInfoSharingPolicies = function(namespace, name, ...){
      apiResponse <- self$GetUDFInfoSharingPoliciesWithHttpInfo(namespace, name, ...)
      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
      }
    },

    GetUDFInfoSharingPoliciesWithHttpInfo = function(namespace, name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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, "array[UDFSharing]", 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)
      }
    },
    RegisterUDFInfo = function(namespace, name, udf, ...){
      apiResponse <- self$RegisterUDFInfoWithHttpInfo(namespace, name, udf, ...)
      resp <- apiResponse$response
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

    RegisterUDFInfoWithHttpInfo = function(namespace, name, udf, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

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

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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,
                                 ...)

      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },
    ShareUDFInfo = function(namespace, name, udf.sharing, ...){
      apiResponse <- self$ShareUDFInfoWithHttpInfo(namespace, name, udf.sharing, ...)
      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
      }
    },

    ShareUDFInfoWithHttpInfo = function(namespace, name, udf.sharing, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      if (!missing(`udf.sharing`)) {
        body <- `udf.sharing`$toJSONString()
      } else {
        body <- NULL
      }

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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 = "PATCH",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        ApiResponse$new(NULL, 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)
      }
    },
    SubmitGenericUDF = function(namespace, udf, accept.encoding=NULL, ...){
      apiResponse <- self$SubmitGenericUDFWithHttpInfo(namespace, udf, accept.encoding, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

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

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

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

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

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

      urlPath <- "/udfs/generic/{namespace}"
      if (!is.null(`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,
                                 ...)
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },
    SubmitMultiArrayUDF = function(namespace, udf, accept.encoding=NULL, ...){
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      apiResponse <- self$SubmitMultiArrayUDFWithHttpInfo(namespace, udf, accept.encoding, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },
    SubmitMultiArrayUDFWithHttpInfo = function(namespace, udf, accept.encoding=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

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

      urlPath <- "/udfs/arrays/{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, ...)
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },

    SubmitUDF = function(namespace, array, udf, x.payer=NULL, accept.encoding=NULL, v2=NULL, ...){
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      apiResponse <- self$SubmitUDFWithHttpInfo(namespace, array, udf, x.payer, accept.encoding, v2, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

    SubmitUDFWithHttpInfo = function(namespace, array, udf, x.payer=NULL, accept.encoding=NULL, v2=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      if (!missing(`x.payer`)) {
        headerParams['X-Payer'] <- `x.payer`
      }

      # Without this we get
      # 'Error in headerParams["Accept-Encoding"] <- accept.encoding : replacement has length zero'
      if (!is.null(`accept.encoding`)) {
        headerParams['Accept-Encoding'] <- accept.encoding
      }

      queryParams['v2'] <- v2

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

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

      if (!missing(`array`)) {
        urlPath <- gsub(paste0("\\{", "array", "\\}"), URLencode(as.character(`array`), 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, ...)

      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    },
    UdfNamespaceArrayEndTimestampsGet = function(namespace, array, page=NULL, per.page=NULL, ...){
      apiResponse <- self$UdfNamespaceArrayEndTimestampsGetWithHttpInfo(namespace, array, page, per.page, ...)
      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
      }
    },

    UdfNamespaceArrayEndTimestampsGetWithHttpInfo = function(namespace, array, page=NULL, per.page=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

      queryParams['page'] <- page

      queryParams['per_page'] <- per.page

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

      if (!missing(`array`)) {
        urlPath <- gsub(paste0("\\{", "array", "\\}"), URLencode(as.character(`array`), 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, "ArrayEndTimestampData", 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)
      }
    },
    UpdateUDFInfo = function(namespace, name, udf, ...){
      apiResponse <- self$UpdateUDFInfoWithHttpInfo(namespace, name, udf, ...)
      resp <- apiResponse$response
      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else {
        apiResponse
      }
    },

    UpdateUDFInfoWithHttpInfo = function(namespace, name, udf, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

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

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

      if (!missing(`name`)) {
        urlPath <- gsub(paste0("\\{", "name", "\\}"), URLencode(as.character(`name`), 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 = "PATCH",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      # MANUAL EDIT AFTER OPENAPI AUTOGEN
      .wrap_as_api_response(resp)
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.