2023-04-24 03:18:24 -07:00
|
|
|
import type { ILdapConfig, ILdapSyncData, IRestApiContext } from '@/Interface';
|
2023-05-10 08:10:03 -07:00
|
|
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
2023-04-24 03:18:24 -07:00
|
|
|
import type { IDataObject } from 'n8n-workflow';
|
2023-01-24 17:18:39 -08:00
|
|
|
|
2023-05-10 08:10:03 -07:00
|
|
|
export async function getLdapConfig(context: IRestApiContext): Promise<ILdapConfig> {
|
2023-01-24 17:18:39 -08:00
|
|
|
return makeRestApiRequest(context, 'GET', '/ldap/config');
|
|
|
|
}
|
|
|
|
|
2023-05-10 08:10:03 -07:00
|
|
|
export async function testLdapConnection(context: IRestApiContext): Promise<{}> {
|
2023-01-24 17:18:39 -08:00
|
|
|
return makeRestApiRequest(context, 'POST', '/ldap/test-connection');
|
|
|
|
}
|
|
|
|
|
2023-05-10 08:10:03 -07:00
|
|
|
export async function updateLdapConfig(
|
2023-01-24 17:18:39 -08:00
|
|
|
context: IRestApiContext,
|
|
|
|
adConfig: ILdapConfig,
|
|
|
|
): Promise<ILdapConfig> {
|
|
|
|
return makeRestApiRequest(context, 'PUT', '/ldap/config', adConfig as unknown as IDataObject);
|
|
|
|
}
|
|
|
|
|
2023-05-10 08:10:03 -07:00
|
|
|
export async function runLdapSync(context: IRestApiContext, data: IDataObject): Promise<{}> {
|
2023-01-24 17:18:39 -08:00
|
|
|
return makeRestApiRequest(context, 'POST', '/ldap/sync', data as unknown as IDataObject);
|
|
|
|
}
|
|
|
|
|
2023-05-10 08:10:03 -07:00
|
|
|
export async function getLdapSynchronizations(
|
2023-01-24 17:18:39 -08:00
|
|
|
context: IRestApiContext,
|
|
|
|
pagination: { page: number },
|
|
|
|
): Promise<ILdapSyncData[]> {
|
|
|
|
return makeRestApiRequest(context, 'GET', '/ldap/sync', pagination);
|
|
|
|
}
|