R/workflow_description.R

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

#' @docType class
#' @title WorkflowDescription
#'
#' @description WorkflowDescription Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field valid  character 
#'
#' @field errors  list( character ) 
#'
#' @field name  character 
#'
#' @field inputs  list( \link{ToolInputParameter} ) 
#'
#' @field outputs  list( \link{ToolOutputParameter} ) 
#'
#' @field submittedDescriptorType  \link{DescriptorTypeAndVersion} 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
WorkflowDescription <- R6::R6Class(
  'WorkflowDescription',
  public = list(
    `valid` = NULL,
    `errors` = NULL,
    `name` = NULL,
    `inputs` = NULL,
    `outputs` = NULL,
    `submittedDescriptorType` = NULL,
    initialize = function(
        `valid`, `errors`, `name`, `inputs`, `outputs`, `submittedDescriptorType`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`valid`)) {
        self$`valid` <- `valid`
      }
      if (!missing(`errors`)) {
        stopifnot(is.vector(`errors`), length(`errors`) != 0)
        sapply(`errors`, function(x) stopifnot(is.character(x)))
        self$`errors` <- `errors`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`inputs`)) {
        stopifnot(is.vector(`inputs`), length(`inputs`) != 0)
        sapply(`inputs`, function(x) stopifnot(R6::is.R6(x)))
        self$`inputs` <- `inputs`
      }
      if (!missing(`outputs`)) {
        stopifnot(is.vector(`outputs`), length(`outputs`) != 0)
        sapply(`outputs`, function(x) stopifnot(R6::is.R6(x)))
        self$`outputs` <- `outputs`
      }
      if (!missing(`submittedDescriptorType`)) {
        stopifnot(R6::is.R6(`submittedDescriptorType`))
        self$`submittedDescriptorType` <- `submittedDescriptorType`
      }
    },
    toJSON = function() {
      WorkflowDescriptionObject <- list()
      if (!is.null(self$`valid`)) {
        WorkflowDescriptionObject[['valid']] <-
          self$`valid`
      }
      if (!is.null(self$`errors`)) {
        WorkflowDescriptionObject[['errors']] <-
          self$`errors`
      }
      if (!is.null(self$`name`)) {
        WorkflowDescriptionObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`inputs`)) {
        WorkflowDescriptionObject[['inputs']] <-
          lapply(self$`inputs`, function(x) x$toJSON())
      }
      if (!is.null(self$`outputs`)) {
        WorkflowDescriptionObject[['outputs']] <-
          lapply(self$`outputs`, function(x) x$toJSON())
      }
      if (!is.null(self$`submittedDescriptorType`)) {
        WorkflowDescriptionObject[['submittedDescriptorType']] <-
          self$`submittedDescriptorType`$toJSON()
      }

      WorkflowDescriptionObject
    },
    fromJSON = function(WorkflowDescriptionJson) {
      WorkflowDescriptionObject <- jsonlite::fromJSON(WorkflowDescriptionJson)
      if (!is.null(WorkflowDescriptionObject$`valid`)) {
        self$`valid` <- WorkflowDescriptionObject$`valid`
      }
      if (!is.null(WorkflowDescriptionObject$`errors`)) {
        self$`errors` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`errors`, "array[character]", loadNamespace("openapi"))
      }
      if (!is.null(WorkflowDescriptionObject$`name`)) {
        self$`name` <- WorkflowDescriptionObject$`name`
      }
      if (!is.null(WorkflowDescriptionObject$`inputs`)) {
        self$`inputs` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`inputs`, "array[ToolInputParameter]", loadNamespace("openapi"))
      }
      if (!is.null(WorkflowDescriptionObject$`outputs`)) {
        self$`outputs` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`outputs`, "array[ToolOutputParameter]", loadNamespace("openapi"))
      }
      if (!is.null(WorkflowDescriptionObject$`submittedDescriptorType`)) {
        submittedDescriptorTypeObject <- DescriptorTypeAndVersion$new()
        submittedDescriptorTypeObject$fromJSON(jsonlite::toJSON(WorkflowDescriptionObject$submittedDescriptorType, auto_unbox = TRUE, digits = NA))
        self$`submittedDescriptorType` <- submittedDescriptorTypeObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`valid`)) {
        sprintf(
        '"valid":
          "%s"
                ',
        self$`valid`
        )},
        if (!is.null(self$`errors`)) {
        sprintf(
        '"errors":
           [%s]
        ',
        paste(unlist(lapply(self$`errors`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`inputs`)) {
        sprintf(
        '"inputs":
        [%s]
',
        paste(sapply(self$`inputs`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`outputs`)) {
        sprintf(
        '"outputs":
        [%s]
',
        paste(sapply(self$`outputs`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`submittedDescriptorType`)) {
        sprintf(
        '"submittedDescriptorType":
        %s
        ',
        jsonlite::toJSON(self$`submittedDescriptorType`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(WorkflowDescriptionJson) {
      WorkflowDescriptionObject <- jsonlite::fromJSON(WorkflowDescriptionJson)
      self$`valid` <- WorkflowDescriptionObject$`valid`
      self$`errors` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`errors`, "array[character]", loadNamespace("openapi"))
      self$`name` <- WorkflowDescriptionObject$`name`
      self$`inputs` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`inputs`, "array[ToolInputParameter]", loadNamespace("openapi"))
      self$`outputs` <- ApiClient$new()$deserializeObj(WorkflowDescriptionObject$`outputs`, "array[ToolOutputParameter]", loadNamespace("openapi"))
      self$`submittedDescriptorType` <- DescriptorTypeAndVersion$new()$fromJSON(jsonlite::toJSON(WorkflowDescriptionObject$submittedDescriptorType, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.