R/SystemRole.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' SystemRole Class
#'
#' A role granted a user on a system
#'
#' @field username The username to whom the role applies.
#' @field role 
#' @field created The date the role was first granted
#' @field lastUpdated The date the role was last updated.
#' @field id The unique id of this role grant
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SystemRole <- R6::R6Class(
  'SystemRole',
  public = list(
    `username` = NULL,
    `role` = NULL,
    `created` = NULL,
    `lastUpdated` = NULL,
    `id` = NULL,
    initialize = function(`username`, `role`, `created`, `lastUpdated`, `id`){
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!missing(`role`)) {
        stopifnot(R6::is.R6(`role`))
        self$`role` <- `role`
      }
      if (!missing(`created`)) {
        stopifnot(is.character(`created`), length(`created`) == 1)
        self$`created` <- `created`
      }
      if (!missing(`lastUpdated`)) {
        stopifnot(is.character(`lastUpdated`), length(`lastUpdated`) == 1)
        self$`lastUpdated` <- `lastUpdated`
      }
      if (!missing(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      SystemRoleObject <- list()
      if (!is.null(self$`username`)) {
        SystemRoleObject[['username']] <- self$`username`
      }
      else {
        SystemRoleObject[['username']] <- NULL
      }
      if (!is.null(self$`role`)) {
        SystemRoleObject[['role']] <- self$`role`$toJSON()
      }
      else {
        SystemRoleObject[['role']] <- NULL
      }
      if (!is.null(self$`created`)) {
        SystemRoleObject[['created']] <- self$`created`
      }
      else {
        SystemRoleObject[['created']] <- NULL
      }
      if (!is.null(self$`lastUpdated`)) {
        SystemRoleObject[['lastUpdated']] <- self$`lastUpdated`
      }
      else {
        SystemRoleObject[['lastUpdated']] <- NULL
      }
      if (!is.null(self$`id`)) {
        SystemRoleObject[['id']] <- self$`id`
      }
      else {
        SystemRoleObject[['id']] <- NULL
      }

      SystemRoleObject
    },
    fromJSON = function(SystemRoleObject) {
      if (is.character(SystemRoleObject)) {
        SystemRoleObject <- jsonlite::fromJSON(SystemRoleJson)
      }

      if ("result" %in% names(SystemRoleObject)) {
        SystemRoleObject <- SystemRoleObject$result
      }

      if (!is.null(SystemRoleObject$`username`)) {
        self$`username` <- SystemRoleObject$`username`
      }
      if (!is.null(SystemRoleObject$`role`)) {
        roleObject <- SystemRoleType$new()
        roleObject$fromJSON(jsonlite::toJSON(SystemRoleObject$role, auto_unbox = TRUE))
        self$`role` <- roleObject
      }
      if (!is.null(SystemRoleObject$`created`)) {
        self$`created` <- SystemRoleObject$`created`
      }
      if (!is.null(SystemRoleObject$`lastUpdated`)) {
        self$`lastUpdated` <- SystemRoleObject$`lastUpdated`
      }
      if (!is.null(SystemRoleObject$`id`)) {
        self$`id` <- SystemRoleObject$`id`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "username": %s,
           "role": %s,
           "created": %s,
           "lastUpdated": %s,
           "id": %s
        }',
        ifelse( is.null(self$`username`),"null",paste0(c('"', self$`username`, '"'))),
        self$`role`$toJSON(),
        ifelse( is.null(self$`created`),"null",paste0(c('"', self$`created`, '"'))),
        ifelse( is.null(self$`lastUpdated`),"null",paste0(c('"', self$`lastUpdated`, '"'))),
        ifelse( is.null(self$`id`),"null",paste0(c('"', self$`id`, '"')))
      )
    },
    fromJSONString = function(SystemRoleJson) {
      SystemRoleObject <- jsonlite::fromJSON(SystemRoleJson)
      self::fromJSON(SystemRoleObject)

    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.