R/tool.R

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

#' @docType class
#' @title Tool
#'
#' @description Tool Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field url  character 
#'
#' @field id  character 
#'
#' @field organization  character 
#'
#' @field toolname  character [optional]
#'
#' @field toolclass  \link{ToolClass} 
#'
#' @field description  character [optional]
#'
#' @field author  character 
#'
#' @field meta-version  character 
#'
#' @field contains  list( character ) [optional]
#'
#' @field verified  character [optional]
#'
#' @field verified-source  character [optional]
#'
#' @field signed  character [optional]
#'
#' @field versions  list( \link{ToolVersion} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Tool <- R6::R6Class(
  'Tool',
  public = list(
    `url` = NULL,
    `id` = NULL,
    `organization` = NULL,
    `toolname` = NULL,
    `toolclass` = NULL,
    `description` = NULL,
    `author` = NULL,
    `meta-version` = NULL,
    `contains` = NULL,
    `verified` = NULL,
    `verified-source` = NULL,
    `signed` = NULL,
    `versions` = NULL,
    initialize = function(
        `url`, `id`, `organization`, `toolclass`, `author`, `meta-version`, `versions`, `toolname`=NULL, `description`=NULL, `contains`=NULL, `verified`=NULL, `verified-source`=NULL, `signed`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`url`)) {
        stopifnot(is.character(`url`), length(`url`) == 1)
        self$`url` <- `url`
      }
      if (!missing(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`organization`)) {
        stopifnot(is.character(`organization`), length(`organization`) == 1)
        self$`organization` <- `organization`
      }
      if (!missing(`toolclass`)) {
        stopifnot(R6::is.R6(`toolclass`))
        self$`toolclass` <- `toolclass`
      }
      if (!missing(`author`)) {
        stopifnot(is.character(`author`), length(`author`) == 1)
        self$`author` <- `author`
      }
      if (!missing(`meta-version`)) {
        stopifnot(is.character(`meta-version`), length(`meta-version`) == 1)
        self$`meta-version` <- `meta-version`
      }
      if (!missing(`versions`)) {
        stopifnot(is.vector(`versions`), length(`versions`) != 0)
        sapply(`versions`, function(x) stopifnot(R6::is.R6(x)))
        self$`versions` <- `versions`
      }
      if (!is.null(`toolname`)) {
        stopifnot(is.character(`toolname`), length(`toolname`) == 1)
        self$`toolname` <- `toolname`
      }
      if (!is.null(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!is.null(`contains`)) {
        stopifnot(is.vector(`contains`), length(`contains`) != 0)
        sapply(`contains`, function(x) stopifnot(is.character(x)))
        self$`contains` <- `contains`
      }
      if (!is.null(`verified`)) {
        self$`verified` <- `verified`
      }
      if (!is.null(`verified-source`)) {
        stopifnot(is.character(`verified-source`), length(`verified-source`) == 1)
        self$`verified-source` <- `verified-source`
      }
      if (!is.null(`signed`)) {
        self$`signed` <- `signed`
      }
    },
    toJSON = function() {
      ToolObject <- list()
      if (!is.null(self$`url`)) {
        ToolObject[['url']] <-
          self$`url`
      }
      if (!is.null(self$`id`)) {
        ToolObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`organization`)) {
        ToolObject[['organization']] <-
          self$`organization`
      }
      if (!is.null(self$`toolname`)) {
        ToolObject[['toolname']] <-
          self$`toolname`
      }
      if (!is.null(self$`toolclass`)) {
        ToolObject[['toolclass']] <-
          self$`toolclass`$toJSON()
      }
      if (!is.null(self$`description`)) {
        ToolObject[['description']] <-
          self$`description`
      }
      if (!is.null(self$`author`)) {
        ToolObject[['author']] <-
          self$`author`
      }
      if (!is.null(self$`meta-version`)) {
        ToolObject[['meta-version']] <-
          self$`meta-version`
      }
      if (!is.null(self$`contains`)) {
        ToolObject[['contains']] <-
          self$`contains`
      }
      if (!is.null(self$`verified`)) {
        ToolObject[['verified']] <-
          self$`verified`
      }
      if (!is.null(self$`verified-source`)) {
        ToolObject[['verified-source']] <-
          self$`verified-source`
      }
      if (!is.null(self$`signed`)) {
        ToolObject[['signed']] <-
          self$`signed`
      }
      if (!is.null(self$`versions`)) {
        ToolObject[['versions']] <-
          lapply(self$`versions`, function(x) x$toJSON())
      }

      ToolObject
    },
    fromJSON = function(ToolJson) {
      ToolObject <- jsonlite::fromJSON(ToolJson)
      if (!is.null(ToolObject$`url`)) {
        self$`url` <- ToolObject$`url`
      }
      if (!is.null(ToolObject$`id`)) {
        self$`id` <- ToolObject$`id`
      }
      if (!is.null(ToolObject$`organization`)) {
        self$`organization` <- ToolObject$`organization`
      }
      if (!is.null(ToolObject$`toolname`)) {
        self$`toolname` <- ToolObject$`toolname`
      }
      if (!is.null(ToolObject$`toolclass`)) {
        toolclassObject <- ToolClass$new()
        toolclassObject$fromJSON(jsonlite::toJSON(ToolObject$toolclass, auto_unbox = TRUE, digits = NA))
        self$`toolclass` <- toolclassObject
      }
      if (!is.null(ToolObject$`description`)) {
        self$`description` <- ToolObject$`description`
      }
      if (!is.null(ToolObject$`author`)) {
        self$`author` <- ToolObject$`author`
      }
      if (!is.null(ToolObject$`meta-version`)) {
        self$`meta-version` <- ToolObject$`meta-version`
      }
      if (!is.null(ToolObject$`contains`)) {
        self$`contains` <- ApiClient$new()$deserializeObj(ToolObject$`contains`, "array[character]", loadNamespace("openapi"))
      }
      if (!is.null(ToolObject$`verified`)) {
        self$`verified` <- ToolObject$`verified`
      }
      if (!is.null(ToolObject$`verified-source`)) {
        self$`verified-source` <- ToolObject$`verified-source`
      }
      if (!is.null(ToolObject$`signed`)) {
        self$`signed` <- ToolObject$`signed`
      }
      if (!is.null(ToolObject$`versions`)) {
        self$`versions` <- ApiClient$new()$deserializeObj(ToolObject$`versions`, "array[ToolVersion]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`url`)) {
        sprintf(
        '"url":
          "%s"
                ',
        self$`url`
        )},
        if (!is.null(self$`id`)) {
        sprintf(
        '"id":
          "%s"
                ',
        self$`id`
        )},
        if (!is.null(self$`organization`)) {
        sprintf(
        '"organization":
          "%s"
                ',
        self$`organization`
        )},
        if (!is.null(self$`toolname`)) {
        sprintf(
        '"toolname":
          "%s"
                ',
        self$`toolname`
        )},
        if (!is.null(self$`toolclass`)) {
        sprintf(
        '"toolclass":
        %s
        ',
        jsonlite::toJSON(self$`toolclass`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`description`)) {
        sprintf(
        '"description":
          "%s"
                ',
        self$`description`
        )},
        if (!is.null(self$`author`)) {
        sprintf(
        '"author":
          "%s"
                ',
        self$`author`
        )},
        if (!is.null(self$`meta-version`)) {
        sprintf(
        '"meta-version":
          "%s"
                ',
        self$`meta-version`
        )},
        if (!is.null(self$`contains`)) {
        sprintf(
        '"contains":
           [%s]
        ',
        paste(unlist(lapply(self$`contains`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`verified`)) {
        sprintf(
        '"verified":
          "%s"
                ',
        self$`verified`
        )},
        if (!is.null(self$`verified-source`)) {
        sprintf(
        '"verified-source":
          "%s"
                ',
        self$`verified-source`
        )},
        if (!is.null(self$`signed`)) {
        sprintf(
        '"signed":
          "%s"
                ',
        self$`signed`
        )},
        if (!is.null(self$`versions`)) {
        sprintf(
        '"versions":
        [%s]
',
        paste(sapply(self$`versions`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ToolJson) {
      ToolObject <- jsonlite::fromJSON(ToolJson)
      self$`url` <- ToolObject$`url`
      self$`id` <- ToolObject$`id`
      self$`organization` <- ToolObject$`organization`
      self$`toolname` <- ToolObject$`toolname`
      self$`toolclass` <- ToolClass$new()$fromJSON(jsonlite::toJSON(ToolObject$toolclass, auto_unbox = TRUE, digits = NA))
      self$`description` <- ToolObject$`description`
      self$`author` <- ToolObject$`author`
      self$`meta-version` <- ToolObject$`meta-version`
      self$`contains` <- ApiClient$new()$deserializeObj(ToolObject$`contains`, "array[character]", loadNamespace("openapi"))
      self$`verified` <- ToolObject$`verified`
      self$`verified-source` <- ToolObject$`verified-source`
      self$`signed` <- ToolObject$`signed`
      self$`versions` <- ApiClient$new()$deserializeObj(ToolObject$`versions`, "array[ToolVersion]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.