R/error_report.R

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title ErrorReport
#'
#' @description ErrorReport Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field source  character 
#'
#' @field message  character 
#'
#' @field statusCode  integer [optional]
#'
#' @field causes  list( \link{ErrorReport} ) 
#'
#' @field stackTrace  list( \link{StackTraceElement} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ErrorReport <- R6::R6Class(
  'ErrorReport',
  public = list(
    `source` = NULL,
    `message` = NULL,
    `statusCode` = NULL,
    `causes` = NULL,
    `stackTrace` = NULL,
    initialize = function(
        `source`, `message`, `causes`, `stackTrace`, `statusCode`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`source`)) {
        stopifnot(is.character(`source`), length(`source`) == 1)
        self$`source` <- `source`
      }
      if (!missing(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!missing(`causes`)) {
        stopifnot(is.vector(`causes`), length(`causes`) != 0)
        sapply(`causes`, function(x) stopifnot(R6::is.R6(x)))
        self$`causes` <- `causes`
      }
      if (!missing(`stackTrace`)) {
        stopifnot(is.vector(`stackTrace`), length(`stackTrace`) != 0)
        sapply(`stackTrace`, function(x) stopifnot(R6::is.R6(x)))
        self$`stackTrace` <- `stackTrace`
      }
      if (!is.null(`statusCode`)) {
        stopifnot(is.numeric(`statusCode`), length(`statusCode`) == 1)
        self$`statusCode` <- `statusCode`
      }
    },
    toJSON = function() {
      ErrorReportObject <- list()
      if (!is.null(self$`source`)) {
        ErrorReportObject[['source']] <-
          self$`source`
      }
      if (!is.null(self$`message`)) {
        ErrorReportObject[['message']] <-
          self$`message`
      }
      if (!is.null(self$`statusCode`)) {
        ErrorReportObject[['statusCode']] <-
          self$`statusCode`
      }
      if (!is.null(self$`causes`)) {
        ErrorReportObject[['causes']] <-
          lapply(self$`causes`, function(x) x$toJSON())
      }
      if (!is.null(self$`stackTrace`)) {
        ErrorReportObject[['stackTrace']] <-
          lapply(self$`stackTrace`, function(x) x$toJSON())
      }

      ErrorReportObject
    },
    fromJSON = function(ErrorReportJson) {
      ErrorReportObject <- jsonlite::fromJSON(ErrorReportJson)
      if (!is.null(ErrorReportObject$`source`)) {
        self$`source` <- ErrorReportObject$`source`
      }
      if (!is.null(ErrorReportObject$`message`)) {
        self$`message` <- ErrorReportObject$`message`
      }
      if (!is.null(ErrorReportObject$`statusCode`)) {
        self$`statusCode` <- ErrorReportObject$`statusCode`
      }
      if (!is.null(ErrorReportObject$`causes`)) {
        self$`causes` <- ApiClient$new()$deserializeObj(ErrorReportObject$`causes`, "array[ErrorReport]", loadNamespace("openapi"))
      }
      if (!is.null(ErrorReportObject$`stackTrace`)) {
        self$`stackTrace` <- ApiClient$new()$deserializeObj(ErrorReportObject$`stackTrace`, "array[StackTraceElement]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`source`)) {
        sprintf(
        '"source":
          "%s"
                ',
        self$`source`
        )},
        if (!is.null(self$`message`)) {
        sprintf(
        '"message":
          "%s"
                ',
        self$`message`
        )},
        if (!is.null(self$`statusCode`)) {
        sprintf(
        '"statusCode":
          %d
                ',
        self$`statusCode`
        )},
        if (!is.null(self$`causes`)) {
        sprintf(
        '"causes":
        [%s]
',
        paste(sapply(self$`causes`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`stackTrace`)) {
        sprintf(
        '"stackTrace":
        [%s]
',
        paste(sapply(self$`stackTrace`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ErrorReportJson) {
      ErrorReportObject <- jsonlite::fromJSON(ErrorReportJson)
      self$`source` <- ErrorReportObject$`source`
      self$`message` <- ErrorReportObject$`message`
      self$`statusCode` <- ErrorReportObject$`statusCode`
      self$`causes` <- ApiClient$new()$deserializeObj(ErrorReportObject$`causes`, "array[ErrorReport]", loadNamespace("openapi"))
      self$`stackTrace` <- ApiClient$new()$deserializeObj(ErrorReportObject$`stackTrace`, "array[StackTraceElement]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.