R/managed_group_with_members.R

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

#' @docType class
#' @title ManagedGroupWithMembers
#'
#' @description ManagedGroupWithMembers Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field membersGroup  \link{RawlsGroupShort} 
#'
#' @field adminsGroup  \link{RawlsGroupShort} 
#'
#' @field membersEmails  list( character ) 
#'
#' @field adminsEmails  list( character ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ManagedGroupWithMembers <- R6::R6Class(
  'ManagedGroupWithMembers',
  public = list(
    `membersGroup` = NULL,
    `adminsGroup` = NULL,
    `membersEmails` = NULL,
    `adminsEmails` = NULL,
    initialize = function(
        `membersGroup`, `adminsGroup`, `membersEmails`, `adminsEmails`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`membersGroup`)) {
        stopifnot(R6::is.R6(`membersGroup`))
        self$`membersGroup` <- `membersGroup`
      }
      if (!missing(`adminsGroup`)) {
        stopifnot(R6::is.R6(`adminsGroup`))
        self$`adminsGroup` <- `adminsGroup`
      }
      if (!missing(`membersEmails`)) {
        stopifnot(is.vector(`membersEmails`), length(`membersEmails`) != 0)
        sapply(`membersEmails`, function(x) stopifnot(is.character(x)))
        self$`membersEmails` <- `membersEmails`
      }
      if (!missing(`adminsEmails`)) {
        stopifnot(is.vector(`adminsEmails`), length(`adminsEmails`) != 0)
        sapply(`adminsEmails`, function(x) stopifnot(is.character(x)))
        self$`adminsEmails` <- `adminsEmails`
      }
    },
    toJSON = function() {
      ManagedGroupWithMembersObject <- list()
      if (!is.null(self$`membersGroup`)) {
        ManagedGroupWithMembersObject[['membersGroup']] <-
          self$`membersGroup`$toJSON()
      }
      if (!is.null(self$`adminsGroup`)) {
        ManagedGroupWithMembersObject[['adminsGroup']] <-
          self$`adminsGroup`$toJSON()
      }
      if (!is.null(self$`membersEmails`)) {
        ManagedGroupWithMembersObject[['membersEmails']] <-
          self$`membersEmails`
      }
      if (!is.null(self$`adminsEmails`)) {
        ManagedGroupWithMembersObject[['adminsEmails']] <-
          self$`adminsEmails`
      }

      ManagedGroupWithMembersObject
    },
    fromJSON = function(ManagedGroupWithMembersJson) {
      ManagedGroupWithMembersObject <- jsonlite::fromJSON(ManagedGroupWithMembersJson)
      if (!is.null(ManagedGroupWithMembersObject$`membersGroup`)) {
        membersGroupObject <- RawlsGroupShort$new()
        membersGroupObject$fromJSON(jsonlite::toJSON(ManagedGroupWithMembersObject$membersGroup, auto_unbox = TRUE, digits = NA))
        self$`membersGroup` <- membersGroupObject
      }
      if (!is.null(ManagedGroupWithMembersObject$`adminsGroup`)) {
        adminsGroupObject <- RawlsGroupShort$new()
        adminsGroupObject$fromJSON(jsonlite::toJSON(ManagedGroupWithMembersObject$adminsGroup, auto_unbox = TRUE, digits = NA))
        self$`adminsGroup` <- adminsGroupObject
      }
      if (!is.null(ManagedGroupWithMembersObject$`membersEmails`)) {
        self$`membersEmails` <- ApiClient$new()$deserializeObj(ManagedGroupWithMembersObject$`membersEmails`, "array[character]", loadNamespace("openapi"))
      }
      if (!is.null(ManagedGroupWithMembersObject$`adminsEmails`)) {
        self$`adminsEmails` <- ApiClient$new()$deserializeObj(ManagedGroupWithMembersObject$`adminsEmails`, "array[character]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`membersGroup`)) {
        sprintf(
        '"membersGroup":
        %s
        ',
        jsonlite::toJSON(self$`membersGroup`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`adminsGroup`)) {
        sprintf(
        '"adminsGroup":
        %s
        ',
        jsonlite::toJSON(self$`adminsGroup`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`membersEmails`)) {
        sprintf(
        '"membersEmails":
           [%s]
        ',
        paste(unlist(lapply(self$`membersEmails`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`adminsEmails`)) {
        sprintf(
        '"adminsEmails":
           [%s]
        ',
        paste(unlist(lapply(self$`adminsEmails`, function(x) paste0('"', x, '"'))), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ManagedGroupWithMembersJson) {
      ManagedGroupWithMembersObject <- jsonlite::fromJSON(ManagedGroupWithMembersJson)
      self$`membersGroup` <- RawlsGroupShort$new()$fromJSON(jsonlite::toJSON(ManagedGroupWithMembersObject$membersGroup, auto_unbox = TRUE, digits = NA))
      self$`adminsGroup` <- RawlsGroupShort$new()$fromJSON(jsonlite::toJSON(ManagedGroupWithMembersObject$adminsGroup, auto_unbox = TRUE, digits = NA))
      self$`membersEmails` <- ApiClient$new()$deserializeObj(ManagedGroupWithMembersObject$`membersEmails`, "array[character]", loadNamespace("openapi"))
      self$`adminsEmails` <- ApiClient$new()$deserializeObj(ManagedGroupWithMembersObject$`adminsEmails`, "array[character]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.