/*
 * Orvanta API
 *
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0.6
 * Contact: contact@orvanta.cloud
 * Generated by: https://openapi-generator.tech
 */


use reqwest;
use serde::{Deserialize, Serialize};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};


/// struct for typed errors of method [`check_s3_folder_exists`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CheckS3FolderExistsError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`dataset_storage_test_connection`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DatasetStorageTestConnectionError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`delete_s3_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteS3FileError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`duckdb_connection_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuckdbConnectionSettingsError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`duckdb_connection_settings_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DuckdbConnectionSettingsV2Error {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`file_download`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileDownloadError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`file_download_parquet_as_csv`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileDownloadParquetAsCsvError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`file_upload`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum FileUploadError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`git_repo_viewer_file_upload`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GitRepoViewerFileUploadError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`list_git_repo_files`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListGitRepoFilesError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`list_stored_files`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListStoredFilesError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_csv_preview`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadCsvPreviewError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_file_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadFileMetadataError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_file_preview`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadFilePreviewError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_git_repo_file_metadata`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadGitRepoFileMetadataError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_git_repo_file_preview`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadGitRepoFilePreviewError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_parquet_preview`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadParquetPreviewError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`load_table_row_count`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum LoadTableRowCountError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`move_s3_file`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum MoveS3FileError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`polars_connection_settings`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PolarsConnectionSettingsError {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`polars_connection_settings_v2`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PolarsConnectionSettingsV2Error {
    UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`s3_resource_info`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum S3ResourceInfoError {
    UnknownValue(serde_json::Value),
}


