32 lines
981 B
TypeScript
32 lines
981 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
|
|
import { listResourcePermissions } from "../../graph/app.ts";
|
|
import { getGraphClient } from "../../graph/index.ts";
|
|
import { filterByPermissionName } from "./shared.ts";
|
|
|
|
type ListResourcePermissionsOptions = {
|
|
appId?: string;
|
|
displayName?: string;
|
|
filter?: string;
|
|
};
|
|
|
|
export async function runListResourcePermissionsCommand(options: ListResourcePermissionsOptions): Promise<unknown> {
|
|
if (!options.appId && !options.displayName) {
|
|
throw new Error("--app-id or --display-name is required for list-resource-permissions");
|
|
}
|
|
if (options.appId && options.displayName) {
|
|
throw new Error("Use either --app-id or --display-name for list-resource-permissions, not both");
|
|
}
|
|
|
|
const client = await getGraphClient();
|
|
let result = await listResourcePermissions(
|
|
client,
|
|
options.appId,
|
|
options.displayName,
|
|
);
|
|
if (options.filter) {
|
|
result = filterByPermissionName(result, options.filter);
|
|
}
|
|
return result;
|
|
}
|