R/FileMoveAction.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


#' FileMoveAction Class
#'
#' Request for a file/folder to be moved on the target system. Metadata will be preserved after move.
#'
#' @field action 
#' @field path Name of new directory or target file or folder.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FileMoveAction <- R6::R6Class(
  'FileMoveAction',
  public = list(
    `action` = NULL,
    `path` = NULL,
    initialize = function(`action`, `path`){
      if (!missing(`action`)) {
        stopifnot(R6::is.R6(`action`))
        self$`action` <- `action`
      }
      if (!missing(`path`)) {
        stopifnot(is.character(`path`), length(`path`) == 1)
        self$`path` <- `path`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      FileMoveActionObject <- list()
      if (!is.null(self$`action`)) {
        FileMoveActionObject[['action']] <- self$`action`$toJSON()
      }
      else {
        FileMoveActionObject[['action']] <- NULL
      }
      if (!is.null(self$`path`)) {
        FileMoveActionObject[['path']] <- self$`path`
      }
      else {
        FileMoveActionObject[['path']] <- NULL
      }

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

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

      if (!is.null(FileMoveActionObject$`action`)) {
        actionObject <- FileManagementActionType$new()
        actionObject$fromJSON(jsonlite::toJSON(FileMoveActionObject$action, auto_unbox = TRUE))
        self$`action` <- actionObject
      }
      if (!is.null(FileMoveActionObject$`path`)) {
        self$`path` <- FileMoveActionObject$`path`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "action": %s,
           "path": %s
        }',
        self$`action`$toJSON(),
        ifelse( is.null(self$`path`),"null",paste0(c('"', self$`path`, '"')))
      )
    },
    fromJSONString = function(FileMoveActionJson) {
      FileMoveActionObject <- jsonlite::fromJSON(FileMoveActionJson)
      self::fromJSON(FileMoveActionObject)

    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.