Skip to content

Commit

Permalink
Merge pull request #33 from mcnielsen/master
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
mcnielsen authored Mar 17, 2020
2 parents 8d92c44 + 506b912 commit a9b0909
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@al/aims",
"version": "1.1.6",
"version": "1.2.0",
"license": "MIT",
"description": "A client for interacting with the Alert Logic AIMS Public API",
"author": {
Expand Down
23 changes: 23 additions & 0 deletions src/aims-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,29 @@ export class AIMSClientInstance {
return managedAccounts.accounts as AIMSAccount[];
}

/**
* Retrieve a union of user records corresponding to a managed relationship hierarchy between two accounts.
* This is a placeholder for a better implementation based on a relationship topology endpoint from AIMS.0
*/
async getUsersFromManagedRelationship( leafAccountId:string, terminalAccountId?:string, failOnError:boolean = true ):Promise<AIMSUser[]> {
let users = await this.getUsers( leafAccountId, { include_role_ids: false, include_user_credential: false } );
try {
let managing = await this.getAccountsByRelationship( leafAccountId, "managing" );
if ( managing.length > 0 ) {
managing.sort( ( a, b ) => parseInt( b.id, 10 ) - parseInt( a.id, 10 ) ); // this is gross hackery. Kevin did not implement this. Tell no-one of what you've seen!
let parentUsers = await this.getUsersFromManagedRelationship( managing[0].id, terminalAccountId );
if ( Array.isArray( parentUsers ) ) {
users = users.concat( parentUsers );
}
}
} catch( e ) {
if ( failOnError ) {
throw e;
}
}
return users;
}

/**
* Update account MFA requirements
* POST
Expand Down

0 comments on commit a9b0909

Please sign in to comment.