-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.ts
More file actions
51 lines (41 loc) · 1.68 KB
/
create.ts
File metadata and controls
51 lines (41 loc) · 1.68 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
46
47
48
49
50
51
/*---------------------------------------------------------------------------------------------
* 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";
export default class CreateRole extends BaseCommand {
static description = 'Create a new role for an iTwin. To assign permissions after creation, use itp access-control role update.';
static examples = [
{
command: `<%= config.bin %> <%= command.id %> --itwin-id ad0ba809-9241-48ad-9eb0-c8038c1a1d51 --name "Project Manager" --description "Manages all aspects of the project"`,
description: 'Example 1:'
}
];
static flags = {
description: Flags.string({
char: 'd',
description: 'A description of your Role.',
required: true,
}),
"itwin-id": Flags.string({
char: 'i',
description: 'The ID of the iTwin to retrieve permissions.',
required: true,
}),
name: Flags.string({
char: 'n',
description: 'The display name of your Role.',
required: true,
}),
};
async run() {
const { flags } = await this.parse(CreateRole);
const client = await this.getAccessControlApiClient();
const response = await client.createiTwinRole(flags["itwin-id"], {
description: flags.description,
displayName: flags.name,
});
return this.logAndReturnResult(response.role);
}
}