R/Job.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' Job Class
#'
#' 
#'
#' @field appId The unique name of the application being run by this job. This must be a valid application that the calling user has permission to run.
#' @field archive Whether the output from this job should be archived. If true, all new files created by this application's execution will be archived to the archivePath in the user's default storage system.
#' @field archivePath The path of the archive folder for this job on default storage sytem of the user
#' @field archiveSystem The unique id of the storage system on which this job output will be staged.
#' @field batchQueue The queue to which this job should be submitted. This is optional and only applies when the execution system has a batch scheduler.
#' @field endTime The date the job stopped running due to termination, completion, or error in ISO 8601 format.
#' @field executionSystem The system id of the execution system.
#' @field id The unique id of the job.
#' @field inputs 
#' @field localId The process or local job id of the job on the remote execution system.
#' @field memoryPerNode The requested memory for this application to run given in GB.
#' @field message The error message incurred when the job failed.
#' @field name The name of the job.
#' @field nodeCount The number of processors this application should utilize while running. If the application is not of executionType PARALLEL, this should be 1.
#' @field notifications An array of notifications you wish to receive.
#' @field outputPath Relative path of the job output data.
#' @field owner The job owner.
#' @field parameters 
#' @field processorsPerNode The number of processors this application should utilize while running. If the application is not of executionType PARALLEL, this should be 1.
#' @field maxRunTime The requested compute time needed for this application to complete given in HH:mm:ss format.
#' @field retries The number of retires it took to submit this job.
#' @field startTime The date the job started in ISO 8601 format.
#' @field status The status of the job. Possible values are: PENDING, STAGING_INPUTS, CLEANING_UP, ARCHIVING, STAGING_JOB, FINISHED, KILLED, FAILED, STOPPED, RUNNING, PAUSED, QUEUED, SUBMITTING, STAGED, PROCESSING_INPUTS, ARCHIVING_FINISHED, ARCHIVING_FAILED
#' @field submitTime The date the job was submitted in ISO 8601 format.
#' @field workPath The directory on the remote execution system from which the job is running.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Job <- R6::R6Class(
  'Job',
  public = list(
    `appId` = NULL,
    `archive` = NULL,
    `archivePath` = NULL,
    `archiveSystem` = NULL,
    `batchQueue` = NULL,
    `endTime` = NULL,
    `executionSystem` = NULL,
    `id` = NULL,
    `inputs` = NULL,
    `localId` = NULL,
    `memoryPerNode` = NULL,
    `message` = NULL,
    `name` = NULL,
    `nodeCount` = NULL,
    `notifications` = NULL,
    `outputPath` = NULL,
    `owner` = NULL,
    `parameters` = NULL,
    `processorsPerNode` = NULL,
    `maxRunTime` = NULL,
    `retries` = NULL,
    `startTime` = NULL,
    `status` = NULL,
    `submitTime` = NULL,
    `workPath` = NULL,
    initialize = function(`appId`, `archive`, `archivePath`, `archiveSystem`, `batchQueue`, `endTime`, `executionSystem`, `id`, `inputs`, `localId`, `memoryPerNode`, `message`, `name`, `nodeCount`, `notifications`, `outputPath`, `owner`, `parameters`, `processorsPerNode`, `maxRunTime`, `retries`, `startTime`, `status`, `submitTime`, `workPath`){
      if (!missing(`appId`)) {
        stopifnot(is.character(`appId`), length(`appId`) == 1)
        self$`appId` <- `appId`
      }
      if (!missing(`archive`)) {
        self$`archive` <- `archive`
      }
      if (!missing(`archivePath`)) {
        stopifnot(is.character(`archivePath`), length(`archivePath`) == 1)
        self$`archivePath` <- `archivePath`
      }
      if (!missing(`archiveSystem`)) {
        stopifnot(is.character(`archiveSystem`), length(`archiveSystem`) == 1)
        self$`archiveSystem` <- `archiveSystem`
      }
      if (!missing(`batchQueue`)) {
        stopifnot(is.character(`batchQueue`), length(`batchQueue`) == 1)
        self$`batchQueue` <- `batchQueue`
      }
      if (!missing(`endTime`)) {
        stopifnot(is.character(`endTime`), length(`endTime`) == 1)
        self$`endTime` <- `endTime`
      }
      if (!missing(`executionSystem`)) {
        stopifnot(is.character(`executionSystem`), length(`executionSystem`) == 1)
        self$`executionSystem` <- `executionSystem`
      }
      if (!missing(`id`)) {
        stopifnot(is.numeric(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`inputs`)) {
        stopifnot(R6::is.R6(`inputs`))
        self$`inputs` <- `inputs`
      }
      if (!missing(`localId`)) {
        stopifnot(is.character(`localId`), length(`localId`) == 1)
        self$`localId` <- `localId`
      }
      if (!missing(`memoryPerNode`)) {
        stopifnot(is.character(`memoryPerNode`), length(`memoryPerNode`) == 1)
        self$`memoryPerNode` <- `memoryPerNode`
      }
      if (!missing(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`nodeCount`)) {
        stopifnot(is.numeric(`nodeCount`), length(`nodeCount`) == 1)
        self$`nodeCount` <- `nodeCount`
      }
      if (!missing(`notifications`)) {
        stopifnot(is.list(`notifications`), length(`notifications`) != 0)
        lapply(`notifications`, function(x) stopifnot(R6::is.R6(x)))
        self$`notifications` <- `notifications`
      }
      if (!missing(`outputPath`)) {
        stopifnot(is.character(`outputPath`), length(`outputPath`) == 1)
        self$`outputPath` <- `outputPath`
      }
      if (!missing(`owner`)) {
        stopifnot(is.character(`owner`), length(`owner`) == 1)
        self$`owner` <- `owner`
      }
      if (!missing(`parameters`)) {
        stopifnot(R6::is.R6(`parameters`))
        self$`parameters` <- `parameters`
      }
      if (!missing(`processorsPerNode`)) {
        stopifnot(is.numeric(`processorsPerNode`), length(`processorsPerNode`) == 1)
        self$`processorsPerNode` <- `processorsPerNode`
      }
      if (!missing(`maxRunTime`)) {
        stopifnot(is.character(`maxRunTime`), length(`maxRunTime`) == 1)
        self$`maxRunTime` <- `maxRunTime`
      }
      if (!missing(`retries`)) {
        stopifnot(is.numeric(`retries`), length(`retries`) == 1)
        self$`retries` <- `retries`
      }
      if (!missing(`startTime`)) {
        stopifnot(is.character(`startTime`), length(`startTime`) == 1)
        self$`startTime` <- `startTime`
      }
      if (!missing(`status`)) {
        stopifnot(is.character(`status`), length(`status`) == 1)
        self$`status` <- `status`
      }
      if (!missing(`submitTime`)) {
        stopifnot(is.character(`submitTime`), length(`submitTime`) == 1)
        self$`submitTime` <- `submitTime`
      }
      if (!missing(`workPath`)) {
        stopifnot(is.character(`workPath`), length(`workPath`) == 1)
        self$`workPath` <- `workPath`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      JobObject <- list()
      if (!is.null(self$`appId`)) {
        JobObject[['appId']] <- self$`appId`
      }
      else {
        JobObject[['appId']] <- NULL
      }
      if (!is.null(self$`archive`)) {
        JobObject[['archive']] <- self$`archive`
      }
      else {
        JobObject[['archive']] <- NULL
      }
      if (!is.null(self$`archivePath`)) {
        JobObject[['archivePath']] <- self$`archivePath`
      }
      else {
        JobObject[['archivePath']] <- NULL
      }
      if (!is.null(self$`archiveSystem`)) {
        JobObject[['archiveSystem']] <- self$`archiveSystem`
      }
      else {
        JobObject[['archiveSystem']] <- NULL
      }
      if (!is.null(self$`batchQueue`)) {
        JobObject[['batchQueue']] <- self$`batchQueue`
      }
      else {
        JobObject[['batchQueue']] <- NULL
      }
      if (!is.null(self$`endTime`)) {
        JobObject[['endTime']] <- self$`endTime`
      }
      else {
        JobObject[['endTime']] <- NULL
      }
      if (!is.null(self$`executionSystem`)) {
        JobObject[['executionSystem']] <- self$`executionSystem`
      }
      else {
        JobObject[['executionSystem']] <- NULL
      }
      if (!is.null(self$`id`)) {
        JobObject[['id']] <- self$`id`
      }
      else {
        JobObject[['id']] <- NULL
      }
      if (!is.null(self$`inputs`)) {
        JobObject[['inputs']] <- self$`inputs`$toJSON()
      }
      else {
        JobObject[['inputs']] <- NULL
      }
      if (!is.null(self$`localId`)) {
        JobObject[['localId']] <- self$`localId`
      }
      else {
        JobObject[['localId']] <- NULL
      }
      if (!is.null(self$`memoryPerNode`)) {
        JobObject[['memoryPerNode']] <- self$`memoryPerNode`
      }
      else {
        JobObject[['memoryPerNode']] <- NULL
      }
      if (!is.null(self$`message`)) {
        JobObject[['message']] <- self$`message`
      }
      else {
        JobObject[['message']] <- NULL
      }
      if (!is.null(self$`name`)) {
        JobObject[['name']] <- self$`name`
      }
      else {
        JobObject[['name']] <- NULL
      }
      if (!is.null(self$`nodeCount`)) {
        JobObject[['nodeCount']] <- self$`nodeCount`
      }
      else {
        JobObject[['nodeCount']] <- NULL
      }
      if (!is.null(self$`notifications`)) {
        JobObject[['notifications']] <- lapply(self$`notifications`, function(x) x$toJSON())
      }
      else {
        JobObject[['notifications']] <- NULL
      }
      if (!is.null(self$`outputPath`)) {
        JobObject[['outputPath']] <- self$`outputPath`
      }
      else {
        JobObject[['outputPath']] <- NULL
      }
      if (!is.null(self$`owner`)) {
        JobObject[['owner']] <- self$`owner`
      }
      else {
        JobObject[['owner']] <- NULL
      }
      if (!is.null(self$`parameters`)) {
        JobObject[['parameters']] <- self$`parameters`$toJSON()
      }
      else {
        JobObject[['parameters']] <- NULL
      }
      if (!is.null(self$`processorsPerNode`)) {
        JobObject[['processorsPerNode']] <- self$`processorsPerNode`
      }
      else {
        JobObject[['processorsPerNode']] <- NULL
      }
      if (!is.null(self$`maxRunTime`)) {
        JobObject[['maxRunTime']] <- self$`maxRunTime`
      }
      else {
        JobObject[['maxRunTime']] <- NULL
      }
      if (!is.null(self$`retries`)) {
        JobObject[['retries']] <- self$`retries`
      }
      else {
        JobObject[['retries']] <- NULL
      }
      if (!is.null(self$`startTime`)) {
        JobObject[['startTime']] <- self$`startTime`
      }
      else {
        JobObject[['startTime']] <- NULL
      }
      if (!is.null(self$`status`)) {
        JobObject[['status']] <- self$`status`
      }
      else {
        JobObject[['status']] <- NULL
      }
      if (!is.null(self$`submitTime`)) {
        JobObject[['submitTime']] <- self$`submitTime`
      }
      else {
        JobObject[['submitTime']] <- NULL
      }
      if (!is.null(self$`workPath`)) {
        JobObject[['workPath']] <- self$`workPath`
      }
      else {
        JobObject[['workPath']] <- NULL
      }

      JobObject
    },
    fromJSON = function(JobObject) {
      if (is.character(JobObject)) {
        JobObject <- jsonlite::fromJSON(JobJson)
      }

      if ("result" %in% names(JobObject)) {
        JobObject <- JobObject$result
      }

      if (!is.null(JobObject$`appId`)) {
        self$`appId` <- JobObject$`appId`
      }
      if (!is.null(JobObject$`archive`)) {
        self$`archive` <- JobObject$`archive`
      }
      if (!is.null(JobObject$`archivePath`)) {
        self$`archivePath` <- JobObject$`archivePath`
      }
      if (!is.null(JobObject$`archiveSystem`)) {
        self$`archiveSystem` <- JobObject$`archiveSystem`
      }
      if (!is.null(JobObject$`batchQueue`)) {
        self$`batchQueue` <- JobObject$`batchQueue`
      }
      if (!is.null(JobObject$`endTime`)) {
        self$`endTime` <- JobObject$`endTime`
      }
      if (!is.null(JobObject$`executionSystem`)) {
        self$`executionSystem` <- JobObject$`executionSystem`
      }
      if (!is.null(JobObject$`id`)) {
        self$`id` <- JobObject$`id`
      }
      if (!is.null(JobObject$`inputs`)) {
        inputsObject <- JobInputs$new()
        inputsObject$fromJSON(jsonlite::toJSON(JobObject$inputs, auto_unbox = TRUE))
        self$`inputs` <- inputsObject
      }
      if (!is.null(JobObject$`localId`)) {
        self$`localId` <- JobObject$`localId`
      }
      if (!is.null(JobObject$`memoryPerNode`)) {
        self$`memoryPerNode` <- JobObject$`memoryPerNode`
      }
      if (!is.null(JobObject$`message`)) {
        self$`message` <- JobObject$`message`
      }
      if (!is.null(JobObject$`name`)) {
        self$`name` <- JobObject$`name`
      }
      if (!is.null(JobObject$`nodeCount`)) {
        self$`nodeCount` <- JobObject$`nodeCount`
      }
      if (!is.null(JobObject$`notifications`)) {
        self$`notifications` <- lapply(JobObject$`notifications`, function(x) {
          notificationsObject <- Notification$new()
          notificationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          notificationsObject
        })
      }
      if (!is.null(JobObject$`outputPath`)) {
        self$`outputPath` <- JobObject$`outputPath`
      }
      if (!is.null(JobObject$`owner`)) {
        self$`owner` <- JobObject$`owner`
      }
      if (!is.null(JobObject$`parameters`)) {
        parametersObject <- JobParameters$new()
        parametersObject$fromJSON(jsonlite::toJSON(JobObject$parameters, auto_unbox = TRUE))
        self$`parameters` <- parametersObject
      }
      if (!is.null(JobObject$`processorsPerNode`)) {
        self$`processorsPerNode` <- JobObject$`processorsPerNode`
      }
      if (!is.null(JobObject$`maxRunTime`)) {
        self$`maxRunTime` <- JobObject$`maxRunTime`
      }
      if (!is.null(JobObject$`retries`)) {
        self$`retries` <- JobObject$`retries`
      }
      if (!is.null(JobObject$`startTime`)) {
        self$`startTime` <- JobObject$`startTime`
      }
      if (!is.null(JobObject$`status`)) {
        self$`status` <- JobObject$`status`
      }
      if (!is.null(JobObject$`submitTime`)) {
        self$`submitTime` <- JobObject$`submitTime`
      }
      if (!is.null(JobObject$`workPath`)) {
        self$`workPath` <- JobObject$`workPath`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "appId": %s,
           "archive": %s,
           "archivePath": %s,
           "archiveSystem": %s,
           "batchQueue": %s,
           "endTime": %s,
           "executionSystem": %s,
           "id": %d,
           "inputs": %s,
           "localId": %s,
           "memoryPerNode": %s,
           "message": %s,
           "name": %s,
           "nodeCount": %d,
           "notifications": [%s],
           "outputPath": %s,
           "owner": %s,
           "parameters": %s,
           "processorsPerNode": %d,
           "maxRunTime": %s,
           "retries": %d,
           "startTime": %s,
           "status": %s,
           "submitTime": %s,
           "workPath": %s
        }',
        ifelse( is.null(self$`appId`),"null",paste0(c('"', self$`appId`, '"'))),
        ifelse( is.null(self$`archive`),"null",paste0(c('"', self$`archive`, '"'))),
        ifelse( is.null(self$`archivePath`),"null",paste0(c('"', self$`archivePath`, '"'))),
        ifelse( is.null(self$`archiveSystem`),"null",paste0(c('"', self$`archiveSystem`, '"'))),
        ifelse( is.null(self$`batchQueue`),"null",paste0(c('"', self$`batchQueue`, '"'))),
        ifelse( is.null(self$`endTime`),"null",paste0(c('"', self$`endTime`, '"'))),
        ifelse( is.null(self$`executionSystem`),"null",paste0(c('"', self$`executionSystem`, '"'))),
        ifelse( is.null(self$`id`),"null",paste0(c('"', self$`id`, '"'))),
        self$`inputs`$toJSON(),
        ifelse( is.null(self$`localId`),"null",paste0(c('"', self$`localId`, '"'))),
        ifelse( is.null(self$`memoryPerNode`),"null",paste0(c('"', self$`memoryPerNode`, '"'))),
        ifelse( is.null(self$`message`),"null",paste0(c('"', self$`message`, '"'))),
        ifelse( is.null(self$`name`),"null",paste0(c('"', self$`name`, '"'))),
        ifelse( is.null(self$`nodeCount`),"null",paste0(c('"', self$`nodeCount`, '"'))),
        lapply(self$`notifications`, function(x) paste(x$toJSON(), sep=",")),
        ifelse( is.null(self$`outputPath`),"null",paste0(c('"', self$`outputPath`, '"'))),
        ifelse( is.null(self$`owner`),"null",paste0(c('"', self$`owner`, '"'))),
        self$`parameters`$toJSON(),
        ifelse( is.null(self$`processorsPerNode`),"null",paste0(c('"', self$`processorsPerNode`, '"'))),
        ifelse( is.null(self$`maxRunTime`),"null",paste0(c('"', self$`maxRunTime`, '"'))),
        ifelse( is.null(self$`retries`),"null",paste0(c('"', self$`retries`, '"'))),
        ifelse( is.null(self$`startTime`),"null",paste0(c('"', self$`startTime`, '"'))),
        ifelse( is.null(self$`status`),"null",paste0(c('"', self$`status`, '"'))),
        ifelse( is.null(self$`submitTime`),"null",paste0(c('"', self$`submitTime`, '"'))),
        ifelse( is.null(self$`workPath`),"null",paste0(c('"', self$`workPath`, '"')))
      )
    },
    fromJSONString = function(JobJson) {
      JobObject <- jsonlite::fromJSON(JobJson)
      self::fromJSON(JobObject)

    }
  )
)
deardooley/agave-rlang-sdk documentation built on May 17, 2019, 10:12 p.m.