R/descriptor_type.R

Defines functions .parse_DescriptorType

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title DescriptorType
#'
#' @description DescriptorType Class
#'
#' @format An \code{R6Class} generator object
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DescriptorType <- R6::R6Class(
    "DescriptorType",
    public = list(
        initialize = function(...) {
            local.optional.var <- list(...)
            val <- unlist(local.optional.var)
            enumvec <- .parse_DescriptorType()

            stopifnot(length(val) == 1L)

            if (!val %in% enumvec)
                stop("Use one of the valid values: ",
                    paste0(enumvec, collapse = ", "))
            private$value <- val
        },
        toJSON = function() {
            jsonlite::toJSON(private$value, auto_unbox = TRUE)
        },
        fromJSON = function(DescriptorTypeJson) {
            private$value <- jsonlite::fromJSON(DescriptorTypeJson,
                simplifyVector = FALSE)
            self
        },
        toJSONString = function() {
            as.character(jsonlite::toJSON(private$value,
                auto_unbox = TRUE))
        },
        fromJSONString = function(DescriptorTypeJson) {
            private$value <- jsonlite::fromJSON(DescriptorTypeJson,
                simplifyVector = FALSE)
            self
        }
    ),
    private = list(
        value = NULL
    )
)

# add to utils.R
.parse_DescriptorType <- function(vals) {
    res <- gsub("^\\[|\\]$", "",
        "[CWL, WDL]"
    )
    unlist(strsplit(res, ", "))
}
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.