From 75bafe64cabae202c03ffa7c67e1f7068d840b41 Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 18 Mar 2021 21:56:30 +0200 Subject: [PATCH] added fileattribute service --- README.md | 2 +- libs/red-ui-http/src/lib/api.module.ts | 4 +- libs/red-ui-http/src/lib/api/api.ts | 6 +- .../api/fileAttributesController.service.ts | 284 ++++++++++++++++++ .../src/lib/model/fileAttribute.ts | 18 ++ .../src/lib/model/fileAttributes.ts | 15 + .../src/lib/model/fileAttributesConfig.ts | 16 + .../src/lib/model/importCsvRequest.ts | 18 ++ .../src/lib/model/importCsvResponse.ts | 15 + libs/red-ui-http/src/lib/model/models.ts | 5 + 10 files changed, 380 insertions(+), 3 deletions(-) create mode 100644 libs/red-ui-http/src/lib/api/fileAttributesController.service.ts create mode 100644 libs/red-ui-http/src/lib/model/fileAttribute.ts create mode 100644 libs/red-ui-http/src/lib/model/fileAttributes.ts create mode 100644 libs/red-ui-http/src/lib/model/fileAttributesConfig.ts create mode 100644 libs/red-ui-http/src/lib/model/importCsvRequest.ts create mode 100644 libs/red-ui-http/src/lib/model/importCsvResponse.ts diff --git a/README.md b/README.md index abe0df64e..c68238cde 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ To re-generate http rune swagger YOu need swagger-codegen installed `brew install swagger-codegen` ``` -BASE=https://redapi-staging.iqser.cloud/ +BASE=http://redaction.redaction-timo-12027.178.63.47.73.xip.io/ URL="$BASE"v2/api-docs?group=redaction-gateway-v1 mkdir -p /tmp/swagger swagger-codegen generate -i "$URL" -l typescript-angular -o /tmp/swagger diff --git a/libs/red-ui-http/src/lib/api.module.ts b/libs/red-ui-http/src/lib/api.module.ts index 6cb9481cf..32079f878 100644 --- a/libs/red-ui-http/src/lib/api.module.ts +++ b/libs/red-ui-http/src/lib/api.module.ts @@ -21,6 +21,7 @@ import { RuleSetControllerService } from './api/ruleSetController.service'; import { DownloadControllerService } from './api/downloadController.service'; import { DigitalSignatureControllerService } from './api/digitalSignatureController.service'; import { AuditControllerService } from './api/auditController.service'; +import { FileAttributesControllerService } from './api/fileAttributesController.service'; @NgModule({ imports: [], @@ -45,7 +46,8 @@ import { AuditControllerService } from './api/auditController.service'; LegalBasisMappingControllerService, WatermarkControllerService, DownloadControllerService, - DigitalSignatureControllerService + DigitalSignatureControllerService, + FileAttributesControllerService ] }) export class ApiModule { diff --git a/libs/red-ui-http/src/lib/api/api.ts b/libs/red-ui-http/src/lib/api/api.ts index 1653d5ae1..878522f41 100644 --- a/libs/red-ui-http/src/lib/api/api.ts +++ b/libs/red-ui-http/src/lib/api/api.ts @@ -19,6 +19,7 @@ import { ViewedPagesControllerService } from './viewedPagesController.service'; import { WatermarkControllerService } from './watermarkController.service'; import { DownloadControllerService } from './downloadController.service'; import { DigitalSignatureControllerService } from './digitalSignatureController.service'; +import { FileAttributesControllerService } from './fileAttributesController.service'; export * from './auditController.service'; @@ -62,6 +63,8 @@ export * from './digitalSignatureController.service'; export * from './debugController.service'; +export * from './fileAttributesController.service'; + export const APIS = [ AuditControllerService, DebugControllerService, @@ -83,5 +86,6 @@ export const APIS = [ ViewedPagesControllerService, WatermarkControllerService, DownloadControllerService, - DigitalSignatureControllerService + DigitalSignatureControllerService, + FileAttributesControllerService ]; diff --git a/libs/red-ui-http/src/lib/api/fileAttributesController.service.ts b/libs/red-ui-http/src/lib/api/fileAttributesController.service.ts new file mode 100644 index 000000000..918c8d00a --- /dev/null +++ b/libs/red-ui-http/src/lib/api/fileAttributesController.service.ts @@ -0,0 +1,284 @@ +/** + * 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, HttpResponse } from '@angular/common/http'; + +import { Observable } from 'rxjs'; + +import { FileAttributes } from '../model/fileAttributes'; +import { FileAttributesConfig } from '../model/fileAttributesConfig'; +import { ImportCsvRequest } from '../model/importCsvRequest'; +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; + } + + /** + * 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 body importCsvRequest + * @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 importCsv(body: ImportCsvRequest, projectId: string, observe?: 'body', reportProgress?: boolean): Observable; + public importCsv(body: ImportCsvRequest, projectId: string, observe?: 'response', reportProgress?: boolean): Observable>; + public importCsv(body: ImportCsvRequest, projectId: string, observe?: 'events', reportProgress?: boolean): Observable>; + public importCsv(body: ImportCsvRequest, projectId: 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 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[] = ['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/csvImport/${encodeURIComponent(String(projectId))}`, { + body: body, + 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 + } + ); + } + + /** + * Set the file attributes that can be used at importing csv. + * None + * @param body fileAttributes + * @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: FileAttributesConfig, + ruleSetId: string, + observe?: 'body', + reportProgress?: boolean + ): Observable; + public setFileAttributesConfiguration( + body: FileAttributesConfig, + ruleSetId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public setFileAttributesConfiguration( + body: FileAttributesConfig, + ruleSetId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public setFileAttributesConfiguration( + body: FileAttributesConfig, + 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/${encodeURIComponent(String(ruleSetId))}`, { + body: body, + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + }); + } +} diff --git a/libs/red-ui-http/src/lib/model/fileAttribute.ts b/libs/red-ui-http/src/lib/model/fileAttribute.ts new file mode 100644 index 000000000..c182c7015 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/fileAttribute.ts @@ -0,0 +1,18 @@ +/** + * 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. + */ + +export interface FileAttribute { + editable?: boolean; + id?: string; + name?: string; + visible?: boolean; +} diff --git a/libs/red-ui-http/src/lib/model/fileAttributes.ts b/libs/red-ui-http/src/lib/model/fileAttributes.ts new file mode 100644 index 000000000..f54f234f4 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/fileAttributes.ts @@ -0,0 +1,15 @@ +/** + * 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. + */ + +export interface FileAttributes { + attributeIdToValue?: any; +} diff --git a/libs/red-ui-http/src/lib/model/fileAttributesConfig.ts b/libs/red-ui-http/src/lib/model/fileAttributesConfig.ts new file mode 100644 index 000000000..2ab9b474e --- /dev/null +++ b/libs/red-ui-http/src/lib/model/fileAttributesConfig.ts @@ -0,0 +1,16 @@ +/** + * 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. + */ +import { FileAttribute } from './fileAttribute'; + +export interface FileAttributesConfig { + fileAttributes?: Array; +} diff --git a/libs/red-ui-http/src/lib/model/importCsvRequest.ts b/libs/red-ui-http/src/lib/model/importCsvRequest.ts new file mode 100644 index 000000000..2e0da5c62 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/importCsvRequest.ts @@ -0,0 +1,18 @@ +/** + * 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. + */ + +export interface ImportCsvRequest { + delimiter?: string; + fileStatusFilenameColumn?: number; + attributeIdToColumnMapping?: { [key: string]: number }; + csvFile?: string; +} diff --git a/libs/red-ui-http/src/lib/model/importCsvResponse.ts b/libs/red-ui-http/src/lib/model/importCsvResponse.ts new file mode 100644 index 000000000..7d671b42a --- /dev/null +++ b/libs/red-ui-http/src/lib/model/importCsvResponse.ts @@ -0,0 +1,15 @@ +/** + * 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. + */ + +export interface ImportCsvResponse { + affectedFileIds?: Array; +} diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index 98a0186d6..a69404006 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -58,3 +58,8 @@ export * from './auditModel'; export * from './auditResponse'; export * from './auditSearchRequest'; export * from './categoryModel'; +export * from './fileAttribute'; +export * from './fileAttributes'; +export * from './fileAttributesConfig'; +export * from './importCsvRequest'; +export * from './importCsvResponse';