import { z } from 'zod';
import { cli } from '../../../../cli/cli.js';
import { globalOptionsZod } from '../../../../Command.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().alias('i'),
    force: z.boolean().optional().alias('f')
});
class GraphSchemaExtensionRemoveCommand extends GraphCommand {
    get name() {
        return commands.SCHEMAEXTENSION_REMOVE;
    }
    get description() {
        return 'Removes specified Microsoft Graph schema extension';
    }
    get schema() {
        return options;
    }
    async commandAction(logger, args) {
        const removeSchemaExtension = async () => {
            if (this.verbose) {
                await logger.logToStderr(`Removes specified Microsoft Graph schema extension with id '${args.options.id}'...`);
            }
            const requestOptions = {
                url: `${this.resource}/v1.0/schemaExtensions/${args.options.id}`,
                headers: {
                    accept: 'application/json;odata.metadata=none',
                    'content-type': 'application/json'
                },
                responseType: 'json'
            };
            try {
                await request.delete(requestOptions);
            }
            catch (err) {
                this.handleRejectedODataJsonPromise(err);
            }
        };
        if (args.options.force) {
            await removeSchemaExtension();
        }
        else {
            const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the schema extension with ID ${args.options.id}?` });
            if (result) {
                await removeSchemaExtension();
            }
        }
    }
}
export default new GraphSchemaExtensionRemoveCommand();
//# sourceMappingURL=schemaextension-remove.js.map