Create Custom Ruleset

Note: This endpoint is in preview and is subject to change. If you have any feedback, contact Datadog support.

PUT https://api.ap1.datadoghq.com/api/v2/static-analysis/custom/rulesetshttps://api.ap2.datadoghq.com/api/v2/static-analysis/custom/rulesetshttps://api.datadoghq.eu/api/v2/static-analysis/custom/rulesetshttps://api.ddog-gov.com/api/v2/static-analysis/custom/rulesetshttps://api.us2.ddog-gov.com/api/v2/static-analysis/custom/rulesetshttps://api.uk1.datadoghq.com/api/v2/static-analysis/custom/rulesetshttps://api.datadoghq.com/api/v2/static-analysis/custom/rulesetshttps://api.us3.datadoghq.com/api/v2/static-analysis/custom/rulesetshttps://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets

개요

인증된 조직을 위한 새 커스텀 규칙 세트를 생성합니다.

OAuth apps require the code_analysis_read authorization scope to access this endpoint.

요청

Body Data (required)

Expand All

항목

유형

설명

data

object

Data object for a custom ruleset create or update request. The resource id is required and must equal both attributes.name and, on update, the ruleset_name path parameter; a request that omits it or supplies a different value is rejected with a 412 response.

attributes [required]

object

Attributes for creating or updating a custom ruleset. name is required and must equal the resource id; the server rejects a mismatch with a 412 response.

description

string

Base64-encoded full description

name [required]

string

Ruleset name, which must be the same as the resource identifier.

rules

[object]

Rules in the ruleset

created_at

date-time

Creation timestamp

created_by

string

Creator identifier

id [required]

string

Rule identifier, which is the same as the rule name.

last_revision

object

Most recent revision

arguments

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum

string

Code checksum

code

string

Rule code

created_at

date-time

Creation timestamp

created_by

string

Creator identifier

creation_message

string

Revision creation message

cve

string

Associated CVE

cwe

string

Associated CWE

description

string

Base64-encoded full description

documentation_url

string

Documentation URL

id

string

Revision identifier

is_published

boolean

Whether the revision should be published

is_testing

boolean

Whether this is a testing revision

language

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 13 more,SWIFT,DART,DOCKERFILE,ELIXIR,JSON,RUST,TERRAFORM,STARLARK,BASH,MARKDOWN,APEX,R,SQL

severity

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE,NONE

short_description

string

Base64-encoded short description

should_use_ai_fix

boolean

Whether to use AI for fixes

tags

[string]

Rule tags

tests

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query

string

Tree-sitter query

version_id

int64

Monotonically increasing version number of the revision.

name [required]

string

Rule name

revisions

[object]

Revision history of the rule.

arguments

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum

string

Code checksum

code

string

Rule code

created_at

date-time

Creation timestamp

created_by

string

Creator identifier

creation_message

string

Revision creation message

cve

string

Associated CVE

cwe

string

Associated CWE

description

string

Base64-encoded full description

documentation_url

string

Documentation URL

id

string

Revision identifier

is_published

boolean

Whether the revision should be published

is_testing

boolean

Whether this is a testing revision

language

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 13 more,SWIFT,DART,DOCKERFILE,ELIXIR,JSON,RUST,TERRAFORM,STARLARK,BASH,MARKDOWN,APEX,R,SQL

severity

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE,NONE

short_description

string

Base64-encoded short description

should_use_ai_fix

boolean

Whether to use AI for fixes

tags

[string]

Rule tags

tests

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query

string

Tree-sitter query

version_id

int64

Monotonically increasing version number of the revision.

short_description

string

Base64-encoded short description

id [required]

string

Ruleset identifier, which is the same as the ruleset name.

type [required]

enum

Resource type Allowed enum values: custom_ruleset

