UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

53 lines 1.89 kB
import { z } from 'zod'; import { cli } from '../../../../cli/cli.js'; import { globalOptionsZod } from '../../../../Command.js'; import request from '../../../../request.js'; import { validation } from '../../../../utils/validation.js'; import GraphCommand from '../../../base/GraphCommand.js'; import commands from '../../commands.js'; export const options = z.strictObject({ ...globalOptionsZod.shape, id: z.string().refine(val => validation.isValidGuid(val), { message: 'The value must be a valid GUID.' }).alias('i'), force: z.boolean().optional().alias('f') }); class PurviewRetentionEventRemoveCommand extends GraphCommand { get name() { return commands.RETENTIONEVENT_REMOVE; } get description() { return 'Deletes a retention event'; } get schema() { return options; } async commandAction(logger, args) { if (args.options.force) { await this.removeRetentionEvent(args.options); } else { const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the retention event ${args.options.id}?` }); if (result) { await this.removeRetentionEvent(args.options); } } } async removeRetentionEvent(options) { try { const requestOptions = { url: `${this.resource}/v1.0/security/triggers/retentionEvents/${options.id}`, headers: { accept: 'application/json;odata.metadata=none' }, responseType: 'json' }; await request.delete(requestOptions); } catch (err) { this.handleRejectedODataJsonPromise(err); } } } export default new PurviewRetentionEventRemoveCommand(); //# sourceMappingURL=retentionevent-remove.js.map