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


#' Tensor Class
#'
#' @field dtype 
#' @field name 
#' @field tensor_shape 
#' @field key 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Tensor <- R6::R6Class(
  'Tensor',
  public = list(
    `dtype` = NULL,
    `name` = NULL,
    `tensor_shape` = NULL,
    `key` = NULL,
    initialize = function(`dtype`, `name`, `tensor_shape`, `key`){
      if (!missing(`dtype`)) {
        stopifnot(is.character(`dtype`), length(`dtype`) == 1)
        self$`dtype` <- `dtype`
      }
      if (!missing(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!missing(`tensor_shape`)) {
        stopifnot(is.character(`tensor_shape`), length(`tensor_shape`) == 1)
        self$`tensor_shape` <- `tensor_shape`
      }
      if (!missing(`key`)) {
        stopifnot(is.character(`key`), length(`key`) == 1)
        self$`key` <- `key`
      }
    },
    toJSON = function() {
      TensorObject <- list()
      if (!is.null(self$`dtype`)) {
        TensorObject[['dtype']] <- self$`dtype`
      }
      if (!is.null(self$`name`)) {
        TensorObject[['name']] <- self$`name`
      }
      if (!is.null(self$`tensor_shape`)) {
        TensorObject[['tensor_shape']] <- self$`tensor_shape`
      }
      if (!is.null(self$`key`)) {
        TensorObject[['key']] <- self$`key`
      }

      TensorObject
    },
    fromJSON = function(TensorJson) {
      TensorObject <- jsonlite::fromJSON(TensorJson)
      if (!is.null(TensorObject$`dtype`)) {
        self$`dtype` <- TensorObject$`dtype`
      }
      if (!is.null(TensorObject$`name`)) {
        self$`name` <- TensorObject$`name`
      }
      if (!is.null(TensorObject$`tensor_shape`)) {
        self$`tensor_shape` <- TensorObject$`tensor_shape`
      }
      if (!is.null(TensorObject$`key`)) {
        self$`key` <- TensorObject$`key`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "dtype": %s,
           "name": %s,
           "tensor_shape": %s,
           "key": %s
        }',
        self$`dtype`,
        self$`name`,
        self$`tensor_shape`,
        self$`key`
      )
    },
    fromJSONString = function(TensorJson) {
      TensorObject <- jsonlite::fromJSON(TensorJson)
      self$`dtype` <- TensorObject$`dtype`
      self$`name` <- TensorObject$`name`
      self$`tensor_shape` <- TensorObject$`tensor_shape`
      self$`key` <- TensorObject$`key`
    }
  )
)
riteshkarvaloc/dkubeR documentation built on Feb. 25, 2021, 9:28 p.m.