{
  "data": {
    "attributes": {
      "description": "bG9uZyBkZXNjcmlwdGlvbg==",
      "name": "my-ruleset",
      "rules": [
        {
          "id": "my-rule",
          "last_revision": {
            "arguments": [
              {
                "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                "name": "YXJndW1lbnRfbmFtZQ=="
              }
            ],
            "category": "SECURITY",
            "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            "creation_message": "Initial revision",
            "cve": "CVE-2024-1234",
            "cwe": "CWE-79",
            "description": "bG9uZyBkZXNjcmlwdGlvbg==",
            "documentation_url": "https://docs.example.com/rules/my-rule",
            "is_published": false,
            "is_testing": false,
            "language": "PYTHON",
            "severity": "ERROR",
            "short_description": "c2hvcnQgZGVzY3JpcHRpb24=",
            "should_use_ai_fix": false,
            "tags": [
              "security",
              "custom"
            ],
            "tests": [
              {
                "annotation_count": 1,
                "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                "filename": "test.yaml"
              }
            ],
            "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="
          },
          "name": "my-rule",
          "revisions": [
            {
              "arguments": [
                {
                  "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  "name": "YXJndW1lbnRfbmFtZQ=="
                }
              ],
              "category": "SECURITY",
              "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              "creation_message": "Initial revision",
              "cve": "CVE-2024-1234",
              "cwe": "CWE-79",
              "description": "bG9uZyBkZXNjcmlwdGlvbg==",
              "documentation_url": "https://docs.example.com/rules/my-rule",
              "is_published": false,
              "is_testing": false,
              "language": "PYTHON",
              "severity": "ERROR",
              "short_description": "c2hvcnQgZGVzY3JpcHRpb24=",
              "should_use_ai_fix": false,
              "tags": [
                "security",
                "custom"
              ],
              "tests": [
                {
                  "annotation_count": 1,
                  "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                  "filename": "test.yaml"
                }
              ],
              "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="
            }
          ]
        }
      ],
      "short_description": "c2hvcnQgZGVzY3JpcHRpb24="
    },
    "id": "my-ruleset",
    "type": "custom_ruleset"
  }
}

응답

OK

Response containing a single custom ruleset.

Expand All

항목

유형

설명

data [required]

object

A custom static analysis ruleset containing a set of user-defined rules.

attributes [required]

object

Attributes of a custom ruleset, including its name, description, and rules.

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

description [required]

string

Base64-encoded full description

name [required]

string

Ruleset name

rules [required]

[object]

Rules in the ruleset

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

id [required]

string

Rule identifier, which is the same as the rule name.

last_revision [required]

object

Most recent revision of the rule, or null when the rule has no revisions.

arguments [required]

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category [required]

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum [required]

string

Code checksum

code [required]

string

Rule code

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

creation_message [required]

string

Revision creation message

cve

string

Associated CVE. Omitted when the revision has no associated CVE.

cwe

string

Associated CWE. Omitted when the revision has no associated CWE.

description [required]

string

Full description

documentation_url

string

Documentation URL. Omitted when the revision has no documentation URL.

id [required]

string

Revision identifier

is_published [required]

boolean

Whether the revision is published

is_testing [required]

boolean

Whether this is a testing revision

language [required]

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 13 more,SWIFT,DART,DOCKERFILE,ELIXIR,JSON,RUST,TERRAFORM,STARLARK,BASH,MARKDOWN,APEX,R,SQL

severity [required]

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE,NONE

short_description [required]

string

Short description

should_use_ai_fix [required]

boolean

Whether to use AI for fixes

tags [required]

[string]

Rule tags

tests [required]

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query [required]

string

Tree-sitter query

version_id [required]

int64

Monotonically increasing version number of the revision.

name [required]

string

Rule name

revisions [required]

[object]

Revision history of the rule.

arguments [required]

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category [required]

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum [required]

string

Code checksum

code [required]

string

Rule code

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

creation_message [required]

string

Revision creation message

cve

string

Associated CVE. Omitted when the revision has no associated CVE.

cwe

string

Associated CWE. Omitted when the revision has no associated CWE.

description [required]

string

Full description

documentation_url

string

Documentation URL. Omitted when the revision has no documentation URL.

id [required]

string

Revision identifier

is_published [required]

boolean

Whether the revision is published

is_testing [required]

boolean

Whether this is a testing revision

language [required]

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 13 more,SWIFT,DART,DOCKERFILE,ELIXIR,JSON,RUST,TERRAFORM,STARLARK,BASH,MARKDOWN,APEX,R,SQL

severity [required]

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE,NONE

short_description [required]

string

Short description

should_use_ai_fix [required]

boolean

Whether to use AI for fixes

tags [required]

[string]

Rule tags

tests [required]

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query [required]

string

Tree-sitter query

version_id [required]

int64

Monotonically increasing version number of the revision.

