diff --git a/docsfera.json b/docsfera.json index b3a85b5..e4d97f7 100644 --- a/docsfera.json +++ b/docsfera.json @@ -5924,6 +5924,49 @@ ] } }, + "/catalog/data-asset/{id}/columns-metadata/description": { + "patch": { + "operationId": "CatalogController_updateColumnDescription", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, "/catalog/data-asset/{id}/preview": { "get": { "operationId": "CatalogController_getDataAssetPreview", diff --git a/src/modules/catalog/catalog.controller.ts b/src/modules/catalog/catalog.controller.ts index ef8ab78..1941aa5 100644 --- a/src/modules/catalog/catalog.controller.ts +++ b/src/modules/catalog/catalog.controller.ts @@ -9,6 +9,7 @@ import { Inject, NotFoundException, Param, + Patch, Post, Put, Query, @@ -431,6 +432,42 @@ export class CatalogController { return { columns_metadata }; } + @Patch('data-asset/:id/columns-metadata/description') + @RequireSomePermission( + PERMISSIONS_GROUPS.CATALOG.permissions.UPDATE, + PERMISSIONS_GROUPS.CATALOG.permissions.DATA_MANAGER, + ) + async updateColumnDescription( + @User() user: RequestUser, + @Language() language: LanguageEnum, + @Param('id') id: string, + @Body() body: { column_name: string; description: string }, + ): Promise<{ success: boolean }> { + const { customer_name, customer_id, user_id, username } = user; + + this.logger.info(`/catalog - update column description`, { + user_id, + customer_name, + }); + + const metadata = PackTheMetadata({ + customer_name, + customer_id, + user_id, + username, + language, + }); + + await this.catalogService.updateColumnDescription( + id, + body.column_name, + body.description, + metadata, + ); + + return { success: true }; + } + @Get('data-asset/:id/preview') @RequireSomePermission( PERMISSIONS_GROUPS.CATALOG.permissions.GET, diff --git a/src/modules/catalog/catalog.service.ts b/src/modules/catalog/catalog.service.ts index f0fced8..94ea9c6 100644 --- a/src/modules/catalog/catalog.service.ts +++ b/src/modules/catalog/catalog.service.ts @@ -463,6 +463,25 @@ class CatalogService implements OnModuleInit { return result; } + async updateColumnDescription( + id: string, + column_name: string, + description: string, + metadata: Metadata, + ) { + await lastValueFrom( + this.catalogWriteService.UpdateDataAsset( + { + id, + changes: JSON.stringify({ + column_description: { column_name, description }, + }), + }, + metadata, + ), + ); + } + async createDataDocs(body: CreateDataDocsDTO, metadata: Metadata) { if (body.asset_type === 'table' || body.asset_type === 'view') { return this.createDataDocsViaNimbus(body);