@lightdash-tools/cli 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -1
- package/dist/commands/ai-agents.js +8 -6
- package/dist/commands/charts.js +8 -6
- package/dist/commands/content.d.ts +8 -0
- package/dist/commands/content.js +48 -0
- package/dist/commands/dashboards.js +4 -2
- package/dist/commands/explores.js +34 -4
- package/dist/commands/groups.js +6 -4
- package/dist/commands/metrics.d.ts +8 -0
- package/dist/commands/metrics.js +59 -0
- package/dist/commands/organization-roles.js +10 -8
- package/dist/commands/organization.js +4 -2
- package/dist/commands/project-access.js +8 -6
- package/dist/commands/project-role-assignments.js +12 -10
- package/dist/commands/projects.js +38 -4
- package/dist/commands/query.js +4 -2
- package/dist/commands/schedulers.d.ts +8 -0
- package/dist/commands/schedulers.js +59 -0
- package/dist/commands/spaces.js +6 -4
- package/dist/commands/tags.d.ts +8 -0
- package/dist/commands/tags.js +52 -0
- package/dist/commands/users.js +6 -4
- package/dist/index.js +13 -1
- package/dist/utils/safety.d.ts +11 -0
- package/dist/utils/safety.js +39 -0
- package/dist/utils/safety.test.d.ts +1 -0
- package/dist/utils/safety.test.js +50 -0
- package/package.json +3 -3
- package/src/commands/ai-agents.ts +53 -45
- package/src/commands/charts.ts +59 -47
- package/src/commands/content.ts +55 -0
- package/src/commands/dashboards.ts +17 -13
- package/src/commands/explores.ts +77 -26
- package/src/commands/groups.ts +59 -53
- package/src/commands/metrics.ts +69 -0
- package/src/commands/organization-roles.ts +78 -68
- package/src/commands/organization.ts +17 -13
- package/src/commands/project-access.ts +50 -39
- package/src/commands/project-role-assignments.ts +87 -75
- package/src/commands/projects.ts +77 -28
- package/src/commands/query.ts +30 -23
- package/src/commands/schedulers.ts +66 -0
- package/src/commands/spaces.ts +32 -26
- package/src/commands/tags.ts +53 -0
- package/src/commands/users.ts +51 -45
- package/src/index.ts +17 -1
- package/src/utils/safety.test.ts +53 -0
- package/src/utils/safety.ts +33 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metrics command implementation.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
7
|
+
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Registers the metrics command and its subcommands.
|
|
12
|
+
*/
|
|
13
|
+
export function registerMetricsCommand(program: Command): void {
|
|
14
|
+
const metricsCmd = program.command('metrics').description('Manage metrics');
|
|
15
|
+
|
|
16
|
+
metricsCmd
|
|
17
|
+
.command('list <projectUuid>')
|
|
18
|
+
.description('List metrics in a project')
|
|
19
|
+
.option('--search <query>', 'Search query')
|
|
20
|
+
.option('--page <number>', 'Page number', (v) => parseInt(v, 10))
|
|
21
|
+
.option('--page-size <number>', 'Page size', (v) => parseInt(v, 10))
|
|
22
|
+
.action(
|
|
23
|
+
wrapAction(
|
|
24
|
+
READ_ONLY_DEFAULT,
|
|
25
|
+
async (
|
|
26
|
+
projectUuid: string,
|
|
27
|
+
options: { search?: string; page?: number; pageSize?: number },
|
|
28
|
+
) => {
|
|
29
|
+
try {
|
|
30
|
+
const client = getClient();
|
|
31
|
+
const result = await client.v1.metrics.listMetrics(projectUuid, {
|
|
32
|
+
search: options.search,
|
|
33
|
+
page: options.page,
|
|
34
|
+
pageSize: options.pageSize,
|
|
35
|
+
});
|
|
36
|
+
console.log(JSON.stringify(result, null, 2));
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(
|
|
39
|
+
'Error listing metrics:',
|
|
40
|
+
error instanceof Error ? error.message : String(error),
|
|
41
|
+
);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
metricsCmd
|
|
49
|
+
.command('get <projectUuid> <tableName> <metricName>')
|
|
50
|
+
.description('Get a metric by table and name')
|
|
51
|
+
.action(
|
|
52
|
+
wrapAction(
|
|
53
|
+
READ_ONLY_DEFAULT,
|
|
54
|
+
async (projectUuid: string, tableName: string, metricName: string) => {
|
|
55
|
+
try {
|
|
56
|
+
const client = getClient();
|
|
57
|
+
const result = await client.v1.metrics.getMetric(projectUuid, tableName, metricName);
|
|
58
|
+
console.log(JSON.stringify(result, null, 2));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(
|
|
61
|
+
'Error fetching metric:',
|
|
62
|
+
error instanceof Error ? error.message : String(error),
|
|
63
|
+
);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the organization roles subcommands under the existing organization command.
|
|
@@ -22,45 +24,49 @@ export function registerOrganizationRolesCommand(program: Command): void {
|
|
|
22
24
|
.description('List organization roles')
|
|
23
25
|
.option('--load <value>', 'Load query param')
|
|
24
26
|
.option('--role-type-filter <value>', 'Filter by role type')
|
|
25
|
-
.action(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
.action(
|
|
28
|
+
wrapAction(READ_ONLY_DEFAULT, async function (this: Command) {
|
|
29
|
+
const options = this.opts() as { load?: string; roleTypeFilter?: string };
|
|
30
|
+
try {
|
|
31
|
+
const client = getClient();
|
|
32
|
+
const org = await client.v1.organizations.getCurrentOrganization();
|
|
33
|
+
const orgUuid = (org as { organizationUuid: string }).organizationUuid;
|
|
34
|
+
const params =
|
|
35
|
+
options.load != null || options.roleTypeFilter != null
|
|
36
|
+
? { load: options.load, roleTypeFilter: options.roleTypeFilter }
|
|
37
|
+
: undefined;
|
|
38
|
+
const result = await client.v2.organizationRoles.getRoles(orgUuid, params);
|
|
39
|
+
console.log(JSON.stringify(result, null, 2));
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(
|
|
42
|
+
'Error listing organization roles:',
|
|
43
|
+
error instanceof Error ? error.message : String(error),
|
|
44
|
+
);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
45
49
|
|
|
46
50
|
rolesCmd
|
|
47
51
|
.command('get <roleUuid>')
|
|
48
52
|
.description('Get an organization role by UUID')
|
|
49
|
-
.action(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
.action(
|
|
54
|
+
wrapAction(READ_ONLY_DEFAULT, async (roleUuid: string) => {
|
|
55
|
+
try {
|
|
56
|
+
const client = getClient();
|
|
57
|
+
const org = await client.v1.organizations.getCurrentOrganization();
|
|
58
|
+
const orgUuid = (org as { organizationUuid: string }).organizationUuid;
|
|
59
|
+
const role = await client.v2.organizationRoles.getRole(orgUuid, roleUuid);
|
|
60
|
+
console.log(JSON.stringify(role, null, 2));
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error(
|
|
63
|
+
'Error fetching organization role:',
|
|
64
|
+
error instanceof Error ? error.message : String(error),
|
|
65
|
+
);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
64
70
|
|
|
65
71
|
const assignmentsCmd = rolesCmd
|
|
66
72
|
.command('assignments')
|
|
@@ -68,42 +74,46 @@ export function registerOrganizationRolesCommand(program: Command): void {
|
|
|
68
74
|
assignmentsCmd
|
|
69
75
|
.command('list')
|
|
70
76
|
.description('List organization role assignments')
|
|
71
|
-
.action(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
.action(
|
|
78
|
+
wrapAction(READ_ONLY_DEFAULT, async () => {
|
|
79
|
+
try {
|
|
80
|
+
const client = getClient();
|
|
81
|
+
const org = await client.v1.organizations.getCurrentOrganization();
|
|
82
|
+
const orgUuid = (org as { organizationUuid: string }).organizationUuid;
|
|
83
|
+
const result = await client.v2.organizationRoles.listRoleAssignments(orgUuid);
|
|
84
|
+
console.log(JSON.stringify(result, null, 2));
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error(
|
|
87
|
+
'Error listing role assignments:',
|
|
88
|
+
error instanceof Error ? error.message : String(error),
|
|
89
|
+
);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
);
|
|
86
94
|
|
|
87
95
|
rolesCmd
|
|
88
96
|
.command('assign <userUuid>')
|
|
89
97
|
.description('Assign an organization role to a user')
|
|
90
98
|
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
91
|
-
.action(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
.action(
|
|
100
|
+
wrapAction(WRITE_IDEMPOTENT, async (userUuid: string, cmd: Command) => {
|
|
101
|
+
const options = cmd.opts() as { roleId: string };
|
|
102
|
+
try {
|
|
103
|
+
const client = getClient();
|
|
104
|
+
const org = await client.v1.organizations.getCurrentOrganization();
|
|
105
|
+
const orgUuid = (org as { organizationUuid: string }).organizationUuid;
|
|
106
|
+
const result = await client.v2.organizationRoles.assignRoleToUser(orgUuid, userUuid, {
|
|
107
|
+
roleId: options.roleId,
|
|
108
|
+
});
|
|
109
|
+
console.log(JSON.stringify(result, null, 2));
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(
|
|
112
|
+
'Error assigning role to user:',
|
|
113
|
+
error instanceof Error ? error.message : String(error),
|
|
114
|
+
);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
}),
|
|
118
|
+
);
|
|
109
119
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the organization command and its subcommands.
|
|
@@ -14,17 +16,19 @@ export function registerOrganizationCommand(program: Command): void {
|
|
|
14
16
|
orgCmd
|
|
15
17
|
.command('get')
|
|
16
18
|
.description('Get current organization')
|
|
17
|
-
.action(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
.action(
|
|
20
|
+
wrapAction(READ_ONLY_DEFAULT, async () => {
|
|
21
|
+
try {
|
|
22
|
+
const client = getClient();
|
|
23
|
+
const org = await client.v1.organizations.getCurrentOrganization();
|
|
24
|
+
console.log(JSON.stringify(org, null, 2));
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(
|
|
27
|
+
'Error fetching organization:',
|
|
28
|
+
error instanceof Error ? error.message : String(error),
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
30
34
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the projects access subcommands under the existing projects command.
|
|
@@ -19,52 +21,61 @@ export function registerProjectAccessCommand(program: Command): void {
|
|
|
19
21
|
accessCmd
|
|
20
22
|
.command('list <projectUuid>')
|
|
21
23
|
.description('List users with project access')
|
|
22
|
-
.action(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
.action(
|
|
25
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
26
|
+
try {
|
|
27
|
+
const client = getClient();
|
|
28
|
+
const result = await client.v1.projectAccess.listProjectAccess(projectUuid);
|
|
29
|
+
console.log(JSON.stringify(result, null, 2));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(
|
|
32
|
+
'Error listing project access:',
|
|
33
|
+
error instanceof Error ? error.message : String(error),
|
|
34
|
+
);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
35
39
|
|
|
36
40
|
const groupsCmd = accessCmd.command('groups').description('Project group access');
|
|
37
41
|
groupsCmd
|
|
38
42
|
.command('list <projectUuid>')
|
|
39
43
|
.description('List group access for a project')
|
|
40
|
-
.action(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
.action(
|
|
45
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
46
|
+
try {
|
|
47
|
+
const client = getClient();
|
|
48
|
+
const result = await client.v1.projectAccess.listProjectGroupAccesses(projectUuid);
|
|
49
|
+
console.log(JSON.stringify(result, null, 2));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(
|
|
52
|
+
'Error listing project group access:',
|
|
53
|
+
error instanceof Error ? error.message : String(error),
|
|
54
|
+
);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
53
59
|
|
|
54
60
|
accessCmd
|
|
55
61
|
.command('get <projectUuid> <userUuid>')
|
|
56
62
|
.description('Get a project member access')
|
|
57
|
-
.action(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
.action(
|
|
64
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string, userUuid: string) => {
|
|
65
|
+
try {
|
|
66
|
+
const client = getClient();
|
|
67
|
+
const result = await client.v1.projectAccess.getProjectMemberAccess(
|
|
68
|
+
projectUuid,
|
|
69
|
+
userUuid,
|
|
70
|
+
);
|
|
71
|
+
console.log(JSON.stringify(result, null, 2));
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(
|
|
74
|
+
'Error fetching project member access:',
|
|
75
|
+
error instanceof Error ? error.message : String(error),
|
|
76
|
+
);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
70
81
|
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { Command } from 'commander';
|
|
6
|
+
import { READ_ONLY_DEFAULT, WRITE_IDEMPOTENT, WRITE_DESTRUCTIVE } from '@lightdash-tools/common';
|
|
6
7
|
import { getClient } from '../utils/client';
|
|
8
|
+
import { wrapAction } from '../utils/safety';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Registers the projects roles subcommands under the existing projects command.
|
|
@@ -19,99 +21,109 @@ export function registerProjectRoleAssignmentsCommand(program: Command): void {
|
|
|
19
21
|
rolesCmd
|
|
20
22
|
.command('list <projectUuid>')
|
|
21
23
|
.description('List project role assignments')
|
|
22
|
-
.action(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
.action(
|
|
25
|
+
wrapAction(READ_ONLY_DEFAULT, async (projectUuid: string) => {
|
|
26
|
+
try {
|
|
27
|
+
const client = getClient();
|
|
28
|
+
const result = await client.v2.projectRoleAssignments.listAssignments(projectUuid);
|
|
29
|
+
console.log(JSON.stringify(result, null, 2));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(
|
|
32
|
+
'Error listing project role assignments:',
|
|
33
|
+
error instanceof Error ? error.message : String(error),
|
|
34
|
+
);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
35
39
|
|
|
36
40
|
const assignCmd = rolesCmd.command('assign').description('Assign role to user or group');
|
|
37
41
|
assignCmd
|
|
38
42
|
.command('user <projectUuid> <userUuid>')
|
|
39
43
|
.description('Assign a role to a user in a project')
|
|
40
44
|
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
41
|
-
.action(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
.action(
|
|
46
|
+
wrapAction(WRITE_IDEMPOTENT, async (projectUuid: string, userUuid: string, cmd: Command) => {
|
|
47
|
+
const opts = cmd.opts() as { roleId: string };
|
|
48
|
+
try {
|
|
49
|
+
const client = getClient();
|
|
50
|
+
const result = await client.v2.projectRoleAssignments.upsertUserAssignment(
|
|
51
|
+
projectUuid,
|
|
52
|
+
userUuid,
|
|
53
|
+
{ roleId: opts.roleId },
|
|
54
|
+
);
|
|
55
|
+
console.log(JSON.stringify(result, null, 2));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error(
|
|
58
|
+
'Error assigning role to user:',
|
|
59
|
+
error instanceof Error ? error.message : String(error),
|
|
60
|
+
);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
59
65
|
|
|
60
66
|
assignCmd
|
|
61
67
|
.command('group <projectUuid> <groupId>')
|
|
62
68
|
.description('Assign a role to a group in a project')
|
|
63
69
|
.requiredOption('--role-id <roleId>', 'Role ID to assign')
|
|
64
|
-
.action(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
70
|
+
.action(
|
|
71
|
+
wrapAction(WRITE_IDEMPOTENT, async (projectUuid: string, groupId: string, cmd: Command) => {
|
|
72
|
+
const opts = cmd.opts() as { roleId: string };
|
|
73
|
+
try {
|
|
74
|
+
const client = getClient();
|
|
75
|
+
const result = await client.v2.projectRoleAssignments.upsertGroupAssignment(
|
|
76
|
+
projectUuid,
|
|
77
|
+
groupId,
|
|
78
|
+
{ roleId: opts.roleId },
|
|
79
|
+
);
|
|
80
|
+
console.log(JSON.stringify(result, null, 2));
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error(
|
|
83
|
+
'Error assigning role to group:',
|
|
84
|
+
error instanceof Error ? error.message : String(error),
|
|
85
|
+
);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
82
90
|
|
|
83
91
|
const unassignCmd = rolesCmd.command('unassign').description('Remove role assignment');
|
|
84
92
|
unassignCmd
|
|
85
93
|
.command('user <projectUuid> <userUuid>')
|
|
86
94
|
.description('Remove role assignment from a user')
|
|
87
|
-
.action(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
.action(
|
|
96
|
+
wrapAction(WRITE_DESTRUCTIVE, async (projectUuid: string, userUuid: string) => {
|
|
97
|
+
try {
|
|
98
|
+
const client = getClient();
|
|
99
|
+
await client.v2.projectRoleAssignments.deleteUserAssignment(projectUuid, userUuid);
|
|
100
|
+
console.log(JSON.stringify({ ok: true }, null, 2));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error(
|
|
103
|
+
'Error removing user role assignment:',
|
|
104
|
+
error instanceof Error ? error.message : String(error),
|
|
105
|
+
);
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
100
110
|
|
|
101
111
|
unassignCmd
|
|
102
112
|
.command('group <projectUuid> <groupId>')
|
|
103
113
|
.description('Remove role assignment from a group')
|
|
104
|
-
.action(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
.action(
|
|
115
|
+
wrapAction(WRITE_DESTRUCTIVE, async (projectUuid: string, groupId: string) => {
|
|
116
|
+
try {
|
|
117
|
+
const client = getClient();
|
|
118
|
+
await client.v2.projectRoleAssignments.deleteGroupAssignment(projectUuid, groupId);
|
|
119
|
+
console.log(JSON.stringify({ ok: true }, null, 2));
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error(
|
|
122
|
+
'Error removing group role assignment:',
|
|
123
|
+
error instanceof Error ? error.message : String(error),
|
|
124
|
+
);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
117
129
|
}
|