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


#' FileInfo Class
#'
#' @field format The file type of the file.
#' @field lastModified The date this file was last modified in ISO 8601 format.
#' @field length The length of the file/folder.
#' @field mimeType The mime type of the file/folder. If unknown, it defaults to application/binary.
#' @field name The name of the file/folder.
#' @field path The absolute path to the file/folder.
#' @field permissions The remote system permission of the invoking user on the file/folder.
#' @field system The id of the system where this file lives.
#' @field type The filetype. Almost always "raw-0" or "dir"
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
FileInfo <- R6::R6Class(
  'FileInfo',
  public = list(
    `format` = NULL,
    `lastModified` = NULL,
    `length` = NULL,
    `mimeType` = NULL,
    `name` = NULL,
    `path` = NULL,
    `permissions` = NULL,
    `system` = NULL,
    `type` = NULL,
    initialize = function(`format`, `lastModified`, `length`, `mimeType`, `name`, `path`, `permissions`, `system`, `type`){
      if (!missing(`format`)) {
        stopifnot(is.character(`format`), length(`format`) == 1)
        self$`format` <- `format`
      }
      if (!missing(`lastModified`)) {
        stopifnot(is.character(`lastModified`), length(`lastModified`) == 1)
        self$`lastModified` <- `lastModified`
      }
      if (!missing(`length`)) {
        stopifnot(is.numeric(`length`), length(`length`) == 1)
        self$`length` <- `length`
      }
      if (!missing(`mimeType`)) {
        stopifnot(is.character(`mimeType`), length(`mimeType`) == 1)
        self$`mimeType` <- `mimeType`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`path`)) {
        stopifnot(is.character(`path`), length(`path`) == 1)
        self$`path` <- `path`
      }
      if (!missing(`permissions`)) {
        stopifnot(is.character(`permissions`), length(`permissions`) == 1)
        self$`permissions` <- `permissions`
      }
      if (!missing(`system`)) {
        stopifnot(is.character(`system`), length(`system`) == 1)
        self$`system` <- `system`
      }
      if (!missing(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
    },
    toJSON = function() {
      FileInfoObject <- list()
      if (!is.null(self$`format`)) {
        FileInfoObject[['format']] <- self$`format`
      }
      if (!is.null(self$`lastModified`)) {
        FileInfoObject[['lastModified']] <- self$`lastModified`
      }
      if (!is.null(self$`length`)) {
        FileInfoObject[['length']] <- self$`length`
      }
      if (!is.null(self$`mimeType`)) {
        FileInfoObject[['mimeType']] <- self$`mimeType`
      }
      if (!is.null(self$`name`)) {
        FileInfoObject[['name']] <- self$`name`
      }
      if (!is.null(self$`path`)) {
        FileInfoObject[['path']] <- self$`path`
      }
      if (!is.null(self$`permissions`)) {
        FileInfoObject[['permissions']] <- self$`permissions`
      }
      if (!is.null(self$`system`)) {
        FileInfoObject[['system']] <- self$`system`
      }
      if (!is.null(self$`type`)) {
        FileInfoObject[['type']] <- self$`type`$toJSON()
      }

      FileInfoObject
    },
    fromJSON = function(FileInfoObject) {
      if (is.character(FileInfoObject) || is.primitive(FileInfoObject)) {
        self$fromJSONString(FileInfoObject)
      }
      else {
        if ("result" %in% names(FileInfoObject)) {
          FileInfoObject <- FileInfoObject$result
        }

        if (!is.null(FileInfoObject$`format`)) {
          self$`format` <- FileInfoObject$`format`
        }
        if (!is.null(FileInfoObject$`lastModified`)) {
          self$`lastModified` <- FileInfoObject$`lastModified`
        }
        if (!is.null(FileInfoObject$`length`)) {
          self$`length` <- FileInfoObject$`length`
        }
        if (!is.null(FileInfoObject$`mimeType`)) {
          self$`mimeType` <- FileInfoObject$`mimeType`
        }
        if (!is.null(FileInfoObject$`name`)) {
          self$`name` <- FileInfoObject$`name`
        }
        if (!is.null(FileInfoObject$`path`)) {
          self$`path` <- FileInfoObject$`path`
        }
        if (!is.null(FileInfoObject$`permissions`)) {
          self$`permissions` <- FileInfoObject$`permissions`
        }
        if (!is.null(FileInfoObject$`system`)) {
          self$`system` <- FileInfoObject$`system`
        }
        if (!is.null(FileInfoObject$`type`)) {
          typeObject <- FileType$new()
          typeObject$fromJSON(jsonlite::toJSON(FileInfoObject$type, auto_unbox = TRUE))
          self$`type` <- typeObject
        }
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "format": %s,
           "lastModified": %s,
           "length": %d,
           "mimeType": %s,
           "name": %s,
           "path": %s,
           "permissions": %s,
           "system": %s,
           "type": %s
        }',
        self$`format`,
        self$`lastModified`,
        self$`length`,
        self$`mimeType`,
        self$`name`,
        self$`path`,
        self$`permissions`,
        self$`system`,
        self$`type`$toJSON()
      )
    },
    fromJSONString = function(FileInfoJson) {
      FileInfoObject <- jsonlite::fromJSON(FileInfoJson)
      if ("result" %in% names(FileInfoObject)) {
        FileInfoObject <- FileInfoObject$result
      }

      self$`format` <- FileInfoObject$`format`
      self$`lastModified` <- FileInfoObject$`lastModified`
      self$`length` <- FileInfoObject$`length`
      self$`mimeType` <- FileInfoObject$`mimeType`
      self$`name` <- FileInfoObject$`name`
      self$`path` <- FileInfoObject$`path`
      self$`permissions` <- FileInfoObject$`permissions`
      self$`system` <- FileInfoObject$`system`
      FileTypeObject <- FileType$new()
      self$`type` <- FileTypeObject$fromJSON(jsonlite::toJSON(FileInfoObject$type, auto_unbox = TRUE))
    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.