R/workflow_metadata_response.R

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

#' @docType class
#' @title WorkflowMetadataResponse
#'
#' @description WorkflowMetadataResponse Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field id  character 
#'
#' @field status  character 
#'
#' @field submission  character 
#'
#' @field start  character [optional]
#'
#' @field end  character [optional]
#'
#' @field inputs  named list( object ) [optional]
#'
#' @field outputs  named list( object ) [optional]
#'
#' @field calls  \link{CallMetadata} [optional]
#'
#' @field failures  \link{FailureMessage} [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
WorkflowMetadataResponse <- R6::R6Class(
  'WorkflowMetadataResponse',
  public = list(
    `id` = NULL,
    `status` = NULL,
    `submission` = NULL,
    `start` = NULL,
    `end` = NULL,
    `inputs` = NULL,
    `outputs` = NULL,
    `calls` = NULL,
    `failures` = NULL,
    initialize = function(
        `id`, `status`, `submission`, `start`=NULL, `end`=NULL, `inputs`=NULL, `outputs`=NULL, `calls`=NULL, `failures`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`status`)) {
        stopifnot(is.character(`status`), length(`status`) == 1)
        self$`status` <- `status`
      }
      if (!missing(`submission`)) {
        stopifnot(is.character(`submission`), length(`submission`) == 1)
        self$`submission` <- `submission`
      }
      if (!is.null(`start`)) {
        stopifnot(is.character(`start`), length(`start`) == 1)
        self$`start` <- `start`
      }
      if (!is.null(`end`)) {
        stopifnot(is.character(`end`), length(`end`) == 1)
        self$`end` <- `end`
      }
      if (!is.null(`inputs`)) {
        stopifnot(is.vector(`inputs`), length(`inputs`) != 0)
        sapply(`inputs`, function(x) stopifnot(is.character(x)))
        self$`inputs` <- `inputs`
      }
      if (!is.null(`outputs`)) {
        stopifnot(is.vector(`outputs`), length(`outputs`) != 0)
        sapply(`outputs`, function(x) stopifnot(is.character(x)))
        self$`outputs` <- `outputs`
      }
      if (!is.null(`calls`)) {
        stopifnot(R6::is.R6(`calls`))
        self$`calls` <- `calls`
      }
      if (!is.null(`failures`)) {
        stopifnot(R6::is.R6(`failures`))
        self$`failures` <- `failures`
      }
    },
    toJSON = function() {
      WorkflowMetadataResponseObject <- list()
      if (!is.null(self$`id`)) {
        WorkflowMetadataResponseObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`status`)) {
        WorkflowMetadataResponseObject[['status']] <-
          self$`status`
      }
      if (!is.null(self$`submission`)) {
        WorkflowMetadataResponseObject[['submission']] <-
          self$`submission`
      }
      if (!is.null(self$`start`)) {
        WorkflowMetadataResponseObject[['start']] <-
          self$`start`
      }
      if (!is.null(self$`end`)) {
        WorkflowMetadataResponseObject[['end']] <-
          self$`end`
      }
      if (!is.null(self$`inputs`)) {
        WorkflowMetadataResponseObject[['inputs']] <-
          self$`inputs`
      }
      if (!is.null(self$`outputs`)) {
        WorkflowMetadataResponseObject[['outputs']] <-
          self$`outputs`
      }
      if (!is.null(self$`calls`)) {
        WorkflowMetadataResponseObject[['calls']] <-
          self$`calls`$toJSON()
      }
      if (!is.null(self$`failures`)) {
        WorkflowMetadataResponseObject[['failures']] <-
          self$`failures`$toJSON()
      }

      WorkflowMetadataResponseObject
    },
    fromJSON = function(WorkflowMetadataResponseJson) {
      WorkflowMetadataResponseObject <- jsonlite::fromJSON(WorkflowMetadataResponseJson)
      if (!is.null(WorkflowMetadataResponseObject$`id`)) {
        self$`id` <- WorkflowMetadataResponseObject$`id`
      }
      if (!is.null(WorkflowMetadataResponseObject$`status`)) {
        self$`status` <- WorkflowMetadataResponseObject$`status`
      }
      if (!is.null(WorkflowMetadataResponseObject$`submission`)) {
        self$`submission` <- WorkflowMetadataResponseObject$`submission`
      }
      if (!is.null(WorkflowMetadataResponseObject$`start`)) {
        self$`start` <- WorkflowMetadataResponseObject$`start`
      }
      if (!is.null(WorkflowMetadataResponseObject$`end`)) {
        self$`end` <- WorkflowMetadataResponseObject$`end`
      }
      if (!is.null(WorkflowMetadataResponseObject$`inputs`)) {
        self$`inputs` <- ApiClient$new()$deserializeObj(WorkflowMetadataResponseObject$`inputs`, "map(object)", loadNamespace("openapi"))
      }
      if (!is.null(WorkflowMetadataResponseObject$`outputs`)) {
        self$`outputs` <- ApiClient$new()$deserializeObj(WorkflowMetadataResponseObject$`outputs`, "map(object)", loadNamespace("openapi"))
      }
      if (!is.null(WorkflowMetadataResponseObject$`calls`)) {
        callsObject <- CallMetadata$new()
        callsObject$fromJSON(jsonlite::toJSON(WorkflowMetadataResponseObject$calls, auto_unbox = TRUE, digits = NA))
        self$`calls` <- callsObject
      }
      if (!is.null(WorkflowMetadataResponseObject$`failures`)) {
        failuresObject <- FailureMessage$new()
        failuresObject$fromJSON(jsonlite::toJSON(WorkflowMetadataResponseObject$failures, auto_unbox = TRUE, digits = NA))
        self$`failures` <- failuresObject
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`id`)) {
        sprintf(
        '"id":
          "%s"
                ',
        self$`id`
        )},
        if (!is.null(self$`status`)) {
        sprintf(
        '"status":
          "%s"
                ',
        self$`status`
        )},
        if (!is.null(self$`submission`)) {
        sprintf(
        '"submission":
          "%s"
                ',
        self$`submission`
        )},
        if (!is.null(self$`start`)) {
        sprintf(
        '"start":
          "%s"
                ',
        self$`start`
        )},
        if (!is.null(self$`end`)) {
        sprintf(
        '"end":
          "%s"
                ',
        self$`end`
        )},
        if (!is.null(self$`inputs`)) {
        sprintf(
        '"inputs":
          "%s"
        ',
        jsonlite::toJSON(lapply(self$`inputs`, function(x){ x }), auto_unbox = TRUE, digits=NA)
        )},
        if (!is.null(self$`outputs`)) {
        sprintf(
        '"outputs":
          "%s"
        ',
        jsonlite::toJSON(lapply(self$`outputs`, function(x){ x }), auto_unbox = TRUE, digits=NA)
        )},
        if (!is.null(self$`calls`)) {
        sprintf(
        '"calls":
        %s
        ',
        jsonlite::toJSON(self$`calls`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`failures`)) {
        sprintf(
        '"failures":
        %s
        ',
        jsonlite::toJSON(self$`failures`$toJSON(), auto_unbox=TRUE, digits = NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(WorkflowMetadataResponseJson) {
      WorkflowMetadataResponseObject <- jsonlite::fromJSON(WorkflowMetadataResponseJson)
      self$`id` <- WorkflowMetadataResponseObject$`id`
      self$`status` <- WorkflowMetadataResponseObject$`status`
      self$`submission` <- WorkflowMetadataResponseObject$`submission`
      self$`start` <- WorkflowMetadataResponseObject$`start`
      self$`end` <- WorkflowMetadataResponseObject$`end`
      self$`inputs` <- ApiClient$new()$deserializeObj(WorkflowMetadataResponseObject$`inputs`, "map(object)", loadNamespace("openapi"))
      self$`outputs` <- ApiClient$new()$deserializeObj(WorkflowMetadataResponseObject$`outputs`, "map(object)", loadNamespace("openapi"))
      self$`calls` <- CallMetadata$new()$fromJSON(jsonlite::toJSON(WorkflowMetadataResponseObject$calls, auto_unbox = TRUE, digits = NA))
      self$`failures` <- FailureMessage$new()$fromJSON(jsonlite::toJSON(WorkflowMetadataResponseObject$failures, auto_unbox = TRUE, digits = NA))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.