R/nih_status.R

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

#' @docType class
#' @title NihStatus
#'
#' @description NihStatus Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field linkedNihUsername  character 
#'
#' @field datasetPermissions  list( \link{DatasetPermission} ) [optional]
#'
#' @field linkExpireTime  integer [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
NihStatus <- R6::R6Class(
  'NihStatus',
  public = list(
    `linkedNihUsername` = NULL,
    `datasetPermissions` = NULL,
    `linkExpireTime` = NULL,
    initialize = function(
        `linkedNihUsername`, `datasetPermissions`=NULL, `linkExpireTime`=0, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`linkedNihUsername`)) {
        stopifnot(is.character(`linkedNihUsername`), length(`linkedNihUsername`) == 1)
        self$`linkedNihUsername` <- `linkedNihUsername`
      }
      if (!is.null(`datasetPermissions`)) {
        stopifnot(is.vector(`datasetPermissions`), length(`datasetPermissions`) != 0)
        sapply(`datasetPermissions`, function(x) stopifnot(R6::is.R6(x)))
        self$`datasetPermissions` <- `datasetPermissions`
      }
      if (!is.null(`linkExpireTime`)) {
        stopifnot(is.numeric(`linkExpireTime`), length(`linkExpireTime`) == 1)
        self$`linkExpireTime` <- `linkExpireTime`
      }
    },
    toJSON = function() {
      NihStatusObject <- list()
      if (!is.null(self$`linkedNihUsername`)) {
        NihStatusObject[['linkedNihUsername']] <-
          self$`linkedNihUsername`
      }
      if (!is.null(self$`datasetPermissions`)) {
        NihStatusObject[['datasetPermissions']] <-
          lapply(self$`datasetPermissions`, function(x) x$toJSON())
      }
      if (!is.null(self$`linkExpireTime`)) {
        NihStatusObject[['linkExpireTime']] <-
          self$`linkExpireTime`
      }

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