R/copy_entity.R

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

#' @docType class
#' @title CopyEntity
#'
#' @description CopyEntity Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field sourceWorkspace  \link{Namespace} [optional]
#'
#' @field entityType  character [optional]
#'
#' @field entityNames  list( character ) [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
CopyEntity <- R6::R6Class(
  'CopyEntity',
  public = list(
    `sourceWorkspace` = NULL,
    `entityType` = NULL,
    `entityNames` = NULL,
    initialize = function(
        `sourceWorkspace`=NULL, `entityType`=NULL, `entityNames`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`sourceWorkspace`)) {
        stopifnot(R6::is.R6(`sourceWorkspace`))
        self$`sourceWorkspace` <- `sourceWorkspace`
      }
      if (!is.null(`entityType`)) {
        stopifnot(is.character(`entityType`), length(`entityType`) == 1)
        self$`entityType` <- `entityType`
      }
      if (!is.null(`entityNames`)) {
        stopifnot(is.vector(`entityNames`), length(`entityNames`) != 0)
        sapply(`entityNames`, function(x) stopifnot(is.character(x)))
        self$`entityNames` <- `entityNames`
      }
    },
    toJSON = function() {
      CopyEntityObject <- list()
      if (!is.null(self$`sourceWorkspace`)) {
        CopyEntityObject[['sourceWorkspace']] <-
          self$`sourceWorkspace`$toJSON()
      }
      if (!is.null(self$`entityType`)) {
        CopyEntityObject[['entityType']] <-
          self$`entityType`
      }
      if (!is.null(self$`entityNames`)) {
        CopyEntityObject[['entityNames']] <-
          self$`entityNames`
      }

      CopyEntityObject
    },
    fromJSON = function(CopyEntityJson) {
      CopyEntityObject <- jsonlite::fromJSON(CopyEntityJson)
      if (!is.null(CopyEntityObject$`sourceWorkspace`)) {
        sourceWorkspaceObject <- Namespace$new()
        sourceWorkspaceObject$fromJSON(jsonlite::toJSON(CopyEntityObject$sourceWorkspace, auto_unbox = TRUE, digits = NA))
        self$`sourceWorkspace` <- sourceWorkspaceObject
      }
      if (!is.null(CopyEntityObject$`entityType`)) {
        self$`entityType` <- CopyEntityObject$`entityType`
      }
      if (!is.null(CopyEntityObject$`entityNames`)) {
        self$`entityNames` <- ApiClient$new()$deserializeObj(CopyEntityObject$`entityNames`, "array[character]", loadNamespace("openapi"))
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`sourceWorkspace`)) {
        sprintf(
        '"sourceWorkspace":
        %s
        ',
        jsonlite::toJSON(self$`sourceWorkspace`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`entityType`)) {
        sprintf(
        '"entityType":
          "%s"
                ',
        self$`entityType`
        )},
        if (!is.null(self$`entityNames`)) {
        sprintf(
        '"entityNames":
           [%s]
        ',
        paste(unlist(lapply(self$`entityNames`, function(x) paste0('"', x, '"'))), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(CopyEntityJson) {
      CopyEntityObject <- jsonlite::fromJSON(CopyEntityJson)
      self$`sourceWorkspace` <- Namespace$new()$fromJSON(jsonlite::toJSON(CopyEntityObject$sourceWorkspace, auto_unbox = TRUE, digits = NA))
      self$`entityType` <- CopyEntityObject$`entityType`
      self$`entityNames` <- ApiClient$new()$deserializeObj(CopyEntityObject$`entityNames`, "array[character]", loadNamespace("openapi"))
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.