/** * 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; public addOrUpdateFileAttributesBaseConfig( body: FileAttributesBaseConfigRequest, ruleSetId: string, observe?: 'response', reportProgress?: boolean ): Observable>; public addOrUpdateFileAttributesBaseConfig( body: FileAttributesBaseConfigRequest, ruleSetId: string, observe?: 'events', reportProgress?: boolean ): Observable>; public addOrUpdateFileAttributesBaseConfig( body: FileAttributesBaseConfigRequest, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { 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( '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; public getFileAttributesConfiguration(ruleSetId: string, observe?: 'response', reportProgress?: boolean): Observable>; public getFileAttributesConfiguration(ruleSetId: string, observe?: 'events', reportProgress?: boolean): Observable>; public getFileAttributesConfiguration(ruleSetId: string, observe: any = 'body', reportProgress: boolean = false): Observable { 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('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; public importCsvForm(file: Blob, projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; public importCsvForm(file: Blob, projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; public importCsvForm(file: Blob, projectId: string, observe: any = 'body', reportProgress: boolean = false): Observable { 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', file) as any) || formParams; } return this.httpClient.request('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; public setFileAttributes( body: FileAttributes, projectId: string, fileId: string, observe?: 'response', reportProgress?: boolean ): Observable>; public setFileAttributes(body: FileAttributes, projectId: string, fileId: string, observe?: 'events', reportProgress?: boolean): Observable>; public setFileAttributes(body: FileAttributes, projectId: string, fileId: string, observe: any = 'body', reportProgress: boolean = false): Observable { 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( '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; public setFileAttributesConfiguration( body: FileAttributeConfig, ruleSetId: string, observe?: 'response', reportProgress?: boolean ): Observable>; public setFileAttributesConfiguration( body: FileAttributeConfig, ruleSetId: string, observe?: 'events', reportProgress?: boolean ): Observable>; public setFileAttributesConfiguration( body: FileAttributeConfig, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { 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( '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; public deleteFileAttributesConfiguration( ruleSetId: string, fileAttributeId: string, observe?: 'response', reportProgress?: boolean ): Observable>; public deleteFileAttributesConfiguration( ruleSetId: string, fileAttributeId: string, observe?: 'events', reportProgress?: boolean ): Observable>; public deleteFileAttributesConfiguration( ruleSetId: string, fileAttributeId: string, observe: any = 'body', reportProgress: boolean = false ): Observable { 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( 'delete', `${this.basePath}/fileAttributes/config/fileAttribute/${encodeURIComponent(String(ruleSetId))}/${encodeURIComponent(String(fileAttributeId))}`, { withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, reportProgress: reportProgress } ); } }