R/generic_udf.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 GenericUDF
#'
#' @description GenericUDF Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field udf_info_name  character [optional]
#'
#' @field language  \link{UDFLanguage} [optional]
#'
#' @field version  character [optional]
#'
#' @field image_name  character [optional]
#'
#' @field resource_class  character [optional]
#'
#' @field exec  character [optional]
#'
#' @field exec_raw  character [optional]
#'
#' @field argument  character [optional]
#'
#' @field stored_param_uuids  list( character ) [optional]
#'
#' @field result_format  \link{ResultFormat} [optional]
#'
#' @field task_name  character [optional]
#'
#' @field store_results  character [optional]
#'
#' @field timeout  integer [optional]
#'
#' @field dont_download_results  character [optional]
#'
#' @field task_graph_uuid  character [optional]
#'
#' @field client_node_uuid  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
GenericUDF <- R6::R6Class(
  'GenericUDF',
  public = list(
    `udf_info_name` = NULL,
    `language` = NULL,
    `version` = NULL,
    `image_name` = NULL,
    `resource_class` = NULL,
    `exec` = NULL,
    `exec_raw` = NULL,
    `argument` = NULL,
    `stored_param_uuids` = NULL,
    `result_format` = NULL,
    `task_name` = NULL,
    `store_results` = NULL,
    `timeout` = NULL,
    `dont_download_results` = NULL,
    `task_graph_uuid` = NULL,
    `client_node_uuid` = NULL,
    initialize = function(
        `udf_info_name`=NULL, `language`=NULL, `version`=NULL, `image_name`=NULL, `resource_class`=NULL, `exec`=NULL, `exec_raw`=NULL, `argument`=NULL, `stored_param_uuids`=NULL, `result_format`=NULL, `task_name`=NULL, `store_results`=NULL, `timeout`=NULL, `dont_download_results`=NULL, `task_graph_uuid`=NULL, `client_node_uuid`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`udf_info_name`)) {
        stopifnot(is.character(`udf_info_name`), length(`udf_info_name`) == 1)
        self$`udf_info_name` <- `udf_info_name`
      }
      if (!is.null(`language`)) {
        stopifnot(R6::is.R6(`language`))
        self$`language` <- `language`
      }
      if (!is.null(`version`)) {
        stopifnot(is.character(`version`), length(`version`) == 1)
        self$`version` <- `version`
      }
      if (!is.null(`image_name`)) {
        stopifnot(is.character(`image_name`), length(`image_name`) == 1)
        self$`image_name` <- `image_name`
      }
      if (!is.null(`resource_class`)) {
        stopifnot(is.character(`resource_class`), length(`resource_class`) == 1)
        self$`resource_class` <- `resource_class`
      }
      if (!is.null(`exec`)) {
        stopifnot(is.character(`exec`), length(`exec`) == 1)
        self$`exec` <- `exec`
      }
      if (!is.null(`exec_raw`)) {
        stopifnot(is.character(`exec_raw`), length(`exec_raw`) == 1)
        self$`exec_raw` <- `exec_raw`
      }
      if (!is.null(`argument`)) {
        stopifnot(is.character(`argument`), length(`argument`) == 1)
        self$`argument` <- `argument`
      }
      if (!is.null(`stored_param_uuids`)) {
        stopifnot(is.vector(`stored_param_uuids`), length(`stored_param_uuids`) != 0)
        sapply(`stored_param_uuids`, function(x) stopifnot(is.character(x)))
        self$`stored_param_uuids` <- `stored_param_uuids`
      }
      if (!is.null(`result_format`)) {
        stopifnot(R6::is.R6(`result_format`))
        self$`result_format` <- `result_format`
      }
      if (!is.null(`task_name`)) {
        stopifnot(is.character(`task_name`), length(`task_name`) == 1)
        self$`task_name` <- `task_name`
      }
      if (!is.null(`store_results`)) {
        self$`store_results` <- `store_results`
      }
      if (!is.null(`timeout`)) {
        stopifnot(is.numeric(`timeout`), length(`timeout`) == 1)
        self$`timeout` <- `timeout`
      }
      if (!is.null(`dont_download_results`)) {
        self$`dont_download_results` <- `dont_download_results`
      }
      if (!is.null(`task_graph_uuid`)) {
        stopifnot(is.character(`task_graph_uuid`), length(`task_graph_uuid`) == 1)
        self$`task_graph_uuid` <- `task_graph_uuid`
      }
      if (!is.null(`client_node_uuid`)) {
        stopifnot(is.character(`client_node_uuid`), length(`client_node_uuid`) == 1)
        self$`client_node_uuid` <- `client_node_uuid`
      }
    },
    toJSON = function() {
      GenericUDFObject <- list()
      if (!is.null(self$`udf_info_name`)) {
        GenericUDFObject[['udf_info_name']] <-
          self$`udf_info_name`
      }
      if (!is.null(self$`language`)) {
        GenericUDFObject[['language']] <-
          self$`language`$toJSON()
      }
      if (!is.null(self$`version`)) {
        GenericUDFObject[['version']] <-
          self$`version`
      }
      if (!is.null(self$`image_name`)) {
        GenericUDFObject[['image_name']] <-
          self$`image_name`
      }
      if (!is.null(self$`resource_class`)) {
        GenericUDFObject[['resource_class']] <-
          self$`resource_class`
      }
      if (!is.null(self$`exec`)) {
        GenericUDFObject[['exec']] <-
          self$`exec`
      }
      if (!is.null(self$`exec_raw`)) {
        GenericUDFObject[['exec_raw']] <-
          self$`exec_raw`
      }
      if (!is.null(self$`argument`)) {
        GenericUDFObject[['argument']] <-
          self$`argument`
      }
      if (!is.null(self$`stored_param_uuids`)) {
        GenericUDFObject[['stored_param_uuids']] <-
          self$`stored_param_uuids`
      }
      if (!is.null(self$`result_format`)) {
        GenericUDFObject[['result_format']] <-
          self$`result_format`$toJSON()
      }
      if (!is.null(self$`task_name`)) {
        GenericUDFObject[['task_name']] <-
          self$`task_name`
      }
      if (!is.null(self$`store_results`)) {
        GenericUDFObject[['store_results']] <-
          self$`store_results`
      }
      if (!is.null(self$`timeout`)) {
        GenericUDFObject[['timeout']] <-
          self$`timeout`
      }
      if (!is.null(self$`dont_download_results`)) {
        GenericUDFObject[['dont_download_results']] <-
          self$`dont_download_results`
      }
      if (!is.null(self$`task_graph_uuid`)) {
        GenericUDFObject[['task_graph_uuid']] <-
          self$`task_graph_uuid`
      }
      if (!is.null(self$`client_node_uuid`)) {
        GenericUDFObject[['client_node_uuid']] <-
          self$`client_node_uuid`
      }

      GenericUDFObject
    },
    fromJSON = function(GenericUDFJson) {
      GenericUDFObject <- jsonlite::fromJSON(GenericUDFJson)
      if (!is.null(GenericUDFObject$`udf_info_name`)) {
        self$`udf_info_name` <- GenericUDFObject$`udf_info_name`
      }
      if (!is.null(GenericUDFObject$`language`)) {
        # MANUAL EDIT AFTER OPENAPI AUTOGEN
        # For enums, OpenAPI autogen (1) generates a constructor which requires being called
        # with one arguent; (2) generates callsites (such as here) that calls that constructor
        # with zero arguments.
        #
        #languageObject <- UDFLanguage$new()
        #languageObject$fromJSON(jsonlite::toJSON(GenericUDFObject$language, auto_unbox = TRUE, digits = NA))
        languageObject <- UDFLanguage$new(GenericUDFObject$language)
        self$`language` <- languageObject
      }
      if (!is.null(GenericUDFObject$`version`)) {
        self$`version` <- GenericUDFObject$`version`
      }
      if (!is.null(GenericUDFObject$`image_name`)) {
        self$`image_name` <- GenericUDFObject$`image_name`
      }
      if (!is.null(GenericUDFObject$`resource_class`)) {
        self$`resource_class` <- GenericUDFObject$`resource_class`
      }
      if (!is.null(GenericUDFObject$`exec`)) {
        self$`exec` <- GenericUDFObject$`exec`
      }
      if (!is.null(GenericUDFObject$`exec_raw`)) {
        self$`exec_raw` <- GenericUDFObject$`exec_raw`
      }
      if (!is.null(GenericUDFObject$`argument`)) {
        self$`argument` <- GenericUDFObject$`argument`
      }
      if (!is.null(GenericUDFObject$`stored_param_uuids`)) {
        self$`stored_param_uuids` <- ApiClient$new()$deserializeObj(GenericUDFObject$`stored_param_uuids`, "array[character]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(GenericUDFObject$`result_format`)) {
        # MANUAL EDIT AFTER OPENAPI AUTOGEN
        # For enums, OpenAPI autogen (1) generates a constructor which requires being called
        # with one arguent; (2) generates callsites (such as here) that calls that constructor
        # with zero arguments.
        #
        #result_formatObject <- ResultFormat$new()
        #result_formatObject$fromJSON(jsonlite::toJSON(GenericUDFObject$result_format, auto_unbox = TRUE, digits = NA))
        result_formatObject <- ResultFormat$new(GenericUDFObject$result_format)
        self$`result_format` <- result_formatObject
      }
      if (!is.null(GenericUDFObject$`task_name`)) {
        self$`task_name` <- GenericUDFObject$`task_name`
      }
      if (!is.null(GenericUDFObject$`store_results`)) {
        self$`store_results` <- GenericUDFObject$`store_results`
      }
      if (!is.null(GenericUDFObject$`timeout`)) {
        self$`timeout` <- GenericUDFObject$`timeout`
      }
      if (!is.null(GenericUDFObject$`dont_download_results`)) {
        self$`dont_download_results` <- GenericUDFObject$`dont_download_results`
      }
      if (!is.null(GenericUDFObject$`task_graph_uuid`)) {
        self$`task_graph_uuid` <- GenericUDFObject$`task_graph_uuid`
      }
      if (!is.null(GenericUDFObject$`client_node_uuid`)) {
        self$`client_node_uuid` <- GenericUDFObject$`client_node_uuid`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`udf_info_name`)) {
        sprintf(
        '"udf_info_name":
          "%s"
                ',
        self$`udf_info_name`
        )},
        if (!is.null(self$`language`)) {
        sprintf(
        '"language":
        %s
        ',
        jsonlite::toJSON(self$`language`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`version`)) {
        sprintf(
        '"version":
          "%s"
                ',
        self$`version`
        )},
        if (!is.null(self$`image_name`)) {
        sprintf(
        '"image_name":
          "%s"
                ',
        self$`image_name`
        )},
        if (!is.null(self$`resource_class`)) {
        sprintf(
        '"resource_class":
          "%s"
                ',
        self$`resource_class`
        )},
        if (!is.null(self$`exec`)) {
        sprintf(
        '"exec":
          "%s"
                ',
        self$`exec`
        )},
        if (!is.null(self$`exec_raw`)) {
        sprintf(
        '"exec_raw":
          "%s"
                ',
        self$`exec_raw`
        )},
        if (!is.null(self$`argument`)) {
        sprintf(
        '"argument":
          "%s"
                ',
        self$`argument`
        )},
        if (!is.null(self$`stored_param_uuids`)) {
        sprintf(
        '"stored_param_uuids":
           [%s]
        ',
        paste(unlist(lapply(self$`stored_param_uuids`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`result_format`)) {
        sprintf(
        '"result_format":
        %s
        ',
        jsonlite::toJSON(self$`result_format`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`task_name`)) {
        sprintf(
        '"task_name":
          "%s"
                ',
        self$`task_name`
        )},
        if (!is.null(self$`store_results`)) {
        sprintf(
        '"store_results":
          "%s"
                ',
        self$`store_results`
        )},
        if (!is.null(self$`timeout`)) {
        sprintf(
        '"timeout":
          %d
                ',
        self$`timeout`
        )},
        if (!is.null(self$`dont_download_results`)) {
        sprintf(
        '"dont_download_results":
          "%s"
                ',
        self$`dont_download_results`
        )},
        if (!is.null(self$`task_graph_uuid`)) {
        sprintf(
        '"task_graph_uuid":
          "%s"
                ',
        self$`task_graph_uuid`
        )},
        if (!is.null(self$`client_node_uuid`)) {
        sprintf(
        '"client_node_uuid":
          "%s"
                ',
        self$`client_node_uuid`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(GenericUDFJson) {
      GenericUDFObject <- jsonlite::fromJSON(GenericUDFJson)
      self$`udf_info_name` <- GenericUDFObject$`udf_info_name`
      self$`language` <- UDFLanguage$new()$fromJSON(jsonlite::toJSON(GenericUDFObject$language, auto_unbox = TRUE, digits = NA))
      self$`version` <- GenericUDFObject$`version`
      self$`image_name` <- GenericUDFObject$`image_name`
      self$`resource_class` <- GenericUDFObject$`resource_class`
      self$`exec` <- GenericUDFObject$`exec`
      self$`exec_raw` <- GenericUDFObject$`exec_raw`
      self$`argument` <- GenericUDFObject$`argument`
      self$`stored_param_uuids` <- ApiClient$new()$deserializeObj(GenericUDFObject$`stored_param_uuids`, "array[character]", loadNamespace("tiledbcloud"))
      self$`result_format` <- ResultFormat$new()$fromJSON(jsonlite::toJSON(GenericUDFObject$result_format, auto_unbox = TRUE, digits = NA))
      self$`task_name` <- GenericUDFObject$`task_name`
      self$`store_results` <- GenericUDFObject$`store_results`
      self$`timeout` <- GenericUDFObject$`timeout`
      self$`dont_download_results` <- GenericUDFObject$`dont_download_results`
      self$`task_graph_uuid` <- GenericUDFObject$`task_graph_uuid`
      self$`client_node_uuid` <- GenericUDFObject$`client_node_uuid`
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.