import { z } from 'zod';
import { globalOptionsZod } from '../../../../Command.js';
import { formatting } from '../../../../utils/formatting.js';
import { odata } from '../../../../utils/odata.js';
import PowerAppsCommand from '../../../base/PowerAppsCommand.js';
import flowCommands from '../../../flow/commands.js';
import commands from '../../commands.js';
export const options = z.strictObject({
    ...globalOptionsZod.shape,
    environmentName: z.string().alias('e')
});
class PaConnectorListCommand extends PowerAppsCommand {
    get name() {
        return commands.CONNECTOR_LIST;
    }
    get description() {
        return 'Lists custom connectors in the given environment';
    }
    alias() {
        return [flowCommands.CONNECTOR_LIST];
    }
    defaultProperties() {
        return ['name', 'displayName'];
    }
    get schema() {
        return options;
    }
    async commandAction(logger, args) {
        const url = `${this.resource}/providers/Microsoft.PowerApps/apis?api-version=2016-11-01&$filter=environment%20eq%20%27${formatting.encodeQueryParameter(args.options.environmentName)}%27%20and%20IsCustomApi%20eq%20%27True%27`;
        try {
            const connectors = await odata.getAllItems(url);
            if (connectors.length > 0) {
                connectors.forEach(c => {
                    c.displayName = c.properties.displayName;
                });
            }
            await logger.log(connectors);
        }
        catch (err) {
            this.handleRejectedODataJsonPromise(err);
        }
    }
}
export default new PaConnectorListCommand();
//# sourceMappingURL=connector-list.js.map