Viewing Rules of a Rule Set
Function
This API is used to query rules based on conditions such as the project ID and rule set ID.
Calling Method
For details, see Calling APIs.
URI
GET /v2/{project_id}/ruleset/{ruleset_id}/rules
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Definition 32-character UUID of a project. Obtain the ID by calling the API for querying projects. Constraints N/A Range 32-character project ID. Default Value N/A |
ruleset_id |
Yes |
String |
Definition Rule set ID. Obtain a rule set ID by calling the API for querying rule sets. Constraints N/A Range 32-character rule set ID. Default Value N/A |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
types |
No |
String |
Definition Rule status. Constraints N/A Range Default Value 1 |
languages |
No |
String |
Definition Rule language. Constraints N/A Range N/A Default Value N/A |
tags |
No |
String |
Definition Rule tag. Constraints N/A Range N/A Default Value N/A |
offset |
No |
Integer |
Definition Offset for pagination. Constraints N/A Range 0–999 |
limit |
No |
Integer |
Definition Number of records displayed on each page. Constraints N/A Range 0–200 |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
Definition User token. Obtain a token by calling the IAM API forobtaining a user token. The value of X-Subject-Token in the response header is the user token. Constraints N/A Range 1–100,000 characters Default Value N/A |
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
info |
Array of RuleItem objects |
Definition Rules of a rule set. Range N/A |
total |
Integer |
Definition Total number. Range N/A |
Parameter |
Type |
Description |
---|---|---|
rule_id |
String |
Definition Rule ID. Range 32-character UUID. |
rule_language |
String |
Definition Rule language. Range Supported languages include: ArkTS, C#, C++, CSS, Go, HTML, Java, JavaScript, Kotlin, Lua, PHP, Python, Rust, Scala, Shell, SQL, and TypeScript. |
rule_name |
String |
Definition Rule name. Range N/A |
rule_severity |
String |
Definition Issue severity. Range |
tags |
String |
Definition Rule tag. Range The options include huawei, iso5055, cert, cwe, top10, top25, misra, GJB, autosar, and PCI DSS. |
checked |
String |
Definition Rule status. Range |
rule_config_list |
Array of RuleConfigParam objects |
Rule threshold information. |
Parameter |
Type |
Description |
---|---|---|
id |
Integer |
Definition Rule configuration ID. Obtain a rule configuration ID by calling the API for obtaining rules. Range 32-character UUID. |
rule_id |
String |
Definition Tool rule ID, that is, the ID of a threshold for configuring a threshold rule. To obtain such an ID, contact customer service. Range 32-character UUID. |
default_value |
String |
Definition Default threshold. Range N/A |
option_value |
String |
Definition New threshold of a parameter. Range N/A |
option_key |
String |
Definition Key of the current rule configuration item. Obtain a rule configuration ID by calling the API for obtaining rules. Range N/A |
option_name |
String |
Definition Key of the current rule configuration item. Obtain a rule configuration ID by calling the API for obtaining rules. Range N/A |
template_id |
String |
Definition Rule set ID. Obtain a rule set ID by calling the API for querying rule sets. Range 32-character UUID. |
description |
String |
Definition Parameter description. This parameter is optional. Range N/A |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Status code: 401
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Error message. |
Example Requests
GET https://{endpoint}/v2/{project_id}/ruleset/{ruleset_id}/rules
Example Responses
Status code: 200
Request succeeded!
{ "info" : [ { "rule_language" : "cpp", "rule_id" : "1614", "checked" : "1", "rule_name" : "A buffer must have size of 2 integers if used as parameter of pipe().", "rule_severity" : "1", "tags" : "cwe", "rule_config_list" : [ ] }, { "rule_language" : "cpp", "rule_id" : "1611", "checked" : "1", "rule_name" : "A buffer must have size of 2 integers if used as parameter of pipe().", "rule_severity" : "1", "tags" : "cwe", "rule_config_list" : [ { "id" : 250, "rule_id" : 11707, "template_id" : "906e7eac47dd4bde9c984f5e6f2a54e8", "option_key" : "threshold", "option_name" : "Adding a threshold", "option_value" : "10", "default_value" : "20", "description" : "If the code complexity exceeds the threshold, the code is identified as a huge cyclomatic complexity. The difference between the large cyclomatic complexity and cyclomatic complexity statistics is that only the number of switch statements is counted. The parameter is mandatory." }, { "id" : 251, "rule_id" : 11707, "template_id" : "906e7eac47dd4bde9c984f5e6f2a54e8", "option_key" : "threshold_modify", "option_name" : "Modifying a threshold", "option_value" : "30", "default_value" : "20", "description" : "If the code complexity exceeds the threshold, the code is identified as a huge cyclomatic complexity. The difference between the large cyclomatic complexity and cyclomatic complexity statistics is that only the number of switch statements is counted. The modified threshold must be greater than the new threshold. This parameter is optional." } ] } ], "total" : 2 }
Status code: 400
Bad Request
{ "error_code" : "CC.00000000", "error_msg" : "Network busy. Try again later." }
Status code: 401
Unauthorized
{ "error_code" : "CC.00000003", "error_msg" : "Authentication information expired." }
Status Codes
Status Code |
Description |
---|---|
200 |
Request succeeded! |
400 |
Bad Request |
401 |
Unauthorized |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot