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


#' FilePermissionRequest Class
#'
#' The permission to apply for the given user onthe given resource
#'
#' @field username The name of the user for this permission object.
#' @field permission 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FilePermissionRequest <- R6::R6Class(
  'FilePermissionRequest',
  public = list(
    `username` = NULL,
    `permission` = NULL,
    initialize = function(`username`, `permission`){
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!missing(`permission`)) {
        stopifnot(R6::is.R6(`permission`))
        self$`permission` <- `permission`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      FilePermissionRequestObject <- list()
      if (!is.null(self$`username`)) {
        FilePermissionRequestObject[['username']] <- self$`username`
      }
      else {
        FilePermissionRequestObject[['username']] <- NULL
      }
      if (!is.null(self$`permission`)) {
        FilePermissionRequestObject[['permission']] <- self$`permission`$toJSON()
      }
      else {
        FilePermissionRequestObject[['permission']] <- NULL
      }

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

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

      if (!is.null(FilePermissionRequestObject$`username`)) {
        self$`username` <- FilePermissionRequestObject$`username`
      }
      if (!is.null(FilePermissionRequestObject$`permission`)) {
        permissionObject <- PermissionType$new()
        permissionObject$fromJSON(jsonlite::toJSON(FilePermissionRequestObject$permission, auto_unbox = TRUE))
        self$`permission` <- permissionObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "username": %s,
           "permission": %s
        }',
        ifelse( is.null(self$`username`),"null",paste0(c('"', self$`username`, '"'))),
        self$`permission`$toJSON()
      )
    },
    fromJSONString = function(FilePermissionRequestJson) {
      FilePermissionRequestObject <- jsonlite::fromJSON(FilePermissionRequestJson)
      self::fromJSON(FilePermissionRequestObject)

    }
  )
)
deardooley/agave-rlang-sdk documentation built on May 17, 2019, 10:12 p.m.