Merge branch 'main' into SOLENG-4628-feat/restrict-asset-options

This commit is contained in:
Gabriel Rosa
2024-07-08 09:39:53 -03:00
8 changed files with 147 additions and 24 deletions
+4 -8
View File
@@ -87,10 +87,6 @@ jobs:
run: | run: |
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
- name: Install Docker Compose
run: |
python3 -m pip install docker-compose --upgrade
- name: Install AWS CLI - name: Install AWS CLI
run: | run: |
python3 -m pip install awscli --upgrade python3 -m pip install awscli --upgrade
@@ -115,8 +111,8 @@ jobs:
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: | run: |
docker-compose -f build.docker-compose.yml build docker compose -f build.docker-compose.yml build
docker-compose -f build.docker-compose.yml push docker compose -f build.docker-compose.yml push
- name: Login to Docker Hub - name: Login to Docker Hub
if: ${{inputs.push_to_dockerhub}} if: ${{inputs.push_to_dockerhub}}
@@ -132,8 +128,8 @@ jobs:
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: | run: |
docker-compose -f build.docker-compose.dockerhub.yml build docker compose -f build.docker-compose.dockerhub.yml build
docker-compose -f build.docker-compose.dockerhub.yml push docker compose -f build.docker-compose.dockerhub.yml push
- name: Create ZIP file to Deploy AWS Beanstalk - name: Create ZIP file to Deploy AWS Beanstalk
env: env:
+7 -1
View File
@@ -9,7 +9,13 @@ jobs:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
id: aws
with:
aws-region: us-east-1
- name: Build - name: Build
env: env:
+40 -1
View File
@@ -515,6 +515,45 @@
] ]
} }
}, },
"/pipelinesV2/monitoring-dashboard": {
"get": {
"operationId": "PipelinesController_getMonitoringDashboard",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
},
"tags": [
"PipelinesV2"
],
"security": [
{
"access-token": []
}
]
}
},
"/pipelinesV2": { "/pipelinesV2": {
"post": { "post": {
"operationId": "PipelinesController_create", "operationId": "PipelinesController_create",
@@ -1889,7 +1928,7 @@
} }
}, },
"info": { "info": {
"title": "Maestro - SOLENG-4628-feat/restrict-asset-options", "title": "Maestro - feat/new-customer-monitoring",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
+23 -1
View File
@@ -5135,6 +5135,28 @@
] ]
} }
}, },
"/customers/monitoring-dashboard": {
"get": {
"operationId": "CustomersController_getCustomerMonitoringDashboard",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/health": { "/health": {
"get": { "get": {
"operationId": "HealthController_check", "operationId": "HealthController_check",
@@ -5151,7 +5173,7 @@
} }
}, },
"info": { "info": {
"title": "Maestro - SOLENG-4628-feat/restrict-asset-options", "title": "Maestro - feat/new-customer-monitoring",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
+19 -11
View File
@@ -67,7 +67,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
PIPELINE: { PIPELINE: {
title: { title: {
'pt-br': 'Coletar | Pipelines', 'pt-br': 'Coletar | Pipelines',
@@ -117,7 +116,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CONNECTION: { CONNECTION: {
title: { title: {
'pt-br': 'Coletar | Fontes de dados', 'pt-br': 'Coletar | Fontes de dados',
@@ -157,7 +155,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
NETWORK_CONFIG: { NETWORK_CONFIG: {
title: { title: {
'pt-br': 'Coletar | Redes', 'pt-br': 'Coletar | Redes',
@@ -187,7 +184,6 @@ export const PERMISSIONS_GROUPS = {
// }, // },
}, },
}, },
OUTPUT: { OUTPUT: {
title: { title: {
'pt-br': 'Output', 'pt-br': 'Output',
@@ -237,7 +233,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
TRANSFORMATIONS: { TRANSFORMATIONS: {
title: { title: {
'pt-br': 'Micro-transformações', 'pt-br': 'Micro-transformações',
@@ -287,7 +282,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CATALOG: { CATALOG: {
title: { title: {
'pt-br': 'Explorar | Catálogo', 'pt-br': 'Explorar | Catálogo',
@@ -368,7 +362,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CONNECTORS: { CONNECTORS: {
title: { title: {
'pt-br': 'Conectores', 'pt-br': 'Conectores',
@@ -418,7 +411,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
SNOWFLAKE: { SNOWFLAKE: {
title: { title: {
'pt-br': 'Explorar | Consolidar', 'pt-br': 'Explorar | Consolidar',
@@ -438,7 +430,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
ZENDESK: { ZENDESK: {
title: { title: {
'pt-br': 'Zendesk', 'pt-br': 'Zendesk',
@@ -458,7 +449,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
DATAVIZ: { DATAVIZ: {
title: { title: {
'pt-br': 'Analisar | Visualização', 'pt-br': 'Analisar | Visualização',
@@ -497,7 +487,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
MODULES: { MODULES: {
title: { title: {
'pt-br': 'Módulos da Dadosfera', 'pt-br': 'Módulos da Dadosfera',
@@ -594,6 +583,25 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CUSTOMER: {
title: {
'pt-br': 'Organização',
'en-us': 'Organization',
'es-es': 'Organización',
},
permissions: {
MONITORING_DASHBOARD: {
seqid: 47,
claim: 'customer:monitoring-dashboard',
usage: PermissionUsages.PUBLIC,
name: {
'pt-br': 'Ver o dashboard de monitoramento',
'en-us': 'View the monitoring dashboard',
'es-es': 'Ver el dashboard de monitoreo',
},
},
},
},
}; };
export interface DadosferaModule { export interface DadosferaModule {
name: string; name: string;
@@ -24,6 +24,7 @@ import { CustomersService } from './customers.service';
import { CustomerLinkRequest, CustomerLinksResponse } from './dtos/customers'; import { CustomerLinkRequest, CustomerLinksResponse } from './dtos/customers';
import { RequestUser, User } from 'src/decorators/user.decorator'; import { RequestUser, User } from 'src/decorators/user.decorator';
import type { StringValue } from 'ms'; import type { StringValue } from 'ms';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
@ApiTags('Customers') @ApiTags('Customers')
@Controller('customers') @Controller('customers')
@@ -76,4 +77,17 @@ export class CustomersController {
}; };
return this.customersService.generateToken(exp, data); return this.customersService.generateToken(exp, data);
} }
@Get('monitoring-dashboard')
@RequireAllPermissions(
PERMISSIONS_GROUPS.CUSTOMER.permissions.MONITORING_DASHBOARD,
)
async getCustomerMonitoringDashboard(
@User() user: RequestUser,
): Promise<{ url: string }> {
this.logger.info('getCustomerMonitoringDashboard');
const metadata = PackTheMetadata(user);
return this.customersService.getMonitoringDashboardUrl(metadata);
}
} }
+9 -2
View File
@@ -4,11 +4,18 @@ import { ClientsModule } from '@nestjs/microservices';
import { DucClient } from '../duc/client.config'; import { DucClient } from '../duc/client.config';
import { CustomersController } from './customers.controller'; import { CustomersController } from './customers.controller';
import { CustomersService } from './customers.service'; import { CustomersService } from './customers.service';
import { PipelinesClientConfiguration } from '../pipelinesV2/pipelines-client';
const client = new DucClient(); const ducClient = new DucClient();
const piFactoryClient = new PipelinesClientConfiguration();
@Module({ @Module({
imports: [ClientsModule.register([client.providerOptions])], imports: [
ClientsModule.register([
ducClient.providerOptions,
piFactoryClient.providerOptions,
]),
],
controllers: [CustomersController], controllers: [CustomersController],
providers: [CustomersService, DadosferaLogger], providers: [CustomersService, DadosferaLogger],
exports: [CustomersService], exports: [CustomersService],
@@ -22,20 +22,34 @@ import {
} from '@aws-sdk/client-secrets-manager'; } from '@aws-sdk/client-secrets-manager';
import getEnv from 'src/utils/getEnv'; import getEnv from 'src/utils/getEnv';
import { logger } from 'elastic-apm-node'; import { logger } from 'elastic-apm-node';
import {
ReadService,
ProtoServices as PipelineProtoServices,
} from '@dadosfera/protospack-v2/dist/lib/PipelineV2';
import { Metadata } from '@grpc/grpc-js';
import { PipelinesClientConfiguration } from '../pipelinesV2/pipelines-client';
// This function will accept any string, which may result in a bug. // This function will accept any string, which may result in a bug.
@Injectable() @Injectable()
export class CustomersService implements OnModuleInit { export class CustomersService implements OnModuleInit {
private customerService: CustomersProtoService; private customerService: CustomersProtoService;
private pipelineReadService: ReadService.PipelineV2ReadService;
constructor( constructor(
@Inject(DucClient.name) private readonly grpcClient: ClientGrpc, @Inject(DucClient.name) private readonly grpcClient: ClientGrpc,
@Inject(PipelinesClientConfiguration.name)
private readonly pipelinesGrpcClient: ClientGrpc,
) {} ) {}
onModuleInit() { onModuleInit() {
this.customerService = this.grpcClient.getService<CustomersProtoService>( this.customerService = this.grpcClient.getService<CustomersProtoService>(
ProtoServices.CustomersProtoService, ProtoServices.CustomersProtoService,
); );
this.pipelineReadService =
this.pipelinesGrpcClient.getService<ReadService.PipelineV2ReadService>(
PipelineProtoServices.PipelineV2ReadService,
);
} }
async getLinks(customerId: string) { async getLinks(customerId: string) {
@@ -120,4 +134,21 @@ export class CustomersService implements OnModuleInit {
// const decoded = jwt.decode(jwt_token, { complete: true }); // const decoded = jwt.decode(jwt_token, { complete: true });
return jwt_token; return jwt_token;
} }
async getMonitoringDashboardUrl(metadata: Metadata) {
logger.info('CustomersService - getMonitoringDashboardUrl');
const res = await lastValueFrom(
this.pipelineReadService.PipelineV2GetDashboardUrl(
{
dashboard_id: '45',
exp: '15m',
metabase_customer_name: 'dadosferatech',
},
metadata,
),
);
logger.info('Done');
return res;
}
} }