R/v0_api.R

# HCA Matrix Service
#
# Human Cell Atlas Matrix Service API
#
# The version of the OpenAPI document: 1.0.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title V0 operations
#' @description hcamatrixapi.V0
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ MatrixLambdasApiV0CoreGetFormats } \emph{ Returns supported output formats. }
#' Returns the list of expression matrix formats that can be requested from this service.
#'
#' \itemize{
#' \item \emph{ @returnType } \link[hcamatrixapi:v0_MatrixFormat]{ list(v0_MatrixFormat) }   \cr
#'
#'
#' \item status code : 200 | Success
#'
#' \item return type : array[V0MatrixFormat] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ MatrixLambdasApiV0CoreGetMatrix } \emph{ Retrieve the status, and result if available, of a matrix query request. }
#' Returns the status, and URI of the result if available, of a matrix query request. The status of a request can be 'Complete', 'In Progress' or 'Failed'. If the request is 'Complete', the matrix_location field will be populated with a URL to download the matrix. If the request 'Failed', the error message will be available in the message field.
#'
#' \itemize{
#' \item \emph{ @param } request.id character
#' \item \emph{ @returnType } \link[hcamatrixapi:v0_MatrixGetResponse]{ V0MatrixGetResponse }   \cr
#'
#'
#' \item status code : 200 | Request found
#'
#' \item return type : V0MatrixGetResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Request not found
#'
#' \item return type : V0MatrixErrorResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ MatrixLambdasApiV0CorePostMatrix } \emph{ Submit a matrix query request. }
#' Prepares a single expression matrix combining all expression matrices belonging to the specified analysis bundles. On success, this request will asynchronously start a job to prepare the expression matrix and return with the request ID of the job. The request ID can be used to retrieve the status and results of the job from the GET endpoint.
#'
#' \itemize{
#' \item \emph{ @param } v0.matrix.request \link[hcamatrixapi:V0MatrixRequest]{ V0MatrixRequest }
#' \item \emph{ @returnType } \link[hcamatrixapi:v0_MatrixPostResponse]{ V0MatrixPostResponse }   \cr
#'
#'
#' \item status code : 202 | Matrix request accepted
#'
#' \item return type : V0MatrixPostResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad request
#'
#' \item return type : V0MatrixErrorResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \donttest{
#' ####################  MatrixLambdasApiV0CoreGetFormats  ####################
#'
#' library(hcamatrixapi)
#'
#' #Returns supported output formats.
#' api.instance <- V0Api$new()
#'
#' result <- api.instance$MatrixLambdasApiV0CoreGetFormats()
#'
#'
#' ####################  MatrixLambdasApiV0CoreGetMatrix  ####################
#'
#' library(hcamatrixapi)
#' var.request.id <- 'request.id_example' # character | The request ID generated by a POST request.
#'
#' #Retrieve the status, and result if available, of a matrix query request.
#' api.instance <- V0Api$new()
#'
#' result <- api.instance$MatrixLambdasApiV0CoreGetMatrix(var.request.id)
#'
#'
#' ####################  MatrixLambdasApiV0CorePostMatrix  ####################
#'
#' library(hcamatrixapi)
#' var.v0.matrix.request <- V0MatrixRequest$new() # V0MatrixRequest | Use either bundle_fqids or bundle_fqids_url to specify input analysis bundles; bundle_fqids expects a list of fully-qualified IDs (bundle_uuid.bundle_version); bundle_fqids_url expects a URL that serves a Data Browser download manifest TSV file. Use the format field to specify the desired file format of the output expression matrix. Supported format values are 'loom', 'csv' and 'mtx'.
#'
#' #Submit a matrix query request.
#' api.instance <- V0Api$new()
#'
#' result <- api.instance$MatrixLambdasApiV0CorePostMatrix(v0.matrix.request=var.v0.matrix.request)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom caTools base64encode
#' @export
V0Api <- R6::R6Class(
  'V0Api',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    MatrixLambdasApiV0CoreGetFormats = function(...){
      apiResponse <- self$MatrixLambdasApiV0CoreGetFormatsWithHttpInfo(...)
      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
      }
    },

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

      urlPath <- "/v0/matrix/formats"

      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[V0MatrixFormat]", "package:hcamatrixapi"),
          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)
      }
    },
    MatrixLambdasApiV0CoreGetMatrix = function(request.id, ...){
      apiResponse <- self$MatrixLambdasApiV0CoreGetMatrixWithHttpInfo(request.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
      }
    },

    MatrixLambdasApiV0CoreGetMatrixWithHttpInfo = function(request.id, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/v0/matrix/{request_id}"
      if (!missing(`request.id`)) {
        urlPath <- gsub(paste0("\\{", "request_id", "\\}"), URLencode(as.character(`request.id`), reserved = TRUE), urlPath)
      }


      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, "V0MatrixGetResponse", "package:hcamatrixapi"),
          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)
      }
    },
    MatrixLambdasApiV0CorePostMatrix = function(v0.matrix.request=NULL, ...){
      apiResponse <- self$MatrixLambdasApiV0CorePostMatrixWithHttpInfo(v0.matrix.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
      }
    },

    MatrixLambdasApiV0CorePostMatrixWithHttpInfo = function(v0.matrix.request=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/v0/matrix"

      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, "V0MatrixPostResponse", "package:hcamatrixapi"),
          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)
      }
    }
  )
)
Bioconductor/hcamatrixapi documentation built on Nov. 6, 2019, 12:10 a.m.