R/submission.R

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

#' @docType class
#' @title Submission
#'
#' @description Submission Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field submissionId  character [optional]
#'
#' @field submissionDate  character [optional]
#'
#' @field submitter  character [optional]
#'
#' @field methodConfigurationNamespace  character [optional]
#'
#' @field methodConfigurationName  character [optional]
#'
#' @field submissionEntity  \link{AttributeEntityReference} [optional]
#'
#' @field workflows  list( \link{Workflow} ) [optional]
#'
#' @field status  \link{SubmissionStatus} [optional]
#'
#' @field cost  numeric [optional]
#'
#' @field useCallCache  character [optional]
#'
#' @field deleteIntermediateOutputFiles  character [optional]
#'
#' @field workflowFailureMode  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Submission <- R6::R6Class(
  'Submission',
  public = list(
    `submissionId` = NULL,
    `submissionDate` = NULL,
    `submitter` = NULL,
    `methodConfigurationNamespace` = NULL,
    `methodConfigurationName` = NULL,
    `submissionEntity` = NULL,
    `workflows` = NULL,
    `status` = NULL,
    `cost` = NULL,
    `useCallCache` = NULL,
    `deleteIntermediateOutputFiles` = NULL,
    `workflowFailureMode` = NULL,
    initialize = function(
        `submissionId`=NULL, `submissionDate`=NULL, `submitter`=NULL, `methodConfigurationNamespace`=NULL, `methodConfigurationName`=NULL, `submissionEntity`=NULL, `workflows`=NULL, `status`=NULL, `cost`=NULL, `useCallCache`=NULL, `deleteIntermediateOutputFiles`=NULL, `workflowFailureMode`='NoNewCalls', ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`submissionId`)) {
        stopifnot(is.character(`submissionId`), length(`submissionId`) == 1)
        self$`submissionId` <- `submissionId`
      }
      if (!is.null(`submissionDate`)) {
        stopifnot(is.character(`submissionDate`), length(`submissionDate`) == 1)
        self$`submissionDate` <- `submissionDate`
      }
      if (!is.null(`submitter`)) {
        stopifnot(is.character(`submitter`), length(`submitter`) == 1)
        self$`submitter` <- `submitter`
      }
      if (!is.null(`methodConfigurationNamespace`)) {
        stopifnot(is.character(`methodConfigurationNamespace`), length(`methodConfigurationNamespace`) == 1)
        self$`methodConfigurationNamespace` <- `methodConfigurationNamespace`
      }
      if (!is.null(`methodConfigurationName`)) {
        stopifnot(is.character(`methodConfigurationName`), length(`methodConfigurationName`) == 1)
        self$`methodConfigurationName` <- `methodConfigurationName`
      }
      if (!is.null(`submissionEntity`)) {
        stopifnot(R6::is.R6(`submissionEntity`))
        self$`submissionEntity` <- `submissionEntity`
      }
      if (!is.null(`workflows`)) {
        stopifnot(is.vector(`workflows`), length(`workflows`) != 0)
        sapply(`workflows`, function(x) stopifnot(R6::is.R6(x)))
        self$`workflows` <- `workflows`
      }
      if (!is.null(`status`)) {
        stopifnot(R6::is.R6(`status`))
        self$`status` <- `status`
      }
      if (!is.null(`cost`)) {
        stopifnot(is.numeric(`cost`), length(`cost`) == 1)
        self$`cost` <- `cost`
      }
      if (!is.null(`useCallCache`)) {
        self$`useCallCache` <- `useCallCache`
      }
      if (!is.null(`deleteIntermediateOutputFiles`)) {
        self$`deleteIntermediateOutputFiles` <- `deleteIntermediateOutputFiles`
      }
      if (!is.null(`workflowFailureMode`)) {
        stopifnot(is.character(`workflowFailureMode`), length(`workflowFailureMode`) == 1)
        self$`workflowFailureMode` <- `workflowFailureMode`
      }
    },
    toJSON = function() {
      SubmissionObject <- list()
      if (!is.null(self$`submissionId`)) {
        SubmissionObject[['submissionId']] <-
          self$`submissionId`
      }
      if (!is.null(self$`submissionDate`)) {
        SubmissionObject[['submissionDate']] <-
          self$`submissionDate`
      }
      if (!is.null(self$`submitter`)) {
        SubmissionObject[['submitter']] <-
          self$`submitter`
      }
      if (!is.null(self$`methodConfigurationNamespace`)) {
        SubmissionObject[['methodConfigurationNamespace']] <-
          self$`methodConfigurationNamespace`
      }
      if (!is.null(self$`methodConfigurationName`)) {
        SubmissionObject[['methodConfigurationName']] <-
          self$`methodConfigurationName`
      }
      if (!is.null(self$`submissionEntity`)) {
        SubmissionObject[['submissionEntity']] <-
          self$`submissionEntity`$toJSON()
      }
      if (!is.null(self$`workflows`)) {
        SubmissionObject[['workflows']] <-
          lapply(self$`workflows`, function(x) x$toJSON())
      }
      if (!is.null(self$`status`)) {
        SubmissionObject[['status']] <-
          self$`status`$toJSON()
      }
      if (!is.null(self$`cost`)) {
        SubmissionObject[['cost']] <-
          self$`cost`
      }
      if (!is.null(self$`useCallCache`)) {
        SubmissionObject[['useCallCache']] <-
          self$`useCallCache`
      }
      if (!is.null(self$`deleteIntermediateOutputFiles`)) {
        SubmissionObject[['deleteIntermediateOutputFiles']] <-
          self$`deleteIntermediateOutputFiles`
      }
      if (!is.null(self$`workflowFailureMode`)) {
        SubmissionObject[['workflowFailureMode']] <-
          self$`workflowFailureMode`
      }

      SubmissionObject
    },
    fromJSON = function(SubmissionJson) {
      SubmissionObject <- jsonlite::fromJSON(SubmissionJson)
      if (!is.null(SubmissionObject$`submissionId`)) {
        self$`submissionId` <- SubmissionObject$`submissionId`
      }
      if (!is.null(SubmissionObject$`submissionDate`)) {
        self$`submissionDate` <- SubmissionObject$`submissionDate`
      }
      if (!is.null(SubmissionObject$`submitter`)) {
        self$`submitter` <- SubmissionObject$`submitter`
      }
      if (!is.null(SubmissionObject$`methodConfigurationNamespace`)) {
        self$`methodConfigurationNamespace` <- SubmissionObject$`methodConfigurationNamespace`
      }
      if (!is.null(SubmissionObject$`methodConfigurationName`)) {
        self$`methodConfigurationName` <- SubmissionObject$`methodConfigurationName`
      }
      if (!is.null(SubmissionObject$`submissionEntity`)) {
        submissionEntityObject <- AttributeEntityReference$new()
        submissionEntityObject$fromJSON(jsonlite::toJSON(SubmissionObject$submissionEntity, auto_unbox = TRUE, digits = NA))
        self$`submissionEntity` <- submissionEntityObject
      }
      if (!is.null(SubmissionObject$`workflows`)) {
        self$`workflows` <- ApiClient$new()$deserializeObj(SubmissionObject$`workflows`, "array[Workflow]", loadNamespace("openapi"))
      }
      if (!is.null(SubmissionObject$`status`)) {
        statusObject <- SubmissionStatus$new()
        statusObject$fromJSON(jsonlite::toJSON(SubmissionObject$status, auto_unbox = TRUE, digits = NA))
        self$`status` <- statusObject
      }
      if (!is.null(SubmissionObject$`cost`)) {
        self$`cost` <- SubmissionObject$`cost`
      }
      if (!is.null(SubmissionObject$`useCallCache`)) {
        self$`useCallCache` <- SubmissionObject$`useCallCache`
      }
      if (!is.null(SubmissionObject$`deleteIntermediateOutputFiles`)) {
        self$`deleteIntermediateOutputFiles` <- SubmissionObject$`deleteIntermediateOutputFiles`
      }
      if (!is.null(SubmissionObject$`workflowFailureMode`)) {
        self$`workflowFailureMode` <- SubmissionObject$`workflowFailureMode`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`submissionId`)) {
        sprintf(
        '"submissionId":
          "%s"
                ',
        self$`submissionId`
        )},
        if (!is.null(self$`submissionDate`)) {
        sprintf(
        '"submissionDate":
          "%s"
                ',
        self$`submissionDate`
        )},
        if (!is.null(self$`submitter`)) {
        sprintf(
        '"submitter":
          "%s"
                ',
        self$`submitter`
        )},
        if (!is.null(self$`methodConfigurationNamespace`)) {
        sprintf(
        '"methodConfigurationNamespace":
          "%s"
                ',
        self$`methodConfigurationNamespace`
        )},
        if (!is.null(self$`methodConfigurationName`)) {
        sprintf(
        '"methodConfigurationName":
          "%s"
                ',
        self$`methodConfigurationName`
        )},
        if (!is.null(self$`submissionEntity`)) {
        sprintf(
        '"submissionEntity":
        %s
        ',
        jsonlite::toJSON(self$`submissionEntity`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`workflows`)) {
        sprintf(
        '"workflows":
        [%s]
',
        paste(sapply(self$`workflows`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`status`)) {
        sprintf(
        '"status":
        %s
        ',
        jsonlite::toJSON(self$`status`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`cost`)) {
        sprintf(
        '"cost":
          %d
                ',
        self$`cost`
        )},
        if (!is.null(self$`useCallCache`)) {
        sprintf(
        '"useCallCache":
          "%s"
                ',
        self$`useCallCache`
        )},
        if (!is.null(self$`deleteIntermediateOutputFiles`)) {
        sprintf(
        '"deleteIntermediateOutputFiles":
          "%s"
                ',
        self$`deleteIntermediateOutputFiles`
        )},
        if (!is.null(self$`workflowFailureMode`)) {
        sprintf(
        '"workflowFailureMode":
          "%s"
                ',
        self$`workflowFailureMode`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SubmissionJson) {
      SubmissionObject <- jsonlite::fromJSON(SubmissionJson)
      self$`submissionId` <- SubmissionObject$`submissionId`
      self$`submissionDate` <- SubmissionObject$`submissionDate`
      self$`submitter` <- SubmissionObject$`submitter`
      self$`methodConfigurationNamespace` <- SubmissionObject$`methodConfigurationNamespace`
      self$`methodConfigurationName` <- SubmissionObject$`methodConfigurationName`
      self$`submissionEntity` <- AttributeEntityReference$new()$fromJSON(jsonlite::toJSON(SubmissionObject$submissionEntity, auto_unbox = TRUE, digits = NA))
      self$`workflows` <- ApiClient$new()$deserializeObj(SubmissionObject$`workflows`, "array[Workflow]", loadNamespace("openapi"))
      self$`status` <- SubmissionStatus$new()$fromJSON(jsonlite::toJSON(SubmissionObject$status, auto_unbox = TRUE, digits = NA))
      self$`cost` <- SubmissionObject$`cost`
      self$`useCallCache` <- SubmissionObject$`useCallCache`
      self$`deleteIntermediateOutputFiles` <- SubmissionObject$`deleteIntermediateOutputFiles`
      self$`workflowFailureMode` <- SubmissionObject$`workflowFailureMode`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.