R/sql_parameters.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 SQLParameters
#'
#' @description SQLParameters Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field name  character [optional]
#'
#' @field query  character [optional]
#'
#' @field output_uri  character [optional]
#'
#' @field store_results  character [optional]
#'
#' @field dont_download_results  character [optional]
#'
#' @field result_format  \link{ResultFormat} [optional]
#'
#' @field init_commands  list( character ) [optional]
#'
#' @field parameters  list( object ) [optional]
#'
#' @field task_graph_uuid  character [optional]
#'
#' @field client_node_uuid  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SQLParameters <- R6::R6Class(
  'SQLParameters',
  public = list(
    `name` = NULL,
    `query` = NULL,
    `output_uri` = NULL,
    `store_results` = NULL,
    `dont_download_results` = NULL,
    `result_format` = NULL,
    `init_commands` = NULL,
    `parameters` = NULL,
    `task_graph_uuid` = NULL,
    `client_node_uuid` = NULL,
    initialize = function(
        `name`=NULL, `query`=NULL, `output_uri`=NULL, `store_results`=NULL, `dont_download_results`=NULL, `result_format`=NULL, `init_commands`=NULL, `parameters`=NULL, `task_graph_uuid`=NULL, `client_node_uuid`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`query`)) {
        stopifnot(is.character(`query`), length(`query`) == 1)
        # MANUAL EDIT AFTER OPENAPI AUTOGEN
        # Avoid this:
        # Error: tiledbcloud: received error response: Server returned 400 response status code.
        # Message:  could not parse request body: invalid character '\n' in string literal
        self$`query` <- gsub("\n", " ", `query`)
      }
      if (!is.null(`output_uri`)) {
        stopifnot(is.character(`output_uri`), length(`output_uri`) == 1)
        self$`output_uri` <- `output_uri`
      }
      if (!is.null(`store_results`)) {
        self$`store_results` <- `store_results`
      }
      if (!is.null(`dont_download_results`)) {
        self$`dont_download_results` <- `dont_download_results`
      }
      if (!is.null(`result_format`)) {
        stopifnot(R6::is.R6(`result_format`))
        self$`result_format` <- `result_format`
      }
      if (!is.null(`init_commands`)) {
        stopifnot(is.vector(`init_commands`), length(`init_commands`) != 0)
        sapply(`init_commands`, function(x) stopifnot(is.character(x)))
        self$`init_commands` <- `init_commands`
      }
      if (!is.null(`parameters`)) {
        stopifnot(is.vector(`parameters`), length(`parameters`) != 0)
        sapply(`parameters`, function(x) stopifnot(is.character(x)))
        self$`parameters` <- `parameters`
      }
      if (!is.null(`task_graph_uuid`)) {
        stopifnot(is.character(`task_graph_uuid`), length(`task_graph_uuid`) == 1)
        self$`task_graph_uuid` <- `task_graph_uuid`
      }
      if (!is.null(`client_node_uuid`)) {
        stopifnot(is.character(`client_node_uuid`), length(`client_node_uuid`) == 1)
        self$`client_node_uuid` <- `client_node_uuid`
      }
    },
    toJSON = function() {
      SQLParametersObject <- list()
      if (!is.null(self$`name`)) {
        SQLParametersObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`query`)) {
        SQLParametersObject[['query']] <-
          self$`query`
      }
      if (!is.null(self$`output_uri`)) {
        SQLParametersObject[['output_uri']] <-
          self$`output_uri`
      }
      if (!is.null(self$`store_results`)) {
        SQLParametersObject[['store_results']] <-
          self$`store_results`
      }
      if (!is.null(self$`dont_download_results`)) {
        SQLParametersObject[['dont_download_results']] <-
          self$`dont_download_results`
      }
      if (!is.null(self$`result_format`)) {
        SQLParametersObject[['result_format']] <-
          self$`result_format`$toJSON()
      }
      if (!is.null(self$`init_commands`)) {
        SQLParametersObject[['init_commands']] <-
          self$`init_commands`
      }
      if (!is.null(self$`parameters`)) {
        SQLParametersObject[['parameters']] <-
          self$`parameters`
      }
      if (!is.null(self$`task_graph_uuid`)) {
        SQLParametersObject[['task_graph_uuid']] <-
          self$`task_graph_uuid`
      }
      if (!is.null(self$`client_node_uuid`)) {
        SQLParametersObject[['client_node_uuid']] <-
          self$`client_node_uuid`
      }

      SQLParametersObject
    },
    fromJSON = function(SQLParametersJson) {
      SQLParametersObject <- jsonlite::fromJSON(SQLParametersJson)
      if (!is.null(SQLParametersObject$`name`)) {
        self$`name` <- SQLParametersObject$`name`
      }
      if (!is.null(SQLParametersObject$`query`)) {
        self$`query` <- SQLParametersObject$`query`
      }
      if (!is.null(SQLParametersObject$`output_uri`)) {
        self$`output_uri` <- SQLParametersObject$`output_uri`
      }
      if (!is.null(SQLParametersObject$`store_results`)) {
        self$`store_results` <- SQLParametersObject$`store_results`
      }
      if (!is.null(SQLParametersObject$`dont_download_results`)) {
        self$`dont_download_results` <- SQLParametersObject$`dont_download_results`
      }
      if (!is.null(SQLParametersObject$`result_format`)) {
        # 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.
        #
        #result_formatObject <- ResultFormat$new()
        #result_formatObject$fromJSON(jsonlite::toJSON(SQLParametersObject$result_format, auto_unbox = TRUE, digits = NA))
        result_formatObject <- ResultFormat$new(SQLParametersObject$result_format)
        self$`result_format` <- result_formatObject
      }
      if (!is.null(SQLParametersObject$`init_commands`)) {
        self$`init_commands` <- ApiClient$new()$deserializeObj(SQLParametersObject$`init_commands`, "array[character]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(SQLParametersObject$`parameters`)) {
        self$`parameters` <- ApiClient$new()$deserializeObj(SQLParametersObject$`parameters`, "array[object]", loadNamespace("tiledbcloud"))
      }
      if (!is.null(SQLParametersObject$`task_graph_uuid`)) {
        self$`task_graph_uuid` <- SQLParametersObject$`task_graph_uuid`
      }
      if (!is.null(SQLParametersObject$`client_node_uuid`)) {
        self$`client_node_uuid` <- SQLParametersObject$`client_node_uuid`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`query`)) {
        sprintf(
        '"query":
          "%s"
                ',
        self$`query`
        )},
        if (!is.null(self$`output_uri`)) {
        sprintf(
        '"output_uri":
          "%s"
                ',
        self$`output_uri`
        )},
        if (!is.null(self$`store_results`)) {
        sprintf(
        '"store_results":
          "%s"
                ',
        self$`store_results`
        )},
        if (!is.null(self$`dont_download_results`)) {
        sprintf(
        '"dont_download_results":
          "%s"
                ',
        self$`dont_download_results`
        )},
        if (!is.null(self$`result_format`)) {
        sprintf(
        '"result_format":
        %s
        ',
        jsonlite::toJSON(self$`result_format`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`init_commands`)) {
        sprintf(
        '"init_commands":
           [%s]
        ',
        paste(unlist(lapply(self$`init_commands`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`parameters`)) {
        sprintf(
        '"parameters":
           [%s]
        ',
        paste(unlist(lapply(self$`parameters`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`task_graph_uuid`)) {
        sprintf(
        '"task_graph_uuid":
          "%s"
                ',
        self$`task_graph_uuid`
        )},
        if (!is.null(self$`client_node_uuid`)) {
        sprintf(
        '"client_node_uuid":
          "%s"
                ',
        self$`client_node_uuid`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SQLParametersJson) {
      SQLParametersObject <- jsonlite::fromJSON(SQLParametersJson)
      self$`name` <- SQLParametersObject$`name`
      self$`query` <- SQLParametersObject$`query`
      self$`output_uri` <- SQLParametersObject$`output_uri`
      self$`store_results` <- SQLParametersObject$`store_results`
      self$`dont_download_results` <- SQLParametersObject$`dont_download_results`
      self$`result_format` <- ResultFormat$new()$fromJSON(jsonlite::toJSON(SQLParametersObject$result_format, auto_unbox = TRUE, digits = NA))
      self$`init_commands` <- ApiClient$new()$deserializeObj(SQLParametersObject$`init_commands`, "array[character]", loadNamespace("tiledbcloud"))
      self$`parameters` <- ApiClient$new()$deserializeObj(SQLParametersObject$`parameters`, "array[object]", loadNamespace("tiledbcloud"))
      self$`task_graph_uuid` <- SQLParametersObject$`task_graph_uuid`
      self$`client_node_uuid` <- SQLParametersObject$`client_node_uuid`
      self
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.