-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from vscheuber/main
- Loading branch information
Showing
6 changed files
with
370 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
import util from 'util'; | ||
|
||
import { State } from '../shared/State'; | ||
import { getHostBaseUrl } from '../utils/ForgeRockUtils'; | ||
import { IdObjectSkeletonInterface } from './ApiTypes'; | ||
import { generateIdmApi } from './BaseApi'; | ||
|
||
const apiVersion = 'resource=1.0'; | ||
const apiConfig = { headers: { 'Accept-API-Version': apiVersion } }; | ||
|
||
const reconUrlTemplate = '%s/openidm/recon'; | ||
const reconByIdUrlTemplate = '%s/openidm/recon/%s'; | ||
const startReconUrlTemplate = '%s/openidm/recon?_action=recon&mapping=%s'; | ||
const startReconByIdUrlTemplate = | ||
'%s/openidm/recon?_action=reconById&mapping=%s&id=%s'; | ||
const cancelReconUrlTemplate = '%s/openidm/recon/%s?_action=cancel'; | ||
|
||
export type ReconType = IdObjectSkeletonInterface & { | ||
mapping: string; | ||
state: 'SUCCESS' | string; | ||
stage: 'COMPLETED_SUCCESS' | string; | ||
stageDescription: string; | ||
progress: { | ||
source: { existing: { processed: number; total: string } }; | ||
target: { | ||
existing: { processed: number; total: string }; | ||
created: number; | ||
unchanged: number; | ||
updated: number; | ||
deleted: number; | ||
}; | ||
links: { existing: { processed: number; total: string }; created: number }; | ||
}; | ||
situationSummary: { | ||
SOURCE_IGNORED: number; | ||
TARGET_CHANGED: number; | ||
SOURCE_TARGET_CONFLICT: number; | ||
FOUND_ALREADY_LINKED: number; | ||
UNQUALIFIED: number; | ||
ABSENT: number; | ||
TARGET_IGNORED: number; | ||
MISSING: number; | ||
ALL_GONE: number; | ||
UNASSIGNED: number; | ||
AMBIGUOUS: number; | ||
CONFIRMED: number; | ||
LINK_ONLY: number; | ||
SOURCE_MISSING: number; | ||
FOUND: number; | ||
}; | ||
statusSummary: { SUCCESS: number; FAILURE: number }; | ||
durationSummary: { | ||
sourceQuery: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
auditLog: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
defaultPropertyMapping: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
sourceLinkQuery: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
updateTargetObject: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
propertyMappingScript: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
updateLastSync: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
targetObjectQuery: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
sourcePhase: { | ||
min: number; | ||
max: number; | ||
mean: number; | ||
count: number; | ||
sum: number; | ||
stdDev: number; | ||
}; | ||
}; | ||
parameters: { | ||
sourceIds: [string]; | ||
sourceQuery: { | ||
resourceName: string; | ||
_queryFilter: string; | ||
_fields: string; | ||
}; | ||
targetQuery: { | ||
resourceName: string; | ||
queryFilter: string; | ||
_fields: string; | ||
}; | ||
}; | ||
started: string; | ||
ended: string; | ||
duration: number; | ||
sourceProcessedByNode: object; | ||
}; | ||
|
||
export type ReconStatusType = IdObjectSkeletonInterface & { | ||
state: 'ACTIVE' | string; | ||
action: 'cancel' | string; | ||
status: 'INITIATED' | string; | ||
}; | ||
|
||
export async function getRecons({ | ||
state, | ||
}: { | ||
state: State; | ||
}): Promise<ReconType[]> { | ||
const urlString = util.format( | ||
reconUrlTemplate, | ||
getHostBaseUrl(state.getHost()) | ||
); | ||
const { data } = await generateIdmApi({ | ||
requestOverride: apiConfig, | ||
state, | ||
}).get(urlString); | ||
return data; | ||
} | ||
|
||
export async function getRecon({ | ||
reconId, | ||
state, | ||
}: { | ||
reconId: string; | ||
state: State; | ||
}): Promise<ReconType> { | ||
const urlString = util.format( | ||
reconByIdUrlTemplate, | ||
getHostBaseUrl(state.getHost()), | ||
reconId | ||
); | ||
const { data } = await generateIdmApi({ | ||
requestOverride: apiConfig, | ||
state, | ||
}).get(urlString); | ||
return data; | ||
} | ||
|
||
export async function startRecon({ | ||
mappingName, | ||
state, | ||
}: { | ||
mappingName: string; | ||
state: State; | ||
}): Promise<ReconStatusType> { | ||
const urlString = util.format( | ||
startReconUrlTemplate, | ||
getHostBaseUrl(state.getHost()), | ||
mappingName | ||
); | ||
const { data } = await generateIdmApi({ | ||
requestOverride: apiConfig, | ||
state, | ||
}).post(urlString); | ||
return data; | ||
} | ||
|
||
export async function startReconById({ | ||
mappingName, | ||
objectId, | ||
state, | ||
}: { | ||
mappingName: string; | ||
objectId: string; | ||
state: State; | ||
}): Promise<ReconStatusType> { | ||
const urlString = util.format( | ||
startReconByIdUrlTemplate, | ||
getHostBaseUrl(state.getHost()), | ||
mappingName, | ||
objectId | ||
); | ||
const { data } = await generateIdmApi({ | ||
requestOverride: apiConfig, | ||
state, | ||
}).post(urlString); | ||
return data; | ||
} | ||
|
||
export async function cancelRecon({ | ||
reconId, | ||
state, | ||
}: { | ||
reconId: string; | ||
state: State; | ||
}): Promise<ReconStatusType> { | ||
const urlString = util.format( | ||
cancelReconUrlTemplate, | ||
getHostBaseUrl(state.getHost()), | ||
reconId | ||
); | ||
const { data } = await generateIdmApi({ | ||
requestOverride: apiConfig, | ||
state, | ||
}).post(urlString); | ||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.