R/submissions_api.R

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

#' @docType class
#' @title Submissions operations
#' @description openapi.Submissions
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ AbortSubmission } \emph{ abort a submission  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission.id character
#'
#'
#' \item status code : 204 | Aborted successfully
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Submission not found
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ CountSubmissions } \emph{ Count submissions by status }
#' Counts all submissions run in the workspace, grouped by status. Returns a map of status:count.
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @returnType } \link{SubmissionsCountResponse} \cr
#'
#'
#' \item status code : 200 | Successful Request
#'
#' \item return type : SubmissionsCountResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ CreateSubmission } \emph{ Create a submission.  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission \link{SubmissionRequest}
#'
#'
#' \item status code : 201 | Successful Request
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Expression eval failed or entities are not of type required by method config
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Method Configuration or Entity not found
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 409 | Method Configuration failed to resolve input expressions with the supplied Entity
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ListSubmissions } \emph{ List submissions.  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#'
#'
#' \item status code : 200 | List of submissions
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace not found
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ MonitorSubmission } \emph{ Monitor submission status  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission.id character
#' \item \emph{ @returnType } \link{Submission} \cr
#'
#'
#' \item status code : 200 | Successful Request
#'
#' \item return type : Submission 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Submission not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ValidateSubmission } \emph{ Validate submission }
#' Validate expression syntax for a submission
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission \link{SubmissionRequest}
#' \item \emph{ @returnType } \link{SubmissionValidationReport} \cr
#'
#'
#' \item status code : 200 | Validation Response
#'
#' \item return type : SubmissionValidationReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Expression evaluation failed or entities are not of type required by method config
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace, Method Configuration or Entity not found
#'
#' \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}{
#' }
#' \item status code : 502 | Trouble talking to Agora
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ WorkflowCostInSubmission } \emph{ Retrieve workflow cost, if available.  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission.id character
#' \item \emph{ @param } workflow.id character
#' \item \emph{ @returnType } \link{WorkflowCost} \cr
#'
#'
#' \item status code : 200 | Successful Request
#'
#' \item return type : WorkflowCost 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace, Submission or Workflow not found
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ WorkflowMetadata } \emph{ Get call-level metadata for workflow }
#' Get call-level metadata for workflow
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission.id character
#' \item \emph{ @param } workflow.id character
#' \item \emph{ @param } include.key list( character )
#' \item \emph{ @param } exclude.key list( character )
#' \item \emph{ @param } expand.sub.workflows character
#'
#'
#' \item status code : 200 | Successful Request
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace, Submission or Workflow not found
#'
#' \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{ WorkflowOutputsInSubmission } \emph{ Get workflow outputs.  }
#' 
#'
#' \itemize{
#' \item \emph{ @param } workspace.namespace character
#' \item \emph{ @param } workspace.name character
#' \item \emph{ @param } submission.id character
#' \item \emph{ @param } workflow.id character
#'
#'
#' \item status code : 200 | Get workflow outputs
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 404 | Workspace, Submission or Workflow not found
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Internal Error
#'
#'
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ WorkflowQueueStatus } \emph{ workflow queue status }
#' List workflow counts by queueing state
#'
#' \itemize{
#' \item \emph{ @returnType } \link{WorkflowQueueStatusResponse} \cr
#'
#'
#' \item status code : 200 | Successful Request
#'
#' \item return type : WorkflowQueueStatusResponse 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 500 | Rawls Internal Error
#'
#' \item return type : ErrorReport 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  AbortSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission.id <- 'submission.id_example' # character | Submission ID
#'
#' #abort a submission 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$AbortSubmission(var.workspace.namespace, var.workspace.name, var.submission.id)
#'
#'
#' ####################  CountSubmissions  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#'
#' #Count submissions by status
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$CountSubmissions(var.workspace.namespace, var.workspace.name)
#'
#'
#' ####################  CreateSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission <- SubmissionRequest$new() # SubmissionRequest | Post Submission
#'
#' #Create a submission. 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$CreateSubmission(var.workspace.namespace, var.workspace.name, var.submission)
#'
#'
#' ####################  ListSubmissions  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#'
#' #List submissions. 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$ListSubmissions(var.workspace.namespace, var.workspace.name)
#'
#'
#' ####################  MonitorSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission.id <- 'submission.id_example' # character | Submission ID
#'
#' #Monitor submission status 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$MonitorSubmission(var.workspace.namespace, var.workspace.name, var.submission.id)
#'
#'
#' ####################  ValidateSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission <- SubmissionRequest$new() # SubmissionRequest | Description of a submission.
#'
#' #Validate submission
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$ValidateSubmission(var.workspace.namespace, var.workspace.name, var.submission)
#'
#'
#' ####################  WorkflowCostInSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission.id <- 'submission.id_example' # character | Submission ID
#' var.workflow.id <- 'workflow.id_example' # character | Workflow ID
#'
#' #Retrieve workflow cost, if available. 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$WorkflowCostInSubmission(var.workspace.namespace, var.workspace.name, var.submission.id, var.workflow.id)
#'
#'
#' ####################  WorkflowMetadata  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission.id <- 'submission.id_example' # character | Submission ID
#' var.workflow.id <- 'workflow.id_example' # character | Workflow ID
#' var.include.key <- ['include.key_example'] # array[character] | When specified, return only these keys in the response. Matches any key in the response, including within nested blocks. May not be used with excludeKey. 
#' var.exclude.key <- ['exclude.key_example'] # array[character] | When specified, omit these keys from the response. Matches any key in the response, including within nested blocks. May not be used with includeKey. 
#' var.expand.sub.workflows <- FALSE # character | When true, metadata for sub workflows will be fetched and inserted automatically in the metadata response. 
#'
#' #Get call-level metadata for workflow
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$WorkflowMetadata(var.workspace.namespace, var.workspace.name, var.submission.id, var.workflow.id, include.key=var.include.key, exclude.key=var.exclude.key, expand.sub.workflows=var.expand.sub.workflows)
#'
#'
#' ####################  WorkflowOutputsInSubmission  ####################
#'
#' library(openapi)
#' var.workspace.namespace <- 'workspace.namespace_example' # character | Workspace Namespace
#' var.workspace.name <- 'workspace.name_example' # character | Workspace Name
#' var.submission.id <- 'submission.id_example' # character | Submission ID
#' var.workflow.id <- 'workflow.id_example' # character | Workflow ID
#'
#' #Get workflow outputs. 
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$WorkflowOutputsInSubmission(var.workspace.namespace, var.workspace.name, var.submission.id, var.workflow.id)
#'
#'
#' ####################  WorkflowQueueStatus  ####################
#'
#' library(openapi)
#'
#' #workflow queue status
#' api.instance <- SubmissionsApi$new()
#'
#' # Configure OAuth2 access token for authorization: googleoauth
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
#'
#' result <- api.instance$WorkflowQueueStatus()
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
SubmissionsApi <- R6::R6Class(
  'SubmissionsApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    AbortSubmission = function(workspace.namespace, workspace.name, submission.id, ...){
      apiResponse <- self$AbortSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission.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
      }
    },

    AbortSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission.id, ...){
      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`.")
      }

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

      body <- NULL
      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/{submissionId}"
      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)
      }

      if (!missing(`submission.id`)) {
        urlPath <- gsub(paste0("\\{", "submissionId", "\\}"), URLencode(as.character(`submission.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 = "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)
      }
    },
    CountSubmissions = function(workspace.namespace, workspace.name, ...){
      apiResponse <- self$CountSubmissionsWithHttpInfo(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
      }
    },

    CountSubmissionsWithHttpInfo = 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/workspaces/{workspaceNamespace}/{workspaceName}/submissionsCount"
      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, "SubmissionsCountResponse", 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)
      }
    },
    CreateSubmission = function(workspace.namespace, workspace.name, submission, ...){
      apiResponse <- self$CreateSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission, ...)
      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
      }
    },

    CreateSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission, ...){
      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`.")
      }

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

      if (!missing(`submission`)) {
        body <- `submission`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions"
      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 = "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)
      }
    },
    ListSubmissions = function(workspace.namespace, workspace.name, ...){
      apiResponse <- self$ListSubmissionsWithHttpInfo(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
      }
    },

    ListSubmissionsWithHttpInfo = 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/workspaces/{workspaceNamespace}/{workspaceName}/submissions"
      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) {
        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)
      }
    },
    MonitorSubmission = function(workspace.namespace, workspace.name, submission.id, ...){
      apiResponse <- self$MonitorSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission.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
      }
    },

    MonitorSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission.id, ...){
      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`.")
      }

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

      body <- NULL
      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/{submissionId}"
      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)
      }

      if (!missing(`submission.id`)) {
        urlPath <- gsub(paste0("\\{", "submissionId", "\\}"), URLencode(as.character(`submission.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, "Submission", 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)
      }
    },
    ValidateSubmission = function(workspace.namespace, workspace.name, submission, ...){
      apiResponse <- self$ValidateSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission, ...)
      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
      }
    },

    ValidateSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission, ...){
      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`.")
      }

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

      if (!missing(`submission`)) {
        body <- `submission`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/validate"
      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 = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "SubmissionValidationReport", 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)
      }
    },
    WorkflowCostInSubmission = function(workspace.namespace, workspace.name, submission.id, workflow.id, ...){
      apiResponse <- self$WorkflowCostInSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission.id, workflow.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
      }
    },

    WorkflowCostInSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission.id, workflow.id, ...){
      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`.")
      }

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

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

      body <- NULL
      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/{submissionId}/workflows/{workflowId}/cost"
      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)
      }

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

      if (!missing(`workflow.id`)) {
        urlPath <- gsub(paste0("\\{", "workflowId", "\\}"), URLencode(as.character(`workflow.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, "WorkflowCost", 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)
      }
    },
    WorkflowMetadata = function(workspace.namespace, workspace.name, submission.id, workflow.id, include.key=NULL, exclude.key=NULL, expand.sub.workflows=FALSE, ...){
      apiResponse <- self$WorkflowMetadataWithHttpInfo(workspace.namespace, workspace.name, submission.id, workflow.id, include.key, exclude.key, expand.sub.workflows, ...)
      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
      }
    },

    WorkflowMetadataWithHttpInfo = function(workspace.namespace, workspace.name, submission.id, workflow.id, include.key=NULL, exclude.key=NULL, expand.sub.workflows=FALSE, ...){
      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`.")
      }

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

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

      queryParams['includeKey'] <- include.key

      queryParams['excludeKey'] <- exclude.key

      queryParams['expandSubWorkflows'] <- expand.sub.workflows

      body <- NULL
      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/{submissionId}/workflows/{workflowId}"
      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)
      }

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

      if (!missing(`workflow.id`)) {
        urlPath <- gsub(paste0("\\{", "workflowId", "\\}"), URLencode(as.character(`workflow.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) {
        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)
      }
    },
    WorkflowOutputsInSubmission = function(workspace.namespace, workspace.name, submission.id, workflow.id, ...){
      apiResponse <- self$WorkflowOutputsInSubmissionWithHttpInfo(workspace.namespace, workspace.name, submission.id, workflow.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
      }
    },

    WorkflowOutputsInSubmissionWithHttpInfo = function(workspace.namespace, workspace.name, submission.id, workflow.id, ...){
      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`.")
      }

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

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

      body <- NULL
      urlPath <- "/api/workspaces/{workspaceNamespace}/{workspaceName}/submissions/{submissionId}/workflows/{workflowId}/outputs"
      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)
      }

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

      if (!missing(`workflow.id`)) {
        urlPath <- gsub(paste0("\\{", "workflowId", "\\}"), URLencode(as.character(`workflow.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) {
        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)
      }
    },
    WorkflowQueueStatus = function(...){
      apiResponse <- self$WorkflowQueueStatusWithHttpInfo(...)
      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
      }
    },

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

      body <- NULL
      urlPath <- "/api/submissions/queueStatus"
      # 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, "WorkflowQueueStatusResponse", 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.