R/method_acl_pair.R

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

#' @docType class
#' @title MethodAclPair
#'
#' @description MethodAclPair Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field method  \link{MethodRepoMethod} 
#'
#' @field acls  list( \link{FireCloudPermission} ) 
#'
#' @field message  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
MethodAclPair <- R6::R6Class(
  'MethodAclPair',
  public = list(
    `method` = NULL,
    `acls` = NULL,
    `message` = NULL,
    initialize = function(
        `method`, `acls`, `message`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`method`)) {
        stopifnot(R6::is.R6(`method`))
        self$`method` <- `method`
      }
      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(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
    },
    toJSON = function() {
      MethodAclPairObject <- list()
      if (!is.null(self$`method`)) {
        MethodAclPairObject[['method']] <-
          self$`method`$toJSON()
      }
      if (!is.null(self$`acls`)) {
        MethodAclPairObject[['acls']] <-
          lapply(self$`acls`, function(x) x$toJSON())
      }
      if (!is.null(self$`message`)) {
        MethodAclPairObject[['message']] <-
          self$`message`
      }

      MethodAclPairObject
    },
    fromJSON = function(MethodAclPairJson) {
      MethodAclPairObject <- jsonlite::fromJSON(MethodAclPairJson)
      if (!is.null(MethodAclPairObject$`method`)) {
        methodObject <- MethodRepoMethod$new()
        methodObject$fromJSON(jsonlite::toJSON(MethodAclPairObject$method, auto_unbox = TRUE, digits = NA))
        self$`method` <- methodObject
      }
      if (!is.null(MethodAclPairObject$`acls`)) {
        self$`acls` <- ApiClient$new()$deserializeObj(MethodAclPairObject$`acls`, "array[FireCloudPermission]", loadNamespace("openapi"))
      }
      if (!is.null(MethodAclPairObject$`message`)) {
        self$`message` <- MethodAclPairObject$`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$`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(MethodAclPairJson) {
      MethodAclPairObject <- jsonlite::fromJSON(MethodAclPairJson)
      self$`method` <- MethodRepoMethod$new()$fromJSON(jsonlite::toJSON(MethodAclPairObject$method, auto_unbox = TRUE, digits = NA))
      self$`acls` <- ApiClient$new()$deserializeObj(MethodAclPairObject$`acls`, "array[FireCloudPermission]", loadNamespace("openapi"))
      self$`message` <- MethodAclPairObject$`message`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.