Updating rulesets and rules with the toolkit CLI
Use the API Connect toolkit CLI to update a ruleset or individual rules.
Updating a ruleset
- Create a JSON file that defines the updated ruleset.The following example shows an updated ruleset:
where:{ "title": "custom-ruleset-2", "description": "short ruleset updated", "ruleset_type": "custom" }titleis updated to a new title for the ruleset.descriptionis updated to a new description for the ruleset.ruleset_typeis updated to be custom for the ruleset.
- Log in to the toolkit as an Admin or as the owner of the provider organization that owns the ruleset.
- Run the
rulesets:updatetoolkit command ingovernancemode:
where:apic -m governance rulesets:update --org <target_org> --server <server_url> RULESET RULESET_FILE<target_org>is the name of the organization that owns the ruleset.<server_url>is the management server URL that you use for logging in to the toolkit.RULESET_FILEis the path and filename of the JSON file that contains the updated ruleset.RULESETis the name or the unique ID of the updated ruleset.To determine the ID of a ruleset, run the following command:apic -m governance rulesets:list --org <target_org> --server <server_url>
Updating a rule
- Create a JSON file that defines the updated rule.The following example shows an updated rule in a file called:
where:{ "description": "Updated the rule", "message": "Schema of type array must specify maxItems and minItems. {{path}} {{error}}", "formats": [ "oas3" ], "severity": "warn", "recommended": true, "given": [ "$..[?(@.type==\"array\")]" ] }descriptionis updated to a new title for the rulemessageis updated to a new message for the ruleformatsarray is replaced to have only the format oas3 for the ruleseverityis updated to the warn value for the rulerecommendedis updated to have a new value for the rulegivenarray is replaced to have new values for the rule
- Log in to the toolkit as an Admin or as the owner of the provider organization that owns the rule.
- Run the
rules:updatetoolkit command ingovernancemode.There are two ways to specify the updated rule in the command, depending on whether you provide the rule name and version, or the rule ID:
- Specify the rule name and version in the update command
where:apic -m governance rules:update --org <target_org> --server <server_url> --ruleset <ruleset_name or ruleset_id> NAME:VERSION RULE_FILE<target_org>is the name of the organization that owns the rule.<server_url>is the management server URL that you use for logging in to the toolkit.<ruleset_name or ruleset_id>is the name or the unique ID of the ruleset to which the updated rule belongs.NAMEis the name of the updated rule.VERSIONis the version of the updated rule; increase the version when you update the rule, using themajor.minor.patchformat as in "1.0.1".RULE_FILEis the path and filename of the JSON file that contains the updated rule.
- Specify the rule ID in the update command
- Instead of providing the rule's name and version, you can provide its unique ID instead by
running the following command:
where:apic -m governance rules:update --org <target_org> --server <server_url> --ruleset <ruleset_name or ruleset_id> --id <rule_id> RULE_FILE<target_org>is the name of the organization that owns the rule.<server_url>is the management server URL that you specified when you logged in to the toolkit.<ruleset_name or ruleset_id>is the name or the unique ID of the ruleset to which the update rule belongs.RULE_FILEis the path and filename of the JSON file that contains the updated rule.<rule_id>is the value of the updated rule's unique ID.To determine the ID of a rule, run the following command:apic -m governance rules:list --org <target_org> --server <server_url> --ruleset <ruleset_name> RULE_NAME