R/array.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 Array
#'
#' @description Array Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field timestamp  numeric 
#'
#' @field queryType  \link{Querytype} 
#'
#' @field uri  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Array <- R6::R6Class(
  'Array',
  public = list(
    `timestamp` = NULL,
    `queryType` = NULL,
    `uri` = NULL,
    initialize = function(
        `timestamp`, `queryType`, `uri`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`timestamp`)) {
        self$`timestamp` <- `timestamp`
      }
      if (!missing(`queryType`)) {
        stopifnot(R6::is.R6(`queryType`))
        self$`queryType` <- `queryType`
      }
      if (!missing(`uri`)) {
        stopifnot(is.character(`uri`), length(`uri`) == 1)
        self$`uri` <- `uri`
      }
    },
    toJSON = function() {
      ArrayObject <- list()
      if (!is.null(self$`timestamp`)) {
        ArrayObject[['timestamp']] <-
          self$`timestamp`
      }
      if (!is.null(self$`queryType`)) {
        ArrayObject[['queryType']] <-
          self$`queryType`$toJSON()
      }
      if (!is.null(self$`uri`)) {
        ArrayObject[['uri']] <-
          self$`uri`
      }

      ArrayObject
    },
    fromJSON = function(ArrayJson) {
      ArrayObject <- jsonlite::fromJSON(ArrayJson)
      if (!is.null(ArrayObject$`timestamp`)) {
        self$`timestamp` <- ArrayObject$`timestamp`
      }
      if (!is.null(ArrayObject$`queryType`)) {
        # MANUAL EDIT AFTER OPENAPI AUTOGEN
        # For enums, OpenAPI autogen (1) generates a constructor which requires being called
        # with one arguent; (2) generates callsites (such as here) that calls that constructor
        # with zero arguments.
        #
        #queryTypeObject <- Querytype$new()
        #queryTypeObject$fromJSON(jsonlite::toJSON(ArrayObject$queryType, auto_unbox = TRUE, digits = NA))
        queryTypeObject <- Querytype$new(ArrayObject$queryType)
        self$`queryType` <- queryTypeObject
      }
      if (!is.null(ArrayObject$`uri`)) {
        self$`uri` <- ArrayObject$`uri`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`timestamp`)) {
        sprintf(
        '"timestamp":
          %d
                ',
        self$`timestamp`
        )},
        if (!is.null(self$`queryType`)) {
        sprintf(
        '"queryType":
        %s
        ',
        jsonlite::toJSON(self$`queryType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`uri`)) {
        sprintf(
        '"uri":
          "%s"
                ',
        self$`uri`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ArrayJson) {
      ArrayObject <- jsonlite::fromJSON(ArrayJson)
      self$`timestamp` <- ArrayObject$`timestamp`
      self$`queryType` <- Querytype$new()$fromJSON(jsonlite::toJSON(ArrayObject$queryType, auto_unbox = TRUE, digits = NA))
      self$`uri` <- ArrayObject$`uri`
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.