R/UserProfile.r

# Dkube api server
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 2.2.1.11
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' UserProfile Class
#'
#' @field name 
#' @field uid 
#' @field user 
#' @field homedir 
#' @field options 
#' @field shareddir 
#' @field extra_mounts 
#' @field limits 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
UserProfile <- R6::R6Class(
  'UserProfile',
  public = list(
    `name` = NULL,
    `uid` = NULL,
    `user` = NULL,
    `homedir` = NULL,
    `options` = NULL,
    `shareddir` = NULL,
    `extra_mounts` = NULL,
    `limits` = NULL,
    initialize = function(`name`, `uid`, `user`, `homedir`, `options`, `shareddir`, `extra_mounts`, `limits`){
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`uid`)) {
        stopifnot(is.character(`uid`), length(`uid`) == 1)
        self$`uid` <- `uid`
      }
      if (!missing(`user`)) {
        stopifnot(is.character(`user`), length(`user`) == 1)
        self$`user` <- `user`
      }
      if (!missing(`homedir`)) {
        stopifnot(is.character(`homedir`), length(`homedir`) == 1)
        self$`homedir` <- `homedir`
      }
      if (!missing(`options`)) {
        stopifnot(is.list(`options`), length(`options`) != 0)
        lapply(`options`, function(x) stopifnot(R6::is.R6(x)))
        self$`options` <- `options`
      }
      if (!missing(`shareddir`)) {
        stopifnot(is.character(`shareddir`), length(`shareddir`) == 1)
        self$`shareddir` <- `shareddir`
      }
      if (!missing(`extra_mounts`)) {
        stopifnot(is.list(`extra_mounts`), length(`extra_mounts`) != 0)
        lapply(`extra_mounts`, function(x) stopifnot(is.character(x)))
        self$`extra_mounts` <- `extra_mounts`
      }
      if (!missing(`limits`)) {
        stopifnot(R6::is.R6(`limits`))
        self$`limits` <- `limits`
      }
    },
    toJSON = function() {
      UserProfileObject <- list()
      if (!is.null(self$`name`)) {
        UserProfileObject[['name']] <- self$`name`
      }
      if (!is.null(self$`uid`)) {
        UserProfileObject[['uid']] <- self$`uid`
      }
      if (!is.null(self$`user`)) {
        UserProfileObject[['user']] <- self$`user`
      }
      if (!is.null(self$`homedir`)) {
        UserProfileObject[['homedir']] <- self$`homedir`
      }
      if (!is.null(self$`options`)) {
        UserProfileObject[['options']] <- lapply(self$`options`, function(x) x$toJSON())
      }
      if (!is.null(self$`shareddir`)) {
        UserProfileObject[['shareddir']] <- self$`shareddir`
      }
      if (!is.null(self$`extra_mounts`)) {
        UserProfileObject[['extra_mounts']] <- self$`extra_mounts`
      }
      if (!is.null(self$`limits`)) {
        UserProfileObject[['limits']] <- self$`limits`$toJSON()
      }

      UserProfileObject
    },
    fromJSON = function(UserProfileJson) {
      UserProfileObject <- jsonlite::fromJSON(UserProfileJson)
      if (!is.null(UserProfileObject$`name`)) {
        self$`name` <- UserProfileObject$`name`
      }
      if (!is.null(UserProfileObject$`uid`)) {
        self$`uid` <- UserProfileObject$`uid`
      }
      if (!is.null(UserProfileObject$`user`)) {
        self$`user` <- UserProfileObject$`user`
      }
      if (!is.null(UserProfileObject$`homedir`)) {
        self$`homedir` <- UserProfileObject$`homedir`
      }
      if (!is.null(UserProfileObject$`options`)) {
        self$`options` <- lapply(UserProfileObject$`options`, function(x) {
          optionsObject <- UserProfileOptions$new()
          optionsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          optionsObject
        })
      }
      if (!is.null(UserProfileObject$`shareddir`)) {
        self$`shareddir` <- UserProfileObject$`shareddir`
      }
      if (!is.null(UserProfileObject$`extra_mounts`)) {
        self$`extra_mounts` <- UserProfileObject$`extra_mounts`
      }
      if (!is.null(UserProfileObject$`limits`)) {
        limitsObject <- UserProfileLimits$new()
        limitsObject$fromJSON(jsonlite::toJSON(UserProfileObject$limits, auto_unbox = TRUE))
        self$`limits` <- limitsObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "name": %s,
           "uid": %s,
           "user": %s,
           "homedir": %s,
           "options": [%s],
           "shareddir": %s,
           "extra_mounts": [%s],
           "limits": %s
        }',
        self$`name`,
        self$`uid`,
        self$`user`,
        self$`homedir`,
        lapply(self$`options`, function(x) paste(x$toJSON(), sep=",")),
        self$`shareddir`,
        lapply(self$`extra_mounts`, function(x) paste(paste0('"', x, '"'), sep=",")),
        self$`limits`$toJSON()
      )
    },
    fromJSONString = function(UserProfileJson) {
      UserProfileObject <- jsonlite::fromJSON(UserProfileJson)
      self$`name` <- UserProfileObject$`name`
      self$`uid` <- UserProfileObject$`uid`
      self$`user` <- UserProfileObject$`user`
      self$`homedir` <- UserProfileObject$`homedir`
      self$`options` <- lapply(UserProfileObject$`options`, function(x) UserProfileOptions$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
      self$`shareddir` <- UserProfileObject$`shareddir`
      self$`extra_mounts` <- UserProfileObject$`extra_mounts`
      UserProfileLimitsObject <- UserProfileLimits$new()
      self$`limits` <- UserProfileLimitsObject$fromJSON(jsonlite::toJSON(UserProfileObject$limits, auto_unbox = TRUE))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.