Merge pull request #9379 from backjo/feature/AddExpandParamToMsGraphQuery

feat: add optional userExpand parameter for ms graph
This commit is contained in:
Ben Lambert
2022-02-07 19:27:23 +01:00
committed by GitHub
5 changed files with 18 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend-module-msgraph': patch
---
Add userExpand option to allow users to expand fields retrieved from the Graph API - for use in custom transformers
@@ -149,6 +149,7 @@ export type MicrosoftGraphProviderConfig = {
clientId: string;
clientSecret: string;
userFilter?: string;
userExpand?: string[];
userGroupMemberFilter?: string;
groupFilter?: string;
};
@@ -178,6 +179,7 @@ export function readMicrosoftGraphOrg(
client: MicrosoftGraphClient,
tenantId: string,
options: {
userExpand?: string[];
userFilter?: string;
userGroupMemberFilter?: string;
groupFilter?: string;
@@ -52,6 +52,12 @@ export type MicrosoftGraphProviderConfig = {
* E.g. "accountEnabled eq true and userType eq 'member'"
*/
userFilter?: string;
/**
* The expand argument to apply to users.
*
* E.g. "manager"
*/
userExpand?: string[];
/**
* The filter to apply to extract users by groups memberships.
*
@@ -85,6 +85,7 @@ export async function readMicrosoftGraphUsers(
client: MicrosoftGraphClient,
options: {
userFilter?: string;
userExpand?: string[];
transformer?: UserTransformer;
logger: Logger;
},
@@ -99,6 +100,7 @@ export async function readMicrosoftGraphUsers(
for await (const user of client.getUsers({
filter: options.userFilter,
expand: options.userExpand,
})) {
// Process all users in parallel, otherwise it can take quite some time
promises.push(
@@ -500,6 +502,7 @@ export async function readMicrosoftGraphOrg(
client: MicrosoftGraphClient,
tenantId: string,
options: {
userExpand?: string[];
userFilter?: string;
userGroupMemberFilter?: string;
groupFilter?: string;
@@ -524,6 +527,7 @@ export async function readMicrosoftGraphOrg(
} else {
const { users: usersWithFilter } = await readMicrosoftGraphUsers(client, {
userFilter: options.userFilter,
userExpand: options.userExpand,
transformer: options.userTransformer,
logger: options.logger,
});
@@ -102,6 +102,7 @@ export class MicrosoftGraphOrgReaderProcessor implements CatalogProcessor {
client,
provider.tenantId,
{
userExpand: provider.userExpand,
userFilter: provider.userFilter,
userGroupMemberFilter: provider.userGroupMemberFilter,
groupFilter: provider.groupFilter,