R/billing_api.R

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

#' @docType class
#' @title Billing operations
#' @description openapi.Billing
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ AddUserToBillingProject } \emph{ add user to billing project the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } project.id character
#' \item \emph{ @param } workbench.role Enum < [user, owner] > 
#' \item \emph{ @param } email character
#'
#'
#' \item status code : 200 | Successfully Added User To Billing Project
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be a project owner to add a user to a billing project
#'
#' \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{ CreateBillingProjectFull } \emph{ create billing project in FireCloud and google }
#' 
#'
#' \itemize{
#' \item \emph{ @param } create.project.request \link{CreateRawlsBillingProjectFullRequest}
#'
#'
#' \item status code : 204 | Successfully Created Billing Project in FireCloud and Google
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | FireCloud billing user must be an admin of the billing account
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be an admin of the google billing account
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 409 | project already exists in FireCloud or google
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | FireCloud Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ DeleteBillingProject } \emph{ delete billing project }
#' delete billing project
#'
#' \itemize{
#' \item \emph{ @param } project.name character
#'
#'
#' \item status code : 200 | Successfully delete billing project
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Project cannot be deleted because it contains workspaces.
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be a project owner to delete billing project
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Rawls Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ListBillingProjectMembers } \emph{ list members of billing project the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } project.id character
#' \item \emph{ @returnType } list( \link{BillingProjectMember} ) \cr
#'
#'
#' \item status code : 200 | Success
#'
#' \item return type : array[BillingProjectMember] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be a project owner to view the members of a project
#'
#' \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{ RemoveUserFromBillingProject } \emph{ remove user from billing project the caller owns }
#' 
#'
#' \itemize{
#' \item \emph{ @param } project.id character
#' \item \emph{ @param } workbench.role Enum < [user, owner] > 
#' \item \emph{ @param } email character
#'
#'
#' \item status code : 200 | Successfully Removed User From Billing Project
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 403 | You must be a project owner to add a user to a billing project
#'
#' \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}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  AddUserToBillingProject  ####################
#'
#' library(openapi)
#' var.project.id <- 'project.id_example' # character | Project ID
#' var.workbench.role <- 'workbench.role_example' # character | role of user for project
#' var.email <- 'email_example' # character | email of user or group to add
#'
#' #add user to billing project the caller owns
#' api.instance <- BillingApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$AddUserToBillingProject(var.project.id, var.workbench.role, var.email)
#'
#'
#' ####################  CreateBillingProjectFull  ####################
#'
#' library(openapi)
#' var.create.project.request <- CreateRawlsBillingProjectFullRequest$new() # CreateRawlsBillingProjectFullRequest | create project request
#'
#' #create billing project in FireCloud and google
#' api.instance <- BillingApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$CreateBillingProjectFull(var.create.project.request)
#'
#'
#' ####################  DeleteBillingProject  ####################
#'
#' library(openapi)
#' var.project.name <- 'project.name_example' # character | Name of the billing project
#'
#' #delete billing project
#' api.instance <- BillingApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$DeleteBillingProject(var.project.name)
#'
#'
#' ####################  ListBillingProjectMembers  ####################
#'
#' library(openapi)
#' var.project.id <- 'project.id_example' # character | Project ID
#'
#' #list members of billing project the caller owns
#' api.instance <- BillingApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$ListBillingProjectMembers(var.project.id)
#'
#'
#' ####################  RemoveUserFromBillingProject  ####################
#'
#' library(openapi)
#' var.project.id <- 'project.id_example' # character | Project ID
#' var.workbench.role <- 'workbench.role_example' # character | role of user for project
#' var.email <- 'email_example' # character | email of user or group to remove
#'
#' #remove user from billing project the caller owns
#' api.instance <- BillingApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$RemoveUserFromBillingProject(var.project.id, var.workbench.role, var.email)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
BillingApi <- R6::R6Class(
  'BillingApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    AddUserToBillingProject = function(project.id, workbench.role, email, ...){
      apiResponse <- self$AddUserToBillingProjectWithHttpInfo(project.id, workbench.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
      }
    },

    AddUserToBillingProjectWithHttpInfo = function(project.id, workbench.role, email, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      body <- NULL
      urlPath <- "/api/billing/{projectId}/{workbenchRole}/{email}"
      if (!missing(`project.id`)) {
        urlPath <- gsub(paste0("\\{", "projectId", "\\}"), URLencode(as.character(`project.id`), reserved = TRUE), urlPath)
      }

      if (!missing(`workbench.role`)) {
        urlPath <- gsub(paste0("\\{", "workbenchRole", "\\}"), URLencode(as.character(`workbench.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)
      }
    },
    CreateBillingProjectFull = function(create.project.request, ...){
      apiResponse <- self$CreateBillingProjectFullWithHttpInfo(create.project.request, ...)
      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
      }
    },

    CreateBillingProjectFullWithHttpInfo = function(create.project.request, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`create.project.request`)) {
        stop("Missing required parameter `create.project.request`.")
      }

      if (!missing(`create.project.request`)) {
        body <- `create.project.request`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api/billing"
      # 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)
      }
    },
    DeleteBillingProject = function(project.name, ...){
      apiResponse <- self$DeleteBillingProjectWithHttpInfo(project.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
      }
    },

    DeleteBillingProjectWithHttpInfo = function(project.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/user/billing/{projectName}"
      if (!missing(`project.name`)) {
        urlPath <- gsub(paste0("\\{", "projectName", "\\}"), URLencode(as.character(`project.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)
      }
    },
    ListBillingProjectMembers = function(project.id, ...){
      apiResponse <- self$ListBillingProjectMembersWithHttpInfo(project.id, ...)
      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
      }
    },

    ListBillingProjectMembersWithHttpInfo = function(project.id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      body <- NULL
      urlPath <- "/api/billing/{projectId}/members"
      if (!missing(`project.id`)) {
        urlPath <- gsub(paste0("\\{", "projectId", "\\}"), URLencode(as.character(`project.id`), 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[BillingProjectMember]", 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)
      }
    },
    RemoveUserFromBillingProject = function(project.id, workbench.role, email, ...){
      apiResponse <- self$RemoveUserFromBillingProjectWithHttpInfo(project.id, workbench.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
      }
    },

    RemoveUserFromBillingProjectWithHttpInfo = function(project.id, workbench.role, email, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

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

      body <- NULL
      urlPath <- "/api/billing/{projectId}/{workbenchRole}/{email}"
      if (!missing(`project.id`)) {
        urlPath <- gsub(paste0("\\{", "projectId", "\\}"), URLencode(as.character(`project.id`), reserved = TRUE), urlPath)
      }

      if (!missing(`workbench.role`)) {
        urlPath <- gsub(paste0("\\{", "workbenchRole", "\\}"), URLencode(as.character(`workbench.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)
      }
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.