Create an AI memory violation result
https://api.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.us3.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.us5.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.datadoghq.eu/api/v2/static-analysis/ai/memoryhttps://api.ap1.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.ap2.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.uk1.datadoghq.com/api/v2/static-analysis/ai/memoryhttps://api.ddog-gov.com/api/v2/static-analysis/ai/memoryhttps://api.us2.ddog-gov.com/api/v2/static-analysis/ai/memory概要
Add a new AI memory violation result for the authenticated organization.
リクエスト
Body Data (required)
dataRequest data for creating an AI memory violation result.
attributesAttributes for creating an AI memory violation result.
line [required]The line number where the violation was found.
message [required]A message explaining the violation result.
name [required]The file path where the violation was found.
repository_id [required]The repository identifier.
rule [required]The rule identifier in the format ruleset/rule.
sha [required]The git commit SHA where the violation was found.
type [required]The type of AI memory violation result indicating whether it is a true positive or false positive.
TP, FPidThe violation result identifier.
typeAI memory violation result resource type.
ai_memory_violation_result{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive because the input is sanitized.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}応答
Successfully created
Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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"
}
]
}Not Found
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Internal Server Error
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort 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"
}
]
}コード例
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/static-analysis/ai/memory" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"line": 10,
"message": "This is a false positive.",
"name": "src/main.py",
"repository_id": "my-repo",
"rule": "my-ai-ruleset/my-ai-rule",
"sha": "abc123def456789012345678901234567890abcd",
"type": "FP"
},
"id": "violation-abc",
"type": "ai_memory_violation_result"
}
}
EOF// Create an AI memory violation result returns "Successfully created" response
package main
import (
"context"
"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.AiMemoryViolationResultRequest{
Data: &datadogV2.AiMemoryViolationResultRequestData{
Attributes: &datadogV2.AiMemoryViolationResultRequestAttributes{
Line: 10,
Message: "This is a false positive because the input is sanitized.",
Name: "src/main.py",
RepositoryId: "my-repo",
Rule: "my-ai-ruleset/my-ai-rule",
Sha: "abc123def456789012345678901234567890abcd",
Type: datadogV2.AIMEMORYVIOLATIONTYPE_FP,
},
Id: datadog.PtrString("violation-abc"),
Type: datadogV2.AIMEMORYVIOLATIONRESULTDATATYPE_AI_MEMORY_VIOLATION_RESULT.Ptr(),
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateAiMemoryViolationResult", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewStaticAnalysisApi(apiClient)
r, err := api.CreateAiMemoryViolationResult(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `StaticAnalysisApi.CreateAiMemoryViolationResult`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create an AI memory violation result returns "Successfully created" 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.AiMemoryViolationResultDataType;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequest;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequestAttributes;
import com.datadog.api.client.v2.model.AiMemoryViolationResultRequestData;
import com.datadog.api.client.v2.model.AiMemoryViolationType;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createAiMemoryViolationResult", true);
StaticAnalysisApi apiInstance = new StaticAnalysisApi(defaultClient);
AiMemoryViolationResultRequest body =
new AiMemoryViolationResultRequest()
.data(
new AiMemoryViolationResultRequestData()
.attributes(
new AiMemoryViolationResultRequestAttributes()
.line(10L)
.message("This is a false positive because the input is sanitized.")
.name("src/main.py")
.repositoryId("my-repo")
.rule("my-ai-ruleset/my-ai-rule")
.sha("abc123def456789012345678901234567890abcd")
.type(AiMemoryViolationType.FP))
.id("violation-abc")
.type(AiMemoryViolationResultDataType.AI_MEMORY_VIOLATION_RESULT));
try {
apiInstance.createAiMemoryViolationResult(body);
} catch (ApiException e) {
System.err.println("Exception when calling StaticAnalysisApi#createAiMemoryViolationResult");
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create an AI memory violation result returns "Successfully created" 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.ai_memory_violation_result_data_type import AiMemoryViolationResultDataType
from datadog_api_client.v2.model.ai_memory_violation_result_request import AiMemoryViolationResultRequest
from datadog_api_client.v2.model.ai_memory_violation_result_request_attributes import (
AiMemoryViolationResultRequestAttributes,
)
from datadog_api_client.v2.model.ai_memory_violation_result_request_data import AiMemoryViolationResultRequestData
from datadog_api_client.v2.model.ai_memory_violation_type import AiMemoryViolationType
body = AiMemoryViolationResultRequest(
data=AiMemoryViolationResultRequestData(
attributes=AiMemoryViolationResultRequestAttributes(
line=10,
message="This is a false positive because the input is sanitized.",
name="src/main.py",
repository_id="my-repo",
rule="my-ai-ruleset/my-ai-rule",
sha="abc123def456789012345678901234567890abcd",
type=AiMemoryViolationType.FP,
),
id="violation-abc",
type=AiMemoryViolationResultDataType.AI_MEMORY_VIOLATION_RESULT,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_ai_memory_violation_result"] = True
with ApiClient(configuration) as api_client:
api_instance = StaticAnalysisApi(api_client)
api_instance.create_ai_memory_violation_result(body=body)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create an AI memory violation result returns "Successfully created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_ai_memory_violation_result".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new
body = DatadogAPIClient::V2::AiMemoryViolationResultRequest.new({
data: DatadogAPIClient::V2::AiMemoryViolationResultRequestData.new({
attributes: DatadogAPIClient::V2::AiMemoryViolationResultRequestAttributes.new({
line: 10,
message: "This is a false positive because the input is sanitized.",
name: "src/main.py",
repository_id: "my-repo",
rule: "my-ai-ruleset/my-ai-rule",
sha: "abc123def456789012345678901234567890abcd",
type: DatadogAPIClient::V2::AiMemoryViolationType::FP,
}),
id: "violation-abc",
type: DatadogAPIClient::V2::AiMemoryViolationResultDataType::AI_MEMORY_VIOLATION_RESULT,
}),
})
p api_instance.create_ai_memory_violation_result(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create an AI memory violation result returns "Successfully created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultDataType;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequest;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequestAttributes;
use datadog_api_client::datadogV2::model::AiMemoryViolationResultRequestData;
use datadog_api_client::datadogV2::model::AiMemoryViolationType;
#[tokio::main]
async fn main() {
let body = AiMemoryViolationResultRequest::new().data(
AiMemoryViolationResultRequestData::new()
.attributes(AiMemoryViolationResultRequestAttributes::new(
10,
"This is a false positive because the input is sanitized.".to_string(),
"src/main.py".to_string(),
"my-repo".to_string(),
"my-ai-ruleset/my-ai-rule".to_string(),
"abc123def456789012345678901234567890abcd".to_string(),
AiMemoryViolationType::FP,
))
.id("violation-abc".to_string())
.type_(AiMemoryViolationResultDataType::AI_MEMORY_VIOLATION_RESULT),
);
let mut configuration = datadog::Configuration::new();
configuration.set_unstable_operation_enabled("v2.create_ai_memory_violation_result", true);
let api = StaticAnalysisAPI::with_config(configuration);
let resp = api.create_ai_memory_violation_result(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.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create an AI memory violation result returns "Successfully created" 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.createAiMemoryViolationResult"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);
const params: v2.StaticAnalysisApiCreateAiMemoryViolationResultRequest = {
body: {
data: {
attributes: {
line: 10,
message: "This is a false positive because the input is sanitized.",
name: "src/main.py",
repositoryId: "my-repo",
rule: "my-ai-ruleset/my-ai-rule",
sha: "abc123def456789012345678901234567890abcd",
type: "FP",
},
id: "violation-abc",
type: "ai_memory_violation_result",
},
},
};
apiInstance
.createAiMemoryViolationResult(params)
.then((data: any) => {
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.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"