mirror of
https://github.com/LukeHagar/sailpoint-cli.git
synced 2025-12-10 12:47:50 +00:00
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import {
|
|
Context,
|
|
createConnector,
|
|
readConfig,
|
|
Response,
|
|
logger,
|
|
StdAccountListOutput,
|
|
StdAccountReadInput,
|
|
StdAccountReadOutput,
|
|
StdTestConnectionOutput,
|
|
} from '@sailpoint/connector-sdk'
|
|
import { MyClient } from './my-client'
|
|
|
|
// Connector must be exported as module property named connector
|
|
export const connector = async () => {
|
|
|
|
// Get connector source config
|
|
const config = await readConfig()
|
|
|
|
// Use the vendor SDK, or implement own client as necessary, to initialize a client
|
|
const myClient = new MyClient(config)
|
|
|
|
return createConnector()
|
|
.stdTestConnection(async (context: Context, input: undefined, res: Response<StdTestConnectionOutput>) => {
|
|
logger.info("Running test connection")
|
|
res.send(await myClient.testConnection())
|
|
})
|
|
.stdAccountList(async (context: Context, input: undefined, res: Response<StdAccountListOutput>) => {
|
|
const accounts = await myClient.getAllAccounts()
|
|
|
|
for (const account of accounts) {
|
|
res.send({
|
|
identity: account.username,
|
|
uuid: account.id,
|
|
attributes: {
|
|
firstName: account.firstName,
|
|
lastName: account.lastName,
|
|
email: account.email,
|
|
},
|
|
})
|
|
}
|
|
logger.info(`stdAccountList sent ${accounts.length} accounts`)
|
|
})
|
|
.stdAccountRead(async (context: Context, input: StdAccountReadInput, res: Response<StdAccountReadOutput>) => {
|
|
const account = await myClient.getAccount(input.identity)
|
|
|
|
res.send({
|
|
identity: account.username,
|
|
uuid: account.id,
|
|
attributes: {
|
|
firstName: account.firstName,
|
|
lastName: account.lastName,
|
|
email: account.email,
|
|
},
|
|
})
|
|
logger.info(`stdAccountRead read account : ${input.identity}`)
|
|
|
|
})
|
|
}
|