R/error.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 Error
#'
#' @description Error Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field code  integer [optional]
#'
#' @field message  character [optional]
#'
#' @field request_id  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Error <- R6::R6Class(
  'Error',
  public = list(
    `code` = NULL,
    `message` = NULL,
    `request_id` = NULL,
    initialize = function(
        `code`=NULL, `message`=NULL, `request_id`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`code`)) {
        stopifnot(is.numeric(`code`), length(`code`) == 1)
        self$`code` <- `code`
      }
      if (!is.null(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!is.null(`request_id`)) {
        stopifnot(is.character(`request_id`), length(`request_id`) == 1)
        self$`request_id` <- `request_id`
      }
    },
    toJSON = function() {
      ErrorObject <- list()
      if (!is.null(self$`code`)) {
        ErrorObject[['code']] <-
          self$`code`
      }
      if (!is.null(self$`message`)) {
        ErrorObject[['message']] <-
          self$`message`
      }
      if (!is.null(self$`request_id`)) {
        ErrorObject[['request_id']] <-
          self$`request_id`
      }

      ErrorObject
    },
    fromJSON = function(ErrorJson) {
      ErrorObject <- jsonlite::fromJSON(ErrorJson)
      if (!is.null(ErrorObject$`code`)) {
        self$`code` <- ErrorObject$`code`
      }
      if (!is.null(ErrorObject$`message`)) {
        self$`message` <- ErrorObject$`message`
      }
      if (!is.null(ErrorObject$`request_id`)) {
        self$`request_id` <- ErrorObject$`request_id`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`code`)) {
        sprintf(
        '"code":
          %d
                ',
        self$`code`
        )},
        if (!is.null(self$`message`)) {
        sprintf(
        '"message":
          "%s"
                ',
        self$`message`
        )},
        if (!is.null(self$`request_id`)) {
        sprintf(
        '"request_id":
          "%s"
                ',
        self$`request_id`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ErrorJson) {
      ErrorObject <- jsonlite::fromJSON(ErrorJson)
      self$`code` <- ErrorObject$`code`
      self$`message` <- ErrorObject$`message`
      self$`request_id` <- ErrorObject$`request_id`
      self
    }
  )
)
TileDB-Inc/TileDB-Cloud-R documentation built on July 18, 2024, 3:33 p.m.