R/result_format.R

Defines functions .parse_ResultFormat

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

            .check_openapi_enum("ResultFormat", val, .parse_ResultFormat())

            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
            # { ..., "result_format": "\"arrow\"", ... }
            # Here, we make sure that instead the following is generated:
            # { ..., "result_format": "arrow", ... }
            #
            # jsonlite::toJSON(private$value, auto_unbox = TRUE)
            private$value
        },
        fromJSON = function(ResultFormatJson) {
            private$value <- jsonlite::fromJSON(ResultFormatJson,
                simplifyVector = FALSE)
            self
        },
        toJSONString = function() {
            as.character(jsonlite::toJSON(private$value,
                auto_unbox = TRUE))
        },
        fromJSONString = function(ResultFormatJson) {
            private$value <- jsonlite::fromJSON(ResultFormatJson,
                simplifyVector = FALSE)
            self
        }
    ),
    private = list(
        value = NULL
    )
)

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