import { z } from 'zod';
import { globalOptionsZod } from '../../../../Command.js';
import request from '../../../../request.js';
import { formatting } from '../../../../utils/formatting.js';
import GraphCommand from '../../../base/GraphCommand.js';
import commands from '../../commands.js';
export const options = globalOptionsZod
    .extend({
    grantId: z.string().alias('i'),
    scope: z.string().alias('s')
}).strict();
class EntraOAuth2GrantSetCommand extends GraphCommand {
    get name() {
        return commands.OAUTH2GRANT_SET;
    }
    get description() {
        return 'Updates OAuth2 permissions for the service principal';
    }
    get schema() {
        return options;
    }
    async commandAction(logger, args) {
        if (this.verbose) {
            await logger.logToStderr(`Updating OAuth2 permissions...`);
        }
        try {
            const requestOptions = {
                url: `${this.resource}/v1.0/oauth2PermissionGrants/${formatting.encodeQueryParameter(args.options.grantId)}`,
                headers: {
                    'content-type': 'application/json'
                },
                responseType: 'json',
                data: {
                    "scope": args.options.scope
                }
            };
            await request.patch(requestOptions);
        }
        catch (err) {
            this.handleRejectedODataJsonPromise(err);
        }
    }
}
export default new EntraOAuth2GrantSetCommand();
//# sourceMappingURL=oauth2grant-set.js.map