short_description [required]

string

Base64-encoded short description

id [required]

string

Ruleset identifier

type [required]

enum

Resource type Allowed enum values: custom_ruleset

{
  "data": {
    "attributes": {
      "created_at": "2026-01-09T13:00:57.473141Z",
      "created_by": "foobarbaz",
      "description": "bG9uZyBkZXNjcmlwdGlvbg==",
      "name": "my-ruleset",
      "rules": [
        {
          "created_at": "2026-01-09T13:00:57.473141Z",
          "created_by": "foobarbaz",
          "id": "my-rule",
          "last_revision": {
            "arguments": [
              {
                "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                "name": "YXJndW1lbnRfbmFtZQ=="
              }
            ],
            "category": "SECURITY",
            "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
            "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            "created_at": "2026-01-09T13:00:57.473141Z",
            "created_by": "foobarbaz",
            "creation_message": "Initial revision",
            "cve": "CVE-2024-1234",
            "cwe": "CWE-79",
            "description": "bG9uZyBkZXNjcmlwdGlvbg==",
            "documentation_url": "https://docs.example.com/rules/my-rule",
            "id": "revision-123",
            "is_published": false,
            "is_testing": false,
            "language": "PYTHON",
            "severity": "ERROR",
            "short_description": "c2hvcnQgZGVzY3JpcHRpb24=",
            "should_use_ai_fix": false,
            "tags": [
              "security",
              "custom"
            ],
            "tests": [
              {
                "annotation_count": 1,
                "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                "filename": "test.yaml"
              }
            ],
            "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            "version_id": 1
          },
          "name": "my-rule",
          "revisions": [
            {
              "arguments": [
                {
                  "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  "name": "YXJndW1lbnRfbmFtZQ=="
                }
              ],
              "category": "SECURITY",
              "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
              "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              "created_at": "2026-01-09T13:00:57.473141Z",
              "created_by": "foobarbaz",
              "creation_message": "Initial revision",
              "cve": "CVE-2024-1234",
              "cwe": "CWE-79",
              "description": "bG9uZyBkZXNjcmlwdGlvbg==",
              "documentation_url": "https://docs.example.com/rules/my-rule",
              "id": "revision-123",
              "is_published": false,
              "is_testing": false,
              "language": "PYTHON",
              "severity": "ERROR",
              "short_description": "c2hvcnQgZGVzY3JpcHRpb24=",
              "should_use_ai_fix": false,
              "tags": [
                "security",
                "custom"
              ],
              "tests": [
                {
                  "annotation_count": 1,
                  "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                  "filename": "test.yaml"
                }
              ],
              "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              "version_id": 1
            }
          ]
        }
      ],
      "short_description": "c2hvcnQgZGVzY3JpcHRpb24="
    },
    "id": "my-ruleset",
    "type": "custom_ruleset"
  }
}

Bad Request

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Unauthorized

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Conflict

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Precondition Failed

API error response.

Expand All

항목

유형

설명

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}

Too many requests

API error response.

Expand All

항목

유형

설명

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

코드 예시

                  ## default
# 

# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

