feat: add forced WAP server deletion support to clean up associated organizations and runtime bots
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import axios from "axios";
|
||||
import { Request, Response } from "express";
|
||||
import { WapService } from "../services/wap.service";
|
||||
import { CreateWapServerParams, PaginateWapServerParams, UpdateWapServerParams, WapServerByIdParams, WapServerOrganizationActionParams } from "src/models/WapServers.Model";
|
||||
import { CreateWapServerParams, PaginateWapServerParams, UpdateWapServerParams, WapServerByIdParams, WapServerDeleteParams, WapServerOrganizationActionParams } from "src/models/WapServers.Model";
|
||||
|
||||
const wapService = new WapService();
|
||||
|
||||
@@ -83,7 +83,7 @@ export class WapController {
|
||||
|
||||
public deleteServer = async (req: Request, res: Response): Promise<void> => {
|
||||
try {
|
||||
const data: WapServerByIdParams = req.body as WapServerByIdParams;
|
||||
const data: WapServerDeleteParams = req.body as WapServerDeleteParams;
|
||||
const result = await wapService.deleteWapServer(data);
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
|
||||
@@ -62,9 +62,19 @@ export type WapServerByIdParams = {
|
||||
serverId: string;
|
||||
};
|
||||
|
||||
export type WapServerDeleteParams = WapServerByIdParams & {
|
||||
force?: boolean;
|
||||
};
|
||||
|
||||
export type WapServerDeleteResult = {
|
||||
serverId: string;
|
||||
deleted: true;
|
||||
force?: boolean;
|
||||
detachedOrganizations?: number;
|
||||
deletedRuntimeBots?: number;
|
||||
skippedRuntimeBots?: number;
|
||||
auditFailed?: boolean;
|
||||
auditMessage?: string;
|
||||
};
|
||||
|
||||
export type WapServerOrganizationActionParams = WapServerByIdParams & {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
PaginateWapServerResults,
|
||||
WapServerAuditResult,
|
||||
WapServerByIdParams,
|
||||
WapServerDeleteParams,
|
||||
WapServerDeleteResult,
|
||||
WapServerDetachResult,
|
||||
WapServerOrganizationActionParams,
|
||||
@@ -82,7 +83,7 @@ export class WapService {
|
||||
return response.data as WapServerRecalculateCountResult;
|
||||
}
|
||||
|
||||
public async deleteWapServer(data: WapServerByIdParams): Promise<WapServerDeleteResult> {
|
||||
public async deleteWapServer(data: WapServerDeleteParams): Promise<WapServerDeleteResult> {
|
||||
const nonce = await getSysAdminNonce();
|
||||
const postData = { ...data, ...{ payload: getPayload(nonce) } };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user