R/workspace_access_level.R

Defines functions .parse_WorkspaceAccessLevel

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

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

            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(WorkspaceAccessLevelJson) {
            private$value <- jsonlite::fromJSON(WorkspaceAccessLevelJson,
                simplifyVector = FALSE)
            self
        },
        toJSONString = function() {
            as.character(jsonlite::toJSON(private$value,
                auto_unbox = TRUE))
        },
        fromJSONString = function(WorkspaceAccessLevelJson) {
            private$value <- jsonlite::fromJSON(WorkspaceAccessLevelJson,
                simplifyVector = FALSE)
            self
        }
    ),
    private = list(
        value = NULL
    )
)

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