mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 14:27:30 +00:00
add simple api to trigger integration sync
This commit is contained in:
@@ -8,6 +8,7 @@ import { getFolderByPath } from "../../services/FolderService";
|
|||||||
import { BadRequestError } from "../../utils/errors";
|
import { BadRequestError } from "../../utils/errors";
|
||||||
import { EEAuditLogService } from "../../ee/services";
|
import { EEAuditLogService } from "../../ee/services";
|
||||||
import { EventType } from "../../ee/models";
|
import { EventType } from "../../ee/models";
|
||||||
|
import { syncSecretsToActiveIntegrationsQueue } from "../../queues/integrations/syncSecretsToThirdPartyServices";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create/initialize an (empty) integration for integration authorization
|
* Create/initialize an (empty) integration for integration authorization
|
||||||
@@ -76,7 +77,7 @@ export const createIntegration = async (req: Request, res: Response) => {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await EEAuditLogService.createAuditLog(
|
await EEAuditLogService.createAuditLog(
|
||||||
req.authData,
|
req.authData,
|
||||||
{
|
{
|
||||||
@@ -218,3 +219,15 @@ export const deleteIntegration = async (req: Request, res: Response) => {
|
|||||||
integration
|
integration
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Will trigger sync for all integrations within the given env and workspace id
|
||||||
|
export const manualSync = async (req: Request, res: Response) => {
|
||||||
|
const { workspaceId, environment } = req.body;
|
||||||
|
syncSecretsToActiveIntegrationsQueue({
|
||||||
|
workspaceId,
|
||||||
|
environment
|
||||||
|
})
|
||||||
|
|
||||||
|
res.status(200).send()
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
requireAuth,
|
requireAuth,
|
||||||
requireIntegrationAuth,
|
requireIntegrationAuth,
|
||||||
requireIntegrationAuthorizationAuth,
|
requireIntegrationAuthorizationAuth,
|
||||||
|
requireWorkspaceAuth,
|
||||||
validateRequest,
|
validateRequest,
|
||||||
} from "../../middleware";
|
} from "../../middleware";
|
||||||
import {
|
import {
|
||||||
@@ -73,4 +74,19 @@ router.delete(
|
|||||||
integrationController.deleteIntegration
|
integrationController.deleteIntegration
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/manual-sync",
|
||||||
|
requireAuth({
|
||||||
|
acceptedAuthModes: [AuthMode.JWT]
|
||||||
|
}),
|
||||||
|
requireWorkspaceAuth({
|
||||||
|
acceptedRoles: [ADMIN, MEMBER],
|
||||||
|
locationWorkspaceId: "body",
|
||||||
|
}),
|
||||||
|
body("environment").isString().exists().trim(),
|
||||||
|
body("workspaceId").exists().trim(),
|
||||||
|
validateRequest,
|
||||||
|
integrationController.manualSync
|
||||||
|
);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
Reference in New Issue
Block a user