R/entity_bundle_services_v2_api.R

#' Synapse REST API
#'
#' No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
#'
#' The version of the OpenAPI document: v1
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title EntityBundleServicesV2 operations
#' @description EntityBundleServicesV2Api
#' @format An \code{R6Class} generator object
#' @field api_client Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ PostRepoV1EntityBundle2Create } \emph{  }
#'
#' \itemize{
#' \item \emph{ @param } org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundleCreate}
#' \item \emph{ @param } generated_by character
#' \item \emph{ @returnType } \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundle} \cr
#'
#'
#' \item status code : 201 | Auto-generated description
#'
#' \item return type : OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ PostRepoV1EntityIdBundle2 } \emph{  }
#'
#' \itemize{
#' \item \emph{ @param } id character
#' \item \emph{ @param } org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundleRequest}
#' \item \emph{ @returnType } \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundle} \cr
#'
#'
#' \item status code : 200 | The requested Entity if it exists.
#'
#' \item return type : OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ PostRepoV1EntityIdVersionVersionNumberBundle2 } \emph{  }
#'
#' \itemize{
#' \item \emph{ @param } id character
#' \item \emph{ @param } version_number numeric
#' \item \emph{ @param } org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundleRequest}
#' \item \emph{ @returnType } \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundle} \cr
#'
#'
#' \item status code : 200 | The requested Entity if it exists.
#'
#' \item return type : OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ PutRepoV1EntityIdBundle2 } \emph{  }
#'
#' \itemize{
#' \item \emph{ @param } id character
#' \item \emph{ @param } org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundleCreate}
#' \item \emph{ @param } generated_by character
#' \item \emph{ @returnType } \link{OrgSagebionetworksRepoModelEntitybundleV2EntityBundle} \cr
#'
#'
#' \item status code : 200 | Auto-generated description
#'
#' \item return type : OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  PostRepoV1EntityBundle2Create  ####################
#'
#' library(synclient)
#' var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create <- org.sagebionetworks.repo.model.entitybundle.v2.EntityBundleCreate$new(org.sagebionetworks.repo.model.Entity$new("name_example", "description_example", "id_example", "etag_example", "createdOn_example", "modifiedOn_example", "createdBy_example", "modifiedBy_example", "parentId_example", "concreteType_example", "repositoryName_example", "isManaged_example", 123, "versionLabel_example", "versionComment_example", "isLatestVersion_example", c("columnIds_example"), "isSearchEnabled_example", c(org.sagebionetworks.repo.model.EntityRef$new("entityId_example", 123)), 123, "type_example", c("scopeIds_example"), "definingSQL_example", org.sagebionetworks.repo.model.Reference$new("targetId_example", 123), "linksToClassName_example", "previewString_example", c("headers_example"), c(org.sagebionetworks.repo.model.Row$new(c("cells_example"))), "dataFileHandleId_example", "fileNameOverride_example", "alias_example", 123, "checksum_example", 123, "singleString_example", c("stringList_example"), "singleDate_example", c("dateList_example"), 123, c(123), 123, c(123), "concept_example", "someEnum_example", c(org.sagebionetworks.repo.model.Reference$new("targetId_example", 123)), c(org.sagebionetworks.repo.model.EnvironmentDescriptor$new("type_example", "name_example", "quantifier_example"))), org.sagebionetworks.repo.model.annotation.v2.Annotations$new("id_example", "etag_example", c(key = org.sagebionetworks.repo.model.annotation.v2.AnnotationsValue$new("type_example", c("value_example")))), org.sagebionetworks.repo.model.AccessControlList$new("id_example", "createdBy_example", "creationDate_example", "modifiedBy_example", "modifiedOn_example", "etag_example", c(org.sagebionetworks.repo.model.ResourceAccess$new(123, c("accessType_example"))))) # OrgSagebionetworksRepoModelEntitybundleV2EntityBundleCreate | 
#' var_generated_by <- "generated_by_example" # character |  (Optional)
#'
#' api_instance <- EntityBundleServicesV2Api$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$PostRepoV1EntityBundle2Create(var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = var_generated_bydata_file = "result.txt")
#' result <- api_instance$PostRepoV1EntityBundle2Create(var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = var_generated_by)
#' dput(result)
#'
#'
#' ####################  PostRepoV1EntityIdBundle2  ####################
#'
#' library(synclient)
#' var_id <- "id_example" # character | - The ID of the entity to fetch.
#' var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request <- org.sagebionetworks.repo.model.entitybundle.v2.EntityBundleRequest$new("includeEntity_example", "includeAnnotations_example", "includePermissions_example", "includeEntityPath_example", "includeHasChildren_example", "includeAccessControlList_example", "includeFileHandles_example", "includeTableBundle_example", "includeRootWikiId_example", "includeBenefactorACL_example", "includeDOIAssociation_example", "includeFileName_example", "includeThreadCount_example", "includeRestrictionInformation_example") # OrgSagebionetworksRepoModelEntitybundleV2EntityBundleRequest | 
#'
#' api_instance <- EntityBundleServicesV2Api$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$PostRepoV1EntityIdBundle2(var_id, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_requestdata_file = "result.txt")
#' result <- api_instance$PostRepoV1EntityIdBundle2(var_id, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request)
#' dput(result)
#'
#'
#' ####################  PostRepoV1EntityIdVersionVersionNumberBundle2  ####################
#'
#' library(synclient)
#' var_id <- "id_example" # character | - The ID of the entity to fetch.
#' var_version_number <- 3.4 # numeric | - The version of the entity to fetch
#' var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request <- org.sagebionetworks.repo.model.entitybundle.v2.EntityBundleRequest$new("includeEntity_example", "includeAnnotations_example", "includePermissions_example", "includeEntityPath_example", "includeHasChildren_example", "includeAccessControlList_example", "includeFileHandles_example", "includeTableBundle_example", "includeRootWikiId_example", "includeBenefactorACL_example", "includeDOIAssociation_example", "includeFileName_example", "includeThreadCount_example", "includeRestrictionInformation_example") # OrgSagebionetworksRepoModelEntitybundleV2EntityBundleRequest | 
#'
#' api_instance <- EntityBundleServicesV2Api$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$PostRepoV1EntityIdVersionVersionNumberBundle2(var_id, var_version_number, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_requestdata_file = "result.txt")
#' result <- api_instance$PostRepoV1EntityIdVersionVersionNumberBundle2(var_id, var_version_number, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request)
#' dput(result)
#'
#'
#' ####################  PutRepoV1EntityIdBundle2  ####################
#'
#' library(synclient)
#' var_id <- "id_example" # character | 
#' var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create <- org.sagebionetworks.repo.model.entitybundle.v2.EntityBundleCreate$new(org.sagebionetworks.repo.model.Entity$new("name_example", "description_example", "id_example", "etag_example", "createdOn_example", "modifiedOn_example", "createdBy_example", "modifiedBy_example", "parentId_example", "concreteType_example", "repositoryName_example", "isManaged_example", 123, "versionLabel_example", "versionComment_example", "isLatestVersion_example", c("columnIds_example"), "isSearchEnabled_example", c(org.sagebionetworks.repo.model.EntityRef$new("entityId_example", 123)), 123, "type_example", c("scopeIds_example"), "definingSQL_example", org.sagebionetworks.repo.model.Reference$new("targetId_example", 123), "linksToClassName_example", "previewString_example", c("headers_example"), c(org.sagebionetworks.repo.model.Row$new(c("cells_example"))), "dataFileHandleId_example", "fileNameOverride_example", "alias_example", 123, "checksum_example", 123, "singleString_example", c("stringList_example"), "singleDate_example", c("dateList_example"), 123, c(123), 123, c(123), "concept_example", "someEnum_example", c(org.sagebionetworks.repo.model.Reference$new("targetId_example", 123)), c(org.sagebionetworks.repo.model.EnvironmentDescriptor$new("type_example", "name_example", "quantifier_example"))), org.sagebionetworks.repo.model.annotation.v2.Annotations$new("id_example", "etag_example", c(key = org.sagebionetworks.repo.model.annotation.v2.AnnotationsValue$new("type_example", c("value_example")))), org.sagebionetworks.repo.model.AccessControlList$new("id_example", "createdBy_example", "creationDate_example", "modifiedBy_example", "modifiedOn_example", "etag_example", c(org.sagebionetworks.repo.model.ResourceAccess$new(123, c("accessType_example"))))) # OrgSagebionetworksRepoModelEntitybundleV2EntityBundleCreate | 
#' var_generated_by <- "generated_by_example" # character |  (Optional)
#'
#' api_instance <- EntityBundleServicesV2Api$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$PutRepoV1EntityIdBundle2(var_id, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = var_generated_bydata_file = "result.txt")
#' result <- api_instance$PutRepoV1EntityIdBundle2(var_id, var_org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = var_generated_by)
#' dput(result)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
EntityBundleServicesV2Api <- R6::R6Class(
  "EntityBundleServicesV2Api",
  public = list(
    api_client = NULL,
    #' Initialize a new EntityBundleServicesV2Api.
    #'
    #' @description
    #' Initialize a new EntityBundleServicesV2Api.
    #'
    #' @param api_client An instance of API client.
    #' @export
    initialize = function(api_client) {
      if (!missing(api_client)) {
        self$api_client <- api_client
      } else {
        self$api_client <- ApiClient$new()
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create 
    #' @param generated_by (optional) No description
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
    #' @export
    PostRepoV1EntityBundle2Create = function(org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = NULL, data_file = NULL, ...) {
      local_var_response <- self$PostRepoV1EntityBundle2CreateWithHttpInfo(org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create 
    #' @param generated_by (optional) No description
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return API response (OrgSagebionetworksRepoModelEntitybundleV2EntityBundle) with additional information such as HTTP status code, headers
    #' @export
    PostRepoV1EntityBundle2CreateWithHttpInfo = function(org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = NULL, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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



      query_params[["generatedBy"]] <- `generated_by`

      if (!is.null(`org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create`)) {
        local_var_body <- `org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/repo/v1/entity/bundle2/create"
      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "POST",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrgSagebionetworksRepoModelEntitybundleV2EntityBundle", loadNamespace("synclient")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id - The ID of the entity to fetch.
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request 
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
    #' @export
    PostRepoV1EntityIdBundle2 = function(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = NULL, ...) {
      local_var_response <- self$PostRepoV1EntityIdBundle2WithHttpInfo(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id - The ID of the entity to fetch.
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request 
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return API response (OrgSagebionetworksRepoModelEntitybundleV2EntityBundle) with additional information such as HTTP status code, headers
    #' @export
    PostRepoV1EntityIdBundle2WithHttpInfo = function(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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



      if (!is.null(`org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request`)) {
        local_var_body <- `org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/repo/v1/entity/{id}/bundle2"
      if (!missing(`id`)) {
        local_var_url_path <- gsub("\\{id\\}", URLencode(as.character(`id`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "POST",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrgSagebionetworksRepoModelEntitybundleV2EntityBundle", loadNamespace("synclient")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id - The ID of the entity to fetch.
    #' @param version_number - The version of the entity to fetch
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request 
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
    #' @export
    PostRepoV1EntityIdVersionVersionNumberBundle2 = function(id, version_number, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = NULL, ...) {
      local_var_response <- self$PostRepoV1EntityIdVersionVersionNumberBundle2WithHttpInfo(id, version_number, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id - The ID of the entity to fetch.
    #' @param version_number - The version of the entity to fetch
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request 
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return API response (OrgSagebionetworksRepoModelEntitybundleV2EntityBundle) with additional information such as HTTP status code, headers
    #' @export
    PostRepoV1EntityIdVersionVersionNumberBundle2WithHttpInfo = function(id, version_number, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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

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




      if (!is.null(`org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request`)) {
        local_var_body <- `org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_request`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/repo/v1/entity/{id}/version/{versionNumber}/bundle2"
      if (!missing(`id`)) {
        local_var_url_path <- gsub("\\{id\\}", URLencode(as.character(`id`), reserved = TRUE), local_var_url_path)
      }

      if (!missing(`version_number`)) {
        local_var_url_path <- gsub("\\{versionNumber\\}", URLencode(as.character(`version_number`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "POST",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrgSagebionetworksRepoModelEntitybundleV2EntityBundle", loadNamespace("synclient")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id 
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create 
    #' @param generated_by (optional) No description
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return OrgSagebionetworksRepoModelEntitybundleV2EntityBundle
    #' @export
    PutRepoV1EntityIdBundle2 = function(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = NULL, data_file = NULL, ...) {
      local_var_response <- self$PutRepoV1EntityIdBundle2WithHttpInfo(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },
    #' 
    #'
    #' @description
    #' 
    #'
    #' @param id 
    #' @param org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create 
    #' @param generated_by (optional) No description
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #' @return API response (OrgSagebionetworksRepoModelEntitybundleV2EntityBundle) with additional information such as HTTP status code, headers
    #' @export
    PutRepoV1EntityIdBundle2WithHttpInfo = function(id, org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create, generated_by = NULL, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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




      query_params[["generatedBy"]] <- `generated_by`

      if (!is.null(`org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create`)) {
        local_var_body <- `org_sagebionetworks_repo_model_entitybundle_v2_entity_bundle_create`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/repo/v1/entity/{id}/bundle2"
      if (!missing(`id`)) {
        local_var_url_path <- gsub("\\{id\\}", URLencode(as.character(`id`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "PUT",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrgSagebionetworksRepoModelEntitybundleV2EntityBundle", loadNamespace("synclient")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    }
  )
)
thomasyu888/synr-sdk-client documentation built on Dec. 31, 2024, 11:29 a.m.