Skip to main content

set_rule

Function set_rule 

Source
pub fn set_rule(config_json: &str, params: SetRuleParams<'_>) -> Result<String>
Expand description

Update an existing rule in the configuration

§Arguments

  • config_json - Configuration JSON string
  • rule_code - Rule code to update
  • rule_config - New configuration for the rule

§Returns

Returns modified configuration JSON on success

§Example

use sz_configtool_lib::rules;

let config = r#"{"G2_CONFIG": {"CFG_ERRULE": [{"ERRULE_ID": 1, "ERRULE_CODE": "TEST", "RESOLVE": "No"}], "CFG_ERFRAG": []}}"#;
let params = rules::SetRuleParams {
    code: "TEST",
    resolve: Some("Yes"),
    relate: Some("No"),
    rtype_id: None,
    fragment: None,
    disqualifier: None,
    tier: None,
};
let modified = rules::set_rule(config, params).unwrap();