R/system_metrics_out.R

# NamSor API v2
#
# NamSor API v2 : enpoints to process personal names (gender, cultural origin or ethnicity) in all alphabets or languages. Use GET methods for small tests, but prefer POST methods for higher throughput (batch processing of up to 100 names at a time). Need something you can't find here? We have many more features coming soon. Let us know, we'll do our best to add it! 
#
# The version of the OpenAPI document: 2.0.10
# Contact: contact@namsor.com
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title SystemMetricsOut
#' @description SystemMetricsOut Class
#' @format An \code{R6Class} generator object
#' @field cacheMetrics  list( \link{CacheMetricsOut} ) [optional]
#'
#' @field classifierMetrics  list( \link{ClassifierMetricsOut} ) [optional]
#'
#' @field sourceMetrics  list( \link{SourceMetricsOut} ) [optional]
#'
#' @field totalMem  integer [optional]
#'
#' @field freeMem  integer [optional]
#'
#' @field maxMem  integer [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SystemMetricsOut <- R6::R6Class(
  'SystemMetricsOut',
  public = list(
    `cacheMetrics` = NULL,
    `classifierMetrics` = NULL,
    `sourceMetrics` = NULL,
    `totalMem` = NULL,
    `freeMem` = NULL,
    `maxMem` = NULL,
    initialize = function(`cacheMetrics`=NULL, `classifierMetrics`=NULL, `sourceMetrics`=NULL, `totalMem`=NULL, `freeMem`=NULL, `maxMem`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`cacheMetrics`)) {
        stopifnot(is.vector(`cacheMetrics`), length(`cacheMetrics`) != 0)
        sapply(`cacheMetrics`, function(x) stopifnot(R6::is.R6(x)))
        self$`cacheMetrics` <- `cacheMetrics`
      }
      if (!is.null(`classifierMetrics`)) {
        stopifnot(is.vector(`classifierMetrics`), length(`classifierMetrics`) != 0)
        sapply(`classifierMetrics`, function(x) stopifnot(R6::is.R6(x)))
        self$`classifierMetrics` <- `classifierMetrics`
      }
      if (!is.null(`sourceMetrics`)) {
        stopifnot(is.vector(`sourceMetrics`), length(`sourceMetrics`) != 0)
        sapply(`sourceMetrics`, function(x) stopifnot(R6::is.R6(x)))
        self$`sourceMetrics` <- `sourceMetrics`
      }
      if (!is.null(`totalMem`)) {
        stopifnot(is.numeric(`totalMem`), length(`totalMem`) == 1)
        self$`totalMem` <- `totalMem`
      }
      if (!is.null(`freeMem`)) {
        stopifnot(is.numeric(`freeMem`), length(`freeMem`) == 1)
        self$`freeMem` <- `freeMem`
      }
      if (!is.null(`maxMem`)) {
        stopifnot(is.numeric(`maxMem`), length(`maxMem`) == 1)
        self$`maxMem` <- `maxMem`
      }
    },
    toJSON = function() {
      SystemMetricsOutObject <- list()
      if (!is.null(self$`cacheMetrics`)) {
        SystemMetricsOutObject[['cacheMetrics']] <-
          lapply(self$`cacheMetrics`, function(x) x$toJSON())
      }
      if (!is.null(self$`classifierMetrics`)) {
        SystemMetricsOutObject[['classifierMetrics']] <-
          lapply(self$`classifierMetrics`, function(x) x$toJSON())
      }
      if (!is.null(self$`sourceMetrics`)) {
        SystemMetricsOutObject[['sourceMetrics']] <-
          lapply(self$`sourceMetrics`, function(x) x$toJSON())
      }
      if (!is.null(self$`totalMem`)) {
        SystemMetricsOutObject[['totalMem']] <-
          self$`totalMem`
      }
      if (!is.null(self$`freeMem`)) {
        SystemMetricsOutObject[['freeMem']] <-
          self$`freeMem`
      }
      if (!is.null(self$`maxMem`)) {
        SystemMetricsOutObject[['maxMem']] <-
          self$`maxMem`
      }

      SystemMetricsOutObject
    },
    fromJSON = function(SystemMetricsOutJson) {
      SystemMetricsOutObject <- jsonlite::fromJSON(SystemMetricsOutJson)
      if (!is.null(SystemMetricsOutObject$`cacheMetrics`)) {
        self$`cacheMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`cacheMetrics`, "array[CacheMetricsOut]", loadNamespace("namsor"))
      }
      if (!is.null(SystemMetricsOutObject$`classifierMetrics`)) {
        self$`classifierMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`classifierMetrics`, "array[ClassifierMetricsOut]", loadNamespace("namsor"))
      }
      if (!is.null(SystemMetricsOutObject$`sourceMetrics`)) {
        self$`sourceMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`sourceMetrics`, "array[SourceMetricsOut]", loadNamespace("namsor"))
      }
      if (!is.null(SystemMetricsOutObject$`totalMem`)) {
        self$`totalMem` <- SystemMetricsOutObject$`totalMem`
      }
      if (!is.null(SystemMetricsOutObject$`freeMem`)) {
        self$`freeMem` <- SystemMetricsOutObject$`freeMem`
      }
      if (!is.null(SystemMetricsOutObject$`maxMem`)) {
        self$`maxMem` <- SystemMetricsOutObject$`maxMem`
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`cacheMetrics`)) {
        sprintf(
        '"cacheMetrics":
        [%s]
',
        paste(sapply(self$`cacheMetrics`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`classifierMetrics`)) {
        sprintf(
        '"classifierMetrics":
        [%s]
',
        paste(sapply(self$`classifierMetrics`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`sourceMetrics`)) {
        sprintf(
        '"sourceMetrics":
        [%s]
',
        paste(sapply(self$`sourceMetrics`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`totalMem`)) {
        sprintf(
        '"totalMem":
          %d
                ',
        self$`totalMem`
        )},
        if (!is.null(self$`freeMem`)) {
        sprintf(
        '"freeMem":
          %d
                ',
        self$`freeMem`
        )},
        if (!is.null(self$`maxMem`)) {
        sprintf(
        '"maxMem":
          %d
                ',
        self$`maxMem`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(SystemMetricsOutJson) {
      SystemMetricsOutObject <- jsonlite::fromJSON(SystemMetricsOutJson)
      self$`cacheMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`cacheMetrics`, "array[CacheMetricsOut]", loadNamespace("namsor"))
      self$`classifierMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`classifierMetrics`, "array[ClassifierMetricsOut]", loadNamespace("namsor"))
      self$`sourceMetrics` <- ApiClient$new()$deserializeObj(SystemMetricsOutObject$`sourceMetrics`, "array[SourceMetricsOut]", loadNamespace("namsor"))
      self$`totalMem` <- SystemMetricsOutObject$`totalMem`
      self$`freeMem` <- SystemMetricsOutObject$`freeMem`
      self$`maxMem` <- SystemMetricsOutObject$`maxMem`
      self
    }
  )
)
namsor/namsor-r-sdk2 documentation built on March 15, 2021, 7:12 p.m.