R/udf_language.R

Defines functions .parse_UDFLanguage

# 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 UDFLanguage
#'
#' @description UDFLanguage Class
#'
#' @format An \code{R6Class} generator object
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
UDFLanguage <- R6::R6Class(
    "UDFLanguage",
    public = list(
        initialize = function(...) {
            local.optional.var <- list(...)
            val <- unlist(local.optional.var)

            # MANUAL EDIT AFTER OPENAPI AUTOGEN
            .check_openapi_enum("UDFLanguage", val, .parse_UDFLanguage())

            private$value <- val
        },
        toJSON = function() {
            # MANUAL EDIT AFTER OPENAPI AUTOGEN
            #
            # The name toJSON is a misnomer -- its output is not a string.
            # The name toJSONString is correct -- its output is a string.
            # The way this works for HTTP/JSON serdes is a top-level R6 object
            # (like GenericUDF) gets its toJSONString invoked; that in turn
            # recursively invokes toJSON on various subattributes.
            #
            # This default logic written by OpenAPI results in JSON like
            # { ..., "language": "\"r\"", ... }
            # Here, we make sure that instead the following is generated:
            # { ..., "languae": "r", ... }
            #
            # jsonlite::toJSON(private$value, auto_unbox = TRUE)
            private$value
        },
        fromJSON = function(UDFLanguageJson) {
            private$value <- jsonlite::fromJSON(UDFLanguageJson,
                simplifyVector = FALSE)
            self
        },
        toJSONString = function() {
            as.character(jsonlite::toJSON(private$value,
                auto_unbox = TRUE))
        },
        fromJSONString = function(UDFLanguageJson) {
            private$value <- jsonlite::fromJSON(UDFLanguageJson,
                simplifyVector = FALSE)
            self
        }
    ),
    private = list(
        value = NULL
    )
)

# add to utils.R
.parse_UDFLanguage <- function(vals) {
    res <- gsub("^\\[|\\]$", "",
        "[python, r]"
    )
    unlist(strsplit(res, ", "))
}
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.