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


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

      ClusterDetailsObject
    },
    fromJSON = function(ClusterDetailsJson) {
      ClusterDetailsObject <- jsonlite::fromJSON(ClusterDetailsJson)
      if (!is.null(ClusterDetailsObject$`cluster`)) {
        clusterObject <- Cluster$new()
        clusterObject$fromJSON(jsonlite::toJSON(ClusterDetailsObject$cluster, auto_unbox = TRUE))
        self$`cluster` <- clusterObject
      }
      if (!is.null(ClusterDetailsObject$`nodegroups`)) {
        self$`nodegroups` <- lapply(ClusterDetailsObject$`nodegroups`, function(x) {
          nodegroupsObject <- ClusterDetailsNodegroups$new()
          nodegroupsObject$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE))
          nodegroupsObject
        })
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "cluster": %s,
           "nodegroups": [%s]
        }',
        self$`cluster`$toJSON(),
        lapply(self$`nodegroups`, function(x) paste(x$toJSON(), sep=","))
      )
    },
    fromJSONString = function(ClusterDetailsJson) {
      ClusterDetailsObject <- jsonlite::fromJSON(ClusterDetailsJson)
      ClusterObject <- Cluster$new()
      self$`cluster` <- ClusterObject$fromJSON(jsonlite::toJSON(ClusterDetailsObject$cluster, auto_unbox = TRUE))
      self$`nodegroups` <- lapply(ClusterDetailsObject$`nodegroups`, function(x) ClusterDetailsNodegroups$new()$fromJSON(jsonlite::toJSON(x, auto_unbox = TRUE)))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.