/* tslint:disable */
/* eslint-disable */
/**
 * Vectorize API (Beta)
 * API for Vectorize services
 *
 * The version of the OpenAPI document: 0.0.1
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  GetPipelines400Response,
  StartFileUploadRequest,
  StartFileUploadResponse,
} from '../models/index';
import {
    GetPipelines400ResponseFromJSON,
    GetPipelines400ResponseToJSON,
    StartFileUploadRequestFromJSON,
    StartFileUploadRequestToJSON,
    StartFileUploadResponseFromJSON,
    StartFileUploadResponseToJSON,
} from '../models/index';

export interface StartFileUploadOperationRequest {
    organization: string;
    startFileUploadRequest: StartFileUploadRequest;
}

/**
 * 
 */
export class FilesApi extends runtime.BaseAPI {

    /**
     * Upload a generic file to the platform
     */
    async startFileUploadRaw(requestParameters: StartFileUploadOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<StartFileUploadResponse>> {
        if (requestParameters['organization'] == null) {
            throw new runtime.RequiredError(
                'organization',
                'Required parameter "organization" was null or undefined when calling startFileUpload().'
            );
        }

        if (requestParameters['startFileUploadRequest'] == null) {
            throw new runtime.RequiredError(
                'startFileUploadRequest',
                'Required parameter "startFileUploadRequest" was null or undefined when calling startFileUpload().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("bearerAuth", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }
        const response = await this.request({
            path: `/org/{organization}/files`.replace(`{${"organization"}}`, encodeURIComponent(String(requestParameters['organization']))),
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: StartFileUploadRequestToJSON(requestParameters['startFileUploadRequest']),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => StartFileUploadResponseFromJSON(jsonValue));
    }

    /**
     * Upload a generic file to the platform
     */
    async startFileUpload(requestParameters: StartFileUploadOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<StartFileUploadResponse> {
        const response = await this.startFileUploadRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
