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


#' Transform Class
#'
#' 
#'
#' @field decoders The available decoders for this transform.
#' @field description Description of this transform.
#' @field descriptionurl The URL to find out more information.
#' @field enabled Whether this transform is enabled or not.
#' @field encoder 
#' @field name The name of this transform.
#' @field tags The tags describing this transform.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Transform <- R6::R6Class(
  'Transform',
  public = list(
    `decoders` = NULL,
    `description` = NULL,
    `descriptionurl` = NULL,
    `enabled` = NULL,
    `encoder` = NULL,
    `name` = NULL,
    `tags` = NULL,
    initialize = function(`decoders`, `description`, `descriptionurl`, `enabled`, `encoder`, `name`, `tags`){
      if (!missing(`decoders`)) {
        stopifnot(is.list(`decoders`), length(`decoders`) != 0)
        lapply(`decoders`, function(x) stopifnot(R6::is.R6(x)))
        self$`decoders` <- `decoders`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!missing(`descriptionurl`)) {
        stopifnot(is.character(`descriptionurl`), length(`descriptionurl`) == 1)
        self$`descriptionurl` <- `descriptionurl`
      }
      if (!missing(`enabled`)) {
        self$`enabled` <- `enabled`
      }
      if (!missing(`encoder`)) {
        stopifnot(R6::is.R6(`encoder`))
        self$`encoder` <- `encoder`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`tags`)) {
        stopifnot(is.list(`tags`), length(`tags`) != 0)
        lapply(`tags`, function(x) stopifnot(is.character(x)))
        self$`tags` <- `tags`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      TransformObject <- list()
      if (!is.null(self$`decoders`)) {
        TransformObject[['decoders']] <- lapply(self$`decoders`, function(x) x$toJSON())
      }
      else {
        TransformObject[['decoders']] <- NULL
      }
      if (!is.null(self$`description`)) {
        TransformObject[['description']] <- self$`description`
      }
      else {
        TransformObject[['description']] <- NULL
      }
      if (!is.null(self$`descriptionurl`)) {
        TransformObject[['descriptionurl']] <- self$`descriptionurl`
      }
      else {
        TransformObject[['descriptionurl']] <- NULL
      }
      if (!is.null(self$`enabled`)) {
        TransformObject[['enabled']] <- self$`enabled`
      }
      else {
        TransformObject[['enabled']] <- NULL
      }
      if (!is.null(self$`encoder`)) {
        TransformObject[['encoder']] <- self$`encoder`$toJSON()
      }
      else {
        TransformObject[['encoder']] <- NULL
      }
      if (!is.null(self$`name`)) {
        TransformObject[['name']] <- self$`name`
      }
      else {
        TransformObject[['name']] <- NULL
      }
      if (!is.null(self$`tags`)) {
        TransformObject[['tags']] <- self$`tags`
      }
      else {
        TransformObject[['tags']] <- NULL
      }

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

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

      if (!is.null(TransformObject$`decoders`)) {
        self$`decoders` <- lapply(TransformObject$`decoders`, function(x) {
          decodersObject <- TransformDecoder$new()
          decodersObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          decodersObject
        })
      }
      if (!is.null(TransformObject$`description`)) {
        self$`description` <- TransformObject$`description`
      }
      if (!is.null(TransformObject$`descriptionurl`)) {
        self$`descriptionurl` <- TransformObject$`descriptionurl`
      }
      if (!is.null(TransformObject$`enabled`)) {
        self$`enabled` <- TransformObject$`enabled`
      }
      if (!is.null(TransformObject$`encoder`)) {
        encoderObject <- TransformEncoder$new()
        encoderObject$fromJSON(jsonlite::toJSON(TransformObject$encoder, auto_unbox = TRUE))
        self$`encoder` <- encoderObject
      }
      if (!is.null(TransformObject$`name`)) {
        self$`name` <- TransformObject$`name`
      }
      if (!is.null(TransformObject$`tags`)) {
        self$`tags` <- TransformObject$`tags`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "decoders": [%s],
           "description": %s,
           "descriptionurl": %s,
           "enabled": %s,
           "encoder": %s,
           "name": %s,
           "tags": [%s]
        }',
        lapply(self$`decoders`, function(x) paste(x$toJSON(), sep=",")),
        ifelse( is.null(self$`description`),"null",paste0(c('"', self$`description`, '"'))),
        ifelse( is.null(self$`descriptionurl`),"null",paste0(c('"', self$`descriptionurl`, '"'))),
        ifelse( is.null(self$`enabled`),"null",paste0(c('"', self$`enabled`, '"'))),
        self$`encoder`$toJSON(),
        ifelse( is.null(self$`name`),"null",paste0(c('"', self$`name`, '"'))),
        lapply(self$`tags`, function(x) paste(paste0('"', x, '"'), sep=","))
      )
    },
    fromJSONString = function(TransformJson) {
      TransformObject <- jsonlite::fromJSON(TransformJson)
      self::fromJSON(TransformObject)

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