mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-24 09:59:08 +00:00
FEAT: network config module
This commit is contained in:
Generated
+7
-7
@@ -38,7 +38,7 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"protospack-v2": "3.8.14",
|
||||
"protospack-v2": "^3.9.0-beta.8",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -9018,9 +9018,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/protospack-v2": {
|
||||
"version": "3.8.14",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.8.14.tgz",
|
||||
"integrity": "sha512-wGJ32RR/F62cpXB0EihSvh/rnFCvzsb97vebbOKbVkg9ykUVT6yXUeHYC62eqYB20fOyuReRbUW+tyM5AJL94Q==",
|
||||
"version": "3.9.0-beta.8",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.8.tgz",
|
||||
"integrity": "sha512-C3h62JYRm8Xh5X6mPnKF7ZZA0Ds0qMdu/gFYBu+FEfME5segFgbuiivepkqoVQ3MUoN1gIyV0J5ezmV9kXPPTw==",
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
@@ -17247,9 +17247,9 @@
|
||||
}
|
||||
},
|
||||
"protospack-v2": {
|
||||
"version": "3.8.14",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.8.14.tgz",
|
||||
"integrity": "sha512-wGJ32RR/F62cpXB0EihSvh/rnFCvzsb97vebbOKbVkg9ykUVT6yXUeHYC62eqYB20fOyuReRbUW+tyM5AJL94Q==",
|
||||
"version": "3.9.0-beta.8",
|
||||
"resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/protospack-v2/-/protospack-v2-3.9.0-beta.8.tgz",
|
||||
"integrity": "sha512-C3h62JYRm8Xh5X6mPnKF7ZZA0Ds0qMdu/gFYBu+FEfME5segFgbuiivepkqoVQ3MUoN1gIyV0J5ezmV9kXPPTw==",
|
||||
"requires": {
|
||||
"@grpc/grpc-js": "^1.6.7",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@
|
||||
"passport-hubspot-oauth2": "^1.0.3",
|
||||
"passport-mailchimp": "^1.1.0",
|
||||
"protospack": "2.5.2",
|
||||
"protospack-v2": "3.8.14",
|
||||
"protospack-v2": "^3.9.0-beta.8",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.5.5",
|
||||
|
||||
+3
-2
@@ -44,6 +44,7 @@ import { DadosferaLogger } from 'dadosfera-logs';
|
||||
import { TermsOfUseModule } from './modules/termsOfUse/termsOfUse.module';
|
||||
import { ConnectionModule } from './modules/connection/connection.module';
|
||||
import { ConnectionTestModule } from './modules/connection-test/connection-test.module';
|
||||
import { NetworkConfigModule } from './modules/network-config/network-config.module';
|
||||
|
||||
const inputClient = new InputsClientConfiguration();
|
||||
const outputClient = new OutputsClientConfiguration();
|
||||
@@ -93,6 +94,8 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
PermissionsModule,
|
||||
TermsOfUseModule,
|
||||
ConnectionModule,
|
||||
NetworkConfigModule,
|
||||
ConnectionTestModule,
|
||||
|
||||
ClientsModule.register([
|
||||
{
|
||||
@@ -112,8 +115,6 @@ const transformationClient = new TransformationsClientConfiguration();
|
||||
...pipelineClient.config(),
|
||||
},
|
||||
]),
|
||||
|
||||
ConnectionTestModule,
|
||||
],
|
||||
})
|
||||
export class AppModule {}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import {
|
||||
ApiProperty,
|
||||
ApiPropertyOptional,
|
||||
OmitType,
|
||||
PickType,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
export enum NetworkConfigTypesEnum {
|
||||
vpn = 'vpn',
|
||||
}
|
||||
export enum NetworkConfigPluginsEnum {
|
||||
openvpn = 'openvpn',
|
||||
}
|
||||
export class NetworkConfigDto {
|
||||
@ApiProperty()
|
||||
config_id: string;
|
||||
@ApiProperty()
|
||||
secret_id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
customer_name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
@ApiProperty({ enum: NetworkConfigTypesEnum })
|
||||
type: NetworkConfigTypesEnum;
|
||||
@ApiProperty({ enum: NetworkConfigPluginsEnum })
|
||||
plugin: NetworkConfigPluginsEnum;
|
||||
@ApiProperty()
|
||||
credentials: any;
|
||||
@ApiProperty()
|
||||
created_at: string;
|
||||
@ApiProperty()
|
||||
updated_at: string;
|
||||
}
|
||||
export class NetworkConfigNoSecrets extends OmitType(NetworkConfigDto, [
|
||||
'secret_id',
|
||||
'credentials',
|
||||
]) {}
|
||||
export class NetworkConfigOpenVpnProperties {
|
||||
@ApiProperty({ enum: NetworkConfigPluginsEnum })
|
||||
plugin: NetworkConfigPluginsEnum;
|
||||
@ApiProperty()
|
||||
OVPN_FILE: string;
|
||||
@ApiPropertyOptional()
|
||||
CERTIFICATE_FILE?: string;
|
||||
@ApiPropertyOptional()
|
||||
OVPN_CREDENTIALS?: string;
|
||||
@ApiPropertyOptional()
|
||||
TLS_AUTH_FILE?: string;
|
||||
}
|
||||
export class FindAllNetworkConfigsRes {
|
||||
@ApiProperty({ type: [NetworkConfigNoSecrets] })
|
||||
network_configs: NetworkConfigNoSecrets[];
|
||||
}
|
||||
|
||||
export class FindNetworkConfigByidRes {
|
||||
@ApiProperty()
|
||||
network_config: NetworkConfigNoSecrets;
|
||||
}
|
||||
export class CreateNetworkConfigReq extends PickType(NetworkConfigDto, [
|
||||
'name',
|
||||
'description',
|
||||
'type',
|
||||
]) {
|
||||
@ApiProperty()
|
||||
properties: NetworkConfigOpenVpnProperties;
|
||||
}
|
||||
export class CreateNetworkConfigRes {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
}
|
||||
|
||||
export class UpdateNetworkConfigReq {
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
}
|
||||
export class UpdateNetworkConfigRes {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { NetworkConfigController } from './network-config.controller';
|
||||
|
||||
describe('NetworkConfigController', () => {
|
||||
let controller: NetworkConfigController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [NetworkConfigController],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<NetworkConfigController>(NetworkConfigController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Inject,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
} from '@nestjs/common';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { RequestUser, User } from 'src/authentication/user.decorator';
|
||||
import {
|
||||
CreateNetworkConfigReq,
|
||||
CreateNetworkConfigRes,
|
||||
FindAllNetworkConfigsRes,
|
||||
UpdateNetworkConfigReq,
|
||||
UpdateNetworkConfigRes,
|
||||
} from './dto/network-config';
|
||||
|
||||
@ApiTags('Network Config')
|
||||
@Controller('network-config')
|
||||
export class NetworkConfigController {
|
||||
logger: any;
|
||||
constructor(
|
||||
private networkConfigService: NetworkConfigService,
|
||||
@Inject(DadosferaLogger) dadosferaLogger: DadosferaLogger,
|
||||
) {
|
||||
this.logger = dadosferaLogger.logger;
|
||||
}
|
||||
@Get()
|
||||
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
|
||||
async findAllNetworkConfigs(@User() user: RequestUser) {
|
||||
this.logger.info('GET /network-config', {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
return this.networkConfigService.findAllNetworkConfigs(user.customer_name);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOkResponse({ type: CreateNetworkConfigRes })
|
||||
async createNetworkConfigs(
|
||||
@User() user: RequestUser,
|
||||
@Body() body: CreateNetworkConfigReq,
|
||||
) {
|
||||
this.logger.info('POST /network-config', {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
return this.networkConfigService.createNetworkConfig(
|
||||
body,
|
||||
user.customer_name,
|
||||
);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@ApiOkResponse({ type: UpdateNetworkConfigRes })
|
||||
async updateNetworkConfig(
|
||||
@User() user: RequestUser,
|
||||
@Param('id') network_config_id: string,
|
||||
@Body() body: UpdateNetworkConfigReq,
|
||||
) {
|
||||
this.logger.info('POST /network-config', {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
return this.networkConfigService.updateNetworkConfig(
|
||||
body,
|
||||
network_config_id,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOkResponse({ type: FindAllNetworkConfigsRes })
|
||||
async findNetworkConfigById(
|
||||
@User() user: RequestUser,
|
||||
@Param('id') id: string,
|
||||
) {
|
||||
this.logger.info('GET /network-config', {
|
||||
user: user.user_id,
|
||||
customer: user.customer_name,
|
||||
});
|
||||
return this.networkConfigService.findNetworkConfigById(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { NetworkConfigController } from './network-config.controller';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
|
||||
@Module({
|
||||
controllers: [NetworkConfigController],
|
||||
providers: [NetworkConfigService, DadosferaLogger],
|
||||
})
|
||||
export class NetworkConfigModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { NetworkConfigService } from './network-config.service';
|
||||
|
||||
describe('NetworkConfigService', () => {
|
||||
let service: NetworkConfigService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [NetworkConfigService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<NetworkConfigService>(NetworkConfigService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
CreateNetworkConfigReq,
|
||||
CreateNetworkConfigRes,
|
||||
FindAllNetworkConfigsRes,
|
||||
FindNetworkConfigByidRes,
|
||||
UpdateNetworkConfigReq,
|
||||
UpdateNetworkConfigRes,
|
||||
} from './dto/network-config';
|
||||
|
||||
@Injectable()
|
||||
export class NetworkConfigService {
|
||||
async findAllNetworkConfigs(
|
||||
customer_name: string,
|
||||
): Promise<FindAllNetworkConfigsRes> {
|
||||
return { network_configs: [] };
|
||||
}
|
||||
|
||||
async findNetworkConfigById(id: string): Promise<FindNetworkConfigByidRes> {
|
||||
return { network_config: undefined };
|
||||
}
|
||||
|
||||
async createNetworkConfig(
|
||||
body: CreateNetworkConfigReq,
|
||||
customer_name: string,
|
||||
): Promise<CreateNetworkConfigRes> {
|
||||
const { description, name } = body;
|
||||
return { description, id: '', name };
|
||||
}
|
||||
|
||||
async updateNetworkConfig(
|
||||
body: UpdateNetworkConfigReq,
|
||||
network_config_id: string,
|
||||
): Promise<UpdateNetworkConfigRes> {
|
||||
const { description, name } = body;
|
||||
return { description, id: network_config_id, name };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user