pub async fn check_s3_folder_exists(configuration: &configuration::Configuration, workspace: &str, file_key: &str, marker_file: Option<&str>) -> Result<models::CheckS3FolderExists200Response, Error<CheckS3FolderExistsError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/check_s3_folder_exists", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = marker_file {
        local_var_req_builder = local_var_req_builder.query(&[("marker_file", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<CheckS3FolderExistsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn dataset_storage_test_connection(configuration: &configuration::Configuration, workspace: &str, storage: Option<&str>) -> Result<serde_json::Value, Error<DatasetStorageTestConnectionError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/test_connection", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DatasetStorageTestConnectionError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn delete_s3_file(configuration: &configuration::Configuration, workspace: &str, file_key: &str, storage: Option<&str>) -> Result<serde_json::Value, Error<DeleteS3FileError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/delete_s3_file", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DeleteS3FileError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn duckdb_connection_settings(configuration: &configuration::Configuration, workspace: &str, duckdb_connection_settings_request: models::DuckdbConnectionSettingsRequest) -> Result<models::DuckdbConnectionSettings200Response, Error<DuckdbConnectionSettingsError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/duckdb_connection_settings", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&duckdb_connection_settings_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DuckdbConnectionSettingsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn duckdb_connection_settings_v2(configuration: &configuration::Configuration, workspace: &str, duckdb_connection_settings_v2_request: models::DuckdbConnectionSettingsV2Request) -> Result<models::DuckdbConnectionSettingsV2200Response, Error<DuckdbConnectionSettingsV2Error>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/v2/duckdb_connection_settings", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&duckdb_connection_settings_v2_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<DuckdbConnectionSettingsV2Error> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn file_download(configuration: &configuration::Configuration, workspace: &str, file_key: &str, s3_resource_path: Option<&str>, resource_type: Option<&str>, storage: Option<&str>) -> Result<std::path::PathBuf, Error<FileDownloadError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/download_s3_file", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = s3_resource_path {
        local_var_req_builder = local_var_req_builder.query(&[("s3_resource_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = resource_type {
        local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<FileDownloadError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn file_download_parquet_as_csv(configuration: &configuration::Configuration, workspace: &str, file_key: &str, s3_resource_path: Option<&str>, resource_type: Option<&str>) -> Result<String, Error<FileDownloadParquetAsCsvError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/download_s3_parquet_file_as_csv", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = s3_resource_path {
        local_var_req_builder = local_var_req_builder.query(&[("s3_resource_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = resource_type {
        local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<FileDownloadParquetAsCsvError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn file_upload(configuration: &configuration::Configuration, workspace: &str, body: std::path::PathBuf, file_key: Option<&str>, file_extension: Option<&str>, s3_resource_path: Option<&str>, resource_type: Option<&str>, storage: Option<&str>, content_type: Option<&str>, content_disposition: Option<&str>) -> Result<models::FileUpload200Response, Error<FileUploadError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/upload_s3_file", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = file_key {
        local_var_req_builder = local_var_req_builder.query(&[("file_key", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = file_extension {
        local_var_req_builder = local_var_req_builder.query(&[("file_extension", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = s3_resource_path {
        local_var_req_builder = local_var_req_builder.query(&[("s3_resource_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = resource_type {
        local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = content_type {
        local_var_req_builder = local_var_req_builder.query(&[("content_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = content_disposition {
        local_var_req_builder = local_var_req_builder.query(&[("content_disposition", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&body);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<FileUploadError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn git_repo_viewer_file_upload(configuration: &configuration::Configuration, workspace: &str, body: std::path::PathBuf, file_key: Option<&str>, file_extension: Option<&str>, s3_resource_path: Option<&str>, resource_type: Option<&str>, storage: Option<&str>, content_type: Option<&str>, content_disposition: Option<&str>) -> Result<models::FileUpload200Response, Error<GitRepoViewerFileUploadError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/upload_git_repo_file_to_instance_storage", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = file_key {
        local_var_req_builder = local_var_req_builder.query(&[("file_key", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = file_extension {
        local_var_req_builder = local_var_req_builder.query(&[("file_extension", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = s3_resource_path {
        local_var_req_builder = local_var_req_builder.query(&[("s3_resource_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = resource_type {
        local_var_req_builder = local_var_req_builder.query(&[("resource_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = content_type {
        local_var_req_builder = local_var_req_builder.query(&[("content_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = content_disposition {
        local_var_req_builder = local_var_req_builder.query(&[("content_disposition", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&body);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<GitRepoViewerFileUploadError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn list_git_repo_files(configuration: &configuration::Configuration, workspace: &str, max_keys: i32, marker: Option<&str>, prefix: Option<&str>, storage: Option<&str>) -> Result<models::ListStoredFiles200Response, Error<ListGitRepoFilesError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/list_git_repo_files", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("max_keys", &max_keys.to_string())]);
    if let Some(ref local_var_str) = marker {
        local_var_req_builder = local_var_req_builder.query(&[("marker", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = prefix {
        local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<ListGitRepoFilesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn list_stored_files(configuration: &configuration::Configuration, workspace: &str, max_keys: i32, marker: Option<&str>, prefix: Option<&str>, storage: Option<&str>) -> Result<models::ListStoredFiles200Response, Error<ListStoredFilesError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/list_stored_files", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("max_keys", &max_keys.to_string())]);
    if let Some(ref local_var_str) = marker {
        local_var_req_builder = local_var_req_builder.query(&[("marker", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = prefix {
        local_var_req_builder = local_var_req_builder.query(&[("prefix", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<ListStoredFilesError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_csv_preview(configuration: &configuration::Configuration, workspace: &str, path: &str, offset: Option<f64>, limit: Option<f64>, sort_col: Option<&str>, sort_desc: Option<bool>, search_col: Option<&str>, search_term: Option<&str>, storage: Option<&str>, csv_separator: Option<&str>) -> Result<(), Error<LoadCsvPreviewError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_csv_preview/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = offset {
        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = limit {
        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = sort_col {
        local_var_req_builder = local_var_req_builder.query(&[("sort_col", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = sort_desc {
        local_var_req_builder = local_var_req_builder.query(&[("sort_desc", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_col {
        local_var_req_builder = local_var_req_builder.query(&[("search_col", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_term {
        local_var_req_builder = local_var_req_builder.query(&[("search_term", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = csv_separator {
        local_var_req_builder = local_var_req_builder.query(&[("csv_separator", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<LoadCsvPreviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_file_metadata(configuration: &configuration::Configuration, workspace: &str, file_key: &str, storage: Option<&str>) -> Result<models::OrvantaFileMetadata, Error<LoadFileMetadataError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_file_metadata", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<LoadFileMetadataError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_file_preview(configuration: &configuration::Configuration, workspace: &str, file_key: &str, file_size_in_bytes: Option<i32>, file_mime_type: Option<&str>, csv_separator: Option<&str>, csv_has_header: Option<bool>, read_bytes_from: Option<i32>, read_bytes_length: Option<i32>, storage: Option<&str>) -> Result<models::OrvantaFilePreview, Error<LoadFilePreviewError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_file_preview", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = file_size_in_bytes {
        local_var_req_builder = local_var_req_builder.query(&[("file_size_in_bytes", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = file_mime_type {
        local_var_req_builder = local_var_req_builder.query(&[("file_mime_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = csv_separator {
        local_var_req_builder = local_var_req_builder.query(&[("csv_separator", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = csv_has_header {
        local_var_req_builder = local_var_req_builder.query(&[("csv_has_header", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = read_bytes_from {
        local_var_req_builder = local_var_req_builder.query(&[("read_bytes_from", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = read_bytes_length {
        local_var_req_builder = local_var_req_builder.query(&[("read_bytes_length", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<LoadFilePreviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_git_repo_file_metadata(configuration: &configuration::Configuration, workspace: &str, file_key: &str, storage: Option<&str>) -> Result<models::OrvantaFileMetadata, Error<LoadGitRepoFileMetadataError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_git_repo_file_metadata", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<LoadGitRepoFileMetadataError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_git_repo_file_preview(configuration: &configuration::Configuration, workspace: &str, file_key: &str, file_size_in_bytes: Option<i32>, file_mime_type: Option<&str>, csv_separator: Option<&str>, csv_has_header: Option<bool>, read_bytes_from: Option<i32>, read_bytes_length: Option<i32>, storage: Option<&str>) -> Result<models::OrvantaFilePreview, Error<LoadGitRepoFilePreviewError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_git_repo_file_preview", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("file_key", &file_key.to_string())]);
    if let Some(ref local_var_str) = file_size_in_bytes {
        local_var_req_builder = local_var_req_builder.query(&[("file_size_in_bytes", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = file_mime_type {
        local_var_req_builder = local_var_req_builder.query(&[("file_mime_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = csv_separator {
        local_var_req_builder = local_var_req_builder.query(&[("csv_separator", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = csv_has_header {
        local_var_req_builder = local_var_req_builder.query(&[("csv_has_header", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = read_bytes_from {
        local_var_req_builder = local_var_req_builder.query(&[("read_bytes_from", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = read_bytes_length {
        local_var_req_builder = local_var_req_builder.query(&[("read_bytes_length", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<LoadGitRepoFilePreviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_parquet_preview(configuration: &configuration::Configuration, workspace: &str, path: &str, offset: Option<f64>, limit: Option<f64>, sort_col: Option<&str>, sort_desc: Option<bool>, search_col: Option<&str>, search_term: Option<&str>, storage: Option<&str>) -> Result<(), Error<LoadParquetPreviewError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_parquet_preview/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = offset {
        local_var_req_builder = local_var_req_builder.query(&[("offset", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = limit {
        local_var_req_builder = local_var_req_builder.query(&[("limit", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = sort_col {
        local_var_req_builder = local_var_req_builder.query(&[("sort_col", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = sort_desc {
        local_var_req_builder = local_var_req_builder.query(&[("sort_desc", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_col {
        local_var_req_builder = local_var_req_builder.query(&[("search_col", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_term {
        local_var_req_builder = local_var_req_builder.query(&[("search_term", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        Ok(())
    } else {
        let local_var_entity: Option<LoadParquetPreviewError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn load_table_row_count(configuration: &configuration::Configuration, workspace: &str, path: &str, search_col: Option<&str>, search_term: Option<&str>, storage: Option<&str>) -> Result<models::LoadTableRowCount200Response, Error<LoadTableRowCountError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/load_table_count/{path}", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace), path=crate::apis::urlencode(path));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    if let Some(ref local_var_str) = search_col {
        local_var_req_builder = local_var_req_builder.query(&[("search_col", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_term {
        local_var_req_builder = local_var_req_builder.query(&[("search_term", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<LoadTableRowCountError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn move_s3_file(configuration: &configuration::Configuration, workspace: &str, src_file_key: &str, dest_file_key: &str, storage: Option<&str>) -> Result<serde_json::Value, Error<MoveS3FileError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/move_s3_file", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

    local_var_req_builder = local_var_req_builder.query(&[("src_file_key", &src_file_key.to_string())]);
    local_var_req_builder = local_var_req_builder.query(&[("dest_file_key", &dest_file_key.to_string())]);
    if let Some(ref local_var_str) = storage {
        local_var_req_builder = local_var_req_builder.query(&[("storage", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<MoveS3FileError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn polars_connection_settings(configuration: &configuration::Configuration, workspace: &str, duckdb_connection_settings_request: models::DuckdbConnectionSettingsRequest) -> Result<models::PolarsConnectionSettings200Response, Error<PolarsConnectionSettingsError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/polars_connection_settings", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&duckdb_connection_settings_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<PolarsConnectionSettingsError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn polars_connection_settings_v2(configuration: &configuration::Configuration, workspace: &str, duckdb_connection_settings_v2_request: models::DuckdbConnectionSettingsV2Request) -> Result<models::PolarsConnectionSettingsV2200Response, Error<PolarsConnectionSettingsV2Error>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/v2/polars_connection_settings", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&duckdb_connection_settings_v2_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<PolarsConnectionSettingsV2Error> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

pub async fn s3_resource_info(configuration: &configuration::Configuration, workspace: &str, duckdb_connection_settings_v2_request: models::DuckdbConnectionSettingsV2Request) -> Result<models::S3Resource, Error<S3ResourceInfoError>> {
    let local_var_configuration = configuration;

    let local_var_client = &local_var_configuration.client;

    let local_var_uri_str = format!("{}/w/{workspace}/job_helpers/v2/s3_resource_info", local_var_configuration.base_path, workspace=crate::apis::urlencode(workspace));
    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
    }
    if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
        local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
    };
    local_var_req_builder = local_var_req_builder.json(&duckdb_connection_settings_v2_request);

    let local_var_req = local_var_req_builder.build()?;
    let local_var_resp = local_var_client.execute(local_var_req).await?;

    let local_var_status = local_var_resp.status();
    let local_var_content = local_var_resp.text().await?;

    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
        crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).map_err(Error::from)
    } else {
        let local_var_entity: Option<S3ResourceInfoError> = crate::from_str_patched/* Externally injected from /build.nu */(&local_var_content).ok();
        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
        Err(Error::ResponseError(local_var_error))
    }
}

