Updated on 2024-11-28 GMT+08:00

Querying Rule Sets

Function

This API is used to query rule sets based on conditions such as the project ID and language.

Calling Method

For details, see Calling APIs.

URI

GET /v2/{project_id}/rulesets

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

category

No

String

Rule set category.

0: system rule sets; 1: custom rule sets of current user; 2: custom rule sets of other users; 0,1,2: all rule sets.

offset

No

Integer

Offset for pagination.

limit

No

Integer

Number of items on each page.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

info

Array of RulesetItem objects

Rule set list information.

total

Integer

Total number.

Table 5 RulesetItem

Parameter

Type

Description

template_id

String

Rule set ID.

language

String

Rule set language.

template_name

String

Rule set name.

creator_id

String

Creator ID.

creator_name

String

Creator name.

template_create_time

String

Creation time.

is_used

String

Usage status. 1: in use; 0: idle.

rule_ids

String

Rule IDs in a rule set.

is_default

String

Whether the rule set is the default rule set of the language. 0: no; 1: yes.

is_devcloud_project_default

String

Whether the rule set is the default rule set of the language in a project. 0: no; 1: yes.

is_default_template

String

Whether the rule set is a system rule set. 0: no; 1: yes.

Status code: 400

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

GET https://{endpoint}/v2/{project_id}/rulesets

Example Responses

Status code: 200

Request succeeded!

{
  "info" : [ {
    "template_id" : "9698e0cb9d2441c3bd8cec5f8641696e",
    "language" : "Java",
    "template_name" : "test1111",
    "creator_id" : "ae161856f2604229ae12056478a7919f",
    "creator_name" : "Mr. Yang",
    "template_create_time" : "2021-10-21T02:14:55Z",
    "is_used" : "0",
    "rule_ids" : "",
    "is_default" : "0",
    "is_default_template" : "1",
    "is_devcloud_project_default" : "0"
  }, {
    "template_id" : "9698e0cb9d2441c3bd8cec5f8641696e",
    "language" : "cpp",
    "template_name" : "test222",
    "creator_id" : "ae161856f2604229ae12056478a7919f",
    "creator_name" : "Mr. Yang",
    "template_create_time" : "2021-10-21T02:14:55Z",
    "is_used" : "1",
    "rule_ids" : "11152,11153,11154,11155",
    "is_default" : "0",
    "is_default_template" : "1",
    "is_devcloud_project_default" : "1"
  } ],
  "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.