R/ModelTrainingInfo.r

# Dkube api server
#
# No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
#
# OpenAPI spec version: 2.2.1.11
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' ModelTrainingInfo Class
#'
#' @field images 
#' @field training_code 
#' @field datasets 
#' @field featuresets 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ModelTrainingInfo <- R6::R6Class(
  'ModelTrainingInfo',
  public = list(
    `images` = NULL,
    `training_code` = NULL,
    `datasets` = NULL,
    `featuresets` = NULL,
    initialize = function(`images`, `training_code`, `datasets`, `featuresets`){
      if (!missing(`images`)) {
        stopifnot(R6::is.R6(`images`))
        self$`images` <- `images`
      }
      if (!missing(`training_code`)) {
        stopifnot(R6::is.R6(`training_code`))
        self$`training_code` <- `training_code`
      }
      if (!missing(`datasets`)) {
        stopifnot(R6::is.R6(`datasets`))
        self$`datasets` <- `datasets`
      }
      if (!missing(`featuresets`)) {
        stopifnot(is.list(`featuresets`), length(`featuresets`) != 0)
        lapply(`featuresets`, function(x) stopifnot(R6::is.R6(x)))
        self$`featuresets` <- `featuresets`
      }
    },
    toJSON = function() {
      ModelTrainingInfoObject <- list()
      if (!is.null(self$`images`)) {
        ModelTrainingInfoObject[['images']] <- self$`images`$toJSON()
      }
      if (!is.null(self$`training_code`)) {
        ModelTrainingInfoObject[['training_code']] <- self$`training_code`$toJSON()
      }
      if (!is.null(self$`datasets`)) {
        ModelTrainingInfoObject[['datasets']] <- self$`datasets`$toJSON()
      }
      if (!is.null(self$`featuresets`)) {
        ModelTrainingInfoObject[['featuresets']] <- lapply(self$`featuresets`, function(x) x$toJSON())
      }

      ModelTrainingInfoObject
    },
    fromJSON = function(ModelTrainingInfoJson) {
      ModelTrainingInfoObject <- jsonlite::fromJSON(ModelTrainingInfoJson)
      if (!is.null(ModelTrainingInfoObject$`images`)) {
        imagesObject <- ModelTrainingInfoImages$new()
        imagesObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$images, auto_unbox = TRUE))
        self$`images` <- imagesObject
      }
      if (!is.null(ModelTrainingInfoObject$`training_code`)) {
        training_codeObject <- ModelTrainingInfoTrainingCode$new()
        training_codeObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$training_code, auto_unbox = TRUE))
        self$`training_code` <- training_codeObject
      }
      if (!is.null(ModelTrainingInfoObject$`datasets`)) {
        datasetsObject <- ModelTrainingInfoDatasets$new()
        datasetsObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$datasets, auto_unbox = TRUE))
        self$`datasets` <- datasetsObject
      }
      if (!is.null(ModelTrainingInfoObject$`featuresets`)) {
        self$`featuresets` <- lapply(ModelTrainingInfoObject$`featuresets`, function(x) {
          featuresetsObject <- ModelTrainingInfoFeaturesets$new()
          featuresetsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          featuresetsObject
        })
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "images": %s,
           "training_code": %s,
           "datasets": %s,
           "featuresets": [%s]
        }',
        self$`images`$toJSON(),
        self$`training_code`$toJSON(),
        self$`datasets`$toJSON(),
        lapply(self$`featuresets`, function(x) paste(x$toJSON(), sep=","))
      )
    },
    fromJSONString = function(ModelTrainingInfoJson) {
      ModelTrainingInfoObject <- jsonlite::fromJSON(ModelTrainingInfoJson)
      ModelTrainingInfoImagesObject <- ModelTrainingInfoImages$new()
      self$`images` <- ModelTrainingInfoImagesObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$images, auto_unbox = TRUE))
      ModelTrainingInfoTrainingCodeObject <- ModelTrainingInfoTrainingCode$new()
      self$`training_code` <- ModelTrainingInfoTrainingCodeObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$training_code, auto_unbox = TRUE))
      ModelTrainingInfoDatasetsObject <- ModelTrainingInfoDatasets$new()
      self$`datasets` <- ModelTrainingInfoDatasetsObject$fromJSON(jsonlite::toJSON(ModelTrainingInfoObject$datasets, auto_unbox = TRUE))
      self$`featuresets` <- lapply(ModelTrainingInfoObject$`featuresets`, function(x) ModelTrainingInfoFeaturesets$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.