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


#' DevicePoolModel Class
#'
#' @field version 
#' @field name 
#' @field class 
#' @field ndevices 
#' @field created_at 
#' @field generated 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DevicePoolModel <- R6::R6Class(
  'DevicePoolModel',
  public = list(
    `version` = NULL,
    `name` = NULL,
    `class` = NULL,
    `ndevices` = NULL,
    `created_at` = NULL,
    `generated` = NULL,
    initialize = function(`version`, `name`, `class`, `ndevices`, `created_at`, `generated`){
      if (!missing(`version`)) {
        stopifnot(is.character(`version`), length(`version`) == 1)
        self$`version` <- `version`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`class`)) {
        stopifnot(is.character(`class`), length(`class`) == 1)
        self$`class` <- `class`
      }
      if (!missing(`ndevices`)) {
        stopifnot(is.numeric(`ndevices`), length(`ndevices`) == 1)
        self$`ndevices` <- `ndevices`
      }
      if (!missing(`created_at`)) {
        stopifnot(R6::is.R6(`created_at`))
        self$`created_at` <- `created_at`
      }
      if (!missing(`generated`)) {
        stopifnot(R6::is.R6(`generated`))
        self$`generated` <- `generated`
      }
    },
    toJSON = function() {
      DevicePoolModelObject <- list()
      if (!is.null(self$`version`)) {
        DevicePoolModelObject[['version']] <- self$`version`
      }
      if (!is.null(self$`name`)) {
        DevicePoolModelObject[['name']] <- self$`name`
      }
      if (!is.null(self$`class`)) {
        DevicePoolModelObject[['class']] <- self$`class`
      }
      if (!is.null(self$`ndevices`)) {
        DevicePoolModelObject[['ndevices']] <- self$`ndevices`
      }
      if (!is.null(self$`created_at`)) {
        DevicePoolModelObject[['created_at']] <- self$`created_at`$toJSON()
      }
      if (!is.null(self$`generated`)) {
        DevicePoolModelObject[['generated']] <- self$`generated`$toJSON()
      }

      DevicePoolModelObject
    },
    fromJSON = function(DevicePoolModelJson) {
      DevicePoolModelObject <- jsonlite::fromJSON(DevicePoolModelJson)
      if (!is.null(DevicePoolModelObject$`version`)) {
        self$`version` <- DevicePoolModelObject$`version`
      }
      if (!is.null(DevicePoolModelObject$`name`)) {
        self$`name` <- DevicePoolModelObject$`name`
      }
      if (!is.null(DevicePoolModelObject$`class`)) {
        self$`class` <- DevicePoolModelObject$`class`
      }
      if (!is.null(DevicePoolModelObject$`ndevices`)) {
        self$`ndevices` <- DevicePoolModelObject$`ndevices`
      }
      if (!is.null(DevicePoolModelObject$`created_at`)) {
        created_atObject <- TimeStamps$new()
        created_atObject$fromJSON(jsonlite::toJSON(DevicePoolModelObject$created_at, auto_unbox = TRUE))
        self$`created_at` <- created_atObject
      }
      if (!is.null(DevicePoolModelObject$`generated`)) {
        generatedObject <- ModelCatalogItemGenerated$new()
        generatedObject$fromJSON(jsonlite::toJSON(DevicePoolModelObject$generated, auto_unbox = TRUE))
        self$`generated` <- generatedObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "version": %s,
           "name": %s,
           "class": %s,
           "ndevices": %d,
           "created_at": %s,
           "generated": %s
        }',
        self$`version`,
        self$`name`,
        self$`class`,
        self$`ndevices`,
        self$`created_at`$toJSON(),
        self$`generated`$toJSON()
      )
    },
    fromJSONString = function(DevicePoolModelJson) {
      DevicePoolModelObject <- jsonlite::fromJSON(DevicePoolModelJson)
      self$`version` <- DevicePoolModelObject$`version`
      self$`name` <- DevicePoolModelObject$`name`
      self$`class` <- DevicePoolModelObject$`class`
      self$`ndevices` <- DevicePoolModelObject$`ndevices`
      TimeStampsObject <- TimeStamps$new()
      self$`created_at` <- TimeStampsObject$fromJSON(jsonlite::toJSON(DevicePoolModelObject$created_at, auto_unbox = TRUE))
      ModelCatalogItemGeneratedObject <- ModelCatalogItemGenerated$new()
      self$`generated` <- ModelCatalogItemGeneratedObject$fromJSON(jsonlite::toJSON(DevicePoolModelObject$generated, auto_unbox = TRUE))
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.