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


#' FilePermission Class
#'
#' A permission grant for a single file or folder.
#'
#' @field username The username to whom this permission grant applies
#' @field internalUsername The internal user associated with this permission
#' @field permission 
#' @field created The date the permission was created
#' @field lastUpdated The date the permission was last updated
#' @field id The unique id of this permission
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FilePermission <- R6::R6Class(
  'FilePermission',
  public = list(
    `username` = NULL,
    `internalUsername` = NULL,
    `permission` = NULL,
    `created` = NULL,
    `lastUpdated` = NULL,
    `id` = NULL,
    initialize = function(`username`, `internalUsername`, `permission`, `created`, `lastUpdated`, `id`){
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!missing(`internalUsername`)) {
        stopifnot(is.character(`internalUsername`), length(`internalUsername`) == 1)
        self$`internalUsername` <- `internalUsername`
      }
      if (!missing(`permission`)) {
        stopifnot(R6::is.R6(`permission`))
        self$`permission` <- `permission`
      }
      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() {
      FilePermissionObject <- list()
      if (!is.null(self$`username`)) {
        FilePermissionObject[['username']] <- self$`username`
      }
      else {
        FilePermissionObject[['username']] <- NULL
      }
      if (!is.null(self$`internalUsername`)) {
        FilePermissionObject[['internalUsername']] <- self$`internalUsername`
      }
      else {
        FilePermissionObject[['internalUsername']] <- NULL
      }
      if (!is.null(self$`permission`)) {
        FilePermissionObject[['permission']] <- self$`permission`$toJSON()
      }
      else {
        FilePermissionObject[['permission']] <- NULL
      }
      if (!is.null(self$`created`)) {
        FilePermissionObject[['created']] <- self$`created`
      }
      else {
        FilePermissionObject[['created']] <- NULL
      }
      if (!is.null(self$`lastUpdated`)) {
        FilePermissionObject[['lastUpdated']] <- self$`lastUpdated`
      }
      else {
        FilePermissionObject[['lastUpdated']] <- NULL
      }
      if (!is.null(self$`id`)) {
        FilePermissionObject[['id']] <- self$`id`
      }
      else {
        FilePermissionObject[['id']] <- NULL
      }

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

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

      if (!is.null(FilePermissionObject$`username`)) {
        self$`username` <- FilePermissionObject$`username`
      }
      if (!is.null(FilePermissionObject$`internalUsername`)) {
        self$`internalUsername` <- FilePermissionObject$`internalUsername`
      }
      if (!is.null(FilePermissionObject$`permission`)) {
        permissionObject <- PermissionStanza$new()
        permissionObject$fromJSON(jsonlite::toJSON(FilePermissionObject$permission, auto_unbox = TRUE))
        self$`permission` <- permissionObject
      }
      if (!is.null(FilePermissionObject$`created`)) {
        self$`created` <- FilePermissionObject$`created`
      }
      if (!is.null(FilePermissionObject$`lastUpdated`)) {
        self$`lastUpdated` <- FilePermissionObject$`lastUpdated`
      }
      if (!is.null(FilePermissionObject$`id`)) {
        self$`id` <- FilePermissionObject$`id`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "username": %s,
           "internalUsername": %s,
           "permission": %s,
           "created": %s,
           "lastUpdated": %s,
           "id": %s
        }',
        ifelse( is.null(self$`username`),"null",paste0(c('"', self$`username`, '"'))),
        ifelse( is.null(self$`internalUsername`),"null",paste0(c('"', self$`internalUsername`, '"'))),
        self$`permission`$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(FilePermissionJson) {
      FilePermissionObject <- jsonlite::fromJSON(FilePermissionJson)
      self::fromJSON(FilePermissionObject)

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