Skip to content

Commit 6c16ab5

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 38f6b77 of spec repo
1 parent eda32ce commit 6c16ab5

47 files changed

Lines changed: 3044 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.generator/schemas/v2/openapi.yaml‎

Lines changed: 609 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Evaluate an AI Guard request returns "OK" response
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.ai_guard_api import AIGuardApi
8+
from datadog_api_client.v2.model.ai_guard_evaluate_request import AIGuardEvaluateRequest
9+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data import AIGuardEvaluateRequestData
10+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data_attributes import AIGuardEvaluateRequestDataAttributes
11+
from datadog_api_client.v2.model.ai_guard_evaluation_type import AIGuardEvaluationType
12+
from datadog_api_client.v2.model.ai_guard_message import AIGuardMessage
13+
from datadog_api_client.v2.model.ai_guard_message_role import AIGuardMessageRole
14+
from datadog_api_client.v2.model.ai_guard_meta import AIGuardMeta
15+
16+
body = AIGuardEvaluateRequest(
17+
data=AIGuardEvaluateRequestData(
18+
type=AIGuardEvaluationType.EVALUATIONS,
19+
attributes=AIGuardEvaluateRequestDataAttributes(
20+
messages=[
21+
AIGuardMessage(
22+
content="Hello world!",
23+
role=AIGuardMessageRole.USER,
24+
),
25+
],
26+
meta=AIGuardMeta(
27+
confidence_threshold=0.8,
28+
),
29+
),
30+
),
31+
)
32+
33+
configuration = Configuration()
34+
configuration.access_token = environ["DD_BEARER_TOKEN"]
35+
configuration.unstable_operations["evaluate_ai_guard_request"] = True
36+
with ApiClient(configuration) as api_client:
37+
api_instance = AIGuardApi(api_client)
38+
response = api_instance.evaluate_ai_guard_request(body=body)
39+
40+
print(response)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
Evaluate an AI Guard request with per-category confidence thresholds
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.ai_guard_api import AIGuardApi
8+
from datadog_api_client.v2.model.ai_guard_confidence_threshold import AIGuardConfidenceThreshold
9+
from datadog_api_client.v2.model.ai_guard_evaluate_request import AIGuardEvaluateRequest
10+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data import AIGuardEvaluateRequestData
11+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data_attributes import AIGuardEvaluateRequestDataAttributes
12+
from datadog_api_client.v2.model.ai_guard_evaluation_type import AIGuardEvaluationType
13+
from datadog_api_client.v2.model.ai_guard_message import AIGuardMessage
14+
from datadog_api_client.v2.model.ai_guard_message_role import AIGuardMessageRole
15+
from datadog_api_client.v2.model.ai_guard_meta import AIGuardMeta
16+
17+
body = AIGuardEvaluateRequest(
18+
data=AIGuardEvaluateRequestData(
19+
type=AIGuardEvaluationType.EVALUATIONS,
20+
attributes=AIGuardEvaluateRequestDataAttributes(
21+
messages=[
22+
AIGuardMessage(
23+
role=AIGuardMessageRole.USER,
24+
content="Hello world!",
25+
),
26+
],
27+
meta=AIGuardMeta(
28+
confidence_threshold=AIGuardConfidenceThreshold(
29+
flagging_global=0.6,
30+
policy_evasion=0.9,
31+
indirect_prompt_injection=0.4,
32+
),
33+
),
34+
),
35+
),
36+
)
37+
38+
configuration = Configuration()
39+
configuration.access_token = environ["DD_BEARER_TOKEN"]
40+
configuration.unstable_operations["evaluate_ai_guard_request"] = True
41+
with ApiClient(configuration) as api_client:
42+
api_instance = AIGuardApi(api_client)
43+
response = api_instance.evaluate_ai_guard_request(body=body)
44+
45+
print(response)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Evaluate an AI Guard request with a numeric confidence threshold
3+
"""
4+
5+
from os import environ
6+
from datadog_api_client import ApiClient, Configuration
7+
from datadog_api_client.v2.api.ai_guard_api import AIGuardApi
8+
from datadog_api_client.v2.model.ai_guard_evaluate_request import AIGuardEvaluateRequest
9+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data import AIGuardEvaluateRequestData
10+
from datadog_api_client.v2.model.ai_guard_evaluate_request_data_attributes import AIGuardEvaluateRequestDataAttributes
11+
from datadog_api_client.v2.model.ai_guard_evaluation_type import AIGuardEvaluationType
12+
from datadog_api_client.v2.model.ai_guard_message import AIGuardMessage
13+
from datadog_api_client.v2.model.ai_guard_message_role import AIGuardMessageRole
14+
from datadog_api_client.v2.model.ai_guard_meta import AIGuardMeta
15+
16+
body = AIGuardEvaluateRequest(
17+
data=AIGuardEvaluateRequestData(
18+
type=AIGuardEvaluationType.EVALUATIONS,
19+
attributes=AIGuardEvaluateRequestDataAttributes(
20+
messages=[
21+
AIGuardMessage(
22+
role=AIGuardMessageRole.USER,
23+
content="Hello world!",
24+
),
25+
],
26+
meta=AIGuardMeta(
27+
confidence_threshold=0.8,
28+
),
29+
),
30+
),
31+
)
32+
33+
configuration = Configuration()
34+
configuration.access_token = environ["DD_BEARER_TOKEN"]
35+
configuration.unstable_operations["evaluate_ai_guard_request"] = True
36+
with ApiClient(configuration) as api_client:
37+
api_instance = AIGuardApi(api_client)
38+
response = api_instance.evaluate_ai_guard_request(body=body)
39+
40+
print(response)

‎src/datadog_api_client/configuration.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def __init__(
341341
"v2.get_execution_policy": False,
342342
"v2.list_execution_policies": False,
343343
"v2.update_execution_policy": False,
344+
"v2.evaluate_ai_guard_request": False,
344345
"v2.create_annotation": False,
345346
"v2.delete_annotation": False,
346347
"v2.get_page_annotations": False,
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Any, Dict
7+
8+
from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
9+
from datadog_api_client.configuration import Configuration
10+
from datadog_api_client.v2.model.ai_guard_evaluate_response import AIGuardEvaluateResponse
11+
from datadog_api_client.v2.model.ai_guard_evaluate_request import AIGuardEvaluateRequest
12+
13+
14+
class AIGuardApi:
15+
"""
16+
Evaluate LLM interactions for security threats such as prompt injection and jailbreak attempts.
17+
"""
18+
19+
def __init__(self, api_client=None):
20+
if api_client is None:
21+
api_client = ApiClient(Configuration())
22+
self.api_client = api_client
23+
24+
self._evaluate_ai_guard_request_endpoint = _Endpoint(
25+
settings={
26+
"response_type": (AIGuardEvaluateResponse,),
27+
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
28+
"endpoint_path": "/api/v2/ai-guard/evaluate",
29+
"operation_id": "evaluate_ai_guard_request",
30+
"http_method": "POST",
31+
"version": "v2",
32+
},
33+
params_map={
34+
"body": {
35+
"required": True,
36+
"openapi_types": (AIGuardEvaluateRequest,),
37+
"location": "body",
38+
},
39+
},
40+
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
41+
api_client=api_client,
42+
)
43+
44+
def evaluate_ai_guard_request(
45+
self,
46+
body: AIGuardEvaluateRequest,
47+
) -> AIGuardEvaluateResponse:
48+
"""Evaluate an AI Guard request.
49+
50+
Analyzes a conversation for security threats such as prompt injection,
51+
jailbreak attempts, and other AI-specific attacks. Returns an action
52+
recommendation ( ``ALLOW`` , ``DENY`` , or ``ABORT`` ) along with the detected threat
53+
tags and their confidence scores.
54+
AI Guard must be activated for the organization, and the calling user or
55+
application key requires the ``ai_guard_evaluate`` permission. The action is a
56+
recommendation for the caller to enforce: ALLOW permits the interaction,
57+
DENY blocks the interaction, and ABORT terminates the workflow.
58+
This endpoint is rate limited to ``700`` requests per minute per organization.
59+
Organization token limits can also result in a 429 response.
60+
Malformed messages return a 400 response. Requests exceeding the raw-input
61+
limit of 1,000,000 tokens return a 413 response; this limit applies to the
62+
input context, not only the size of the HTTP request body.
63+
64+
:param body: The conversation to evaluate for security threats.
65+
:type body: AIGuardEvaluateRequest
66+
:rtype: AIGuardEvaluateResponse
67+
"""
68+
kwargs: Dict[str, Any] = {}
69+
kwargs["body"] = body
70+
71+
return self._evaluate_ai_guard_request_endpoint.call_with_http_info(**kwargs)

‎src/datadog_api_client/v2/apis/__init__.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from datadog_api_client.v2.api.ai_guard_api import AIGuardApi
12
from datadog_api_client.v2.api.api_management_api import APIManagementApi
23
from datadog_api_client.v2.api.apm_api import APMApi
34
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
@@ -155,6 +156,7 @@
155156

156157

157158
__all__ = [
159+
"AIGuardApi",
158160
"APIManagementApi",
159161
"APMApi",
160162
"APMRetentionFiltersApi",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelSimple,
9+
cached_property,
10+
)
11+
12+
from typing import ClassVar
13+
14+
15+
class AIGuardAction(ModelSimple):
16+
"""
17+
The recommended action for the evaluated conversation.
18+
19+
:param value: Must be one of ["ALLOW", "DENY", "ABORT"].
20+
:type value: str
21+
"""
22+
23+
allowed_values = {
24+
"ALLOW",
25+
"DENY",
26+
"ABORT",
27+
}
28+
ALLOW: ClassVar["AIGuardAction"]
29+
DENY: ClassVar["AIGuardAction"]
30+
ABORT: ClassVar["AIGuardAction"]
31+
32+
@cached_property
33+
def openapi_types(_):
34+
return {
35+
"value": (str,),
36+
}
37+
38+
39+
AIGuardAction.ALLOW = AIGuardAction("ALLOW")
40+
AIGuardAction.DENY = AIGuardAction("DENY")
41+
AIGuardAction.ABORT = AIGuardAction("ABORT")
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
from typing import Union
7+
8+
from datadog_api_client.model_utils import (
9+
ModelNormal,
10+
cached_property,
11+
unset,
12+
UnsetType,
13+
)
14+
15+
16+
class AIGuardConfidenceThreshold(ModelNormal):
17+
@cached_property
18+
def additional_properties_type(_):
19+
return (float,)
20+
21+
@cached_property
22+
def openapi_types(_):
23+
return {
24+
"flagging_global": (float,),
25+
}
26+
27+
attribute_map = {
28+
"flagging_global": "flagging_global",
29+
}
30+
31+
def __init__(self_, flagging_global: Union[float, UnsetType] = unset, **kwargs):
32+
"""
33+
Request-level confidence threshold override. ``flagging_global`` is the global
34+
threshold applied to every threat category. Any other property is a
35+
per-category override keyed by an AI Guard threat tag; per-category values
36+
take precedence over ``flagging_global`` , and categories without an entry fall
37+
back to it. When this object omits flagging_global, the fallback is ``0.5``.
38+
Recognized category keys include policy-evasion, indirect-prompt-injection,
39+
system-and-capability-discovery, credential-access, sensitive-data-collection,
40+
privilege-escalation, malicious-execution, private-network-target,
41+
destructive-or-resource-abuse, tool-abuse, poisoning-or-persistence, and
42+
``data-exfiltration``. Unknown category keys are ignored.
43+
44+
:param flagging_global: The global confidence threshold applied to categories without a specific override.
45+
:type flagging_global: float, optional
46+
"""
47+
if flagging_global is not unset:
48+
kwargs["flagging_global"] = flagging_global
49+
super().__init__(kwargs)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
# Copyright 2019-Present Datadog, Inc.
4+
from __future__ import annotations
5+
6+
7+
from datadog_api_client.model_utils import (
8+
ModelComposed,
9+
cached_property,
10+
)
11+
12+
13+
class AIGuardConfidenceThresholdOverride(ModelComposed):
14+
def __init__(self, **kwargs):
15+
"""
16+
Request-only confidence threshold override. A number sets the threshold
17+
for every threat category; an object supplies a global threshold and
18+
optional per-category overrides. Omit this field to use the stored
19+
sensitivity policy. This field is not returned in evaluation responses.
20+
21+
:param flagging_global: The global confidence threshold applied to categories without a specific override.
22+
:type flagging_global: float, optional
23+
"""
24+
super().__init__(kwargs)
25+
26+
@cached_property
27+
def _composed_schemas(_):
28+
# we need this here to make our import statements work
29+
# we must store _composed_schemas in here so the code is only run
30+
# when we invoke this method. If we kept this at the class
31+
# level we would get an error because the class level
32+
# code would be run when this module is imported, and these composed
33+
# classes don't exist yet because their module has not finished
34+
# loading
35+
from datadog_api_client.v2.model.ai_guard_confidence_threshold import AIGuardConfidenceThreshold
36+
37+
return {
38+
"oneOf": [
39+
float,
40+
AIGuardConfidenceThreshold,
41+
],
42+
}

0 commit comments

Comments
 (0)