red-ui/libs/red-ui-http/src/lib/api/fileAttributesController.service.ts
2021-03-25 14:41:18 +02:00

445 lines
20 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 { FileAttributeConfig } from '../model/fileAttributeConfig';
import { FileAttributes } from '../model/fileAttributes';
import { FileAttributesBaseConfigRequest } from '../model/fileAttributesBaseConfigRequest';
import { FileAttributesConfig } from '../model/fileAttributesConfig';
import { ImportCsvResponse } from '../model/importCsvResponse';
import { BASE_PATH } from '../variables';
import { Configuration } from '../configuration';
@Injectable()
export class FileAttributesControllerService {
protected basePath = '';
public defaultHeaders = new HttpHeaders();
public configuration = new Configuration();
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;
}
}
/**
* @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;
}
/**
* Adds or updates file attributes base configuration
* None
* @param body fileAttributesBaseConfigRequest
* @param ruleSetId ruleSetId
* @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 addOrUpdateFileAttributesBaseConfig(
body: FileAttributesBaseConfigRequest,
ruleSetId: string,
observe?: 'body',
reportProgress?: boolean
): Observable<FileAttributesConfig>;
public addOrUpdateFileAttributesBaseConfig(
body: FileAttributesBaseConfigRequest,
ruleSetId: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<FileAttributesConfig>>;
public addOrUpdateFileAttributesBaseConfig(
body: FileAttributesBaseConfigRequest,
ruleSetId: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<FileAttributesConfig>>;
public addOrUpdateFileAttributesBaseConfig(
body: FileAttributesBaseConfigRequest,
ruleSetId: 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 addOrUpdateFileAttributesBaseConfig.');
}
if (ruleSetId === null || ruleSetId === undefined) {
throw new Error('Required parameter ruleSetId was null or undefined when calling addOrUpdateFileAttributesBaseConfig.');
}
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[] = ['application/json'];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request<FileAttributesConfig>(
'post',
`${this.basePath}/fileAttributes/config/baseConfig/${encodeURIComponent(String(ruleSetId))}`,
{
body: body,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* Get the file attributes that can be used at importing csv.
* None
* @param ruleSetId ruleSetId
* @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 getFileAttributesConfiguration(ruleSetId: string, observe?: 'body', reportProgress?: boolean): Observable<FileAttributesConfig>;
public getFileAttributesConfiguration(ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<FileAttributesConfig>>;
public getFileAttributesConfiguration(ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<FileAttributesConfig>>;
public getFileAttributesConfiguration(ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
if (ruleSetId === null || ruleSetId === undefined) {
throw new Error('Required parameter ruleSetId was null or undefined when calling getFileAttributesConfiguration.');
}
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[] = [];
return this.httpClient.request<FileAttributesConfig>('get', `${this.basePath}/fileAttributes/config/${encodeURIComponent(String(ruleSetId))}`, {
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Import a csv file to set file attributes
* None
* @param file
* @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 importCsvForm(file: Blob, projectId: string, observe?: 'body', reportProgress?: boolean): Observable<ImportCsvResponse>;
public importCsvForm(file: Blob, projectId: string, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<ImportCsvResponse>>;
public importCsvForm(file: Blob, projectId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<ImportCsvResponse>>;
public importCsvForm(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 importCsv.');
}
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling importCsv.');
}
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<ImportCsvResponse>('post', `${this.basePath}/fileAttributes/csvImport/${encodeURIComponent(String(projectId))}`, {
body: convertFormParamsToString ? formParams.toString() : formParams,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
});
}
/**
* Set file attributes to a existing file
* None
* @param body fileAttributes
* @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 setFileAttributes(body: FileAttributes, projectId: string, fileId: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public setFileAttributes(
body: FileAttributes,
projectId: string,
fileId: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public setFileAttributes(body: FileAttributes, projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<any>>;
public setFileAttributes(body: FileAttributes, projectId: string, fileId: 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 setFileAttributes.');
}
if (projectId === null || projectId === undefined) {
throw new Error('Required parameter projectId was null or undefined when calling setFileAttributes.');
}
if (fileId === null || fileId === undefined) {
throw new Error('Required parameter fileId was null or undefined when calling setFileAttributes.');
}
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}/fileAttributes/set/${encodeURIComponent(String(projectId))}/${encodeURIComponent(String(fileId))}`,
{
body: body,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* Add or update a file attribute that can be used at importing csv.
* None
* @param body fileAttribute
* @param ruleSetId ruleSetId
* @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 setFileAttributesConfiguration(
body: FileAttributeConfig,
ruleSetId: string,
observe?: 'body',
reportProgress?: boolean
): Observable<FileAttributeConfig>;
public setFileAttributesConfiguration(
body: FileAttributeConfig,
ruleSetId: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<FileAttributeConfig>>;
public setFileAttributesConfiguration(
body: FileAttributeConfig,
ruleSetId: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<FileAttributeConfig>>;
public setFileAttributesConfiguration(
body: FileAttributeConfig,
ruleSetId: 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 setFileAttributesConfiguration.');
}
if (ruleSetId === null || ruleSetId === undefined) {
throw new Error('Required parameter ruleSetId was null or undefined when calling setFileAttributesConfiguration.');
}
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[] = ['application/json'];
const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
if (httpContentTypeSelected !== undefined) {
headers = headers.set('Content-Type', httpContentTypeSelected);
}
return this.httpClient.request<FileAttributeConfig>(
'post',
`${this.basePath}/fileAttributes/config/fileAttribute/${encodeURIComponent(String(ruleSetId))}`,
{
body: body,
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
/**
* Delete a specific file attribute.
* None
* @param ruleSetId ruleSetId
* @param fileAttributeId fileAttributeId
* @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 deleteFileAttributesConfiguration(ruleSetId: string, fileAttributeId: string, observe?: 'body', reportProgress?: boolean): Observable<any>;
public deleteFileAttributesConfiguration(
ruleSetId: string,
fileAttributeId: string,
observe?: 'response',
reportProgress?: boolean
): Observable<HttpResponse<any>>;
public deleteFileAttributesConfiguration(
ruleSetId: string,
fileAttributeId: string,
observe?: 'events',
reportProgress?: boolean
): Observable<HttpEvent<any>>;
public deleteFileAttributesConfiguration(
ruleSetId: string,
fileAttributeId: string,
observe: any = 'body',
reportProgress: boolean = false
): Observable<any> {
if (ruleSetId === null || ruleSetId === undefined) {
throw new Error('Required parameter ruleSetId was null or undefined when calling setFileAttributesConfiguration1.');
}
if (fileAttributeId === null || fileAttributeId === undefined) {
throw new Error('Required parameter ruleSetId was null or undefined when calling setFileAttributesConfiguration1.');
}
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}/fileAttributes/config/fileAttribute/${encodeURIComponent(String(ruleSetId))}/${encodeURIComponent(String(fileAttributeId))}`,
{
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,
reportProgress: reportProgress
}
);
}
}