@pnp/cli-microsoft365
Version:
Manage Microsoft 365 and SharePoint Framework projects on any platform
53 lines • 1.76 kB
JavaScript
import { z } from 'zod';
import { globalOptionsZod } from '../../../../Command.js';
import { cli } from '../../../../cli/cli.js';
import request from '../../../../request.js';
import GraphCommand from '../../../base/GraphCommand.js';
import commands from '../../commands.js';
export const options = z.strictObject({
...globalOptionsZod.shape,
id: z.string(),
force: z.boolean().optional().alias('f')
});
class PlannerRosterRemoveCommand extends GraphCommand {
get name() {
return commands.ROSTER_REMOVE;
}
get description() {
return 'Removes a Microsoft Planner Roster';
}
get schema() {
return options;
}
async commandAction(logger, args) {
if (args.options.force) {
await this.removeRoster(args, logger);
}
else {
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove roster ${args.options.id}?` });
if (result) {
await this.removeRoster(args, logger);
}
}
}
async removeRoster(args, logger) {
if (this.verbose) {
await logger.logToStderr(`Removing roster ${args.options.id}`);
}
try {
const requestOptions = {
url: `${this.resource}/beta/planner/rosters/${args.options.id}`,
headers: {
accept: 'application/json;odata.metadata=none'
},
responseType: 'json'
};
await request.delete(requestOptions);
}
catch (err) {
this.handleRejectedODataJsonPromise(err);
}
}
}
export default new PlannerRosterRemoveCommand();
//# sourceMappingURL=roster-remove.js.map