317 lines
11 KiB
TypeScript
317 lines
11 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 { Rules } from '../model/rules';
|
|
|
|
import { BASE_PATH } from '../variables';
|
|
import { Configuration } from '../configuration';
|
|
|
|
@Injectable()
|
|
export class RulesControllerService {
|
|
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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns object containing the currently used Drools rules.
|
|
*
|
|
* @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 downloadRules(observe?: 'body', reportProgress?: boolean): Observable<Rules>;
|
|
|
|
public downloadRules(
|
|
observe?: 'response',
|
|
reportProgress?: boolean
|
|
): Observable<HttpResponse<Rules>>;
|
|
|
|
public downloadRules(
|
|
observe?: 'events',
|
|
reportProgress?: boolean
|
|
): Observable<HttpEvent<Rules>>;
|
|
|
|
public downloadRules(observe: any = 'body', reportProgress: boolean = false): Observable<any> {
|
|
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<Rules>('get', `${this.basePath}/rules`, {
|
|
withCredentials: this.configuration.withCredentials,
|
|
headers: headers,
|
|
observe: observe,
|
|
reportProgress: reportProgress
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Returns file containing the currently used Drools rules.
|
|
*
|
|
* @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 downloadRulesFile(observe?: 'body', reportProgress?: boolean): Observable<any>;
|
|
|
|
public downloadRulesFile(
|
|
observe?: 'response',
|
|
reportProgress?: boolean
|
|
): Observable<HttpResponse<any>>;
|
|
|
|
public downloadRulesFile(
|
|
observe?: 'events',
|
|
reportProgress?: boolean
|
|
): Observable<HttpEvent<any>>;
|
|
|
|
public downloadRulesFile(
|
|
observe: any = 'body',
|
|
reportProgress: boolean = false
|
|
): Observable<any> {
|
|
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<any>('get', `${this.basePath}/rules/download`, {
|
|
withCredentials: this.configuration.withCredentials,
|
|
headers: headers,
|
|
observe: observe,
|
|
reportProgress: reportProgress
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Takes object containing string or rules as argument, which will be used by the redaction service.
|
|
*
|
|
* @param body rules
|
|
* @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 uploadRules(body: Rules, observe?: 'body', reportProgress?: boolean): Observable<any>;
|
|
|
|
public uploadRules(
|
|
body: Rules,
|
|
observe?: 'response',
|
|
reportProgress?: boolean
|
|
): Observable<HttpResponse<any>>;
|
|
|
|
public uploadRules(
|
|
body: Rules,
|
|
observe?: 'events',
|
|
reportProgress?: boolean
|
|
): Observable<HttpEvent<any>>;
|
|
|
|
public uploadRules(
|
|
body: Rules,
|
|
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 uploadRules.'
|
|
);
|
|
}
|
|
|
|
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}/rules`, {
|
|
body: body,
|
|
withCredentials: this.configuration.withCredentials,
|
|
headers: headers,
|
|
observe: observe,
|
|
reportProgress: reportProgress
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Takes object containing string or rules as argument, which will be used by the redaction service.
|
|
*
|
|
* @param file
|
|
* @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 uploadRulesFileForm(
|
|
file: Blob,
|
|
observe?: 'body',
|
|
reportProgress?: boolean
|
|
): Observable<any>;
|
|
|
|
public uploadRulesFileForm(
|
|
file: Blob,
|
|
observe?: 'response',
|
|
reportProgress?: boolean
|
|
): Observable<HttpResponse<any>>;
|
|
|
|
public uploadRulesFileForm(
|
|
file: Blob,
|
|
observe?: 'events',
|
|
reportProgress?: boolean
|
|
): Observable<HttpEvent<any>>;
|
|
|
|
public uploadRulesFileForm(
|
|
file: Blob,
|
|
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 uploadRulesFile.'
|
|
);
|
|
}
|
|
|
|
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[] = ['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<any>('post', `${this.basePath}/rules/upload`, {
|
|
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;
|
|
}
|
|
}
|