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


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

      JsonFormObject
    },
    fromJSON = function(JsonFormJson) {
      JsonFormObject <- jsonlite::fromJSON(JsonFormJson)
      if (!is.null(JsonFormObject$`clusters`)) {
        self$`clusters` <- lapply(JsonFormObject$`clusters`, function(x) {
          clustersObject <- JsonFormClusters$new()
          clustersObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          clustersObject
        })
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "clusters": [%s]
        }',
        lapply(self$`clusters`, function(x) paste(x$toJSON(), sep=","))
      )
    },
    fromJSONString = function(JsonFormJson) {
      JsonFormObject <- jsonlite::fromJSON(JsonFormJson)
      self$`clusters` <- lapply(JsonFormObject$`clusters`, function(x) JsonFormClusters$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.