R/permission_report.R

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

#' @docType class
#' @title PermissionReport
#'
#' @description PermissionReport Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field workspaceACL  named list( \link{WorkspaceAccessEntry} ) 
#'
#' @field referencedMethods  list( \link{EntityAccessControl} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
PermissionReport <- R6::R6Class(
  'PermissionReport',
  public = list(
    `workspaceACL` = NULL,
    `referencedMethods` = NULL,
    initialize = function(
        `workspaceACL`, `referencedMethods`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`workspaceACL`)) {
        stopifnot(is.vector(`workspaceACL`), length(`workspaceACL`) != 0)
        sapply(`workspaceACL`, function(x) stopifnot(R6::is.R6(x)))
        self$`workspaceACL` <- `workspaceACL`
      }
      if (!missing(`referencedMethods`)) {
        stopifnot(is.vector(`referencedMethods`), length(`referencedMethods`) != 0)
        sapply(`referencedMethods`, function(x) stopifnot(R6::is.R6(x)))
        self$`referencedMethods` <- `referencedMethods`
      }
    },
    toJSON = function() {
      PermissionReportObject <- list()
      if (!is.null(self$`workspaceACL`)) {
        PermissionReportObject[['workspaceACL']] <-
          lapply(self$`workspaceACL`, function(x) x$toJSON())
      }
      if (!is.null(self$`referencedMethods`)) {
        PermissionReportObject[['referencedMethods']] <-
          lapply(self$`referencedMethods`, function(x) x$toJSON())
      }

      PermissionReportObject
    },
    fromJSON = function(PermissionReportJson) {
      PermissionReportObject <- jsonlite::fromJSON(PermissionReportJson)
      if (!is.null(PermissionReportObject$`workspaceACL`)) {
        self$`workspaceACL` <- ApiClient$new()$deserializeObj(PermissionReportObject$`workspaceACL`, "map(WorkspaceAccessEntry)", loadNamespace("openapi"))
      }
      if (!is.null(PermissionReportObject$`referencedMethods`)) {
        self$`referencedMethods` <- ApiClient$new()$deserializeObj(PermissionReportObject$`referencedMethods`, "array[EntityAccessControl]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`workspaceACL`)) {
        sprintf(
        '"workspaceACL":
        %s
',
        jsonlite::toJSON(lapply(self$`workspaceACL`, function(x){ x$toJSON() }), auto_unbox = TRUE, digits=NA)
        )},
        if (!is.null(self$`referencedMethods`)) {
        sprintf(
        '"referencedMethods":
        [%s]
',
        paste(sapply(self$`referencedMethods`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(PermissionReportJson) {
      PermissionReportObject <- jsonlite::fromJSON(PermissionReportJson)
      self$`workspaceACL` <- ApiClient$new()$deserializeObj(PermissionReportObject$`workspaceACL`, "map(WorkspaceAccessEntry)", loadNamespace("openapi"))
      self$`referencedMethods` <- ApiClient$new()$deserializeObj(PermissionReportObject$`referencedMethods`, "array[EntityAccessControl]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.