diff --git a/README.md b/README.md index c68238cde..122b062a6 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=http://redaction.redaction-timo-12027.178.63.47.73.xip.io/ +BASE=http://redaction.redaction-timo-latest.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/apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component.html b/apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component.html index 6349d3a84..d61ce8d6e 100644 --- a/apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/admin/rule-sets-listing-screen/rule-sets-listing-screen.component.html @@ -6,7 +6,7 @@ ; + 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 @@ -97,17 +174,17 @@ export class FileAttributesControllerService { /** * Import a csv file to set file attributes * None - * @param body importCsvRequest + * @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 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.'); + 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) { @@ -130,14 +207,28 @@ export class FileAttributesControllerService { } // 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); + 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: body, + body: convertFormParamsToString ? formParams.toString() : formParams, withCredentials: this.configuration.withCredentials, headers: headers, observe: observe, @@ -212,33 +303,33 @@ export class FileAttributesControllerService { } /** - * Set the file attributes that can be used at importing csv. + * Add or update a file attribute that can be used at importing csv. * None - * @param body fileAttributes + * @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: FileAttributesConfig, + body: FileAttributeConfig, ruleSetId: string, observe?: 'body', reportProgress?: boolean - ): Observable; + ): Observable; public setFileAttributesConfiguration( - body: FileAttributesConfig, + body: FileAttributeConfig, ruleSetId: string, observe?: 'response', reportProgress?: boolean - ): Observable>; + ): Observable>; public setFileAttributesConfiguration( - body: FileAttributesConfig, + body: FileAttributeConfig, ruleSetId: string, observe?: 'events', reportProgress?: boolean - ): Observable>; + ): Observable>; public setFileAttributesConfiguration( - body: FileAttributesConfig, + body: FileAttributeConfig, ruleSetId: string, observe: any = 'body', reportProgress: boolean = false @@ -273,12 +364,81 @@ export class FileAttributesControllerService { 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 - }); + 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 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 setFileAttributesConfiguration1(ruleSetId: string, fileAttributeId: string, observe?: 'body', reportProgress?: boolean): Observable; + public setFileAttributesConfiguration1( + ruleSetId: string, + fileAttributeId: string, + observe?: 'response', + reportProgress?: boolean + ): Observable>; + public setFileAttributesConfiguration1( + ruleSetId: string, + fileAttributeId: string, + observe?: 'events', + reportProgress?: boolean + ): Observable>; + public setFileAttributesConfiguration1( + 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 (ruleSetId === null || ruleSetId === 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(ruleSetId))}`, + { + withCredentials: this.configuration.withCredentials, + headers: headers, + observe: observe, + reportProgress: reportProgress + } + ); } } diff --git a/libs/red-ui-http/src/lib/model/fileAttributeConfig.ts b/libs/red-ui-http/src/lib/model/fileAttributeConfig.ts new file mode 100644 index 000000000..27d4039c6 --- /dev/null +++ b/libs/red-ui-http/src/lib/model/fileAttributeConfig.ts @@ -0,0 +1,19 @@ +/** + * 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 FileAttributeConfig { + csvColumnHeader?: string; + editable?: boolean; + id?: string; + label?: string; + visible?: boolean; +} diff --git a/libs/red-ui-http/src/lib/model/fileAttributesBaseConfigRequest.ts b/libs/red-ui-http/src/lib/model/fileAttributesBaseConfigRequest.ts new file mode 100644 index 000000000..b29f212cd --- /dev/null +++ b/libs/red-ui-http/src/lib/model/fileAttributesBaseConfigRequest.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. + */ + +export interface FileAttributesBaseConfigRequest { + delimiter?: string; + filenameMappingColumnHeaderName?: string; +} diff --git a/libs/red-ui-http/src/lib/model/models.ts b/libs/red-ui-http/src/lib/model/models.ts index a69404006..18d94c6cb 100644 --- a/libs/red-ui-http/src/lib/model/models.ts +++ b/libs/red-ui-http/src/lib/model/models.ts @@ -63,3 +63,5 @@ export * from './fileAttributes'; export * from './fileAttributesConfig'; export * from './importCsvRequest'; export * from './importCsvResponse'; +export * from './fileAttributeConfig'; +export * from './fileAttributesBaseConfigRequest';