async validateRuleGroupFile()

in source/networkFirewallAutomation/lib/common/firewall-config-validation.ts [167:203]


    async validateRuleGroupFile(ruleGroup: NetworkFirewall.Types.CreateRuleGroupRequest, path: string) {
        //add code to check if this rule source is provided or rules file is being provided
        if (ruleGroup.Rules && ruleGroup.RuleGroup) {
            Logger.log(LOG_LEVEL.DEBUG, `Rule Group file has both Rules and RuleGroup fields.`, ruleGroup)
            this.invalidFiles.push({
                path: path,
                error: "Both RuleGroup and Rules have data, You must provide either the rule group setting or a Rules setting, but not both. "
            })
            return;
        } else if (ruleGroup.Rules) {
            const ruleString = this.fileHandler.copyFileContentToString(ruleGroup.Rules)
            if (!ruleString) {
                ruleGroup.Rules = ruleString
                this.invalidFiles.push({
                    path: path,
                    error: "Rules attribute has invalid file path. " + ruleGroup.Rules
                })
            }
            Logger.log(LOG_LEVEL.DEBUG, `Rule Group file has both Rules and RuleGroup fields.`, ruleGroup.Rules)
        }

        ruleGroup.DryRun = true;
        let response;
        try {
            response = await this.service.createRuleGroup(ruleGroup).promise();
        } catch(error) {
            Logger.log(LOG_LEVEL.DEBUG, `Error response from the create rule group dry run API`, error)
            const errorCode: string = error["code"]
            if (errorCode === "MultipleValidationErrors" || errorCode === "UnexpectedParameter") {
                this.invalidFiles.push({
                    path: path,
                    error: error["message"]
                })
            }
        }
        Logger.log(LOG_LEVEL.DEBUG, `Response from the create rule group dry run API`, response)
    }