R/entity_access_control.R

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

#' @docType class
#' @title EntityAccessControl
#'
#' @description EntityAccessControl Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field method  \link{MethodShort} [optional]
#'
#' @field referencedBy  \link{MethodConfigurationName} 
#'
#' @field acls  list( \link{FireCloudPermission} ) 
#'
#' @field message  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
EntityAccessControl <- R6::R6Class(
  'EntityAccessControl',
  public = list(
    `method` = NULL,
    `referencedBy` = NULL,
    `acls` = NULL,
    `message` = NULL,
    initialize = function(
        `referencedBy`, `acls`, `method`=NULL, `message`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`referencedBy`)) {
        stopifnot(R6::is.R6(`referencedBy`))
        self$`referencedBy` <- `referencedBy`
      }
      if (!missing(`acls`)) {
        stopifnot(is.vector(`acls`), length(`acls`) != 0)
        sapply(`acls`, function(x) stopifnot(R6::is.R6(x)))
        self$`acls` <- `acls`
      }
      if (!is.null(`method`)) {
        stopifnot(R6::is.R6(`method`))
        self$`method` <- `method`
      }
      if (!is.null(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
    },
    toJSON = function() {
      EntityAccessControlObject <- list()
      if (!is.null(self$`method`)) {
        EntityAccessControlObject[['method']] <-
          self$`method`$toJSON()
      }
      if (!is.null(self$`referencedBy`)) {
        EntityAccessControlObject[['referencedBy']] <-
          self$`referencedBy`$toJSON()
      }
      if (!is.null(self$`acls`)) {
        EntityAccessControlObject[['acls']] <-
          lapply(self$`acls`, function(x) x$toJSON())
      }
      if (!is.null(self$`message`)) {
        EntityAccessControlObject[['message']] <-
          self$`message`
      }

      EntityAccessControlObject
    },
    fromJSON = function(EntityAccessControlJson) {
      EntityAccessControlObject <- jsonlite::fromJSON(EntityAccessControlJson)
      if (!is.null(EntityAccessControlObject$`method`)) {
        methodObject <- MethodShort$new()
        methodObject$fromJSON(jsonlite::toJSON(EntityAccessControlObject$method, auto_unbox = TRUE, digits = NA))
        self$`method` <- methodObject
      }
      if (!is.null(EntityAccessControlObject$`referencedBy`)) {
        referencedByObject <- MethodConfigurationName$new()
        referencedByObject$fromJSON(jsonlite::toJSON(EntityAccessControlObject$referencedBy, auto_unbox = TRUE, digits = NA))
        self$`referencedBy` <- referencedByObject
      }
      if (!is.null(EntityAccessControlObject$`acls`)) {
        self$`acls` <- ApiClient$new()$deserializeObj(EntityAccessControlObject$`acls`, "array[FireCloudPermission]", loadNamespace("openapi"))
      }
      if (!is.null(EntityAccessControlObject$`message`)) {
        self$`message` <- EntityAccessControlObject$`message`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`method`)) {
        sprintf(
        '"method":
        %s
        ',
        jsonlite::toJSON(self$`method`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`referencedBy`)) {
        sprintf(
        '"referencedBy":
        %s
        ',
        jsonlite::toJSON(self$`referencedBy`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`acls`)) {
        sprintf(
        '"acls":
        [%s]
',
        paste(sapply(self$`acls`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`message`)) {
        sprintf(
        '"message":
          "%s"
                ',
        self$`message`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(EntityAccessControlJson) {
      EntityAccessControlObject <- jsonlite::fromJSON(EntityAccessControlJson)
      self$`method` <- MethodShort$new()$fromJSON(jsonlite::toJSON(EntityAccessControlObject$method, auto_unbox = TRUE, digits = NA))
      self$`referencedBy` <- MethodConfigurationName$new()$fromJSON(jsonlite::toJSON(EntityAccessControlObject$referencedBy, auto_unbox = TRUE, digits = NA))
      self$`acls` <- ApiClient$new()$deserializeObj(EntityAccessControlObject$`acls`, "array[FireCloudPermission]", loadNamespace("openapi"))
      self$`message` <- EntityAccessControlObject$`message`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.