R/query_json.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 QueryJson
#'
#' @description QueryJson Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field query_ranges  \link{QueryRanges} [optional]
#'
#' @field fields  list( character ) [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
QueryJson <- R6::R6Class(
  'QueryJson',
  public = list(
    `query_ranges` = NULL,
    `fields` = NULL,
    initialize = function(
        `query_ranges`=NULL, `fields`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`query_ranges`)) {
        stopifnot(R6::is.R6(`query_ranges`))
        self$`query_ranges` <- `query_ranges`
      }
      if (!is.null(`fields`)) {
        stopifnot(is.vector(`fields`), length(`fields`) != 0)
        sapply(`fields`, function(x) stopifnot(is.character(x)))
        self$`fields` <- `fields`
      }
    },
    toJSON = function() {
      QueryJsonObject <- list()
      if (!is.null(self$`query_ranges`)) {
        QueryJsonObject[['query_ranges']] <-
          self$`query_ranges`$toJSON()
      }
      if (!is.null(self$`fields`)) {
        QueryJsonObject[['fields']] <-
          self$`fields`
      }

      QueryJsonObject
    },
    fromJSON = function(QueryJsonJson) {
      QueryJsonObject <- jsonlite::fromJSON(QueryJsonJson)
      if (!is.null(QueryJsonObject$`query_ranges`)) {
        query_rangesObject <- QueryRanges$new()
        query_rangesObject$fromJSON(jsonlite::toJSON(QueryJsonObject$query_ranges, auto_unbox = TRUE, digits = NA))
        self$`query_ranges` <- query_rangesObject
      }
      if (!is.null(QueryJsonObject$`fields`)) {
        self$`fields` <- ApiClient$new()$deserializeObj(QueryJsonObject$`fields`, "array[character]", loadNamespace("tiledbcloud"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`query_ranges`)) {
        sprintf(
        '"query_ranges":
        %s
        ',
        jsonlite::toJSON(self$`query_ranges`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`fields`)) {
        sprintf(
        '"fields":
           [%s]
        ',
        paste(unlist(lapply(self$`fields`, function(x) paste0('"', x, '"'))), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(QueryJsonJson) {
      QueryJsonObject <- jsonlite::fromJSON(QueryJsonJson)
      self$`query_ranges` <- QueryRanges$new()$fromJSON(jsonlite::toJSON(QueryJsonObject$query_ranges, auto_unbox = TRUE, digits = NA))
      self$`fields` <- ApiClient$new()$deserializeObj(QueryJsonObject$`fields`, "array[character]", loadNamespace("tiledbcloud"))
      self
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.