# Curl command
curl -X PUT "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer ${DD_BEARER_TOKEN}" \ -d @- << EOF { "data": { "attributes": { "description": "My custom ruleset.", "name": "my-custom-ruleset" }, "id": "my-custom-ruleset", "type": "custom_ruleset" } } EOF
"""
Create Custom Ruleset returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi
from datadog_api_client.v2.model.argument import Argument
from datadog_api_client.v2.model.custom_rule import CustomRule
from datadog_api_client.v2.model.custom_rule_revision_attributes_category import CustomRuleRevisionAttributesCategory
from datadog_api_client.v2.model.custom_rule_revision_attributes_severity import CustomRuleRevisionAttributesSeverity
from datadog_api_client.v2.model.custom_rule_revision_input import CustomRuleRevisionInput
from datadog_api_client.v2.model.custom_rule_revision_test import CustomRuleRevisionTest
from datadog_api_client.v2.model.custom_ruleset_data_type import CustomRulesetDataType
from datadog_api_client.v2.model.custom_ruleset_request import CustomRulesetRequest
from datadog_api_client.v2.model.custom_ruleset_request_data import CustomRulesetRequestData
from datadog_api_client.v2.model.custom_ruleset_request_data_attributes import CustomRulesetRequestDataAttributes
from datadog_api_client.v2.model.language import Language

body = CustomRulesetRequest(
    data=CustomRulesetRequestData(
        attributes=CustomRulesetRequestDataAttributes(
            description="bG9uZyBkZXNjcmlwdGlvbg==",
            name="my-ruleset",
            rules=[
                CustomRule(
                    id="my-rule",
                    last_revision=CustomRuleRevisionInput(
                        arguments=[
                            Argument(
                                description="YXJndW1lbnQgZGVzY3JpcHRpb24=",
                                name="YXJndW1lbnRfbmFtZQ==",
                            ),
                        ],
                        category=CustomRuleRevisionAttributesCategory.SECURITY,
                        code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                        creation_message="Initial revision",
                        cve="CVE-2024-1234",
                        cwe="CWE-79",
                        description="bG9uZyBkZXNjcmlwdGlvbg==",
                        documentation_url="https://docs.example.com/rules/my-rule",
                        is_published=False,
                        is_testing=False,
                        language=Language.PYTHON,
                        severity=CustomRuleRevisionAttributesSeverity.ERROR,
                        short_description="c2hvcnQgZGVzY3JpcHRpb24=",
                        should_use_ai_fix=False,
                        tags=[
                            "security",
                            "custom",
                        ],
                        tests=[
                            CustomRuleRevisionTest(
                                annotation_count=1,
                                code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                                filename="test.yaml",
                            ),
                        ],
                        tree_sitter_query="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                    ),
                    name="my-rule",
                    revisions=[
                        CustomRuleRevisionInput(
                            arguments=[
                                Argument(
                                    description="YXJndW1lbnQgZGVzY3JpcHRpb24=",
                                    name="YXJndW1lbnRfbmFtZQ==",
                                ),
                            ],
                            category=CustomRuleRevisionAttributesCategory.SECURITY,
                            code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                            creation_message="Initial revision",
                            cve="CVE-2024-1234",
                            cwe="CWE-79",
                            description="bG9uZyBkZXNjcmlwdGlvbg==",
                            documentation_url="https://docs.example.com/rules/my-rule",
                            is_published=False,
                            is_testing=False,
                            language=Language.PYTHON,
                            severity=CustomRuleRevisionAttributesSeverity.ERROR,
                            short_description="c2hvcnQgZGVzY3JpcHRpb24=",
                            should_use_ai_fix=False,
                            tags=[
                                "security",
                                "custom",
                            ],
                            tests=[
                                CustomRuleRevisionTest(
                                    annotation_count=1,
                                    code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                                    filename="test.yaml",
                                ),
                            ],
                            tree_sitter_query="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                        ),
                    ],
                ),
            ],
            short_description="c2hvcnQgZGVzY3JpcHRpb24=",
        ),
        id="my-ruleset",
        type=CustomRulesetDataType.CUSTOM_RULESET,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_custom_ruleset"] = True
with ApiClient(configuration) as api_client:
    api_instance = StaticAnalysisApi(api_client)
    response = api_instance.create_custom_ruleset(body=body)

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
# Create Custom Ruleset returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.create_custom_ruleset".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new

body = DatadogAPIClient::V2::CustomRulesetRequest.new({
  data: DatadogAPIClient::V2::CustomRulesetRequestData.new({
    attributes: DatadogAPIClient::V2::CustomRulesetRequestDataAttributes.new({
      description: "bG9uZyBkZXNjcmlwdGlvbg==",
      name: "my-ruleset",
      rules: [
        DatadogAPIClient::V2::CustomRule.new({
          id: "my-rule",
          last_revision: DatadogAPIClient::V2::CustomRuleRevisionInput.new({
            arguments: [
              DatadogAPIClient::V2::Argument.new({
                description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                name: "YXJndW1lbnRfbmFtZQ==",
              }),
            ],
            category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY,
            code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            creation_message: "Initial revision",
            cve: "CVE-2024-1234",
            cwe: "CWE-79",
            description: "bG9uZyBkZXNjcmlwdGlvbg==",
            documentation_url: "https://docs.example.com/rules/my-rule",
            is_published: false,
            is_testing: false,
            language: DatadogAPIClient::V2::Language::PYTHON,
            severity: DatadogAPIClient::V2::CustomRuleRevisionAttributesSeverity::ERROR,
            short_description: "c2hvcnQgZGVzY3JpcHRpb24=",
            should_use_ai_fix: false,
            tags: [
              "security",
              "custom",
            ],
            tests: [
              DatadogAPIClient::V2::CustomRuleRevisionTest.new({
                annotation_count: 1,
                code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                filename: "test.yaml",
              }),
            ],
            tree_sitter_query: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
          }),
          name: "my-rule",
          revisions: [
            DatadogAPIClient::V2::CustomRuleRevisionInput.new({
              arguments: [
                DatadogAPIClient::V2::Argument.new({
                  description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  name: "YXJndW1lbnRfbmFtZQ==",
                }),
              ],
              category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY,
              code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              creation_message: "Initial revision",
              cve: "CVE-2024-1234",
              cwe: "CWE-79",
              description: "bG9uZyBkZXNjcmlwdGlvbg==",
              documentation_url: "https://docs.example.com/rules/my-rule",
              is_published: false,
              is_testing: false,
              language: DatadogAPIClient::V2::Language::PYTHON,
              severity: DatadogAPIClient::V2::CustomRuleRevisionAttributesSeverity::ERROR,
              short_description: "c2hvcnQgZGVzY3JpcHRpb24=",
              should_use_ai_fix: false,
              tags: [
                "security",
                "custom",
              ],
              tests: [
                DatadogAPIClient::V2::CustomRuleRevisionTest.new({
                  annotation_count: 1,
                  code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                  filename: "test.yaml",
                }),
              ],
              tree_sitter_query: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            }),
          ],
        }),
      ],
      short_description: "c2hvcnQgZGVzY3JpcHRpb24=",
    }),
    id: "my-ruleset",
    type: DatadogAPIClient::V2::CustomRulesetDataType::CUSTOM_RULESET,
  }),
})
p api_instance.create_custom_ruleset(body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
// Create Custom Ruleset returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.CustomRulesetRequest{
		Data: &datadogV2.CustomRulesetRequestData{
			Attributes: datadogV2.CustomRulesetRequestDataAttributes{
				Description: datadog.PtrString("bG9uZyBkZXNjcmlwdGlvbg=="),
				Name:        "my-ruleset",
				Rules: []datadogV2.CustomRule{
					{
						Id: "my-rule",
						LastRevision: &datadogV2.CustomRuleRevisionInput{
							Arguments: []datadogV2.Argument{
								{
									Description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
									Name:        "YXJndW1lbnRfbmFtZQ==",
								},
							},
							Category:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESCATEGORY_SECURITY.Ptr(),
							Code:             datadog.PtrString("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="),
							CreationMessage:  datadog.PtrString("Initial revision"),
							Cve:              *datadog.NewNullableString(datadog.PtrString("CVE-2024-1234")),
							Cwe:              *datadog.NewNullableString(datadog.PtrString("CWE-79")),
							Description:      datadog.PtrString("bG9uZyBkZXNjcmlwdGlvbg=="),
							DocumentationUrl: *datadog.NewNullableString(datadog.PtrString("https://docs.example.com/rules/my-rule")),
							IsPublished:      datadog.PtrBool(false),
							IsTesting:        datadog.PtrBool(false),
							Language:         datadogV2.LANGUAGE_PYTHON.Ptr(),
							Severity:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESSEVERITY_ERROR.Ptr(),
							ShortDescription: datadog.PtrString("c2hvcnQgZGVzY3JpcHRpb24="),
							ShouldUseAiFix:   datadog.PtrBool(false),
							Tags: *datadog.NewNullableList(&[]string{
								"security",
								"custom",
							}),
							Tests: []datadogV2.CustomRuleRevisionTest{
								{
									AnnotationCount: 1,
									Code:            "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
									Filename:        "test.yaml",
								},
							},
							TreeSitterQuery: datadog.PtrString("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="),
						},
						Name: "my-rule",
						Revisions: []datadogV2.CustomRuleRevisionInput{
							{
								Arguments: []datadogV2.Argument{
									{
										Description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
										Name:        "YXJndW1lbnRfbmFtZQ==",
									},
								},
								Category:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESCATEGORY_SECURITY.Ptr(),
								Code:             datadog.PtrString("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="),
								CreationMessage:  datadog.PtrString("Initial revision"),
								Cve:              *datadog.NewNullableString(datadog.PtrString("CVE-2024-1234")),
								Cwe:              *datadog.NewNullableString(datadog.PtrString("CWE-79")),
								Description:      datadog.PtrString("bG9uZyBkZXNjcmlwdGlvbg=="),
								DocumentationUrl: *datadog.NewNullableString(datadog.PtrString("https://docs.example.com/rules/my-rule")),
								IsPublished:      datadog.PtrBool(false),
								IsTesting:        datadog.PtrBool(false),
								Language:         datadogV2.LANGUAGE_PYTHON.Ptr(),
								Severity:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESSEVERITY_ERROR.Ptr(),
								ShortDescription: datadog.PtrString("c2hvcnQgZGVzY3JpcHRpb24="),
								ShouldUseAiFix:   datadog.PtrBool(false),
								Tags: *datadog.NewNullableList(&[]string{
									"security",
									"custom",
								}),
								Tests: []datadogV2.CustomRuleRevisionTest{
									{
										AnnotationCount: 1,
										Code:            "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
										Filename:        "test.yaml",
									},
								},
								TreeSitterQuery: datadog.PtrString("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="),
							},
						},
					},
				},
				ShortDescription: datadog.PtrString("c2hvcnQgZGVzY3JpcHRpb24="),
			},
			Id:   "my-ruleset",
			Type: datadogV2.CUSTOMRULESETDATATYPE_CUSTOM_RULESET,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateCustomRuleset", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStaticAnalysisApi(apiClient)
	resp, r, err := api.CreateCustomRuleset(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.CreateCustomRuleset`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.CreateCustomRuleset`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
// Create Custom Ruleset returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StaticAnalysisApi;
import com.datadog.api.client.v2.model.Argument;
import com.datadog.api.client.v2.model.CustomRule;
import com.datadog.api.client.v2.model.CustomRuleRevisionAttributesCategory;
import com.datadog.api.client.v2.model.CustomRuleRevisionAttributesSeverity;
import com.datadog.api.client.v2.model.CustomRuleRevisionInput;
import com.datadog.api.client.v2.model.CustomRuleRevisionTest;
import com.datadog.api.client.v2.model.CustomRulesetDataType;
import com.datadog.api.client.v2.model.CustomRulesetRequest;
import com.datadog.api.client.v2.model.CustomRulesetRequestData;
import com.datadog.api.client.v2.model.CustomRulesetRequestDataAttributes;
import com.datadog.api.client.v2.model.CustomRulesetResponse;
import com.datadog.api.client.v2.model.Language;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    defaultClient.setUnstableOperationEnabled("v2.createCustomRuleset", true);
    StaticAnalysisApi apiInstance = new StaticAnalysisApi(defaultClient);

    CustomRulesetRequest body =
        new CustomRulesetRequest()
            .data(
                new CustomRulesetRequestData()
                    .attributes(
                        new CustomRulesetRequestDataAttributes()
                            .description("bG9uZyBkZXNjcmlwdGlvbg==")
                            .name("my-ruleset")
                            .rules(
                                Collections.singletonList(
                                    new CustomRule()
                                        .id("my-rule")
                                        .lastRevision(
                                            new CustomRuleRevisionInput()
                                                .arguments(
                                                    Collections.singletonList(
                                                        new Argument()
                                                            .description(
                                                                "YXJndW1lbnQgZGVzY3JpcHRpb24=")
                                                            .name("YXJndW1lbnRfbmFtZQ==")))
                                                .category(
                                                    CustomRuleRevisionAttributesCategory.SECURITY)
                                                .code(
                                                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                                .creationMessage("Initial revision")
                                                .cve("CVE-2024-1234")
                                                .cwe("CWE-79")
                                                .description("bG9uZyBkZXNjcmlwdGlvbg==")
                                                .documentationUrl(
                                                    "https://docs.example.com/rules/my-rule")
                                                .isPublished(false)
                                                .isTesting(false)
                                                .language(Language.PYTHON)
                                                .severity(
                                                    CustomRuleRevisionAttributesSeverity.ERROR)
                                                .shortDescription("c2hvcnQgZGVzY3JpcHRpb24=")
                                                .shouldUseAiFix(false)
                                                .tags(Arrays.asList("security", "custom"))
                                                .tests(
                                                    Collections.singletonList(
                                                        new CustomRuleRevisionTest()
                                                            .annotationCount(1L)
                                                            .code(
                                                                "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                                            .filename("test.yaml")))
                                                .treeSitterQuery(
                                                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="))
                                        .name("my-rule")
                                        .revisions(
                                            Collections.singletonList(
                                                new CustomRuleRevisionInput()
                                                    .arguments(
                                                        Collections.singletonList(
                                                            new Argument()
                                                                .description(
                                                                    "YXJndW1lbnQgZGVzY3JpcHRpb24=")
                                                                .name("YXJndW1lbnRfbmFtZQ==")))
                                                    .category(
                                                        CustomRuleRevisionAttributesCategory
                                                            .SECURITY)
                                                    .code(
                                                        "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                                    .creationMessage("Initial revision")
                                                    .cve("CVE-2024-1234")
                                                    .cwe("CWE-79")
                                                    .description("bG9uZyBkZXNjcmlwdGlvbg==")
                                                    .documentationUrl(
                                                        "https://docs.example.com/rules/my-rule")
                                                    .isPublished(false)
                                                    .isTesting(false)
                                                    .language(Language.PYTHON)
                                                    .severity(
                                                        CustomRuleRevisionAttributesSeverity.ERROR)
                                                    .shortDescription("c2hvcnQgZGVzY3JpcHRpb24=")
                                                    .shouldUseAiFix(false)
                                                    .tags(Arrays.asList("security", "custom"))
                                                    .tests(
                                                        Collections.singletonList(
                                                            new CustomRuleRevisionTest()
                                                                .annotationCount(1L)
                                                                .code(
                                                                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                                                .filename("test.yaml")))
                                                    .treeSitterQuery(
                                                        "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")))))
                            .shortDescription("c2hvcnQgZGVzY3JpcHRpb24="))
                    .id("my-ruleset")
                    .type(CustomRulesetDataType.CUSTOM_RULESET));

    try {
      CustomRulesetResponse result = apiInstance.createCustomRuleset(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling StaticAnalysisApi#createCustomRuleset");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Instructions

First install the library and its dependencies and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
// Create Custom Ruleset returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;
use datadog_api_client::datadogV2::model::Argument;
use datadog_api_client::datadogV2::model::CustomRule;
use datadog_api_client::datadogV2::model::CustomRuleRevisionAttributesCategory;
use datadog_api_client::datadogV2::model::CustomRuleRevisionAttributesSeverity;
use datadog_api_client::datadogV2::model::CustomRuleRevisionInput;
use datadog_api_client::datadogV2::model::CustomRuleRevisionTest;
use datadog_api_client::datadogV2::model::CustomRulesetDataType;
use datadog_api_client::datadogV2::model::CustomRulesetRequest;
use datadog_api_client::datadogV2::model::CustomRulesetRequestData;
use datadog_api_client::datadogV2::model::CustomRulesetRequestDataAttributes;
use datadog_api_client::datadogV2::model::Language;

#[tokio::main]
async fn main() {
    let body = CustomRulesetRequest::new().data(CustomRulesetRequestData::new(
        CustomRulesetRequestDataAttributes::new("my-ruleset".to_string())
            .description("bG9uZyBkZXNjcmlwdGlvbg==".to_string())
            .rules(Some(vec![CustomRule::new(
                "my-rule".to_string(),
                "my-rule".to_string(),
            )
            .last_revision(
                CustomRuleRevisionInput::new()
                    .arguments(Some(vec![Argument::new(
                        "YXJndW1lbnQgZGVzY3JpcHRpb24=".to_string(),
                        "YXJndW1lbnRfbmFtZQ==".to_string(),
                    )]))
                    .category(CustomRuleRevisionAttributesCategory::SECURITY)
                    .code("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string())
                    .creation_message("Initial revision".to_string())
                    .cve(Some("CVE-2024-1234".to_string()))
                    .cwe(Some("CWE-79".to_string()))
                    .description("bG9uZyBkZXNjcmlwdGlvbg==".to_string())
                    .documentation_url(Some("https://docs.example.com/rules/my-rule".to_string()))
                    .is_published(false)
                    .is_testing(false)
                    .language(Language::PYTHON)
                    .severity(CustomRuleRevisionAttributesSeverity::ERROR)
                    .short_description("c2hvcnQgZGVzY3JpcHRpb24=".to_string())
                    .should_use_ai_fix(false)
                    .tags(Some(vec!["security".to_string(), "custom".to_string()]))
                    .tests(Some(vec![CustomRuleRevisionTest::new(
                        1,
                        "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                        "test.yaml".to_string(),
                    )]))
                    .tree_sitter_query(
                        "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                    ),
            )
            .revisions(Some(vec![CustomRuleRevisionInput::new()
                .arguments(Some(vec![Argument::new(
                    "YXJndW1lbnQgZGVzY3JpcHRpb24=".to_string(),
                    "YXJndW1lbnRfbmFtZQ==".to_string(),
                )]))
                .category(CustomRuleRevisionAttributesCategory::SECURITY)
                .code("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string())
                .creation_message("Initial revision".to_string())
                .cve(Some("CVE-2024-1234".to_string()))
                .cwe(Some("CWE-79".to_string()))
                .description("bG9uZyBkZXNjcmlwdGlvbg==".to_string())
                .documentation_url(Some("https://docs.example.com/rules/my-rule".to_string()))
                .is_published(false)
                .is_testing(false)
                .language(Language::PYTHON)
                .severity(CustomRuleRevisionAttributesSeverity::ERROR)
                .short_description("c2hvcnQgZGVzY3JpcHRpb24=".to_string())
                .should_use_ai_fix(false)
                .tags(Some(vec!["security".to_string(), "custom".to_string()]))
                .tests(Some(vec![CustomRuleRevisionTest::new(
                    1,
                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                    "test.yaml".to_string(),
                )]))
                .tree_sitter_query(
                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                )]))]))
            .short_description("c2hvcnQgZGVzY3JpcHRpb24=".to_string()),
        "my-ruleset".to_string(),
        CustomRulesetDataType::CUSTOM_RULESET,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateCustomRuleset", true);
    let api = StaticAnalysisAPI::with_config(configuration);
    let resp = api.create_custom_ruleset(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}

Instructions

First install the library and its dependencies and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * Create Custom Ruleset returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
configuration.unstableOperations["v2.createCustomRuleset"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);

const params: v2.StaticAnalysisApiCreateCustomRulesetRequest = {
  body: {
    data: {
      attributes: {
        description: "bG9uZyBkZXNjcmlwdGlvbg==",
        name: "my-ruleset",
        rules: [
          {
            id: "my-rule",
            lastRevision: {
              arguments: [
                {
                  description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  name: "YXJndW1lbnRfbmFtZQ==",
                },
              ],
              category: "SECURITY",
              code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              creationMessage: "Initial revision",
              cve: "CVE-2024-1234",
              cwe: "CWE-79",
              description: "bG9uZyBkZXNjcmlwdGlvbg==",
              documentationUrl: "https://docs.example.com/rules/my-rule",
              isPublished: false,
              isTesting: false,
              language: "PYTHON",
              severity: "ERROR",
              shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
              shouldUseAiFix: false,
              tags: ["security", "custom"],
              tests: [
                {
                  annotationCount: 1,
                  code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                  filename: "test.yaml",
                },
              ],
              treeSitterQuery:
                "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            },
            name: "my-rule",
            revisions: [
              {
                arguments: [
                  {
                    description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                    name: "YXJndW1lbnRfbmFtZQ==",
                  },
                ],
                category: "SECURITY",
                code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                creationMessage: "Initial revision",
                cve: "CVE-2024-1234",
                cwe: "CWE-79",
                description: "bG9uZyBkZXNjcmlwdGlvbg==",
                documentationUrl: "https://docs.example.com/rules/my-rule",
                isPublished: false,
                isTesting: false,
                language: "PYTHON",
                severity: "ERROR",
                shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
                shouldUseAiFix: false,
                tags: ["security", "custom"],
                tests: [
                  {
                    annotationCount: 1,
                    code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                    filename: "test.yaml",
                  },
                ],
                treeSitterQuery:
                  "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              },
            ],
          },
        ],
        shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
      },
      id: "my-ruleset",
      type: "custom_ruleset",
    },
  },
};

apiInstance
  .createCustomRuleset(params)
  .then((data: v2.CustomRulesetResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"