oauth almost complete

This commit is contained in:
Gabriel Rosa
2022-06-09 17:14:11 -03:00
parent 28e55f8fd9
commit 0342386a76
6 changed files with 121 additions and 48 deletions
+20
View File
@@ -0,0 +1,20 @@
export class InputModel {
category: string;
plugin: string;
name: string;
cron?: string;
credentials?: {
connection_type: string;
oauth: string;
oauth_code: string;
start_date: string;
};
options?: {
oauth?: {
get_tokens_url: string;
get_tokens_url_params: string;
get_tokens_set_response: Record<string, string>;
content_type: string;
};
};
}
+16 -17
View File
@@ -47,28 +47,27 @@ export class InputsService {
}
async create(@Body() data) {
this.validateCron(data);
try {
if (
data.plugin == 'csv' ||
data.plugin == 'json' ||
data.plugin == 'parquet'
) {
let response;
switch (data.plugin.toLowerCase()) {
case 'csv':
case 'json':
case 'parquet':
const { info, ...input } = data;
const inputPayload = this.generateInputS3Payload(input);
const createInputResponse = await this.inputClient.createS3Inputs({
response = await this.inputClient.createS3Inputs({
input: inputPayload,
info,
});
return createInputResponse;
} else {
const createInputResponse: any = await this.inputClient.create(data);
if (createInputResponse?.input?.input_jdbc) {
return { input: createInputResponse?.input?.input_jdbc };
}
return createInputResponse;
}
} catch (err) {
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
return response;
case 'oracle':
case 'mysql':
case 'postgresql':
case 'sqlserver':
response = await this.inputClient.newCreate(data);
return { input: response?.input?.input_jdbc };
default:
response = await this.inputClient.createGeneric(data);
return response;
}
}