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" }
title
is updated to a new title for the ruleset.description
is updated to a new description for the ruleset.ruleset_type
is 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:update
toolkit command ingovernance
mode:
where:apic -m governance rulesets:update --org <target_org> --server <platform_api_host_name> RULESET RULESET_FILE
<target_org>
is the name of the organization that owns the ruleset.<platform_api_host_name>
is the hostname portion URL of server that hosts the API Manager(the "management server").Tip: To determine the hostname, you can open the API Manager in a browser and copy the hostname from the URL in the address bar (beginning afterhttps://
and ending before/manager
).RULESET_FILE
is the path and filename of the JSON file that contains the updated ruleset.RULESET
is 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 <platform_api_host_name>
Updating a rule
- Create a JSON file that defines the updated rule.The following example shows an updated rule:
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\")]" ] }
description
is updated to a new title for the rulemessage
is updated to a new message for the ruleformats
array is replaced to have only the format oas3 for the ruleseverity
is updated to the warn value for the rulerecommended
is updated to have a new value for the rulegiven
array 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:update
toolkit command ingovernance
mode.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 <platform_api_host_name> --ruleset <ruleset_name or ruleset_id> NAME:VERSION RULE_FILE
<target_org>
is the name of the organization that owns the rule.<platform_api_host_name>
is the hostname portion URL of server that hosts the API Manager (the "management server").Tip: To determine the hostname, you can open the API Manager in a browser and copy the hostname from the URL in the address bar (beginning afterhttps://
and ending before/manager
).<ruleset_name or ruleset_id>
is the name or the unique ID of the ruleset to which the updated rule belongs.NAME
is the name of the updated rule.VERSION
is the version of the updated rule; increase the version when you update the rule, using themajor.minor.patch
format as in "1.0.1".RULE_FILE
is 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 <platform_api_host_name> --ruleset <ruleset_name or ruleset_id> --id <rule_id> RULE_FILE
<target_org>
is the name of the organization that owns the rule.<platform_api_host_name>
is the hostname portion URL of server that hosts the API Manager (the "management server").Tip: To determine the hostname, you can open the API Manager in a browser and copy the hostname from the URL in the address bar (beginning afterhttps://
and ending before/manager
).<ruleset_name or ruleset_id>
is the name or the unique ID of the ruleset to which the update rule belongs.RULE_FILE
is 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 <platform_api_host_name> --ruleset <ruleset_name> RULE_NAME