R/groups_api.R

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

#' @docType class
#' @title Groups operations
#' @description openapi.Groups
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ AddUserToGroup } \emph{ add a user to a group the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#' \item \emph{ @param } role Enum < [member, admin] > 
#' \item \emph{ @param } email character
#'
#'
#' \item status code : 204 | Successfully Added User To Group
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be an admin of this group in order to add members
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | User not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ CreateGroup } \emph{ create a new group }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#' \item \emph{ @returnType } \link{ManagedGroupWithMembers} \cr
#'
#'
#' \item status code : 201 | Successfully created group
#'
#' \item return type : ManagedGroupWithMembers 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 409 | Group already exists
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ DeleteGroup } \emph{ delete a group that the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#'
#'
#' \item status code : 204 | Successfully Deleted Group
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be an admin of this group in order to delete it
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Group not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 409 | Group is in use and cannot be deleted
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetGroup } \emph{ view the members in a group }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#' \item \emph{ @returnType } \link{ManagedGroupWithMembers} \cr
#'
#'
#' \item status code : 200 | Successfully loaded group
#'
#' \item return type : ManagedGroupWithMembers 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be an admin of this group in order to view members
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Group not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetGroups } \emph{ get the list of the groups that the caller is a member of }
#' 
#'
#' \itemize{
#' \item \emph{ @returnType } list( \link{ManagedGroupAccessResponse} ) \cr
#'
#'
#' \item status code : 200 | Successfully listed group membership
#'
#' \item return type : array[ManagedGroupAccessResponse] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ RemoveUserFromGroup } \emph{ remove a user from a group the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#' \item \emph{ @param } role Enum < [member, admin] > 
#' \item \emph{ @param } email character
#'
#'
#' \item status code : 204 | Successfully Removed User From Group
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be an admin of this group in order to remove members
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | User not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ RequestAccessToGroup } \emph{ request access to a group }
#' 
#'
#' \itemize{
#' \item \emph{ @param } group.name character
#'
#'
#' \item status code : 204 | Successfully requested access
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Group not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  AddUserToGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#' var.role <- 'role_example' # character | role of user for group
#' var.email <- 'email_example' # character | email of user or group to add
#'
#' #add a user to a group the caller owns
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$AddUserToGroup(var.group.name, var.role, var.email)
#'
#'
#' ####################  CreateGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#'
#' #create a new group
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$CreateGroup(var.group.name)
#'
#'
#' ####################  DeleteGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#'
#' #delete a group that the caller owns
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$DeleteGroup(var.group.name)
#'
#'
#' ####################  GetGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#'
#' #view the members in a group
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$GetGroup(var.group.name)
#'
#'
#' ####################  GetGroups  ####################
#'
#' library(openapi)
#'
#' #get the list of the groups that the caller is a member of
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$GetGroups()
#'
#'
#' ####################  RemoveUserFromGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#' var.role <- 'role_example' # character | role of user for group
#' var.email <- 'email_example' # character | email of user or group to add
#'
#' #remove a user from a group the caller owns
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$RemoveUserFromGroup(var.group.name, var.role, var.email)
#'
#'
#' ####################  RequestAccessToGroup  ####################
#'
#' library(openapi)
#' var.group.name <- 'group.name_example' # character | Group name
#'
#' #request access to a group
#' api.instance <- GroupsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$RequestAccessToGroup(var.group.name)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
GroupsApi <- R6::R6Class(
  'GroupsApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    AddUserToGroup = function(group.name, role, email, ...){
      apiResponse <- self$AddUserToGroupWithHttpInfo(group.name, role, email, ...)
      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
      }
    },

    AddUserToGroupWithHttpInfo = function(group.name, role, email, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}/{role}/{email}"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.name`), reserved = TRUE), urlPath)
      }

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

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

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

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

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        ApiResponse$new(NULL, 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)
      }
    },
    CreateGroup = function(group.name, ...){
      apiResponse <- self$CreateGroupWithHttpInfo(group.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
      }
    },

    CreateGroupWithHttpInfo = function(group.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.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 = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "ManagedGroupWithMembers", 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)
      }
    },
    DeleteGroup = function(group.name, ...){
      apiResponse <- self$DeleteGroupWithHttpInfo(group.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
      }
    },

    DeleteGroupWithHttpInfo = function(group.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.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 = "DELETE",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        ApiResponse$new(NULL, 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)
      }
    },
    GetGroup = function(group.name, ...){
      apiResponse <- self$GetGroupWithHttpInfo(group.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
      }
    },

    GetGroupWithHttpInfo = function(group.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.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, "ManagedGroupWithMembers", 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)
      }
    },
    GetGroups = function(...){
      apiResponse <- self$GetGroupsWithHttpInfo(...)
      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
      }
    },

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

      body <- NULL
      urlPath <- "/api/groups"
      # 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[ManagedGroupAccessResponse]", 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)
      }
    },
    RemoveUserFromGroup = function(group.name, role, email, ...){
      apiResponse <- self$RemoveUserFromGroupWithHttpInfo(group.name, role, email, ...)
      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
      }
    },

    RemoveUserFromGroupWithHttpInfo = function(group.name, role, email, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}/{role}/{email}"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.name`), reserved = TRUE), urlPath)
      }

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

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

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

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

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        ApiResponse$new(NULL, 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)
      }
    },
    RequestAccessToGroup = function(group.name, ...){
      apiResponse <- self$RequestAccessToGroupWithHttpInfo(group.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
      }
    },

    RequestAccessToGroupWithHttpInfo = function(group.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/groups/{groupName}/requestAccess"
      if (!missing(`group.name`)) {
        urlPath <- gsub(paste0("\\{", "groupName", "\\}"), URLencode(as.character(`group.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 = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        ApiResponse$new(NULL, 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.