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


#' FileImportRequest Class
#'
#' File import request to copy a file from an accessible URL.
#'
#' @field fileType The file format this file is in. Defaults to raw. This will be used in file transform operations.
#' @field notifications Notifications to set with the successful acceptance of this upload request
#' @field fileName The name to give the upload file. If unset, takes the original file name.
#' @field append Boolean flag indicating this file should be appended to the target file
#' @field urlToImport The URL to import the file from. This parameter is used if not file is uploaded with this post.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FileImportRequest <- R6::R6Class(
  'FileImportRequest',
  public = list(
    `fileType` = NULL,
    `notifications` = NULL,
    `fileName` = NULL,
    `append` = NULL,
    `urlToImport` = NULL,
    initialize = function(`fileType`, `notifications`, `fileName`, `append`, `urlToImport`){
      if (!missing(`fileType`)) {
        stopifnot(is.character(`fileType`), length(`fileType`) == 1)
        self$`fileType` <- `fileType`
      }
      if (!missing(`notifications`)) {
        stopifnot(is.list(`notifications`), length(`notifications`) != 0)
        lapply(`notifications`, function(x) stopifnot(R6::is.R6(x)))
        self$`notifications` <- `notifications`
      }
      if (!missing(`fileName`)) {
        stopifnot(is.character(`fileName`), length(`fileName`) == 1)
        self$`fileName` <- `fileName`
      }
      if (!missing(`append`)) {
        self$`append` <- `append`
      }
      if (!missing(`urlToImport`)) {
        stopifnot(is.character(`urlToImport`), length(`urlToImport`) == 1)
        self$`urlToImport` <- `urlToImport`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      FileImportRequestObject <- list()
      if (!is.null(self$`fileType`)) {
        FileImportRequestObject[['fileType']] <- self$`fileType`
      }
      else {
        FileImportRequestObject[['fileType']] <- NULL
      }
      if (!is.null(self$`notifications`)) {
        FileImportRequestObject[['notifications']] <- lapply(self$`notifications`, function(x) x$toJSON())
      }
      else {
        FileImportRequestObject[['notifications']] <- NULL
      }
      if (!is.null(self$`fileName`)) {
        FileImportRequestObject[['fileName']] <- self$`fileName`
      }
      else {
        FileImportRequestObject[['fileName']] <- NULL
      }
      if (!is.null(self$`append`)) {
        FileImportRequestObject[['append']] <- self$`append`
      }
      else {
        FileImportRequestObject[['append']] <- NULL
      }
      if (!is.null(self$`urlToImport`)) {
        FileImportRequestObject[['urlToImport']] <- self$`urlToImport`
      }
      else {
        FileImportRequestObject[['urlToImport']] <- NULL
      }

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

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

      if (!is.null(FileImportRequestObject$`fileType`)) {
        self$`fileType` <- FileImportRequestObject$`fileType`
      }
      if (!is.null(FileImportRequestObject$`notifications`)) {
        self$`notifications` <- lapply(FileImportRequestObject$`notifications`, function(x) {
          notificationsObject <- NotificationRequest$new()
          notificationsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          notificationsObject
        })
      }
      if (!is.null(FileImportRequestObject$`fileName`)) {
        self$`fileName` <- FileImportRequestObject$`fileName`
      }
      if (!is.null(FileImportRequestObject$`append`)) {
        self$`append` <- FileImportRequestObject$`append`
      }
      if (!is.null(FileImportRequestObject$`urlToImport`)) {
        self$`urlToImport` <- FileImportRequestObject$`urlToImport`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "fileType": %s,
           "notifications": [%s],
           "fileName": %s,
           "append": %s,
           "urlToImport": %s
        }',
        ifelse( is.null(self$`fileType`),"null",paste0(c('"', self$`fileType`, '"'))),
        lapply(self$`notifications`, function(x) paste(x$toJSON(), sep=",")),
        ifelse( is.null(self$`fileName`),"null",paste0(c('"', self$`fileName`, '"'))),
        ifelse( is.null(self$`append`),"null",paste0(c('"', self$`append`, '"'))),
        ifelse( is.null(self$`urlToImport`),"null",paste0(c('"', self$`urlToImport`, '"')))
      )
    },
    fromJSONString = function(FileImportRequestJson) {
      FileImportRequestObject <- jsonlite::fromJSON(FileImportRequestJson)
      self::fromJSON(FileImportRequestObject)

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