mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-30 11:50:05 +00:00
implementation of rest comunication on gateway
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export class CreateRestPipelineDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateRestPipelineDto } from './create-rest-pipeline.dto';
|
||||
|
||||
export class UpdateRestPipelineDto extends PartialType(CreateRestPipelineDto) {}
|
||||
@@ -0,0 +1 @@
|
||||
export class RestPipeline {}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { RestPipelinesController } from './rest-pipelines.controller';
|
||||
import { RestPipelinesService } from './rest-pipelines.service';
|
||||
|
||||
describe('RestPipelinesController', () => {
|
||||
let controller: RestPipelinesController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [RestPipelinesController],
|
||||
providers: [RestPipelinesService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<RestPipelinesController>(RestPipelinesController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,140 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, Put } from '@nestjs/common';
|
||||
import { RestPipelinesService } from './rest-pipelines.service';
|
||||
import { CreateRestPipelineDto } from './dto/create-rest-pipeline.dto';
|
||||
import { UpdateRestPipelineDto } from './dto/update-rest-pipeline.dto';
|
||||
import { AuthenticateController } from 'src/utils/Authenticate';
|
||||
import axios from 'axios';
|
||||
|
||||
@Controller('pipeline')
|
||||
export class RestPipelinesController {
|
||||
constructor(private readonly restPipelinesService: RestPipelinesService) {}
|
||||
|
||||
@Post()
|
||||
async create(@Body() body: CreateRestPipelineDto) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.post(
|
||||
`${process.env.DEV_URL}/pipeline`,
|
||||
body,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`,
|
||||
"Content-Type":"application/json"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Get()
|
||||
async list() {
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.get(
|
||||
`${process.env.DEV_URL}/pipeline`,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Get(':id/logs/details')
|
||||
async showLogs(@Param('id') id: string) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.get(
|
||||
`${process.env.DEV_URL}/pipeline/${id}/logs/details`,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Get(':id/status')
|
||||
async showStatus(@Param('id') id: string) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.get(
|
||||
`${process.env.DEV_URL}/pipeline/${id}/status`,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
async show(@Param('id') id: string) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.get(
|
||||
`${process.env.DEV_URL}/pipeline/${id}`,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
async update(@Param('id') id: string, @Body() body: UpdateRestPipelineDto) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.put(
|
||||
`${process.env.DEV_URL}/pipeline/${id}`,
|
||||
body,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`,
|
||||
"Content-Type":"application/json"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async remove(@Param('id') id: string) {
|
||||
|
||||
const authController = new AuthenticateController()
|
||||
const accessToken = await authController.authenticate()
|
||||
|
||||
const connectionResponse = await axios.delete(
|
||||
`${process.env.DEV_URL}/pipeline/${id}`,
|
||||
{
|
||||
headers:{
|
||||
"Authorization":`Token ${accessToken}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
return connectionResponse.data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { RestPipelinesService } from './rest-pipelines.service';
|
||||
import { RestPipelinesController } from './rest-pipelines.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [RestPipelinesController],
|
||||
providers: [RestPipelinesService]
|
||||
})
|
||||
export class RestPipelinesModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { RestPipelinesService } from './rest-pipelines.service';
|
||||
|
||||
describe('RestPipelinesService', () => {
|
||||
let service: RestPipelinesService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [RestPipelinesService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<RestPipelinesService>(RestPipelinesService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateRestPipelineDto } from './dto/create-rest-pipeline.dto';
|
||||
import { UpdateRestPipelineDto } from './dto/update-rest-pipeline.dto';
|
||||
|
||||
@Injectable()
|
||||
export class RestPipelinesService {
|
||||
create(createRestPipelineDto: CreateRestPipelineDto) {
|
||||
return 'This action adds a new restPipeline';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all restPipelines`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} restPipeline`;
|
||||
}
|
||||
|
||||
update(id: number, updateRestPipelineDto: UpdateRestPipelineDto) {
|
||||
return `This action updates a #${id} restPipeline`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} restPipeline`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user