R/entity_copy_response.R

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title EntityCopyResponse
#'
#' @description EntityCopyResponse Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field entitiesCopied  list( \link{AttributeEntityReference} ) 
#'
#' @field hardConflicts  list( \link{EntityHardConflict} ) 
#'
#' @field softConflicts  list( \link{EntitySoftConflict} ) 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
EntityCopyResponse <- R6::R6Class(
  'EntityCopyResponse',
  public = list(
    `entitiesCopied` = NULL,
    `hardConflicts` = NULL,
    `softConflicts` = NULL,
    initialize = function(
        `entitiesCopied`, `hardConflicts`, `softConflicts`, ...
    ) {
      local.optional.var <- list(...)
      if (!missing(`entitiesCopied`)) {
        stopifnot(is.vector(`entitiesCopied`), length(`entitiesCopied`) != 0)
        sapply(`entitiesCopied`, function(x) stopifnot(R6::is.R6(x)))
        self$`entitiesCopied` <- `entitiesCopied`
      }
      if (!missing(`hardConflicts`)) {
        stopifnot(is.vector(`hardConflicts`), length(`hardConflicts`) != 0)
        sapply(`hardConflicts`, function(x) stopifnot(R6::is.R6(x)))
        self$`hardConflicts` <- `hardConflicts`
      }
      if (!missing(`softConflicts`)) {
        stopifnot(is.vector(`softConflicts`), length(`softConflicts`) != 0)
        sapply(`softConflicts`, function(x) stopifnot(R6::is.R6(x)))
        self$`softConflicts` <- `softConflicts`
      }
    },
    toJSON = function() {
      EntityCopyResponseObject <- list()
      if (!is.null(self$`entitiesCopied`)) {
        EntityCopyResponseObject[['entitiesCopied']] <-
          lapply(self$`entitiesCopied`, function(x) x$toJSON())
      }
      if (!is.null(self$`hardConflicts`)) {
        EntityCopyResponseObject[['hardConflicts']] <-
          lapply(self$`hardConflicts`, function(x) x$toJSON())
      }
      if (!is.null(self$`softConflicts`)) {
        EntityCopyResponseObject[['softConflicts']] <-
          lapply(self$`softConflicts`, function(x) x$toJSON())
      }

      EntityCopyResponseObject
    },
    fromJSON = function(EntityCopyResponseJson) {
      EntityCopyResponseObject <- jsonlite::fromJSON(EntityCopyResponseJson)
      if (!is.null(EntityCopyResponseObject$`entitiesCopied`)) {
        self$`entitiesCopied` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`entitiesCopied`, "array[AttributeEntityReference]", loadNamespace("openapi"))
      }
      if (!is.null(EntityCopyResponseObject$`hardConflicts`)) {
        self$`hardConflicts` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`hardConflicts`, "array[EntityHardConflict]", loadNamespace("openapi"))
      }
      if (!is.null(EntityCopyResponseObject$`softConflicts`)) {
        self$`softConflicts` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`softConflicts`, "array[EntitySoftConflict]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`entitiesCopied`)) {
        sprintf(
        '"entitiesCopied":
        [%s]
',
        paste(sapply(self$`entitiesCopied`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`hardConflicts`)) {
        sprintf(
        '"hardConflicts":
        [%s]
',
        paste(sapply(self$`hardConflicts`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )},
        if (!is.null(self$`softConflicts`)) {
        sprintf(
        '"softConflicts":
        [%s]
',
        paste(sapply(self$`softConflicts`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(EntityCopyResponseJson) {
      EntityCopyResponseObject <- jsonlite::fromJSON(EntityCopyResponseJson)
      self$`entitiesCopied` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`entitiesCopied`, "array[AttributeEntityReference]", loadNamespace("openapi"))
      self$`hardConflicts` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`hardConflicts`, "array[EntityHardConflict]", loadNamespace("openapi"))
      self$`softConflicts` <- ApiClient$new()$deserializeObj(EntityCopyResponseObject$`softConflicts`, "array[EntitySoftConflict]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.