-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.ts
More file actions
45 lines (36 loc) · 1.8 KB
/
add.ts
File metadata and controls
45 lines (36 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { Flags } from "@oclif/core";
import BaseCommand from "../../../../extensions/base-command.js";
import { addMember } from "../../../../services/access-control-client/models/members.js";
export default class AddUserMembers extends BaseCommand {
static description = 'Add one or more user members to an iTwin.';
static examples = [
{
command: `<%= config.bin %> <%= command.id %> --itwin-id "ad0ba809-9241-48ad-9eb0-c8038c1a1d51" --members '[{"email": "[email protected]", "roleIds": ["5abbfcef-0eab-472a-b5f5-5c5a43df34b1", "83ee0d80-dea3-495a-b6c0-7bb102ebbcc3"]}, {"email": "[email protected]", "roleIds": ["5abbfcef-0eab-472a-b5f5-5c5a43df34b1"]}]'`,
description: 'Example 1: Add one or more user members to an iTwin.'
}
];
static flags = {
"itwin-id": Flags.string({
char: 'i',
description: 'The ID of the iTwin to which the users will be added.',
required: true,
}),
members: Flags.string({
description: 'A list of members to add, each with an email and a list of role IDs.',
required: true,
}),
};
async run() {
const { flags } = await this.parse(AddUserMembers);
const client = await this.getAccessControlMemberClient();
const members = JSON.parse(flags.members) as addMember[];
const response = await client.addUserMembers(flags["itwin-id"], {
members,
});
return this.logAndReturnResult(response);
}
}