diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml
index dc42b6b29aa..0516704b1c3 100644
--- a/.generator/schemas/v2/openapi.yaml
+++ b/.generator/schemas/v2/openapi.yaml
@@ -2588,6 +2588,517 @@ components:
$ref: "#/components/schemas/JSONAPIErrorResponse"
description: The server cannot process the request because it contains invalid data.
schemas:
+ AIGuardAction:
+ description: The recommended action for the evaluated conversation.
+ enum:
+ - ALLOW
+ - DENY
+ - ABORT
+ example: ALLOW
+ type: string
+ x-enum-varnames:
+ - ALLOW
+ - DENY
+ - ABORT
+ AIGuardCodingAgent:
+ description: |-
+ The coding agent that produced the conversation. By default, a non-empty
+ value selects the coding-agent evaluator profile, while an omitted or empty
+ value selects the default profile. Known identifiers include `claude-code`,
+ `codex`, `cursor`, and `github-copilot`; other identifiers are accepted.
+ The coding-agent profile assumes the caller can ask the user to confirm
+ Supply Chain Firewall warnings; the default profile assumes it cannot.
+ example: claude-code
+ type: string
+ AIGuardConfidenceThreshold:
+ additionalProperties:
+ description: The confidence threshold override for the threat tag named by the property.
+ example: 0.9
+ format: double
+ type: number
+ description: |-
+ Request-level confidence threshold override. `flagging_global` is the global
+ threshold applied to every threat category. Any other property is a
+ per-category override keyed by an AI Guard threat tag; per-category values
+ take precedence over `flagging_global`, and categories without an entry fall
+ back to it. When this object omits flagging_global, the fallback is `0.5`.
+ Recognized category keys include policy-evasion, indirect-prompt-injection,
+ system-and-capability-discovery, credential-access, sensitive-data-collection,
+ privilege-escalation, malicious-execution, private-network-target,
+ destructive-or-resource-abuse, tool-abuse, poisoning-or-persistence, and
+ `data-exfiltration`. Unknown category keys are ignored.
+ example:
+ flagging_global: 0.6
+ policy-evasion: 0.9
+ properties:
+ flagging_global:
+ description: The global confidence threshold applied to categories without a specific override.
+ example: 0.6
+ format: double
+ type: number
+ type: object
+ AIGuardConfidenceThresholdOverride:
+ description: |-
+ Request-only confidence threshold override. A number sets the threshold
+ for every threat category; an object supplies a global threshold and
+ optional per-category overrides. Omit this field to use the stored
+ sensitivity policy. This field is not returned in evaluation responses.
+ oneOf:
+ - $ref: "#/components/schemas/AIGuardGlobalConfidenceThreshold"
+ - $ref: "#/components/schemas/AIGuardConfidenceThreshold"
+ AIGuardContentPart:
+ description: |-
+ One part of multipart message content, following the OpenAI content part
+ format. For user, system, developer, and tool messages, a text part must
+ include non-empty `text`, and an image part must include `image_url` with
+ a non-empty `url`. These content-part checks do not apply to assistant messages.
+ properties:
+ image_url:
+ $ref: "#/components/schemas/AIGuardImageURL"
+ text:
+ description: The text content, required and non-empty when `type` is `text` in a user, system, developer, or tool message.
+ example: What is the weather like today?
+ type: string
+ type:
+ $ref: "#/components/schemas/AIGuardContentPartType"
+ required:
+ - type
+ type: object
+ AIGuardContentPartType:
+ description: The type of the content part.
+ enum:
+ - text
+ - image_url
+ example: text
+ type: string
+ x-enum-varnames:
+ - TEXT
+ - IMAGE_URL
+ AIGuardEvaluateAttributesResponse:
+ description: The evaluation result with the recommended action and detected threat information.
+ properties:
+ action:
+ $ref: "#/components/schemas/AIGuardAction"
+ global_prob:
+ description: The global threat probability, between `0` and `1`. Included only when computed.
+ example: 0.005218505859375
+ format: double
+ type: number
+ is_blocking_enabled:
+ description: Whether blocking is enabled for the organization.
+ example: false
+ type: boolean
+ reason:
+ description: The explanation for the recommended action, for logging rather than user-facing display.
+ example: No rule match.
+ type: string
+ redaction_replacements:
+ description: The redacted replacements computed for the request. Included only when redaction applies.
+ items:
+ $ref: "#/components/schemas/AIGuardRedactionReplacement"
+ type: array
+ scfw_findings:
+ $ref: "#/components/schemas/AIGuardScfwFindings"
+ sds_findings:
+ description: The sensitive data findings from the Sensitive Data Scanner. Included only when findings exist.
+ items:
+ $ref: "#/components/schemas/AIGuardSdsFinding"
+ type: array
+ tag_probs:
+ additionalProperties:
+ description: The detection confidence for the threat tag named by the property.
+ example: 0.97
+ format: double
+ type: number
+ description: The detection confidence for each threat tag, between `0` and `1`. May be null when the evaluation does not produce per-category scores.
+ example:
+ nullable: true
+ type: object
+ tags:
+ description: The threat tags detected in the conversation.
+ example: []
+ items:
+ description: A detected threat tag.
+ example: destructive-or-resource-abuse
+ type: string
+ type: array
+ required:
+ - action
+ - reason
+ - tags
+ - tag_probs
+ - is_blocking_enabled
+ type: object
+ AIGuardEvaluateDataResponse:
+ description: The JSON:API evaluation resource.
+ properties:
+ attributes:
+ $ref: "#/components/schemas/AIGuardEvaluateAttributesResponse"
+ id:
+ description: The unique identifier of the evaluation.
+ example: a76a703c-324f-42ed-af33-9b17d65e28af
+ type: string
+ type:
+ $ref: "#/components/schemas/AIGuardEvaluationType"
+ required:
+ - id
+ - type
+ - attributes
+ type: object
+ AIGuardEvaluateRequest:
+ description: The request to evaluate a conversation for security threats.
+ example:
+ data:
+ attributes:
+ messages:
+ - content: Hello world!
+ role: user
+ meta:
+ confidence_threshold: 0.8
+ type: evaluations
+ properties:
+ data:
+ $ref: "#/components/schemas/AIGuardEvaluateRequestData"
+ required:
+ - data
+ type: object
+ AIGuardEvaluateRequestData:
+ description: The JSON:API request envelope for an AI Guard evaluation.
+ properties:
+ attributes:
+ $ref: "#/components/schemas/AIGuardEvaluateRequestDataAttributes"
+ type:
+ $ref: "#/components/schemas/AIGuardEvaluationType"
+ required:
+ - type
+ - attributes
+ type: object
+ AIGuardEvaluateRequestDataAttributes:
+ description: The conversation to evaluate and its metadata.
+ properties:
+ messages:
+ description: The messages of the conversation to evaluate, in order. Must contain at least one message.
+ items:
+ $ref: "#/components/schemas/AIGuardMessage"
+ minItems: 1
+ type: array
+ meta:
+ $ref: "#/components/schemas/AIGuardMeta"
+ required:
+ - messages
+ type: object
+ AIGuardEvaluateResponse:
+ description: The response containing the evaluation result.
+ properties:
+ data:
+ $ref: "#/components/schemas/AIGuardEvaluateDataResponse"
+ required:
+ - data
+ type: object
+ AIGuardEvaluationType:
+ description: |-
+ The JSON:API resource type for AI Guard evaluation requests and responses.
+ Its value is `evaluations` for the action endpoint `/api/v2/ai-guard/evaluate`.
+ enum:
+ - evaluations
+ example: evaluations
+ type: string
+ x-enum-varnames:
+ - EVALUATIONS
+ AIGuardGlobalConfidenceThreshold:
+ description: The global confidence threshold applied to every threat category.
+ example: 0.8
+ format: double
+ type: number
+ AIGuardImageURL:
+ description: An image referenced by URL in a message content part.
+ properties:
+ url:
+ description: The image URL or a data URI with an `image/png`, `image/jpeg`, `image/gif`, or `image/webp` MIME type.
+ example: https://example.com/image.png
+ type: string
+ required:
+ - url
+ type: object
+ AIGuardMessage:
+ description: |-
+ A message in the conversation. Content is required for user, system,
+ developer, and tool messages, but may be omitted for assistant messages.
+ For those non-assistant roles, a plain content string may be empty, but a
+ multipart content array must contain at least one valid content part.
+ Only assistant messages may contain tool calls, and tool call entries must
+ not be null. Tool messages must include a non-empty `tool_call_id`; other
+ message roles must not include a non-empty `tool_call_id`.
+ properties:
+ content:
+ $ref: "#/components/schemas/AIGuardMessageContent"
+ role:
+ $ref: "#/components/schemas/AIGuardMessageRole"
+ tool_call_id:
+ description: The identifier of the tool call this message responds to, present on tool result messages.
+ example: call_1
+ type: string
+ tool_calls:
+ description: The tool calls emitted by the assistant, present on assistant messages that call tools.
+ items:
+ $ref: "#/components/schemas/AIGuardToolCall"
+ type: array
+ required:
+ - role
+ type: object
+ AIGuardMessageContent:
+ description: The content of a message, either a plain string or a list of OpenAI-style content parts.
+ oneOf:
+ - $ref: "#/components/schemas/AIGuardMessageContentText"
+ - $ref: "#/components/schemas/AIGuardMessageContentParts"
+ AIGuardMessageContentParts:
+ description: The message content as a list of content parts. The list must be non-empty for user, system, developer, and tool messages.
+ items:
+ $ref: "#/components/schemas/AIGuardContentPart"
+ type: array
+ AIGuardMessageContentText:
+ description: The message content as a plain string.
+ example: What is the weather like today?
+ type: string
+ AIGuardMessageRole:
+ description: The role of the message author in the conversation.
+ enum:
+ - user
+ - assistant
+ - system
+ - developer
+ - tool
+ example: user
+ type: string
+ x-enum-varnames:
+ - USER
+ - ASSISTANT
+ - SYSTEM
+ - DEVELOPER
+ - TOOL
+ AIGuardMeta:
+ description: Metadata about the evaluated conversation, used to select the policy and evaluator behavior.
+ properties:
+ coding_agent:
+ $ref: "#/components/schemas/AIGuardCodingAgent"
+ confidence_threshold:
+ $ref: "#/components/schemas/AIGuardConfidenceThresholdOverride"
+ env:
+ description: The environment the conversation belongs to.
+ example: production
+ type: string
+ is_sds_enabled_override:
+ description: Whether to run the Sensitive Data Scanner for this request, overriding the stored policy.
+ example: true
+ type: boolean
+ service:
+ description: The name of the service the conversation belongs to.
+ example: my-web-app
+ type: string
+ tool_policies:
+ additionalProperties:
+ $ref: "#/components/schemas/AIGuardToolPolicyAction"
+ description: |-
+ A non-empty map replaces stored tool policies for this request only,
+ keyed by tool name. Any called tool not present resolves to EVALUATE.
+ Only takes effect when tool policies are enabled for the organization.
+ example:
+ shell: BLOCK
+ type: object
+ type: object
+ AIGuardRedactionReplacement:
+ description: The fully redacted content for one path in the request.
+ properties:
+ path:
+ description: The path of the redacted content relative to the request attributes.
+ example: messages[0].content
+ type: string
+ replacement:
+ description: The redacted replacement content.
+ example: "[REDACTED]"
+ type: string
+ required:
+ - path
+ - replacement
+ type: object
+ AIGuardScfwFindings:
+ description: |-
+ The Supply Chain Firewall verdict for the version-pinned install packages
+ found in the request. Evaluation requires Supply Chain Firewall to be enabled
+ for the organization and the caller to have the `appsec_vm_read` permission.
+ Without that permission, Supply Chain Firewall evaluation is skipped; the
+ AI Guard evaluation request itself is not rejected. Findings are omitted
+ when Supply Chain Firewall does not produce a result.
+ The recommended action combines the package outcomes.
+ Confirmation support is inferred from the evaluator profile, not from a
+ separate confirmation-capability flag. By default, a non-empty
+ `meta.coding_agent` selects the coding-agent profile, which assumes the caller
+ can ask for confirmation and retains WARN in `recommended_action`.
+ Omitting `meta.coding_agent` or setting it to an empty string selects the
+ default profile, which assumes the caller cannot ask for confirmation and
+ returns ALLOW instead of WARN in `recommended_action`. Package outcomes
+ still retain WARN, and BLOCK is never changed to ALLOW by this rule.
+ properties:
+ packages:
+ description: The packages the firewall evaluated, `ALLOW` ones included.
+ items:
+ $ref: "#/components/schemas/AIGuardScfwPackageFinding"
+ type: array
+ recommended_action:
+ $ref: "#/components/schemas/AIGuardScfwOutcome"
+ required:
+ - recommended_action
+ type: object
+ AIGuardScfwMatchedRule:
+ description: One rule the Supply Chain Firewall matched on a package, with the outcome the rule reached.
+ properties:
+ outcome:
+ $ref: "#/components/schemas/AIGuardScfwOutcome"
+ rule:
+ description: The rule text the firewall reported, or the policy type when no text was reported.
+ example: "Disallow install commands"
+ type: string
+ required:
+ - rule
+ - outcome
+ type: object
+ AIGuardScfwOutcome:
+ description: The Supply Chain Firewall outcome for a package, a matched rule, or the whole request.
+ enum:
+ - ALLOW
+ - WARN
+ - BLOCK
+ example: BLOCK
+ type: string
+ x-enum-descriptions:
+ - Proceed with the install.
+ - Confirm with the user before installing.
+ - Do not install.
+ x-enum-varnames:
+ - ALLOW
+ - WARN
+ - BLOCK
+ AIGuardScfwPackageFinding:
+ description: One package the Supply Chain Firewall evaluated, with the outcome and every matched rule.
+ properties:
+ ecosystem:
+ description: The package ecosystem the firewall evaluated, such as `PyPI`, `npm`, or `crates.io`.
+ example: npm
+ type: string
+ matched_rules:
+ description: Every rule the firewall matched on the package.
+ items:
+ $ref: "#/components/schemas/AIGuardScfwMatchedRule"
+ type: array
+ name:
+ description: The name of the package.
+ example: left-pad
+ type: string
+ outcome:
+ $ref: "#/components/schemas/AIGuardScfwOutcome"
+ version:
+ description: The version of the package.
+ example: 1.3.0
+ type: string
+ required:
+ - ecosystem
+ - name
+ - version
+ - outcome
+ type: object
+ AIGuardSdsFinding:
+ description: A sensitive data finding from the Sensitive Data Scanner.
+ properties:
+ category:
+ description: The category of the sensitive data found.
+ example: financial
+ type: string
+ location:
+ $ref: "#/components/schemas/AIGuardSdsFindingLocation"
+ rule_display_name:
+ description: The display name of the SDS rule that matched.
+ example: Credit Card Number
+ type: string
+ rule_tag:
+ description: The tag of the SDS rule that matched.
+ example: credit-card
+ type: string
+ required:
+ - rule_display_name
+ - rule_tag
+ - category
+ - location
+ type: object
+ AIGuardSdsFindingLocation:
+ description: The location of a sensitive data match within the request.
+ properties:
+ end_index_exclusive:
+ description: The exclusive end index of the match within the located content.
+ example: 42
+ format: int64
+ type: integer
+ path:
+ description: The path of the match relative to the request attributes.
+ example: messages[0].content
+ type: string
+ start_index:
+ description: The start index of the match within the located content.
+ example: 12
+ format: int64
+ type: integer
+ required:
+ - path
+ - start_index
+ - end_index_exclusive
+ type: object
+ AIGuardToolCall:
+ description: A tool call emitted by the assistant.
+ properties:
+ function:
+ $ref: "#/components/schemas/AIGuardToolCallFunction"
+ id:
+ description: The identifier of the tool call.
+ example: call_1
+ type: string
+ required:
+ - id
+ - function
+ type: object
+ AIGuardToolCallFunction:
+ description: The function invoked by a tool call.
+ properties:
+ arguments:
+ description: The arguments of the function call, serialized as a JSON string.
+ example: '{"command":"shutdown"}'
+ type: string
+ name:
+ description: The name of the function to call.
+ example: shell
+ type: string
+ required:
+ - name
+ - arguments
+ type: object
+ AIGuardToolPolicyAction:
+ description: |-
+ The policy action for a tool named by the property. Tool policies override
+ the recommendation after evaluation; they do not skip evaluation.
+ Any BLOCK takes precedence over PASS and EVALUATE. The Supply Chain Firewall
+ is applied afterward and can still return DENY.
+ enum:
+ - PASS
+ - BLOCK
+ - EVALUATE
+ example: EVALUATE
+ type: string
+ x-enum-descriptions:
+ - Recommend ALLOW when all called tools use PASS, overriding the evaluation result.
+ - Recommend DENY if any called tool uses BLOCK, overriding the evaluation result.
+ - Use the evaluation result unless another called tool uses BLOCK.
+ x-enum-varnames:
+ - PASS
+ - BLOCK
+ - EVALUATE
AIImpactUserActivityAttributes:
additionalProperties: false
description: |-
@@ -145100,6 +145611,7 @@ components:
ai_gateway_config_read: View AI Gateway configuration.
ai_gateway_config_write: Create, update, and delete AI Gateway configuration.
ai_gateway_usage: Use AI Gateway and view configuration applicable to the authenticated user.
+ ai_guard_evaluate: Evaluate conversations for security threats with AI Guard.
apm_api_catalog_read: View API catalog and API definitions.
apm_api_catalog_write: Add, modify, and delete API catalog definitions.
apm_read: Read and query APM and Trace Analytics.
@@ -148247,6 +148759,125 @@ paths:
operator: OR
permissions:
- security_monitoring_findings_read
+ /api/v2/ai-guard/evaluate:
+ post:
+ description: |-
+ Analyzes a conversation for security threats such as prompt injection,
+ jailbreak attempts, and other AI-specific attacks. Returns an action
+ recommendation (`ALLOW`, `DENY`, or `ABORT`) along with the detected threat
+ tags and their confidence scores.
+ AI Guard must be activated for the organization, and the calling user or
+ application key requires the `ai_guard_evaluate` permission. The action is a
+ recommendation for the caller to enforce: ALLOW permits the interaction,
+ DENY blocks the interaction, and ABORT terminates the workflow.
+ This endpoint is rate limited to `700` requests per minute per organization.
+ Organization token limits can also result in a 429 response.
+ Malformed messages return a 400 response. Requests exceeding the raw-input
+ limit of 1,000,000 tokens return a 413 response; this limit applies to the
+ input context, not only the size of the HTTP request body.
+ operationId: EvaluateAIGuardRequest
+ requestBody:
+ content:
+ application/json:
+ examples:
+ default:
+ summary: Evaluate a user message
+ value:
+ data:
+ attributes:
+ messages:
+ - content: Hello world!
+ role: user
+ meta:
+ confidence_threshold: 0.8
+ type: evaluations
+ per_category_threshold:
+ summary: Evaluate with per-category confidence thresholds
+ value:
+ data:
+ attributes:
+ messages:
+ - content: Hello world!
+ role: user
+ meta:
+ confidence_threshold:
+ flagging_global: 0.6
+ indirect-prompt-injection: 0.4
+ policy-evasion: 0.9
+ type: evaluations
+ schema:
+ $ref: "#/components/schemas/AIGuardEvaluateRequest"
+ description: The conversation to evaluate for security threats.
+ required: true
+ responses:
+ "200":
+ content:
+ application/json:
+ examples:
+ default:
+ summary: Evaluation of a benign user message
+ value:
+ data:
+ attributes:
+ action: ALLOW
+ global_prob: 0.005218505859375
+ is_blocking_enabled: false
+ reason: No rule match.
+ tag_probs:
+ tags: []
+ id: a76a703c-324f-42ed-af33-9b17d65e28af
+ type: evaluations
+ schema:
+ $ref: "#/components/schemas/AIGuardEvaluateResponse"
+ description: OK
+ "400":
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/JSONAPIErrorResponse"
+ description: Bad Request
+ "401":
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/JSONAPIErrorResponse"
+ description: Unauthorized
+ "403":
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/JSONAPIErrorResponse"
+ description: Forbidden
+ "408":
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/JSONAPIErrorResponse"
+ description: Request Timeout
+ "413":
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/JSONAPIErrorResponse"
+ description: Payload Too Large
+ "429":
+ $ref: "#/components/responses/TooManyRequestsResponse"
+ security:
+ - apiKeyAuth: []
+ appKeyAuth: []
+ - AuthZ:
+ - ai_guard_evaluate
+ summary: Evaluate an AI Guard request
+ tags:
+ - AI Guard
+ x-codegen-request-body-name: body
+ x-permission:
+ operator: AND
+ permissions:
+ - ai_guard_evaluate
+ x-unstable: |-
+ **Note**: This endpoint is in preview and is subject to change.
+ If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
/api/v2/ai_impact/user_activity:
post:
description: |-
@@ -256357,6 +256988,8 @@ servers:
default: api
description: The subdomain where the API is deployed.
tags:
+ - description: Evaluate LLM interactions for security threats such as prompt injection and jailbreak attempts.
+ name: AI Guard
- description: |-
Configure your API endpoints through the Datadog API.
name: API Management
diff --git a/examples/v2/ai-guard/EvaluateAIGuardRequest.java b/examples/v2/ai-guard/EvaluateAIGuardRequest.java
new file mode 100644
index 00000000000..f9064b391f0
--- /dev/null
+++ b/examples/v2/ai-guard/EvaluateAIGuardRequest.java
@@ -0,0 +1,53 @@
+// Evaluate an AI Guard request returns "OK" response
+
+import com.datadog.api.client.ApiClient;
+import com.datadog.api.client.ApiException;
+import com.datadog.api.client.v2.api.AiGuardApi;
+import com.datadog.api.client.v2.model.AIGuardConfidenceThresholdOverride;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequest;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestData;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestDataAttributes;
+import com.datadog.api.client.v2.model.AIGuardEvaluateResponse;
+import com.datadog.api.client.v2.model.AIGuardEvaluationType;
+import com.datadog.api.client.v2.model.AIGuardMessage;
+import com.datadog.api.client.v2.model.AIGuardMessageContent;
+import com.datadog.api.client.v2.model.AIGuardMessageRole;
+import com.datadog.api.client.v2.model.AIGuardMeta;
+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.evaluateAIGuardRequest", true);
+ AiGuardApi apiInstance = new AiGuardApi(defaultClient);
+
+ AIGuardEvaluateRequest body =
+ new AIGuardEvaluateRequest()
+ .data(
+ new AIGuardEvaluateRequestData()
+ .type(AIGuardEvaluationType.EVALUATIONS)
+ .attributes(
+ new AIGuardEvaluateRequestDataAttributes()
+ .messages(
+ Collections.singletonList(
+ new AIGuardMessage()
+ .content(new AIGuardMessageContent("Hello world!"))
+ .role(AIGuardMessageRole.USER)))
+ .meta(
+ new AIGuardMeta()
+ .confidenceThreshold(
+ new AIGuardConfidenceThresholdOverride(0.8)))));
+
+ try {
+ AIGuardEvaluateResponse result = apiInstance.evaluateAIGuardRequest(body);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AiGuardApi#evaluateAIGuardRequest");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/v2/ai-guard/EvaluateAIGuardRequest_1377048937.java b/examples/v2/ai-guard/EvaluateAIGuardRequest_1377048937.java
new file mode 100644
index 00000000000..8f32c8fc9f6
--- /dev/null
+++ b/examples/v2/ai-guard/EvaluateAIGuardRequest_1377048937.java
@@ -0,0 +1,59 @@
+// Evaluate an AI Guard request with per-category confidence thresholds
+
+import com.datadog.api.client.ApiClient;
+import com.datadog.api.client.ApiException;
+import com.datadog.api.client.v2.api.AiGuardApi;
+import com.datadog.api.client.v2.model.AIGuardConfidenceThreshold;
+import com.datadog.api.client.v2.model.AIGuardConfidenceThresholdOverride;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequest;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestData;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestDataAttributes;
+import com.datadog.api.client.v2.model.AIGuardEvaluateResponse;
+import com.datadog.api.client.v2.model.AIGuardEvaluationType;
+import com.datadog.api.client.v2.model.AIGuardMessage;
+import com.datadog.api.client.v2.model.AIGuardMessageContent;
+import com.datadog.api.client.v2.model.AIGuardMessageRole;
+import com.datadog.api.client.v2.model.AIGuardMeta;
+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.evaluateAIGuardRequest", true);
+ AiGuardApi apiInstance = new AiGuardApi(defaultClient);
+
+ AIGuardEvaluateRequest body =
+ new AIGuardEvaluateRequest()
+ .data(
+ new AIGuardEvaluateRequestData()
+ .type(AIGuardEvaluationType.EVALUATIONS)
+ .attributes(
+ new AIGuardEvaluateRequestDataAttributes()
+ .messages(
+ Collections.singletonList(
+ new AIGuardMessage()
+ .role(AIGuardMessageRole.USER)
+ .content(new AIGuardMessageContent("Hello world!"))))
+ .meta(
+ new AIGuardMeta()
+ .confidenceThreshold(
+ new AIGuardConfidenceThresholdOverride(
+ new AIGuardConfidenceThreshold()
+ .flaggingGlobal(0.6)
+ .putAdditionalProperty("policy-evasion", 0.9)
+ .putAdditionalProperty(
+ "indirect-prompt-injection", 0.4))))));
+
+ try {
+ AIGuardEvaluateResponse result = apiInstance.evaluateAIGuardRequest(body);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AiGuardApi#evaluateAIGuardRequest");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/examples/v2/ai-guard/EvaluateAIGuardRequest_3923646360.java b/examples/v2/ai-guard/EvaluateAIGuardRequest_3923646360.java
new file mode 100644
index 00000000000..cf26f6447dc
--- /dev/null
+++ b/examples/v2/ai-guard/EvaluateAIGuardRequest_3923646360.java
@@ -0,0 +1,53 @@
+// Evaluate an AI Guard request with a numeric confidence threshold
+
+import com.datadog.api.client.ApiClient;
+import com.datadog.api.client.ApiException;
+import com.datadog.api.client.v2.api.AiGuardApi;
+import com.datadog.api.client.v2.model.AIGuardConfidenceThresholdOverride;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequest;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestData;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequestDataAttributes;
+import com.datadog.api.client.v2.model.AIGuardEvaluateResponse;
+import com.datadog.api.client.v2.model.AIGuardEvaluationType;
+import com.datadog.api.client.v2.model.AIGuardMessage;
+import com.datadog.api.client.v2.model.AIGuardMessageContent;
+import com.datadog.api.client.v2.model.AIGuardMessageRole;
+import com.datadog.api.client.v2.model.AIGuardMeta;
+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.evaluateAIGuardRequest", true);
+ AiGuardApi apiInstance = new AiGuardApi(defaultClient);
+
+ AIGuardEvaluateRequest body =
+ new AIGuardEvaluateRequest()
+ .data(
+ new AIGuardEvaluateRequestData()
+ .type(AIGuardEvaluationType.EVALUATIONS)
+ .attributes(
+ new AIGuardEvaluateRequestDataAttributes()
+ .messages(
+ Collections.singletonList(
+ new AIGuardMessage()
+ .role(AIGuardMessageRole.USER)
+ .content(new AIGuardMessageContent("Hello world!"))))
+ .meta(
+ new AIGuardMeta()
+ .confidenceThreshold(
+ new AIGuardConfidenceThresholdOverride(0.8)))));
+
+ try {
+ AIGuardEvaluateResponse result = apiInstance.evaluateAIGuardRequest(body);
+ System.out.println(result);
+ } catch (ApiException e) {
+ System.err.println("Exception when calling AiGuardApi#evaluateAIGuardRequest");
+ System.err.println("Status code: " + e.getCode());
+ System.err.println("Reason: " + e.getResponseBody());
+ System.err.println("Response headers: " + e.getResponseHeaders());
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java
index cfe6a77ca07..78c7dec0e9b 100644
--- a/src/main/java/com/datadog/api/client/ApiClient.java
+++ b/src/main/java/com/datadog/api/client/ApiClient.java
@@ -1145,6 +1145,7 @@ public class ApiClient {
put("v2.getExecutionPolicy", false);
put("v2.listExecutionPolicies", false);
put("v2.updateExecutionPolicy", false);
+ put("v2.evaluateAIGuardRequest", false);
put("v2.createAnnotation", false);
put("v2.deleteAnnotation", false);
put("v2.getPageAnnotations", false);
diff --git a/src/main/java/com/datadog/api/client/v2/api/AiGuardApi.java b/src/main/java/com/datadog/api/client/v2/api/AiGuardApi.java
new file mode 100644
index 00000000000..78331864f77
--- /dev/null
+++ b/src/main/java/com/datadog/api/client/v2/api/AiGuardApi.java
@@ -0,0 +1,209 @@
+package com.datadog.api.client.v2.api;
+
+import com.datadog.api.client.ApiClient;
+import com.datadog.api.client.ApiException;
+import com.datadog.api.client.ApiResponse;
+import com.datadog.api.client.Pair;
+import com.datadog.api.client.v2.model.AIGuardEvaluateRequest;
+import com.datadog.api.client.v2.model.AIGuardEvaluateResponse;
+import jakarta.ws.rs.client.Invocation;
+import jakarta.ws.rs.core.GenericType;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+@jakarta.annotation.Generated(
+ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
+public class AiGuardApi {
+ private ApiClient apiClient;
+
+ public AiGuardApi() {
+ this(ApiClient.getDefaultApiClient());
+ }
+
+ public AiGuardApi(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * Get the API client.
+ *
+ * @return API client
+ */
+ public ApiClient getApiClient() {
+ return apiClient;
+ }
+
+ /**
+ * Set the API client.
+ *
+ * @param apiClient an instance of API client
+ */
+ public void setApiClient(ApiClient apiClient) {
+ this.apiClient = apiClient;
+ }
+
+ /**
+ * Evaluate an AI Guard request.
+ *
+ *
See {@link #evaluateAIGuardRequestWithHttpInfo}.
+ *
+ * @param body The conversation to evaluate for security threats. (required)
+ * @return AIGuardEvaluateResponse
+ * @throws ApiException if fails to make API call
+ */
+ public AIGuardEvaluateResponse evaluateAIGuardRequest(AIGuardEvaluateRequest body)
+ throws ApiException {
+ return evaluateAIGuardRequestWithHttpInfo(body).getData();
+ }
+
+ /**
+ * Evaluate an AI Guard request.
+ *
+ *
See {@link #evaluateAIGuardRequestWithHttpInfoAsync}.
+ *
+ * @param body The conversation to evaluate for security threats. (required)
+ * @return CompletableFuture<AIGuardEvaluateResponse>
+ */
+ public CompletableFuture evaluateAIGuardRequestAsync(
+ AIGuardEvaluateRequest body) {
+ return evaluateAIGuardRequestWithHttpInfoAsync(body)
+ .thenApply(
+ response -> {
+ return response.getData();
+ });
+ }
+
+ /**
+ * Analyzes a conversation for security threats such as prompt injection, jailbreak attempts, and
+ * other AI-specific attacks. Returns an action recommendation (ALLOW, DENY
+ * , or ABORT) along with the detected threat tags and their confidence
+ * scores. AI Guard must be activated for the organization, and the calling user or application
+ * key requires the ai_guard_evaluate permission. The action is a recommendation for
+ * the caller to enforce: ALLOW permits the interaction, DENY blocks the interaction, and ABORT
+ * terminates the workflow. This endpoint is rate limited to 700 requests per minute
+ * per organization. Organization token limits can also result in a 429 response. Malformed
+ * messages return a 400 response. Requests exceeding the raw-input limit of 1,000,000 tokens
+ * return a 413 response; this limit applies to the input context, not only the size of the HTTP
+ * request body.
+ *
+ * @param body The conversation to evaluate for security threats. (required)
+ * @return ApiResponse<AIGuardEvaluateResponse>
+ * @throws ApiException if fails to make API call
+ * @http.response.details
+ *
+ * Response details
+ * | Status Code | Description | Response Headers |
+ * | 200 | OK | - |
+ * | 400 | Bad Request | - |
+ * | 401 | Unauthorized | - |
+ * | 403 | Forbidden | - |
+ * | 408 | Request Timeout | - |
+ * | 413 | Payload Too Large | - |
+ * | 429 | Too many requests | - |
+ *
+ */
+ public ApiResponse evaluateAIGuardRequestWithHttpInfo(
+ AIGuardEvaluateRequest body) throws ApiException {
+ // Check if unstable operation is enabled
+ String operationId = "evaluateAIGuardRequest";
+ if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
+ apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
+ } else {
+ throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId));
+ }
+ Object localVarPostBody = body;
+
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ throw new ApiException(
+ 400, "Missing the required parameter 'body' when calling evaluateAIGuardRequest");
+ }
+ // create path and map variables
+ String localVarPath = "/api/v2/ai-guard/evaluate";
+
+ Map localVarHeaderParams = new HashMap();
+
+ Invocation.Builder builder =
+ apiClient.createBuilder(
+ "v2.AiGuardApi.evaluateAIGuardRequest",
+ localVarPath,
+ new ArrayList(),
+ localVarHeaderParams,
+ new HashMap(),
+ new String[] {"application/json"},
+ new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
+ return apiClient.invokeAPI(
+ "POST",
+ builder,
+ localVarHeaderParams,
+ new String[] {"application/json"},
+ localVarPostBody,
+ new HashMap(),
+ false,
+ new GenericType() {});
+ }
+
+ /**
+ * Evaluate an AI Guard request.
+ *
+ * See {@link #evaluateAIGuardRequestWithHttpInfo}.
+ *
+ * @param body The conversation to evaluate for security threats. (required)
+ * @return CompletableFuture<ApiResponse<AIGuardEvaluateResponse>>
+ */
+ public CompletableFuture>
+ evaluateAIGuardRequestWithHttpInfoAsync(AIGuardEvaluateRequest body) {
+ // Check if unstable operation is enabled
+ String operationId = "evaluateAIGuardRequest";
+ if (apiClient.isUnstableOperationEnabled("v2." + operationId)) {
+ apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId));
+ } else {
+ CompletableFuture> result = new CompletableFuture<>();
+ result.completeExceptionally(
+ new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)));
+ return result;
+ }
+ Object localVarPostBody = body;
+
+ // verify the required parameter 'body' is set
+ if (body == null) {
+ CompletableFuture> result = new CompletableFuture<>();
+ result.completeExceptionally(
+ new ApiException(
+ 400, "Missing the required parameter 'body' when calling evaluateAIGuardRequest"));
+ return result;
+ }
+ // create path and map variables
+ String localVarPath = "/api/v2/ai-guard/evaluate";
+
+ Map localVarHeaderParams = new HashMap();
+
+ Invocation.Builder builder;
+ try {
+ builder =
+ apiClient.createBuilder(
+ "v2.AiGuardApi.evaluateAIGuardRequest",
+ localVarPath,
+ new ArrayList(),
+ localVarHeaderParams,
+ new HashMap(),
+ new String[] {"application/json"},
+ new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"});
+ } catch (ApiException ex) {
+ CompletableFuture> result = new CompletableFuture<>();
+ result.completeExceptionally(ex);
+ return result;
+ }
+ return apiClient.invokeAPIAsync(
+ "POST",
+ builder,
+ localVarHeaderParams,
+ new String[] {"application/json"},
+ localVarPostBody,
+ new HashMap(),
+ false,
+ new GenericType() {});
+ }
+}
diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardAction.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardAction.java
new file mode 100644
index 00000000000..f3afa55f79d
--- /dev/null
+++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardAction.java
@@ -0,0 +1,56 @@
+/*
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
+ * Copyright 2019-Present Datadog, Inc.
+ */
+
+package com.datadog.api.client.v2.model;
+
+import com.datadog.api.client.ModelEnum;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/** The recommended action for the evaluated conversation. */
+@JsonSerialize(using = AIGuardAction.AIGuardActionSerializer.class)
+public class AIGuardAction extends ModelEnum {
+
+ private static final Set allowedValues =
+ new HashSet(Arrays.asList("ALLOW", "DENY", "ABORT"));
+
+ public static final AIGuardAction ALLOW = new AIGuardAction("ALLOW");
+ public static final AIGuardAction DENY = new AIGuardAction("DENY");
+ public static final AIGuardAction ABORT = new AIGuardAction("ABORT");
+
+ AIGuardAction(String value) {
+ super(value, allowedValues);
+ }
+
+ public static class AIGuardActionSerializer extends StdSerializer {
+ public AIGuardActionSerializer(Class t) {
+ super(t);
+ }
+
+ public AIGuardActionSerializer() {
+ this(null);
+ }
+
+ @Override
+ public void serialize(AIGuardAction value, JsonGenerator jgen, SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ jgen.writeObject(value.value);
+ }
+ }
+
+ @JsonCreator
+ public static AIGuardAction fromValue(String value) {
+ return new AIGuardAction(value);
+ }
+}
diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThreshold.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThreshold.java
new file mode 100644
index 00000000000..042f5246194
--- /dev/null
+++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThreshold.java
@@ -0,0 +1,146 @@
+/*
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
+ * Copyright 2019-Present Datadog, Inc.
+ */
+
+package com.datadog.api.client.v2.model;
+
+import com.fasterxml.jackson.annotation.JsonAnyGetter;
+import com.fasterxml.jackson.annotation.JsonAnySetter;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Request-level confidence threshold override. flagging_global is the global threshold
+ * applied to every threat category. Any other property is a per-category override keyed by an AI
+ * Guard threat tag; per-category values take precedence over flagging_global, and
+ * categories without an entry fall back to it. When this object omits flagging_global, the fallback
+ * is 0.5. Recognized category keys include policy-evasion, indirect-prompt-injection,
+ * system-and-capability-discovery, credential-access, sensitive-data-collection,
+ * privilege-escalation, malicious-execution, private-network-target, destructive-or-resource-abuse,
+ * tool-abuse, poisoning-or-persistence, and data-exfiltration. Unknown category keys
+ * are ignored.
+ */
+@JsonPropertyOrder({AIGuardConfidenceThreshold.JSON_PROPERTY_FLAGGING_GLOBAL})
+@jakarta.annotation.Generated(
+ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
+public class AIGuardConfidenceThreshold {
+ @JsonIgnore public boolean unparsed = false;
+ public static final String JSON_PROPERTY_FLAGGING_GLOBAL = "flagging_global";
+ private Double flaggingGlobal;
+
+ public AIGuardConfidenceThreshold flaggingGlobal(Double flaggingGlobal) {
+ this.flaggingGlobal = flaggingGlobal;
+ return this;
+ }
+
+ /**
+ * The global confidence threshold applied to categories without a specific override.
+ *
+ * @return flaggingGlobal
+ */
+ @jakarta.annotation.Nullable
+ @JsonProperty(JSON_PROPERTY_FLAGGING_GLOBAL)
+ @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
+ public Double getFlaggingGlobal() {
+ return flaggingGlobal;
+ }
+
+ public void setFlaggingGlobal(Double flaggingGlobal) {
+ this.flaggingGlobal = flaggingGlobal;
+ }
+
+ /**
+ * A container for additional, undeclared properties. This is a holder for any undeclared
+ * properties as specified with the 'additionalProperties' keyword in the OAS document.
+ */
+ private Map additionalProperties;
+
+ /**
+ * Set the additional (undeclared) property with the specified name and value. If the property
+ * does not already exist, create it otherwise replace it.
+ *
+ * @param key The arbitrary key to set
+ * @param value The associated value
+ * @return AIGuardConfidenceThreshold
+ */
+ @JsonAnySetter
+ public AIGuardConfidenceThreshold putAdditionalProperty(String key, Double value) {
+ if (this.additionalProperties == null) {
+ this.additionalProperties = new HashMap();
+ }
+ this.additionalProperties.put(key, value);
+ return this;
+ }
+
+ /**
+ * Return the additional (undeclared) property.
+ *
+ * @return The additional properties
+ */
+ @JsonAnyGetter
+ public Map getAdditionalProperties() {
+ return additionalProperties;
+ }
+
+ /**
+ * Return the additional (undeclared) property with the specified name.
+ *
+ * @param key The arbitrary key to get
+ * @return The specific additional property for the given key
+ */
+ public Double getAdditionalProperty(String key) {
+ if (this.additionalProperties == null) {
+ return null;
+ }
+ return this.additionalProperties.get(key);
+ }
+
+ /** Return true if this AIGuardConfidenceThreshold object is equal to o. */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ AIGuardConfidenceThreshold aiGuardConfidenceThreshold = (AIGuardConfidenceThreshold) o;
+ return Objects.equals(this.flaggingGlobal, aiGuardConfidenceThreshold.flaggingGlobal)
+ && Objects.equals(
+ this.additionalProperties, aiGuardConfidenceThreshold.additionalProperties);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(flaggingGlobal, additionalProperties);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class AIGuardConfidenceThreshold {\n");
+ sb.append(" flaggingGlobal: ").append(toIndentedString(flaggingGlobal)).append("\n");
+ sb.append(" additionalProperties: ")
+ .append(toIndentedString(additionalProperties))
+ .append("\n");
+ sb.append('}');
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces (except the first line).
+ */
+ private String toIndentedString(Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThresholdOverride.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThresholdOverride.java
new file mode 100644
index 00000000000..0f744ff47b0
--- /dev/null
+++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThresholdOverride.java
@@ -0,0 +1,281 @@
+/*
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
+ * Copyright 2019-Present Datadog, Inc.
+ */
+
+package com.datadog.api.client.v2.model;
+
+import com.datadog.api.client.AbstractOpenApiSchema;
+import com.datadog.api.client.JSON;
+import com.datadog.api.client.UnparsedObject;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
+import com.fasterxml.jackson.databind.ser.std.StdSerializer;
+import jakarta.ws.rs.core.GenericType;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+@jakarta.annotation.Generated(
+ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
+@JsonDeserialize(
+ using = AIGuardConfidenceThresholdOverride.AIGuardConfidenceThresholdOverrideDeserializer.class)
+@JsonSerialize(
+ using = AIGuardConfidenceThresholdOverride.AIGuardConfidenceThresholdOverrideSerializer.class)
+public class AIGuardConfidenceThresholdOverride extends AbstractOpenApiSchema {
+ private static final Logger log =
+ Logger.getLogger(AIGuardConfidenceThresholdOverride.class.getName());
+
+ @JsonIgnore public boolean unparsed = false;
+
+ public static class AIGuardConfidenceThresholdOverrideSerializer
+ extends StdSerializer {
+ public AIGuardConfidenceThresholdOverrideSerializer(
+ Class t) {
+ super(t);
+ }
+
+ public AIGuardConfidenceThresholdOverrideSerializer() {
+ this(null);
+ }
+
+ @Override
+ public void serialize(
+ AIGuardConfidenceThresholdOverride value, JsonGenerator jgen, SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ jgen.writeObject(value.getActualInstance());
+ }
+ }
+
+ public static class AIGuardConfidenceThresholdOverrideDeserializer
+ extends StdDeserializer {
+ public AIGuardConfidenceThresholdOverrideDeserializer() {
+ this(AIGuardConfidenceThresholdOverride.class);
+ }
+
+ public AIGuardConfidenceThresholdOverrideDeserializer(Class> vc) {
+ super(vc);
+ }
+
+ @Override
+ public AIGuardConfidenceThresholdOverride deserialize(
+ JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
+ JsonNode tree = jp.readValueAsTree();
+ Object deserialized = null;
+ Object tmp = null;
+ boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
+ int match = 0;
+ JsonToken token = tree.traverse(jp.getCodec()).nextToken();
+ // deserialize Double
+ try {
+ boolean attemptParsing = true;
+ // ensure that we respect type coercion as set on the client ObjectMapper
+ if (Double.class.equals(Integer.class)
+ || Double.class.equals(Long.class)
+ || Double.class.equals(Float.class)
+ || Double.class.equals(Double.class)
+ || Double.class.equals(Boolean.class)
+ || Double.class.equals(String.class)) {
+ attemptParsing = typeCoercion;
+ if (!attemptParsing) {
+ attemptParsing |=
+ ((Double.class.equals(Integer.class) || Double.class.equals(Long.class))
+ && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |=
+ ((Double.class.equals(Float.class) || Double.class.equals(Double.class))
+ && (token == JsonToken.VALUE_NUMBER_FLOAT
+ || token == JsonToken.VALUE_NUMBER_INT));
+ attemptParsing |=
+ (Double.class.equals(Boolean.class)
+ && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |=
+ (Double.class.equals(String.class) && token == JsonToken.VALUE_STRING);
+ }
+ }
+ if (attemptParsing) {
+ tmp = tree.traverse(jp.getCodec()).readValueAs(Double.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ deserialized = tmp;
+ match++;
+
+ log.log(Level.FINER, "Input data matches schema 'Double'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(Level.FINER, "Input data does not match schema 'Double'", e);
+ }
+
+ // deserialize AIGuardConfidenceThreshold
+ try {
+ boolean attemptParsing = true;
+ // ensure that we respect type coercion as set on the client ObjectMapper
+ if (AIGuardConfidenceThreshold.class.equals(Integer.class)
+ || AIGuardConfidenceThreshold.class.equals(Long.class)
+ || AIGuardConfidenceThreshold.class.equals(Float.class)
+ || AIGuardConfidenceThreshold.class.equals(Double.class)
+ || AIGuardConfidenceThreshold.class.equals(Boolean.class)
+ || AIGuardConfidenceThreshold.class.equals(String.class)) {
+ attemptParsing = typeCoercion;
+ if (!attemptParsing) {
+ attemptParsing |=
+ ((AIGuardConfidenceThreshold.class.equals(Integer.class)
+ || AIGuardConfidenceThreshold.class.equals(Long.class))
+ && token == JsonToken.VALUE_NUMBER_INT);
+ attemptParsing |=
+ ((AIGuardConfidenceThreshold.class.equals(Float.class)
+ || AIGuardConfidenceThreshold.class.equals(Double.class))
+ && (token == JsonToken.VALUE_NUMBER_FLOAT
+ || token == JsonToken.VALUE_NUMBER_INT));
+ attemptParsing |=
+ (AIGuardConfidenceThreshold.class.equals(Boolean.class)
+ && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
+ attemptParsing |=
+ (AIGuardConfidenceThreshold.class.equals(String.class)
+ && token == JsonToken.VALUE_STRING);
+ }
+ }
+ if (attemptParsing) {
+ tmp = tree.traverse(jp.getCodec()).readValueAs(AIGuardConfidenceThreshold.class);
+ // TODO: there is no validation against JSON schema constraints
+ // (min, max, enum, pattern...), this does not perform a strict JSON
+ // validation, which means the 'match' count may be higher than it should be.
+ if (!((AIGuardConfidenceThreshold) tmp).unparsed) {
+ deserialized = tmp;
+ match++;
+ }
+ log.log(Level.FINER, "Input data matches schema 'AIGuardConfidenceThreshold'");
+ }
+ } catch (Exception e) {
+ // deserialization failed, continue
+ log.log(Level.FINER, "Input data does not match schema 'AIGuardConfidenceThreshold'", e);
+ }
+
+ AIGuardConfidenceThresholdOverride ret = new AIGuardConfidenceThresholdOverride();
+ if (match == 1) {
+ ret.setActualInstance(deserialized);
+ } else {
+ Map res =
+ new ObjectMapper()
+ .readValue(
+ tree.traverse(jp.getCodec()).readValueAsTree().toString(),
+ new TypeReference