R/token.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 Token
#'
#' @description Token Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field token  character [optional]
#'
#' @field name  character [optional]
#'
#' @field issued_at  character [optional]
#'
#' @field expires_at  character [optional]
#'
#' @field scope  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Token <- R6::R6Class(
  'Token',
  public = list(
    `token` = NULL,
    `name` = NULL,
    `issued_at` = NULL,
    `expires_at` = NULL,
    `scope` = NULL,
    initialize = function(
        `token`=NULL, `name`=NULL, `issued_at`=NULL, `expires_at`=NULL, `scope`='*', ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`token`)) {
        stopifnot(is.character(`token`), length(`token`) == 1)
        self$`token` <- `token`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`issued_at`)) {
        stopifnot(is.character(`issued_at`), length(`issued_at`) == 1)
        self$`issued_at` <- `issued_at`
      }
      if (!is.null(`expires_at`)) {
        stopifnot(is.character(`expires_at`), length(`expires_at`) == 1)
        self$`expires_at` <- `expires_at`
      }
      if (!is.null(`scope`)) {
        stopifnot(is.character(`scope`), length(`scope`) == 1)
        self$`scope` <- `scope`
      }
    },
    toJSON = function() {
      TokenObject <- list()
      if (!is.null(self$`token`)) {
        TokenObject[['token']] <-
          self$`token`
      }
      if (!is.null(self$`name`)) {
        TokenObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`issued_at`)) {
        TokenObject[['issued_at']] <-
          self$`issued_at`
      }
      if (!is.null(self$`expires_at`)) {
        TokenObject[['expires_at']] <-
          self$`expires_at`
      }
      if (!is.null(self$`scope`)) {
        TokenObject[['scope']] <-
          self$`scope`
      }

      TokenObject
    },
    fromJSON = function(TokenJson) {
      TokenObject <- jsonlite::fromJSON(TokenJson)
      if (!is.null(TokenObject$`token`)) {
        self$`token` <- TokenObject$`token`
      }
      if (!is.null(TokenObject$`name`)) {
        self$`name` <- TokenObject$`name`
      }
      if (!is.null(TokenObject$`issued_at`)) {
        self$`issued_at` <- TokenObject$`issued_at`
      }
      if (!is.null(TokenObject$`expires_at`)) {
        self$`expires_at` <- TokenObject$`expires_at`
      }
      if (!is.null(TokenObject$`scope`)) {
        self$`scope` <- TokenObject$`scope`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`token`)) {
        sprintf(
        '"token":
          "%s"
                ',
        self$`token`
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`issued_at`)) {
        sprintf(
        '"issued_at":
          "%s"
                ',
        self$`issued_at`
        )},
        if (!is.null(self$`expires_at`)) {
        sprintf(
        '"expires_at":
          "%s"
                ',
        self$`expires_at`
        )},
        if (!is.null(self$`scope`)) {
        sprintf(
        '"scope":
          "%s"
                ',
        self$`scope`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(TokenJson) {
      TokenObject <- jsonlite::fromJSON(TokenJson)
      self$`token` <- TokenObject$`token`
      self$`name` <- TokenObject$`name`
      self$`issued_at` <- TokenObject$`issued_at`
      self$`expires_at` <- TokenObject$`expires_at`
      self$`scope` <- TokenObject$`scope`
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.