mirror of
https://github.com/dadosfera/maestro.git
synced 2026-12-02 03:00:06 +00:00
Update Protospack Name and Network Config
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
import { Metadata } from '@grpc/grpc-js';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { ClientGrpc } from '@nestjs/microservices';
|
||||
import { NetworkConfig } from 'protospack-v2';
|
||||
import { NetworkConfig } from '@dadosfera/protospack-v2';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import {
|
||||
CreateNetworkConfigReq,
|
||||
CreateNetworkConfigRes,
|
||||
DeleteNetworkConfigRes,
|
||||
FindAllNetworkConfigsRes,
|
||||
FindNetworkConfigByidDetailsRes,
|
||||
FindNetworkConfigByidRes,
|
||||
UpdateNetworkConfigReq,
|
||||
UpdateNetworkConfigRes,
|
||||
@@ -28,13 +30,25 @@ export class NetworkConfigService {
|
||||
NetworkConfig.ProtoServices.NetworkConfigWriteService,
|
||||
);
|
||||
}
|
||||
async findAllNetworkConfigs(
|
||||
customer_name: string,
|
||||
): Promise<FindAllNetworkConfigsRes> {
|
||||
async findAllNetworkConfigs({
|
||||
body,
|
||||
info,
|
||||
}): Promise<FindAllNetworkConfigsRes> {
|
||||
const { search, page, size, filters } = body;
|
||||
const { language, customer_id, customer_name, user_id } = info;
|
||||
|
||||
const meta = new Metadata();
|
||||
|
||||
meta.add('language', language);
|
||||
meta.add('customer_id', customer_id);
|
||||
meta.add('customer_name', customer_name);
|
||||
meta.add('user_id', user_id);
|
||||
|
||||
return lastValueFrom(
|
||||
this.networkConfigReadClient.NetworkConfigFindByCustomer({
|
||||
customer_name,
|
||||
}),
|
||||
this.networkConfigReadClient.NetworkConfigFindAll(
|
||||
{ search, filters: JSON.stringify(filters), page, size },
|
||||
meta,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -47,19 +61,51 @@ export class NetworkConfigService {
|
||||
return { network_config };
|
||||
}
|
||||
|
||||
async findNetworkConfigByIdDetails(
|
||||
id: string,
|
||||
info?,
|
||||
): Promise<FindNetworkConfigByidDetailsRes> {
|
||||
const { customer_name, customer_id, language } = info;
|
||||
|
||||
const meta = new Metadata();
|
||||
|
||||
meta.add('customer_name', customer_name);
|
||||
meta.add('customer_id', customer_id);
|
||||
meta.add('language', language);
|
||||
|
||||
const { network_config } = await lastValueFrom(
|
||||
this.networkConfigReadClient.NetworkConfigFindOneDetailsById(
|
||||
{ id },
|
||||
meta,
|
||||
),
|
||||
);
|
||||
|
||||
Object.assign(network_config, {
|
||||
properties: JSON.parse(network_config.properties),
|
||||
});
|
||||
return { network_config };
|
||||
}
|
||||
|
||||
async createNetworkConfig(
|
||||
body: CreateNetworkConfigReq,
|
||||
customer_name: string,
|
||||
{ customer_name, customer_id },
|
||||
): Promise<CreateNetworkConfigRes> {
|
||||
const { description, name, properties, type } = body;
|
||||
const { description, name, properties, type, network_type_id } = body;
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', customer_id);
|
||||
meta.add('customer_name', customer_name);
|
||||
const { network_config } = await lastValueFrom(
|
||||
this.networkConfigWriteClient.NetworkConfigCreate({
|
||||
customer_name,
|
||||
description,
|
||||
name,
|
||||
properties: JSON.stringify(properties),
|
||||
type,
|
||||
}),
|
||||
this.networkConfigWriteClient.NetworkConfigCreate(
|
||||
{
|
||||
customer_name,
|
||||
description,
|
||||
name,
|
||||
properties: JSON.stringify(properties),
|
||||
type,
|
||||
network_type_id,
|
||||
},
|
||||
meta,
|
||||
),
|
||||
);
|
||||
return { network_config };
|
||||
}
|
||||
@@ -81,11 +127,16 @@ export class NetworkConfigService {
|
||||
|
||||
async deleteNetworkConfig(
|
||||
network_config_id: string,
|
||||
{ customer_name, customer_id },
|
||||
): Promise<DeleteNetworkConfigRes> {
|
||||
const meta = new Metadata();
|
||||
meta.add('customer_id', customer_id);
|
||||
meta.add('customer_name', customer_name);
|
||||
return lastValueFrom(
|
||||
this.networkConfigWriteClient.NetworkConfigDelete({
|
||||
id: network_config_id,
|
||||
}),
|
||||
this.networkConfigWriteClient.NetworkConfigDelete(
|
||||
{ id: network_config_id },
|
||||
meta,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user