red-ui/libs/red-ui-http/src/lib/api/fileManagementController.service.ts
2021-01-06 15:15:27 +02:00

670 lines
29 KiB
TypeScript

/**
* API Documentation for Redaction Gateway
* Description for redaction
*
* OpenAPI spec version: 1.0
*
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/ /* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import { HttpClient, HttpEvent, HttpHeaders, HttpParams, HttpResponse } from '@angular/common/http';
import { CustomHttpUrlEncodingCodec } from '../encoder';
import { Observable } from 'rxjs';
import { BulkDownloadRedactedRequest } from '../model/bulkDownloadRedactedRequest';
import { FileIds } from '../model/fileIds';
import { FileUploadResult } from '../model/fileUploadResult';
import { BASE_PATH } from '../variables';
import { Configuration } from '../configuration';
@Injectable()
export class FileManagementControllerService {
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
protected basePath = '';
constructor(protected httpClient: HttpClient, @Optional() @Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) {
if (basePath) {
this.basePath = basePath;
}
if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
}
}
/**
* Deletes a file for a given projectId and FileId
* None
* @param projectId projectId
* @param fileId fileId
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deleteFile(projectId: string, fileId: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public deleteFile(projectId: string, fileId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
public deleteFile(projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public deleteFile(projectId: string, fileId: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling deleteFile.');
}
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling deleteFile.');
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request<any>(
'delete',
`${this.basePath}/delete/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* Deletes a a list of files for a given projectId
* None
* @param body fileIds
* @param projectId projectId
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public deleteFiles(body: Array<string>, projectId: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public deleteFiles(body: Array<string>, projectId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<any>>;
public deleteFiles(body: Array<string>, projectId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public deleteFiles(body: Array<string>, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling deleteFiles.');
}
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling deleteFiles.');
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = [];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = ['application/json'];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request<any>('post', `${this.basePath}/delete/${encodeURIComponent(String(projectId))}`, {
body: body,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the annotated file with the specified fileId
* Use the optional \&quot;inline\&quot; request parameter to select, if this downloadAnnotated will be opened in the browser.
* @param fileId fileId
* @param inline inline
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadAnnotatedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadAnnotatedFile(
fileId: string,
inline?: boolean,
indicator?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadAnnotatedFile(
fileId: string,
inline?: boolean,
indicator?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<any>>;
public downloadAnnotatedFile(
fileId: string,
inline?: boolean,
indicator?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling downloadAnnotatedFile.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (indicator !== undefined && indicator !== null) {
queryParameters = queryParameters.set('indicator', <any>indicator);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/octet-stream'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request('get', `${this.basePath}/download/annotated/${encodeURIComponent(String(fileId))}`, {
responseType: 'blob',
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the original file with the specified fileId
* Use the optional \&quot;inline\&quot; request parameter to select, if this downloadAnnotated will be opened in the browser.
* @param fileId fileId
* @param inline inline
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadOriginalFile(
fileId: string,
inline?: boolean,
indicator?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public downloadOriginalFile(fileId: string, inline?: boolean, indicator?: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling downloadOriginalFile.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (indicator !== undefined && indicator !== null) {
queryParameters = queryParameters.set('indicator', <any>indicator);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/octet-stream'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request('get', `${this.basePath}/download/original/${encodeURIComponent(String(fileId))}`, {
responseType: 'blob',
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the redacted file with the specified fileId
* Use the optional \&quot;inline\&quot; request parameter to select, if this downloadAnnotated will be opened in the browser.
* @param fileId fileId
* @param inline inline
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadRedactedFile(
fileId: string,
inline?: boolean,
indicator?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public downloadRedactedFile(fileId: string, inline?: boolean, indicator?: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling downloadRedactedFile.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (indicator !== undefined && indicator !== null) {
queryParameters = queryParameters.set('indicator', <any>indicator);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/octet-stream'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request('get', `${this.basePath}/download/redacted/${encodeURIComponent(String(fileId))}`, {
responseType: 'blob',
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the requested files in a zip format
* Use the optional \&quot;inline\&quot; request parameter to select, if this report will be opened in the browser.
* @param body bulkDownloadRedactedRequest
* @param projectId The projectId
* @param inline inline
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadRedactedFiles(
body: BulkDownloadRedactedRequest,
projectId: string,
inline?: boolean,
observe?: 'body',
reportProgress?: boolean
): Observable<any>;
public downloadRedactedFiles(
body: BulkDownloadRedactedRequest,
projectId: string,
inline?: boolean,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadRedactedFiles(
body: BulkDownloadRedactedRequest,
projectId: string,
inline?: boolean,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<any>>;
public downloadRedactedFiles(
body: BulkDownloadRedactedRequest,
projectId: string,
inline?: boolean,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling downloadRedactedFiles.');
}
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling downloadRedactedFiles.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['*/*'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = ['application/json'];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request('post', `${this.basePath}/download/bulk/redacted/${encodeURIComponent(String(projectId))}`, {
responseType: 'blob',
body: body,
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the redaction report file for the specified fileIds
* Use the optional \&quot;inline\&quot; request parameter to select, if this report will be opened in the browser.
* @param body fileIds
* @param inline inline
* @param template template
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadRedactionReport(body: FileIds, inline?: boolean, template?: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public downloadRedactionReport(
body: FileIds,
inline?: boolean,
template?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadRedactionReport(
body: FileIds,
inline?: boolean,
template?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<any>>;
public downloadRedactionReport(
body: FileIds,
inline?: boolean,
template?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
if (body === null || body === undefined) {
throw new Error('Required parameter body was null or undefined when calling downloadRedactionReport.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (template !== undefined && template !== null) {
queryParameters = queryParameters.set('template', <any>template);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['*/*'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = ['application/json'];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request('post', `${this.basePath}/download/report`, {
responseType: 'blob',
body: body,
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Returns a downloadable byte stream of the redaction report file for the specified project
* Use the optional \&quot;inline\&quot; request parameter to select, if this report will be opened in the browser.
* @param projectId The projectId
* @param inline inline
* @param template template
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public downloadRedactionReportForProject(
projectId: string,
inline?: boolean,
template?: string,
observe?: 'body',
reportProgress?: boolean
): Observable<any>;
public downloadRedactionReportForProject(
projectId: string,
inline?: boolean,
template?: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public downloadRedactionReportForProject(
projectId: string,
inline?: boolean,
template?: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<any>>;
public downloadRedactionReportForProject(
projectId: string,
inline?: boolean,
template?: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling downloadRedactionReportForProject.');
}
let queryParameters = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
if (inline !== undefined && inline !== null) {
queryParameters = queryParameters.set('inline', <any>inline);
}
if (template !== undefined && template !== null) {
queryParameters = queryParameters.set('template', <any>template);
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['*/*'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = [];
return this.httpClient.request('get', `${this.basePath}/download/report/${encodeURIComponent(String(projectId))}`, {
responseType: 'blob',
params: queryParameters,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Receives an uploaded file and returns its fileId.
* None
* @param file
* @param projectId The projectId, the file belongs to
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public uploadFileForm(file: Blob, projectId: string, observe?: 'body', reportProgress?: boolean): Observable<FileUploadResult>;
public uploadFileForm(file: Blob, projectId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<FileUploadResult>>;
public uploadFileForm(file: Blob, projectId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<FileUploadResult>>;
public uploadFileForm(file: Blob, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (file === null || file === undefined) {
throw new Error('Required parameter file was null or undefined when calling uploadFile.');
}
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling uploadFile.');
}
let headers = this.defaultHeaders;
// authentication (RED-OAUTH) required
if (this.configuration.accessToken) {
const accessToken = typeof this.configuration.accessToken === 'function' ? this.configuration.accessToken() : this.configuration.accessToken;
headers = headers.set('Authorization', 'Bearer ' + accessToken);
}
// to determine the Accept header
const httpHeaderAccepts: string[] = ['application/json'];
const httpHeaderAcceptSelected: string | undefined = this.configuration.selectHeaderAccept(httpHeaderAccepts);
if (httpHeaderAcceptSelected !== undefined) {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
// to determine the Content-Type header
const consumes: string[] = ['multipart/form-data'];
const canConsumeForm = this.canConsumeForm(consumes);
let formParams: { append(param: string, value: any): void };
let useForm = false;
const convertFormParamsToString = false;
// use FormData to transmit files using content-type "multipart/form-data"
// see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
formParams = new HttpParams({ encoder: new CustomHttpUrlEncodingCodec() });
}
if (file !== undefined) {
formParams = (formParams.append('file', <any>file) as any) || formParams;
}
return this.httpClient.request<FileUploadResult>('post', `${this.basePath}/upload/${encodeURIComponent(String(projectId))}`, {
body: convertFormParamsToString ? formParams.toString() : formParams,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* @param consumes string[] mime-types
* @return true: consumes contains 'multipart/form-data', false: otherwise
*/
private canConsumeForm(consumes: string[]): boolean {
const form = 'multipart/form-data';
for (const consume of consumes) {
if (form === consume) {
return true;
}
}
return false;
}
}