FEAT: Create Data Asset

This commit is contained in:
Victor Radael
2022-11-03 17:18:20 -03:00
parent 0103f100f5
commit 4b4bdfea61
6 changed files with 63 additions and 12 deletions
+21
View File
@@ -25,6 +25,7 @@ import { RequestUser, User } from 'src/authentication/user.decorator';
import {
ICatalogAllResponse,
IColumnsMetadataResponse,
ICreateDataAsset,
IDeleteComment,
IDocsResponse,
IMakeAComment,
@@ -432,6 +433,26 @@ export class CatalogController {
return { message: response.message };
}
@Post()
async createDataAsset(
@User() user: RequestUser,
@Body() body: ICreateDataAsset,
) {
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
const { data_asset } = await this.catalogService.createDataAsset(
body,
metadata,
);
return { data_asset: JSON.parse(data_asset) };
}
@Post('data-asset/:id/comment')
async commentOnDataAsset(
@Param('id') id: string,
+13
View File
@@ -58,6 +58,19 @@ class CatalogService implements OnModuleInit {
)}.dadosfera.ai`;
}
async createDataAsset(data: Messages.CreateDataAssetRequest, metadata) {
this.logger.info('CatalogService - Manage Data assets permissions');
return lastValueFrom(
this.catalogWriteService.CreateDataAsset(data, metadata),
).catch((err) => {
throw new HttpException(
err.details,
err.code === 6 ? HttpStatus.CONFLICT : 404,
);
});
}
async managePermissions(data: Messages.ManagePermissionRequest, metadata) {
this.logger.info('CatalogService - Manage Data assets permissions');
+14
View File
@@ -1,4 +1,5 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { CreateDataAssetRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages';
export class IRole {
@ApiProperty()
@@ -128,6 +129,19 @@ export class IUpdateDataRequest {
tags: string[];
}
export class ICreateDataAsset implements CreateDataAssetRequest {
@ApiProperty()
display_name: string;
@ApiProperty()
description: string;
@ApiProperty()
data_asset_type: string;
@ApiProperty()
external_url: string;
@ApiProperty()
location: string;
}
export class IPreview {
@ApiProperty()
id: string;