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


#' FileRenameAction Class
#'
#' Request for a file/folder to be renamed on the target system. Metadata will be preserved after rename. Rename operations are only applied relative to the file/folder given in the URL. To rename a file/folder to a different path, see the FileMoveAction.
#'
#' @field action 
#' @field path Name of new directory or target file or folder.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FileRenameAction <- R6::R6Class(
  'FileRenameAction',
  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() {
      FileRenameActionObject <- list()
      if (!is.null(self$`action`)) {
        FileRenameActionObject[['action']] <- self$`action`$toJSON()
      }
      else {
        FileRenameActionObject[['action']] <- NULL
      }
      if (!is.null(self$`path`)) {
        FileRenameActionObject[['path']] <- self$`path`
      }
      else {
        FileRenameActionObject[['path']] <- NULL
      }

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

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

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

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