R/user.R

# TileDB Storage Platform API
#
# TileDB Storage Platform REST API
#
# The version of the OpenAPI document: 2.2.19
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title User
#'
#' @description User Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field id  character [optional]
#'
#' @field username  character 
#'
#' @field password  character [optional]
#'
#' @field name  character [optional]
#'
#' @field email  character [optional]
#'
#' @field is_valid_email  character [optional]
#'
#' @field stripe_connect  character [optional]
#'
#' @field company  character [optional]
#'
#' @field logo  character [optional]
#'
#' @field last_activity_date  character [optional]
#'
#' @field timezone  character [optional]
#'
#' @field organizations  list( \link{OrganizationUser} ) [optional]
#'
#' @field allowed_actions  list( \link{NamespaceActions} ) [optional]
#'
#' @field enabled_features  list( character ) [optional]
#'
#' @field unpaid_subscription  character [optional]
#'
#' @field default_s3_path  character [optional]
#'
#' @field default_s3_path_credentials_name  character [optional]
#'
#' @field default_namespace_charged  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
User <- R6::R6Class(
  'User',
  public = list(
    `id` = NULL,
    `username` = NULL,
    `password` = NULL,
    `name` = NULL,
    `email` = NULL,
    `is_valid_email` = NULL,
    `stripe_connect` = NULL,
    `company` = NULL,
    `logo` = NULL,
    `last_activity_date` = NULL,
    `timezone` = NULL,
    `organizations` = NULL,
    `allowed_actions` = NULL,
    `enabled_features` = NULL,
    `unpaid_subscription` = NULL,
    `default_s3_path` = NULL,
    `default_s3_path_credentials_name` = NULL,
    `default_namespace_charged` = NULL,
    initialize = function(
        `username`, `id`=NULL, `password`=NULL, `name`=NULL, `email`=NULL, `is_valid_email`=NULL, `stripe_connect`=NULL, `company`=NULL, `logo`=NULL, `last_activity_date`=NULL, `timezone`=NULL, `organizations`=NULL, `allowed_actions`=NULL, `enabled_features`=NULL, `unpaid_subscription`=NULL, `default_s3_path`=NULL, `default_s3_path_credentials_name`=NULL, `default_namespace_charged`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!is.null(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!is.null(`password`)) {
        stopifnot(is.character(`password`), length(`password`) == 1)
        self$`password` <- `password`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`email`)) {
        stopifnot(is.character(`email`), length(`email`) == 1)
        self$`email` <- `email`
      }
      if (!is.null(`is_valid_email`)) {
        self$`is_valid_email` <- `is_valid_email`
      }
      if (!is.null(`stripe_connect`)) {
        self$`stripe_connect` <- `stripe_connect`
      }
      if (!is.null(`company`)) {
        stopifnot(is.character(`company`), length(`company`) == 1)
        self$`company` <- `company`
      }
      if (!is.null(`logo`)) {
        stopifnot(is.character(`logo`), length(`logo`) == 1)
        self$`logo` <- `logo`
      }
      if (!is.null(`last_activity_date`)) {
        stopifnot(is.character(`last_activity_date`), length(`last_activity_date`) == 1)
        self$`last_activity_date` <- `last_activity_date`
      }
      if (!is.null(`timezone`)) {
        stopifnot(is.character(`timezone`), length(`timezone`) == 1)
        self$`timezone` <- `timezone`
      }
      if (!is.null(`organizations`)) {
        stopifnot(is.vector(`organizations`), length(`organizations`) != 0)
        sapply(`organizations`, function(x) stopifnot(R6::is.R6(x)))
        self$`organizations` <- `organizations`
      }
      if (!is.null(`allowed_actions`)) {
        stopifnot(is.vector(`allowed_actions`), length(`allowed_actions`) != 0)
        sapply(`allowed_actions`, function(x) stopifnot(R6::is.R6(x)))
        self$`allowed_actions` <- `allowed_actions`
      }
      if (!is.null(`enabled_features`)) {
        stopifnot(is.vector(`enabled_features`), length(`enabled_features`) != 0)
        sapply(`enabled_features`, function(x) stopifnot(is.character(x)))
        self$`enabled_features` <- `enabled_features`
      }
      if (!is.null(`unpaid_subscription`)) {
        self$`unpaid_subscription` <- `unpaid_subscription`
      }
      if (!is.null(`default_s3_path`)) {
        stopifnot(is.character(`default_s3_path`), length(`default_s3_path`) == 1)
        self$`default_s3_path` <- `default_s3_path`
      }
      if (!is.null(`default_s3_path_credentials_name`)) {
        stopifnot(is.character(`default_s3_path_credentials_name`), length(`default_s3_path_credentials_name`) == 1)
        self$`default_s3_path_credentials_name` <- `default_s3_path_credentials_name`
      }
      if (!is.null(`default_namespace_charged`)) {
        stopifnot(is.character(`default_namespace_charged`), length(`default_namespace_charged`) == 1)
        self$`default_namespace_charged` <- `default_namespace_charged`
      }
    },
    toJSON = function() {
      UserObject <- list()
      if (!is.null(self$`id`)) {
        UserObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`username`)) {
        UserObject[['username']] <-
          self$`username`
      }
      if (!is.null(self$`password`)) {
        UserObject[['password']] <-
          self$`password`
      }
      if (!is.null(self$`name`)) {
        UserObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`email`)) {
        UserObject[['email']] <-
          self$`email`
      }
      if (!is.null(self$`is_valid_email`)) {
        UserObject[['is_valid_email']] <-
          self$`is_valid_email`
      }
      if (!is.null(self$`stripe_connect`)) {
        UserObject[['stripe_connect']] <-
          self$`stripe_connect`
      }
      if (!is.null(self$`company`)) {
        UserObject[['company']] <-
          self$`company`
      }
      if (!is.null(self$`logo`)) {
        UserObject[['logo']] <-
          self$`logo`
      }
      if (!is.null(self$`last_activity_date`)) {
        UserObject[['last_activity_date']] <-
          self$`last_activity_date`
      }
      if (!is.null(self$`timezone`)) {
        UserObject[['timezone']] <-
          self$`timezone`
      }
      if (!is.null(self$`organizations`)) {
        UserObject[['organizations']] <-
          lapply(self$`organizations`, function(x) x$toJSON())
      }
      if (!is.null(self$`allowed_actions`)) {
        UserObject[['allowed_actions']] <-
          lapply(self$`allowed_actions`, function(x) x$toJSON())
      }
      if (!is.null(self$`enabled_features`)) {
        UserObject[['enabled_features']] <-
          self$`enabled_features`
      }
      if (!is.null(self$`unpaid_subscription`)) {
        UserObject[['unpaid_subscription']] <-
          self$`unpaid_subscription`
      }
      if (!is.null(self$`default_s3_path`)) {
        UserObject[['default_s3_path']] <-
          self$`default_s3_path`
      }
      if (!is.null(self$`default_s3_path_credentials_name`)) {
        UserObject[['default_s3_path_credentials_name']] <-
          self$`default_s3_path_credentials_name`
      }
      if (!is.null(self$`default_namespace_charged`)) {
        UserObject[['default_namespace_charged']] <-
          self$`default_namespace_charged`
      }

      UserObject
    },
    fromJSON = function(UserJson) {
      UserObject <- jsonlite::fromJSON(UserJson)
      if (!is.null(UserObject$`id`)) {
        self$`id` <- UserObject$`id`
      }
      if (!is.null(UserObject$`username`)) {
        self$`username` <- UserObject$`username`
      }
      if (!is.null(UserObject$`password`)) {
        self$`password` <- UserObject$`password`
      }
      if (!is.null(UserObject$`name`)) {
        self$`name` <- UserObject$`name`
      }
      if (!is.null(UserObject$`email`)) {
        self$`email` <- UserObject$`email`
      }
      if (!is.null(UserObject$`is_valid_email`)) {
        self$`is_valid_email` <- UserObject$`is_valid_email`
      }
      if (!is.null(UserObject$`stripe_connect`)) {
        self$`stripe_connect` <- UserObject$`stripe_connect`
      }
      if (!is.null(UserObject$`company`)) {
        self$`company` <- UserObject$`company`
      }
      if (!is.null(UserObject$`logo`)) {
        self$`logo` <- UserObject$`logo`
      }
      if (!is.null(UserObject$`last_activity_date`)) {
        self$`last_activity_date` <- UserObject$`last_activity_date`
      }
      if (!is.null(UserObject$`timezone`)) {
        self$`timezone` <- UserObject$`timezone`
      }
      if (!is.null(UserObject$`organizations`)) {
        self$`organizations` <- ApiClient$new()$deserializeObj(UserObject$`organizations`, "array[OrganizationUser]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(UserObject$`allowed_actions`)) {
        self$`allowed_actions` <- ApiClient$new()$deserializeObj(UserObject$`allowed_actions`, "array[NamespaceActions]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(UserObject$`enabled_features`)) {
        self$`enabled_features` <- ApiClient$new()$deserializeObj(UserObject$`enabled_features`, "array[character]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(UserObject$`unpaid_subscription`)) {
        self$`unpaid_subscription` <- UserObject$`unpaid_subscription`
      }
      if (!is.null(UserObject$`default_s3_path`)) {
        self$`default_s3_path` <- UserObject$`default_s3_path`
      }
      if (!is.null(UserObject$`default_s3_path_credentials_name`)) {
        self$`default_s3_path_credentials_name` <- UserObject$`default_s3_path_credentials_name`
      }
      if (!is.null(UserObject$`default_namespace_charged`)) {
        self$`default_namespace_charged` <- UserObject$`default_namespace_charged`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`id`)) {
        sprintf(
        '"id":
          "%s"
                ',
        self$`id`
        )},
        if (!is.null(self$`username`)) {
        sprintf(
        '"username":
          "%s"
                ',
        self$`username`
        )},
        if (!is.null(self$`password`)) {
        sprintf(
        '"password":
          "%s"
                ',
        self$`password`
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`email`)) {
        sprintf(
        '"email":
          "%s"
                ',
        self$`email`
        )},
        if (!is.null(self$`is_valid_email`)) {
        sprintf(
        '"is_valid_email":
          "%s"
                ',
        self$`is_valid_email`
        )},
        if (!is.null(self$`stripe_connect`)) {
        sprintf(
        '"stripe_connect":
          "%s"
                ',
        self$`stripe_connect`
        )},
        if (!is.null(self$`company`)) {
        sprintf(
        '"company":
          "%s"
                ',
        self$`company`
        )},
        if (!is.null(self$`logo`)) {
        sprintf(
        '"logo":
          "%s"
                ',
        self$`logo`
        )},
        if (!is.null(self$`last_activity_date`)) {
        sprintf(
        '"last_activity_date":
          "%s"
                ',
        self$`last_activity_date`
        )},
        if (!is.null(self$`timezone`)) {
        sprintf(
        '"timezone":
          "%s"
                ',
        self$`timezone`
        )},
        if (!is.null(self$`organizations`)) {
        sprintf(
        '"organizations":
        [%s]
',
        paste(sapply(self$`organizations`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`allowed_actions`)) {
        sprintf(
        '"allowed_actions":
        [%s]
',
        paste(sapply(self$`allowed_actions`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`enabled_features`)) {
        sprintf(
        '"enabled_features":
           [%s]
        ',
        paste(unlist(lapply(self$`enabled_features`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`unpaid_subscription`)) {
        sprintf(
        '"unpaid_subscription":
          "%s"
                ',
        self$`unpaid_subscription`
        )},
        if (!is.null(self$`default_s3_path`)) {
        sprintf(
        '"default_s3_path":
          "%s"
                ',
        self$`default_s3_path`
        )},
        if (!is.null(self$`default_s3_path_credentials_name`)) {
        sprintf(
        '"default_s3_path_credentials_name":
          "%s"
                ',
        self$`default_s3_path_credentials_name`
        )},
        if (!is.null(self$`default_namespace_charged`)) {
        sprintf(
        '"default_namespace_charged":
          "%s"
                ',
        self$`default_namespace_charged`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(UserJson) {
      UserObject <- jsonlite::fromJSON(UserJson)
      self$`id` <- UserObject$`id`
      self$`username` <- UserObject$`username`
      self$`password` <- UserObject$`password`
      self$`name` <- UserObject$`name`
      self$`email` <- UserObject$`email`
      self$`is_valid_email` <- UserObject$`is_valid_email`
      self$`stripe_connect` <- UserObject$`stripe_connect`
      self$`company` <- UserObject$`company`
      self$`logo` <- UserObject$`logo`
      self$`last_activity_date` <- UserObject$`last_activity_date`
      self$`timezone` <- UserObject$`timezone`
      self$`organizations` <- ApiClient$new()$deserializeObj(UserObject$`organizations`, "array[OrganizationUser]", loadNamespace("tiledbcloud"))
      self$`allowed_actions` <- ApiClient$new()$deserializeObj(UserObject$`allowed_actions`, "array[NamespaceActions]", loadNamespace("tiledbcloud"))
      self$`enabled_features` <- ApiClient$new()$deserializeObj(UserObject$`enabled_features`, "array[character]", loadNamespace("tiledbcloud"))
      self$`unpaid_subscription` <- UserObject$`unpaid_subscription`
      self$`default_s3_path` <- UserObject$`default_s3_path`
      self$`default_s3_path_credentials_name` <- UserObject$`default_s3_path_credentials_name`
      self$`default_namespace_charged` <- UserObject$`default_namespace_charged`
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.