R/tool_input_parameter.R

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

#' @docType class
#' @title ToolInputParameter
#'
#' @description ToolInputParameter Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field name  character 
#'
#' @field valueType  \link{ValueType} 
#'
#' @field optional  character 
#'
#' @field default  character 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ToolInputParameter <- R6::R6Class(
  'ToolInputParameter',
  public = list(
    `name` = NULL,
    `valueType` = NULL,
    `optional` = NULL,
    `default` = NULL,
    initialize = function(
        `name`, `valueType`, `optional`, `default`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`valueType`)) {
        stopifnot(R6::is.R6(`valueType`))
        self$`valueType` <- `valueType`
      }
      if (!missing(`optional`)) {
        self$`optional` <- `optional`
      }
      if (!missing(`default`)) {
        stopifnot(is.character(`default`), length(`default`) == 1)
        self$`default` <- `default`
      }
    },
    toJSON = function() {
      ToolInputParameterObject <- list()
      if (!is.null(self$`name`)) {
        ToolInputParameterObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`valueType`)) {
        ToolInputParameterObject[['valueType']] <-
          self$`valueType`$toJSON()
      }
      if (!is.null(self$`optional`)) {
        ToolInputParameterObject[['optional']] <-
          self$`optional`
      }
      if (!is.null(self$`default`)) {
        ToolInputParameterObject[['default']] <-
          self$`default`
      }

      ToolInputParameterObject
    },
    fromJSON = function(ToolInputParameterJson) {
      ToolInputParameterObject <- jsonlite::fromJSON(ToolInputParameterJson)
      if (!is.null(ToolInputParameterObject$`name`)) {
        self$`name` <- ToolInputParameterObject$`name`
      }
      if (!is.null(ToolInputParameterObject$`valueType`)) {
        valueTypeObject <- ValueType$new()
        valueTypeObject$fromJSON(jsonlite::toJSON(ToolInputParameterObject$valueType, auto_unbox = TRUE, digits = NA))
        self$`valueType` <- valueTypeObject
      }
      if (!is.null(ToolInputParameterObject$`optional`)) {
        self$`optional` <- ToolInputParameterObject$`optional`
      }
      if (!is.null(ToolInputParameterObject$`default`)) {
        self$`default` <- ToolInputParameterObject$`default`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`valueType`)) {
        sprintf(
        '"valueType":
        %s
        ',
        jsonlite::toJSON(self$`valueType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`optional`)) {
        sprintf(
        '"optional":
          "%s"
                ',
        self$`optional`
        )},
        if (!is.null(self$`default`)) {
        sprintf(
        '"default":
          "%s"
                ',
        self$`default`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ToolInputParameterJson) {
      ToolInputParameterObject <- jsonlite::fromJSON(ToolInputParameterJson)
      self$`name` <- ToolInputParameterObject$`name`
      self$`valueType` <- ValueType$new()$fromJSON(jsonlite::toJSON(ToolInputParameterObject$valueType, auto_unbox = TRUE, digits = NA))
      self$`optional` <- ToolInputParameterObject$`optional`
      self$`default` <- ToolInputParameterObject$`default`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.