R/query.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 Query
#'
#' @description Query Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field type  \link{Querytype} 
#'
#' @field layout  \link{Layout} 
#'
#' @field status  \link{Querystatus} 
#'
#' @field attributeBufferHeaders  list( \link{AttributeBufferHeader} ) 
#'
#' @field writer  \link{Writer} [optional]
#'
#' @field reader  \link{QueryReader} [optional]
#'
#' @field array  \link{Array} 
#'
#' @field totalFixedLengthBufferBytes  integer 
#'
#' @field totalVarLenBufferBytes  integer 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Query <- R6::R6Class(
  'Query',
  public = list(
    `type` = NULL,
    `layout` = NULL,
    `status` = NULL,
    `attributeBufferHeaders` = NULL,
    `writer` = NULL,
    `reader` = NULL,
    `array` = NULL,
    `totalFixedLengthBufferBytes` = NULL,
    `totalVarLenBufferBytes` = NULL,
    initialize = function(
        `type`, `layout`, `status`, `attributeBufferHeaders`, `array`, `totalFixedLengthBufferBytes`, `totalVarLenBufferBytes`, `writer`=NULL, `reader`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
      if (!missing(`layout`)) {
        stopifnot(R6::is.R6(`layout`))
        self$`layout` <- `layout`
      }
      if (!missing(`status`)) {
        stopifnot(R6::is.R6(`status`))
        self$`status` <- `status`
      }
      if (!missing(`attributeBufferHeaders`)) {
        stopifnot(is.vector(`attributeBufferHeaders`), length(`attributeBufferHeaders`) != 0)
        sapply(`attributeBufferHeaders`, function(x) stopifnot(R6::is.R6(x)))
        self$`attributeBufferHeaders` <- `attributeBufferHeaders`
      }
      if (!missing(`array`)) {
        stopifnot(R6::is.R6(`array`))
        self$`array` <- `array`
      }
      if (!missing(`totalFixedLengthBufferBytes`)) {
        stopifnot(is.numeric(`totalFixedLengthBufferBytes`), length(`totalFixedLengthBufferBytes`) == 1)
        self$`totalFixedLengthBufferBytes` <- `totalFixedLengthBufferBytes`
      }
      if (!missing(`totalVarLenBufferBytes`)) {
        stopifnot(is.numeric(`totalVarLenBufferBytes`), length(`totalVarLenBufferBytes`) == 1)
        self$`totalVarLenBufferBytes` <- `totalVarLenBufferBytes`
      }
      if (!is.null(`writer`)) {
        stopifnot(R6::is.R6(`writer`))
        self$`writer` <- `writer`
      }
      if (!is.null(`reader`)) {
        stopifnot(R6::is.R6(`reader`))
        self$`reader` <- `reader`
      }
    },
    toJSON = function() {
      QueryObject <- list()
      if (!is.null(self$`type`)) {
        QueryObject[['type']] <-
          self$`type`$toJSON()
      }
      if (!is.null(self$`layout`)) {
        QueryObject[['layout']] <-
          self$`layout`$toJSON()
      }
      if (!is.null(self$`status`)) {
        QueryObject[['status']] <-
          self$`status`$toJSON()
      }
      if (!is.null(self$`attributeBufferHeaders`)) {
        QueryObject[['attributeBufferHeaders']] <-
          lapply(self$`attributeBufferHeaders`, function(x) x$toJSON())
      }
      if (!is.null(self$`writer`)) {
        QueryObject[['writer']] <-
          self$`writer`$toJSON()
      }
      if (!is.null(self$`reader`)) {
        QueryObject[['reader']] <-
          self$`reader`$toJSON()
      }
      if (!is.null(self$`array`)) {
        QueryObject[['array']] <-
          self$`array`$toJSON()
      }
      if (!is.null(self$`totalFixedLengthBufferBytes`)) {
        QueryObject[['totalFixedLengthBufferBytes']] <-
          self$`totalFixedLengthBufferBytes`
      }
      if (!is.null(self$`totalVarLenBufferBytes`)) {
        QueryObject[['totalVarLenBufferBytes']] <-
          self$`totalVarLenBufferBytes`
      }

      QueryObject
    },
    fromJSON = function(QueryJson) {
      QueryObject <- jsonlite::fromJSON(QueryJson)
      if (!is.null(QueryObject$`type`)) {
        # 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.
        #
        #typeObject <- Querytype$new()
        #typeObject$fromJSON(jsonlite::toJSON(QueryObject$type, auto_unbox = TRUE, digits = NA))
        typeObject <- Querytype$new(QueryObject$type)
        self$`type` <- typeObject
      }
      if (!is.null(QueryObject$`layout`)) {
        # 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.
        #
        #layoutObject <- Layout$new()
        #layoutObject$fromJSON(jsonlite::toJSON(QueryObject$layout, auto_unbox = TRUE, digits = NA))
        layoutObject <- Layout$new(QueryObject$layout)
        self$`layout` <- layoutObject
      }
      if (!is.null(QueryObject$`status`)) {
        # 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.
        #
        #statusObject <- Querystatus$new()
        #statusObject$fromJSON(jsonlite::toJSON(QueryObject$status, auto_unbox = TRUE, digits = NA))
        statusObject <- Querystatus$new(QueryObject$status)
        self$`status` <- statusObject
      }
      if (!is.null(QueryObject$`attributeBufferHeaders`)) {
        self$`attributeBufferHeaders` <- ApiClient$new()$deserializeObj(QueryObject$`attributeBufferHeaders`, "array[AttributeBufferHeader]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(QueryObject$`writer`)) {
        writerObject <- Writer$new()
        writerObject$fromJSON(jsonlite::toJSON(QueryObject$writer, auto_unbox = TRUE, digits = NA))
        self$`writer` <- writerObject
      }
      if (!is.null(QueryObject$`reader`)) {
        readerObject <- QueryReader$new()
        readerObject$fromJSON(jsonlite::toJSON(QueryObject$reader, auto_unbox = TRUE, digits = NA))
        self$`reader` <- readerObject
      }
      if (!is.null(QueryObject$`array`)) {
        arrayObject <- Array$new()
        arrayObject$fromJSON(jsonlite::toJSON(QueryObject$array, auto_unbox = TRUE, digits = NA))
        self$`array` <- arrayObject
      }
      if (!is.null(QueryObject$`totalFixedLengthBufferBytes`)) {
        self$`totalFixedLengthBufferBytes` <- QueryObject$`totalFixedLengthBufferBytes`
      }
      if (!is.null(QueryObject$`totalVarLenBufferBytes`)) {
        self$`totalVarLenBufferBytes` <- QueryObject$`totalVarLenBufferBytes`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`type`)) {
        sprintf(
        '"type":
        %s
        ',
        jsonlite::toJSON(self$`type`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`layout`)) {
        sprintf(
        '"layout":
        %s
        ',
        jsonlite::toJSON(self$`layout`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`status`)) {
        sprintf(
        '"status":
        %s
        ',
        jsonlite::toJSON(self$`status`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`attributeBufferHeaders`)) {
        sprintf(
        '"attributeBufferHeaders":
        [%s]
',
        paste(sapply(self$`attributeBufferHeaders`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`writer`)) {
        sprintf(
        '"writer":
        %s
        ',
        jsonlite::toJSON(self$`writer`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`reader`)) {
        sprintf(
        '"reader":
        %s
        ',
        jsonlite::toJSON(self$`reader`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`array`)) {
        sprintf(
        '"array":
        %s
        ',
        jsonlite::toJSON(self$`array`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`totalFixedLengthBufferBytes`)) {
        sprintf(
        '"totalFixedLengthBufferBytes":
          %d
                ',
        self$`totalFixedLengthBufferBytes`
        )},
        if (!is.null(self$`totalVarLenBufferBytes`)) {
        sprintf(
        '"totalVarLenBufferBytes":
          %d
                ',
        self$`totalVarLenBufferBytes`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(QueryJson) {
      QueryObject <- jsonlite::fromJSON(QueryJson)
      self$`type` <- Querytype$new()$fromJSON(jsonlite::toJSON(QueryObject$type, auto_unbox = TRUE, digits = NA))
      self$`layout` <- Layout$new()$fromJSON(jsonlite::toJSON(QueryObject$layout, auto_unbox = TRUE, digits = NA))
      self$`status` <- Querystatus$new()$fromJSON(jsonlite::toJSON(QueryObject$status, auto_unbox = TRUE, digits = NA))
      self$`attributeBufferHeaders` <- ApiClient$new()$deserializeObj(QueryObject$`attributeBufferHeaders`, "array[AttributeBufferHeader]", loadNamespace("tiledbcloud"))
      self$`writer` <- Writer$new()$fromJSON(jsonlite::toJSON(QueryObject$writer, auto_unbox = TRUE, digits = NA))
      self$`reader` <- QueryReader$new()$fromJSON(jsonlite::toJSON(QueryObject$reader, auto_unbox = TRUE, digits = NA))
      self$`array` <- Array$new()$fromJSON(jsonlite::toJSON(QueryObject$array, auto_unbox = TRUE, digits = NA))
      self$`totalFixedLengthBufferBytes` <- QueryObject$`totalFixedLengthBufferBytes`
      self$`totalVarLenBufferBytes` <- QueryObject$`totalVarLenBufferBytes`
      self
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.