R/udf_info.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 UDFInfo
#'
#' @description UDFInfo Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field id  character [optional]
#'
#' @field name  character [optional]
#'
#' @field language  \link{UDFLanguage} [optional]
#'
#' @field type  \link{UDFType} [optional]
#'
#' @field readme  character [optional]
#'
#' @field license_id  character [optional]
#'
#' @field license_text  character [optional]
#'
#' @field tags  list( character ) [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
UDFInfo <- R6::R6Class(
  'UDFInfo',
  public = list(
    `id` = NULL,
    `name` = NULL,
    `language` = NULL,
    `type` = NULL,
    `readme` = NULL,
    `license_id` = NULL,
    `license_text` = NULL,
    `tags` = NULL,
    initialize = function(
        `id`=NULL, `name`=NULL, `language`=NULL, `type`=NULL, `readme`=NULL, `license_id`=NULL, `license_text`=NULL, `tags`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`language`)) {
        stopifnot(R6::is.R6(`language`))
        self$`language` <- `language`
      }
      if (!is.null(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
      if (!is.null(`readme`)) {
        stopifnot(is.character(`readme`), length(`readme`) == 1)
        self$`readme` <- `readme`
      }
      if (!is.null(`license_id`)) {
        stopifnot(is.character(`license_id`), length(`license_id`) == 1)
        self$`license_id` <- `license_id`
      }
      if (!is.null(`license_text`)) {
        stopifnot(is.character(`license_text`), length(`license_text`) == 1)
        self$`license_text` <- `license_text`
      }
      if (!is.null(`tags`)) {
        stopifnot(is.vector(`tags`), length(`tags`) != 0)
        sapply(`tags`, function(x) stopifnot(is.character(x)))
        self$`tags` <- `tags`
      }
    },
    toJSON = function() {
      UDFInfoObject <- list()
      if (!is.null(self$`id`)) {
        UDFInfoObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`name`)) {
        UDFInfoObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`language`)) {
        UDFInfoObject[['language']] <-
          self$`language`$toJSON()
      }
      if (!is.null(self$`type`)) {
        UDFInfoObject[['type']] <-
          self$`type`$toJSON()
      }
      if (!is.null(self$`readme`)) {
        UDFInfoObject[['readme']] <-
          self$`readme`
      }
      if (!is.null(self$`license_id`)) {
        UDFInfoObject[['license_id']] <-
          self$`license_id`
      }
      if (!is.null(self$`license_text`)) {
        UDFInfoObject[['license_text']] <-
          self$`license_text`
      }
      if (!is.null(self$`tags`)) {
        UDFInfoObject[['tags']] <-
          self$`tags`
      }

      UDFInfoObject
    },
    fromJSON = function(UDFInfoJson) {
      UDFInfoObject <- jsonlite::fromJSON(UDFInfoJson)
      if (!is.null(UDFInfoObject$`id`)) {
        self$`id` <- UDFInfoObject$`id`
      }
      if (!is.null(UDFInfoObject$`name`)) {
        self$`name` <- UDFInfoObject$`name`
      }
      if (!is.null(UDFInfoObject$`language`)) {
        # 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.
        #
        #languageObject <- UDFLanguage$new()
        #languageObject$fromJSON(jsonlite::toJSON(UDFInfoObject$language, auto_unbox = TRUE, digits = NA))
        languageObject <- UDFLanguage$new(UDFInfoObject$language)
        self$`language` <- languageObject
      }
      if (!is.null(UDFInfoObject$`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 <- UDFType$new()
        #typeObject$fromJSON(jsonlite::toJSON(UDFInfoObject$type, auto_unbox = TRUE, digits = NA))
        typeObject <- UDFType$new(UDFInfoObject$type)
        self$`type` <- typeObject
      }
      if (!is.null(UDFInfoObject$`readme`)) {
        self$`readme` <- UDFInfoObject$`readme`
      }
      if (!is.null(UDFInfoObject$`license_id`)) {
        self$`license_id` <- UDFInfoObject$`license_id`
      }
      if (!is.null(UDFInfoObject$`license_text`)) {
        self$`license_text` <- UDFInfoObject$`license_text`
      }
      if (!is.null(UDFInfoObject$`tags`)) {
        self$`tags` <- ApiClient$new()$deserializeObj(UDFInfoObject$`tags`, "array[character]", loadNamespace("tiledbcloud"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`id`)) {
        sprintf(
        '"id":
          "%s"
                ',
        self$`id`
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`language`)) {
        sprintf(
        '"language":
        %s
        ',
        jsonlite::toJSON(self$`language`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`type`)) {
        sprintf(
        '"type":
        %s
        ',
        jsonlite::toJSON(self$`type`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`readme`)) {
        sprintf(
        '"readme":
          "%s"
                ',
        self$`readme`
        )},
        if (!is.null(self$`license_id`)) {
        sprintf(
        '"license_id":
          "%s"
                ',
        self$`license_id`
        )},
        if (!is.null(self$`license_text`)) {
        sprintf(
        '"license_text":
          "%s"
                ',
        self$`license_text`
        )},
        if (!is.null(self$`tags`)) {
        sprintf(
        '"tags":
           [%s]
        ',
        paste(unlist(lapply(self$`tags`, function(x) paste0('"', x, '"'))), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(UDFInfoJson) {
      UDFInfoObject <- jsonlite::fromJSON(UDFInfoJson)
      self$`id` <- UDFInfoObject$`id`
      self$`name` <- UDFInfoObject$`name`
      self$`language` <- UDFLanguage$new()$fromJSON(jsonlite::toJSON(UDFInfoObject$language, auto_unbox = TRUE, digits = NA))
      self$`type` <- UDFType$new()$fromJSON(jsonlite::toJSON(UDFInfoObject$type, auto_unbox = TRUE, digits = NA))
      self$`readme` <- UDFInfoObject$`readme`
      self$`license_id` <- UDFInfoObject$`license_id`
      self$`license_text` <- UDFInfoObject$`license_text`
      self$`tags` <- ApiClient$new()$deserializeObj(UDFInfoObject$`tags`, "array[character]", loadNamespace("tiledbcloud"))
      self
    }
  )
)
eddelbuettel/tldbclr documentation built on Sept. 25, 2022, 12:46 p.m.