R/SystemRoleRequest.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


#' SystemRoleRequest Class
#'
#' A basic role granted to a user for a particular system
#'
#' @field username The username of the api user granted this role.
#' @field role 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SystemRoleRequest <- R6::R6Class(
  'SystemRoleRequest',
  public = list(
    `username` = NULL,
    `role` = NULL,
    initialize = function(`username`, `role`){
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!missing(`role`)) {
        stopifnot(R6::is.R6(`role`))
        self$`role` <- `role`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      SystemRoleRequestObject <- list()
      if (!is.null(self$`username`)) {
        SystemRoleRequestObject[['username']] <- self$`username`
      }
      else {
        SystemRoleRequestObject[['username']] <- NULL
      }
      if (!is.null(self$`role`)) {
        SystemRoleRequestObject[['role']] <- self$`role`$toJSON()
      }
      else {
        SystemRoleRequestObject[['role']] <- NULL
      }

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

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

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

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