R/SystemCredential.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
# 
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' SystemCredential Class
#'
#' Authentication credential for the default or internal user on a system
#'
#' @field credential The credential used to authenticate to the remote system. Depending on the authentication protocol of the remote system, this could be an OAuth Token, X.509 certificate, Kerberose token, or an private key..
#' @field expirationDate The date the credential expires in ISO 8601 format.
#' @field internalUsername The username of the internal user associated with this credential.
#' @field isDefault Is this the default credential for this internal user of this type on this system?
#' @field parentType 
#' @field password The password on the remote system used to authenticate.
#' @field publicKey The public ssh key used to authenticate to the remote system.
#' @field privateKey The public ssh key used to authenticate to the remote system..
#' @field server 
#' @field type 
#' @field username The local username on the remote system used to authenticate.
#' @field valid Is the credential still valid or has it expired?.
#' @field caCerts A public URL to the location of the trusted CA certs to use with this credential.
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
SystemCredential <- R6::R6Class(
  'SystemCredential',
  public = list(
    `credential` = NULL,
    `expirationDate` = NULL,
    `internalUsername` = NULL,
    `isDefault` = NULL,
    `parentType` = NULL,
    `password` = NULL,
    `publicKey` = NULL,
    `privateKey` = NULL,
    `server` = NULL,
    `type` = NULL,
    `username` = NULL,
    `valid` = NULL,
    `caCerts` = NULL,
    initialize = function(`credential`, `expirationDate`, `internalUsername`, `isDefault`, `parentType`, `password`, `publicKey`, `privateKey`, `server`, `type`, `username`, `valid`, `caCerts`){
      if (!missing(`credential`)) {
        stopifnot(is.character(`credential`), length(`credential`) == 1)
        self$`credential` <- `credential`
      }
      if (!missing(`expirationDate`)) {
        stopifnot(is.character(`expirationDate`), length(`expirationDate`) == 1)
        self$`expirationDate` <- `expirationDate`
      }
      if (!missing(`internalUsername`)) {
        stopifnot(is.character(`internalUsername`), length(`internalUsername`) == 1)
        self$`internalUsername` <- `internalUsername`
      }
      if (!missing(`isDefault`)) {
        self$`isDefault` <- `isDefault`
      }
      if (!missing(`parentType`)) {
        stopifnot(R6::is.R6(`parentType`))
        self$`parentType` <- `parentType`
      }
      if (!missing(`password`)) {
        stopifnot(is.character(`password`), length(`password`) == 1)
        self$`password` <- `password`
      }
      if (!missing(`publicKey`)) {
        stopifnot(is.character(`publicKey`), length(`publicKey`) == 1)
        self$`publicKey` <- `publicKey`
      }
      if (!missing(`privateKey`)) {
        stopifnot(is.character(`privateKey`), length(`privateKey`) == 1)
        self$`privateKey` <- `privateKey`
      }
      if (!missing(`server`)) {
        stopifnot(R6::is.R6(`server`))
        self$`server` <- `server`
      }
      if (!missing(`type`)) {
        stopifnot(R6::is.R6(`type`))
        self$`type` <- `type`
      }
      if (!missing(`username`)) {
        stopifnot(is.character(`username`), length(`username`) == 1)
        self$`username` <- `username`
      }
      if (!missing(`valid`)) {
        self$`valid` <- `valid`
      }
      if (!missing(`caCerts`)) {
        stopifnot(is.character(`caCerts`), length(`caCerts`) == 1)
        self$`caCerts` <- `caCerts`
      }
    },
    asJSON = function() {
      self$toJSON()
    },
    toJSON = function() {
      SystemCredentialObject <- list()
      if (!is.null(self$`credential`)) {
        SystemCredentialObject[['credential']] <- self$`credential`
      }
      else {
        SystemCredentialObject[['credential']] <- NULL
      }
      if (!is.null(self$`expirationDate`)) {
        SystemCredentialObject[['expirationDate']] <- self$`expirationDate`
      }
      else {
        SystemCredentialObject[['expirationDate']] <- NULL
      }
      if (!is.null(self$`internalUsername`)) {
        SystemCredentialObject[['internalUsername']] <- self$`internalUsername`
      }
      else {
        SystemCredentialObject[['internalUsername']] <- NULL
      }
      if (!is.null(self$`isDefault`)) {
        SystemCredentialObject[['isDefault']] <- self$`isDefault`
      }
      else {
        SystemCredentialObject[['isDefault']] <- NULL
      }
      if (!is.null(self$`parentType`)) {
        SystemCredentialObject[['parentType']] <- self$`parentType`$toJSON()
      }
      else {
        SystemCredentialObject[['parentType']] <- NULL
      }
      if (!is.null(self$`password`)) {
        SystemCredentialObject[['password']] <- self$`password`
      }
      else {
        SystemCredentialObject[['password']] <- NULL
      }
      if (!is.null(self$`publicKey`)) {
        SystemCredentialObject[['publicKey']] <- self$`publicKey`
      }
      else {
        SystemCredentialObject[['publicKey']] <- NULL
      }
      if (!is.null(self$`privateKey`)) {
        SystemCredentialObject[['privateKey']] <- self$`privateKey`
      }
      else {
        SystemCredentialObject[['privateKey']] <- NULL
      }
      if (!is.null(self$`server`)) {
        SystemCredentialObject[['server']] <- self$`server`$toJSON()
      }
      else {
        SystemCredentialObject[['server']] <- NULL
      }
      if (!is.null(self$`type`)) {
        SystemCredentialObject[['type']] <- self$`type`$toJSON()
      }
      else {
        SystemCredentialObject[['type']] <- NULL
      }
      if (!is.null(self$`username`)) {
        SystemCredentialObject[['username']] <- self$`username`
      }
      else {
        SystemCredentialObject[['username']] <- NULL
      }
      if (!is.null(self$`valid`)) {
        SystemCredentialObject[['valid']] <- self$`valid`
      }
      else {
        SystemCredentialObject[['valid']] <- NULL
      }
      if (!is.null(self$`caCerts`)) {
        SystemCredentialObject[['caCerts']] <- self$`caCerts`
      }
      else {
        SystemCredentialObject[['caCerts']] <- NULL
      }

      SystemCredentialObject
    },
    fromJSON = function(SystemCredentialObject) {
      if (is.character(SystemCredentialObject)) {
        SystemCredentialObject <- jsonlite::fromJSON(SystemCredentialJson)
      }

      if ("result" %in% names(SystemCredentialObject)) {
        SystemCredentialObject <- SystemCredentialObject$result
      }

      if (!is.null(SystemCredentialObject$`credential`)) {
        self$`credential` <- SystemCredentialObject$`credential`
      }
      if (!is.null(SystemCredentialObject$`expirationDate`)) {
        self$`expirationDate` <- SystemCredentialObject$`expirationDate`
      }
      if (!is.null(SystemCredentialObject$`internalUsername`)) {
        self$`internalUsername` <- SystemCredentialObject$`internalUsername`
      }
      if (!is.null(SystemCredentialObject$`isDefault`)) {
        self$`isDefault` <- SystemCredentialObject$`isDefault`
      }
      if (!is.null(SystemCredentialObject$`parentType`)) {
        parentTypeObject <- SystemType$new()
        parentTypeObject$fromJSON(jsonlite::toJSON(SystemCredentialObject$parentType, auto_unbox = TRUE))
        self$`parentType` <- parentTypeObject
      }
      if (!is.null(SystemCredentialObject$`password`)) {
        self$`password` <- SystemCredentialObject$`password`
      }
      if (!is.null(SystemCredentialObject$`publicKey`)) {
        self$`publicKey` <- SystemCredentialObject$`publicKey`
      }
      if (!is.null(SystemCredentialObject$`privateKey`)) {
        self$`privateKey` <- SystemCredentialObject$`privateKey`
      }
      if (!is.null(SystemCredentialObject$`server`)) {
        serverObject <- SystemAuthConfigServerProtocolType$new()
        serverObject$fromJSON(jsonlite::toJSON(SystemCredentialObject$server, auto_unbox = TRUE))
        self$`server` <- serverObject
      }
      if (!is.null(SystemCredentialObject$`type`)) {
        typeObject <- AuthenticationType$new()
        typeObject$fromJSON(jsonlite::toJSON(SystemCredentialObject$type, auto_unbox = TRUE))
        self$`type` <- typeObject
      }
      if (!is.null(SystemCredentialObject$`username`)) {
        self$`username` <- SystemCredentialObject$`username`
      }
      if (!is.null(SystemCredentialObject$`valid`)) {
        self$`valid` <- SystemCredentialObject$`valid`
      }
      if (!is.null(SystemCredentialObject$`caCerts`)) {
        self$`caCerts` <- SystemCredentialObject$`caCerts`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "credential": %s,
           "expirationDate": %s,
           "internalUsername": %s,
           "isDefault": %s,
           "parentType": %s,
           "password": %s,
           "publicKey": %s,
           "privateKey": %s,
           "server": %s,
           "type": %s,
           "username": %s,
           "valid": %s,
           "caCerts": %s
        }',
        ifelse( is.null(self$`credential`),"null",paste0(c('"', self$`credential`, '"'))),
        ifelse( is.null(self$`expirationDate`),"null",paste0(c('"', self$`expirationDate`, '"'))),
        ifelse( is.null(self$`internalUsername`),"null",paste0(c('"', self$`internalUsername`, '"'))),
        ifelse( is.null(self$`isDefault`),"null",paste0(c('"', self$`isDefault`, '"'))),
        self$`parentType`$toJSON(),
        ifelse( is.null(self$`password`),"null",paste0(c('"', self$`password`, '"'))),
        ifelse( is.null(self$`publicKey`),"null",paste0(c('"', self$`publicKey`, '"'))),
        ifelse( is.null(self$`privateKey`),"null",paste0(c('"', self$`privateKey`, '"'))),
        self$`server`$toJSON(),
        self$`type`$toJSON(),
        ifelse( is.null(self$`username`),"null",paste0(c('"', self$`username`, '"'))),
        ifelse( is.null(self$`valid`),"null",paste0(c('"', self$`valid`, '"'))),
        ifelse( is.null(self$`caCerts`),"null",paste0(c('"', self$`caCerts`, '"')))
      )
    },
    fromJSONString = function(SystemCredentialJson) {
      SystemCredentialObject <- jsonlite::fromJSON(SystemCredentialJson)
      self::fromJSON(SystemCredentialObject)

    }
  )
)
deardooley/agave-rlang-sdk documentation built on May 17, 2019, 10:12 p.m.