R/notifications_api.R

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

#' @docType class
#' @title Notifications operations
#' @description openapi.Notifications
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ GeneralNotifications } \emph{ Gets the general notifications available }
#' 
#'
#' \itemize{
#' \item \emph{ @returnType } list( \link{NotificationType} ) \cr
#'
#'
#' \item status code : 200 | Success
#'
#' \item return type : array[NotificationType] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ WorkspaceNotifications } \emph{ Gets the notifications available for a workspace }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @returnType } list( \link{NotificationType} ) \cr
#'
#'
#' \item status code : 200 | Success
#'
#' \item return type : array[NotificationType] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  GeneralNotifications  ####################
#'
#' library(openapi)
#'
#' #Gets the general notifications available
#' api.instance <- NotificationsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$GeneralNotifications()
#'
#'
#' ####################  WorkspaceNotifications  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | workspace namespace
#' var.workspace.name <- 'workspace.name_example' # character | workspace name
#'
#' #Gets the notifications available for a workspace
#' api.instance <- NotificationsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$WorkspaceNotifications(var.workspace.namespace, var.workspace.name)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
NotificationsApi <- R6::R6Class(
  'NotificationsApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    GeneralNotifications = function(...){
      apiResponse <- self$GeneralNotificationsWithHttpInfo(...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GeneralNotificationsWithHttpInfo = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      body <- NULL
      urlPath <- "/api/notifications/general"
      # OAuth token
      headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[NotificationType]", loadNamespace("openapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    WorkspaceNotifications = function(workspace.namespace, workspace.name, ...){
      apiResponse <- self$WorkspaceNotificationsWithHttpInfo(workspace.namespace, workspace.name, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    WorkspaceNotificationsWithHttpInfo = function(workspace.namespace, workspace.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`workspace.namespace`)) {
        stop("Missing required parameter `workspace.namespace`.")
      }

      if (missing(`workspace.name`)) {
        stop("Missing required parameter `workspace.name`.")
      }

      body <- NULL
      urlPath <- "/api/notifications/workspace/{workspaceNamespace}/{workspaceName}"
      if (!missing(`workspace.namespace`)) {
        urlPath <- gsub(paste0("\\{", "workspaceNamespace", "\\}"), URLencode(as.character(`workspace.namespace`), reserved = TRUE), urlPath)
      }

      if (!missing(`workspace.name`)) {
        urlPath <- gsub(paste0("\\{", "workspaceName", "\\}"), URLencode(as.character(`workspace.name`), reserved = TRUE), urlPath)
      }

      # OAuth token
      headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[NotificationType]", loadNamespace("openapi")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.