Checkly group level sync support

This commit is contained in:
Andrew Atimapre
2023-10-30 18:23:23 +01:00
parent c0592ad904
commit f3c76c79ee
9 changed files with 216 additions and 7 deletions
@@ -1,7 +1,7 @@
import { Request, Response } from "express";
import { Types } from "mongoose";
import { standardRequest } from "../../config/request";
import { getApps, getTeams, revokeAccess } from "../../integrations";
import { getApps, getTeams, getGroups, revokeAccess } from "../../integrations";
import { Bot, IntegrationAuth, Workspace } from "../../models";
import { EventType } from "../../ee/models";
import { IntegrationService } from "../../services";
@@ -208,6 +208,40 @@ export const saveIntegrationToken = async (req: Request, res: Response) => {
});
};
/**
* Return list of groups allowed for integration with integration authorization id [integrationAuthId]
* @param req
* @param res
* @returns
*/
export const getIntegrationAuthGroups = async (req: Request, res: Response) => {
const {
params: { integrationAuthId }
} = await validateRequest(reqValidator.GetIntegrationAuthGroupsV1, req);
const { integrationAuth, accessToken } = await getIntegrationAuthAccessHelper({
integrationAuthId: new ObjectId(integrationAuthId)
});
const { permission } = await getUserProjectPermissions(
req.user._id,
integrationAuth.workspace.toString()
);
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Read,
ProjectPermissionSub.Integrations
);
const groups = await getGroups({
integrationAuth: integrationAuth,
accessToken: accessToken
});
return res.status(200).send({
groups
});
};
/**
* Return list of applications allowed for integration with integration authorization id [integrationAuthId]
* @param req