From 2582f4ab08428c97d1cf0a83c88a15e0d9b3ee2c Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 30 Oct 2026 08:12:59 +0000 Subject: [PATCH] Regenerate client from commit f590ad8 of spec repo --- .generator/schemas/v2/openapi.yaml | 633 ++++++++++++++++++ .../v2/ai-guard/EvaluateAIGuardRequest.java | 53 ++ .../EvaluateAIGuardRequest_1377048937.java | 59 ++ .../EvaluateAIGuardRequest_3923646360.java | 53 ++ .../com/datadog/api/client/ApiClient.java | 1 + .../datadog/api/client/v2/api/AiGuardApi.java | 209 ++++++ .../api/client/v2/model/AIGuardAction.java | 56 ++ .../v2/model/AIGuardConfidenceThreshold.java | 146 ++++ .../AIGuardConfidenceThresholdOverride.java | 281 ++++++++ .../client/v2/model/AIGuardContentPart.java | 214 ++++++ .../v2/model/AIGuardContentPartType.java | 57 ++ .../AIGuardEvaluateAttributesResponse.java | 459 +++++++++++++ .../v2/model/AIGuardEvaluateDataResponse.java | 214 ++++++ .../v2/model/AIGuardEvaluateRequest.java | 148 ++++ .../v2/model/AIGuardEvaluateRequestData.java | 186 +++++ .../AIGuardEvaluateRequestDataAttributes.java | 198 ++++++ .../v2/model/AIGuardEvaluateResponse.java | 148 ++++ .../v2/model/AIGuardEvaluationType.java | 58 ++ .../api/client/v2/model/AIGuardImageURL.java | 143 ++++ .../api/client/v2/model/AIGuardMessage.java | 263 ++++++++ .../v2/model/AIGuardMessageContent.java | 286 ++++++++ .../client/v2/model/AIGuardMessageRole.java | 58 ++ .../api/client/v2/model/AIGuardMeta.java | 304 +++++++++ .../v2/model/AIGuardRedactionReplacement.java | 174 +++++ .../client/v2/model/AIGuardScfwFindings.java | 212 ++++++ .../v2/model/AIGuardScfwMatchedRule.java | 178 +++++ .../client/v2/model/AIGuardScfwOutcome.java | 56 ++ .../v2/model/AIGuardScfwPackageFinding.java | 284 ++++++++ .../client/v2/model/AIGuardSdsFinding.java | 236 +++++++ .../v2/model/AIGuardSdsFindingLocation.java | 203 ++++++ .../api/client/v2/model/AIGuardToolCall.java | 176 +++++ .../v2/model/AIGuardToolCallFunction.java | 173 +++++ .../v2/model/AIGuardToolPolicyAction.java | 62 ++ .../api/client/v2/api/ai_guard.feature | 71 ++ .../com/datadog/api/client/v2/api/undo.json | 6 + .../test-runner-data/manifest.json | 49 ++ ...-rejects-empty-multipart-user-content.json | 38 ++ ...est-rejects-image-parts-without-a-url.json | 45 ++ ...quest-rejects-text-parts-without-text.json | 42 ++ ...-request-returns-bad-request-response.json | 37 + ...-ai-guard-request-returns-ok-response.json | 41 ++ ...t-with-a-numeric-confidence-threshold.json | 41 ++ ...th-per-category-confidence-thresholds.json | 45 ++ .../test-server-data/manifest.json | 5 + .../test-server-data/v2/ai-guard.json | 331 +++++++++ 45 files changed, 6732 insertions(+) create mode 100644 examples/v2/ai-guard/EvaluateAIGuardRequest.java create mode 100644 examples/v2/ai-guard/EvaluateAIGuardRequest_1377048937.java create mode 100644 examples/v2/ai-guard/EvaluateAIGuardRequest_3923646360.java create mode 100644 src/main/java/com/datadog/api/client/v2/api/AiGuardApi.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardAction.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThreshold.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardConfidenceThresholdOverride.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardContentPart.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardContentPartType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateAttributesResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateDataResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestDataAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluationType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardImageURL.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardMessage.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardMessageContent.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardMessageRole.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardMeta.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardRedactionReplacement.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardScfwFindings.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardScfwMatchedRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardScfwOutcome.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardScfwPackageFinding.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFinding.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFindingLocation.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardToolCall.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardToolCallFunction.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/AIGuardToolPolicyAction.java create mode 100644 src/test/resources/com/datadog/api/client/v2/api/ai_guard.feature create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json create mode 100644 src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json create mode 100644 src/test/resources/generated-test/test-server-data/v2/ai-guard.json 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>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public AIGuardConfidenceThresholdOverride getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "AIGuardConfidenceThresholdOverride cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AIGuardConfidenceThresholdOverride() { + super("oneOf", Boolean.FALSE); + } + + public AIGuardConfidenceThresholdOverride(Double o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AIGuardConfidenceThresholdOverride(AIGuardConfidenceThreshold o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("Double", new GenericType() {}); + schemas.put("AIGuardConfidenceThreshold", new GenericType() {}); + JSON.registerDescendants( + AIGuardConfidenceThresholdOverride.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AIGuardConfidenceThresholdOverride.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: Double, AIGuardConfidenceThreshold + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(Double.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(AIGuardConfidenceThreshold.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException("Invalid instance type. Must be Double, AIGuardConfidenceThreshold"); + } + + /** + * Get the actual instance, which can be the following: Double, AIGuardConfidenceThreshold + * + * @return The actual instance (Double, AIGuardConfidenceThreshold) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `Double`. If the actual instance is not `Double`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `Double` + * @throws ClassCastException if the instance is not `Double` + */ + public Double getDouble() throws ClassCastException { + return (Double) super.getActualInstance(); + } + + /** + * Get the actual instance of `AIGuardConfidenceThreshold`. If the actual instance is not + * `AIGuardConfidenceThreshold`, the ClassCastException will be thrown. + * + * @return The actual instance of `AIGuardConfidenceThreshold` + * @throws ClassCastException if the instance is not `AIGuardConfidenceThreshold` + */ + public AIGuardConfidenceThreshold getAIGuardConfidenceThreshold() throws ClassCastException { + return (AIGuardConfidenceThreshold) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardContentPart.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardContentPart.java new file mode 100644 index 00000000000..367d21b8e34 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardContentPart.java @@ -0,0 +1,214 @@ +/* + * 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.JsonCreator; +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; + +/** + * 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. + */ +@JsonPropertyOrder({ + AIGuardContentPart.JSON_PROPERTY_IMAGE_URL, + AIGuardContentPart.JSON_PROPERTY_TEXT, + AIGuardContentPart.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardContentPart { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_IMAGE_URL = "image_url"; + private AIGuardImageURL imageUrl; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public static final String JSON_PROPERTY_TYPE = "type"; + private AIGuardContentPartType type; + + public AIGuardContentPart() {} + + @JsonCreator + public AIGuardContentPart( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) AIGuardContentPartType type) { + this.type = type; + this.unparsed |= !type.isValid(); + } + + public AIGuardContentPart imageUrl(AIGuardImageURL imageUrl) { + this.imageUrl = imageUrl; + this.unparsed |= imageUrl.unparsed; + return this; + } + + /** + * An image referenced by URL in a message content part. + * + * @return imageUrl + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_IMAGE_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AIGuardImageURL getImageUrl() { + return imageUrl; + } + + public void setImageUrl(AIGuardImageURL imageUrl) { + this.imageUrl = imageUrl; + if (imageUrl != null) { + this.unparsed |= imageUrl.unparsed; + } + } + + public AIGuardContentPart text(String text) { + this.text = text; + return this; + } + + /** + * The text content, required and non-empty when type is text in a user, + * system, developer, or tool message. + * + * @return text + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public AIGuardContentPart type(AIGuardContentPartType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type of the content part. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardContentPartType getType() { + return type; + } + + public void setType(AIGuardContentPartType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 AIGuardContentPart + */ + @JsonAnySetter + public AIGuardContentPart putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardContentPart object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardContentPart aiGuardContentPart = (AIGuardContentPart) o; + return Objects.equals(this.imageUrl, aiGuardContentPart.imageUrl) + && Objects.equals(this.text, aiGuardContentPart.text) + && Objects.equals(this.type, aiGuardContentPart.type) + && Objects.equals(this.additionalProperties, aiGuardContentPart.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(imageUrl, text, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardContentPart {\n"); + sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/AIGuardContentPartType.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardContentPartType.java new file mode 100644 index 00000000000..42441b3dd6f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardContentPartType.java @@ -0,0 +1,57 @@ +/* + * 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 type of the content part. */ +@JsonSerialize(using = AIGuardContentPartType.AIGuardContentPartTypeSerializer.class) +public class AIGuardContentPartType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("text", "image_url")); + + public static final AIGuardContentPartType TEXT = new AIGuardContentPartType("text"); + public static final AIGuardContentPartType IMAGE_URL = new AIGuardContentPartType("image_url"); + + AIGuardContentPartType(String value) { + super(value, allowedValues); + } + + public static class AIGuardContentPartTypeSerializer + extends StdSerializer { + public AIGuardContentPartTypeSerializer(Class t) { + super(t); + } + + public AIGuardContentPartTypeSerializer() { + this(null); + } + + @Override + public void serialize( + AIGuardContentPartType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AIGuardContentPartType fromValue(String value) { + return new AIGuardContentPartType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateAttributesResponse.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateAttributesResponse.java new file mode 100644 index 00000000000..8f3db46b6c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateAttributesResponse.java @@ -0,0 +1,459 @@ +/* + * 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.JsonCreator; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The evaluation result with the recommended action and detected threat information. */ +@JsonPropertyOrder({ + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_ACTION, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_GLOBAL_PROB, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_IS_BLOCKING_ENABLED, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_REASON, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_REDACTION_REPLACEMENTS, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_SCFW_FINDINGS, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_SDS_FINDINGS, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_TAG_PROBS, + AIGuardEvaluateAttributesResponse.JSON_PROPERTY_TAGS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateAttributesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ACTION = "action"; + private AIGuardAction action; + + public static final String JSON_PROPERTY_GLOBAL_PROB = "global_prob"; + private Double globalProb; + + public static final String JSON_PROPERTY_IS_BLOCKING_ENABLED = "is_blocking_enabled"; + private Boolean isBlockingEnabled; + + public static final String JSON_PROPERTY_REASON = "reason"; + private String reason; + + public static final String JSON_PROPERTY_REDACTION_REPLACEMENTS = "redaction_replacements"; + private List redactionReplacements = null; + + public static final String JSON_PROPERTY_SCFW_FINDINGS = "scfw_findings"; + private AIGuardScfwFindings scfwFindings; + + public static final String JSON_PROPERTY_SDS_FINDINGS = "sds_findings"; + private List sdsFindings = null; + + public static final String JSON_PROPERTY_TAG_PROBS = "tag_probs"; + private Map tagProbs = new HashMap(); + + public static final String JSON_PROPERTY_TAGS = "tags"; + private List tags = new ArrayList<>(); + + public AIGuardEvaluateAttributesResponse() {} + + @JsonCreator + public AIGuardEvaluateAttributesResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_ACTION) AIGuardAction action, + @JsonProperty(required = true, value = JSON_PROPERTY_IS_BLOCKING_ENABLED) + Boolean isBlockingEnabled, + @JsonProperty(required = true, value = JSON_PROPERTY_REASON) String reason, + @JsonProperty(required = true, value = JSON_PROPERTY_TAG_PROBS) Map tagProbs, + @JsonProperty(required = true, value = JSON_PROPERTY_TAGS) List tags) { + this.action = action; + this.unparsed |= !action.isValid(); + this.isBlockingEnabled = isBlockingEnabled; + this.reason = reason; + this.tagProbs = tagProbs; + if (tagProbs != null) {} + this.tags = tags; + } + + public AIGuardEvaluateAttributesResponse action(AIGuardAction action) { + this.action = action; + this.unparsed |= !action.isValid(); + return this; + } + + /** + * The recommended action for the evaluated conversation. + * + * @return action + */ + @JsonProperty(JSON_PROPERTY_ACTION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardAction getAction() { + return action; + } + + public void setAction(AIGuardAction action) { + if (!action.isValid()) { + this.unparsed = true; + } + this.action = action; + } + + public AIGuardEvaluateAttributesResponse globalProb(Double globalProb) { + this.globalProb = globalProb; + return this; + } + + /** + * The global threat probability, between 0 and 1. Included only when + * computed. + * + * @return globalProb + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_GLOBAL_PROB) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Double getGlobalProb() { + return globalProb; + } + + public void setGlobalProb(Double globalProb) { + this.globalProb = globalProb; + } + + public AIGuardEvaluateAttributesResponse isBlockingEnabled(Boolean isBlockingEnabled) { + this.isBlockingEnabled = isBlockingEnabled; + return this; + } + + /** + * Whether blocking is enabled for the organization. + * + * @return isBlockingEnabled + */ + @JsonProperty(JSON_PROPERTY_IS_BLOCKING_ENABLED) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Boolean getIsBlockingEnabled() { + return isBlockingEnabled; + } + + public void setIsBlockingEnabled(Boolean isBlockingEnabled) { + this.isBlockingEnabled = isBlockingEnabled; + } + + public AIGuardEvaluateAttributesResponse reason(String reason) { + this.reason = reason; + return this; + } + + /** + * The explanation for the recommended action, for logging rather than user-facing display. + * + * @return reason + */ + @JsonProperty(JSON_PROPERTY_REASON) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public AIGuardEvaluateAttributesResponse redactionReplacements( + List redactionReplacements) { + this.redactionReplacements = redactionReplacements; + if (redactionReplacements != null) { + for (AIGuardRedactionReplacement item : redactionReplacements) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public AIGuardEvaluateAttributesResponse addRedactionReplacementsItem( + AIGuardRedactionReplacement redactionReplacementsItem) { + if (this.redactionReplacements == null) { + this.redactionReplacements = new ArrayList<>(); + } + this.redactionReplacements.add(redactionReplacementsItem); + this.unparsed |= redactionReplacementsItem.unparsed; + return this; + } + + /** + * The redacted replacements computed for the request. Included only when redaction applies. + * + * @return redactionReplacements + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_REDACTION_REPLACEMENTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getRedactionReplacements() { + return redactionReplacements; + } + + public void setRedactionReplacements(List redactionReplacements) { + this.redactionReplacements = redactionReplacements; + if (redactionReplacements != null) { + for (AIGuardRedactionReplacement item : redactionReplacements) { + this.unparsed |= item.unparsed; + } + } + } + + public AIGuardEvaluateAttributesResponse scfwFindings(AIGuardScfwFindings scfwFindings) { + this.scfwFindings = scfwFindings; + this.unparsed |= scfwFindings.unparsed; + return this; + } + + /** + * 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. + * + * @return scfwFindings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCFW_FINDINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AIGuardScfwFindings getScfwFindings() { + return scfwFindings; + } + + public void setScfwFindings(AIGuardScfwFindings scfwFindings) { + this.scfwFindings = scfwFindings; + if (scfwFindings != null) { + this.unparsed |= scfwFindings.unparsed; + } + } + + public AIGuardEvaluateAttributesResponse sdsFindings(List sdsFindings) { + this.sdsFindings = sdsFindings; + if (sdsFindings != null) { + for (AIGuardSdsFinding item : sdsFindings) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public AIGuardEvaluateAttributesResponse addSdsFindingsItem(AIGuardSdsFinding sdsFindingsItem) { + if (this.sdsFindings == null) { + this.sdsFindings = new ArrayList<>(); + } + this.sdsFindings.add(sdsFindingsItem); + this.unparsed |= sdsFindingsItem.unparsed; + return this; + } + + /** + * The sensitive data findings from the Sensitive Data Scanner. Included only when findings exist. + * + * @return sdsFindings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SDS_FINDINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getSdsFindings() { + return sdsFindings; + } + + public void setSdsFindings(List sdsFindings) { + this.sdsFindings = sdsFindings; + if (sdsFindings != null) { + for (AIGuardSdsFinding item : sdsFindings) { + this.unparsed |= item.unparsed; + } + } + } + + public AIGuardEvaluateAttributesResponse tagProbs(Map tagProbs) { + this.tagProbs = tagProbs; + if (tagProbs != null) {} + return this; + } + + public AIGuardEvaluateAttributesResponse putTagProbsItem(String key, Double tagProbsItem) { + this.tagProbs.put(key, tagProbsItem); + return this; + } + + /** + * The detection confidence for each threat tag, between 0 and 1. May be + * null when the evaluation does not produce per-category scores. + * + * @return tagProbs + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TAG_PROBS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Map getTagProbs() { + return tagProbs; + } + + public void setTagProbs(Map tagProbs) { + this.tagProbs = tagProbs; + } + + public AIGuardEvaluateAttributesResponse tags(List tags) { + this.tags = tags; + return this; + } + + public AIGuardEvaluateAttributesResponse addTagsItem(String tagsItem) { + this.tags.add(tagsItem); + return this; + } + + /** + * The threat tags detected in the conversation. + * + * @return tags + */ + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + /** + * 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 AIGuardEvaluateAttributesResponse + */ + @JsonAnySetter + public AIGuardEvaluateAttributesResponse putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateAttributesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateAttributesResponse aiGuardEvaluateAttributesResponse = + (AIGuardEvaluateAttributesResponse) o; + return Objects.equals(this.action, aiGuardEvaluateAttributesResponse.action) + && Objects.equals(this.globalProb, aiGuardEvaluateAttributesResponse.globalProb) + && Objects.equals( + this.isBlockingEnabled, aiGuardEvaluateAttributesResponse.isBlockingEnabled) + && Objects.equals(this.reason, aiGuardEvaluateAttributesResponse.reason) + && Objects.equals( + this.redactionReplacements, aiGuardEvaluateAttributesResponse.redactionReplacements) + && Objects.equals(this.scfwFindings, aiGuardEvaluateAttributesResponse.scfwFindings) + && Objects.equals(this.sdsFindings, aiGuardEvaluateAttributesResponse.sdsFindings) + && Objects.equals(this.tagProbs, aiGuardEvaluateAttributesResponse.tagProbs) + && Objects.equals(this.tags, aiGuardEvaluateAttributesResponse.tags) + && Objects.equals( + this.additionalProperties, aiGuardEvaluateAttributesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + action, + globalProb, + isBlockingEnabled, + reason, + redactionReplacements, + scfwFindings, + sdsFindings, + tagProbs, + tags, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateAttributesResponse {\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" globalProb: ").append(toIndentedString(globalProb)).append("\n"); + sb.append(" isBlockingEnabled: ").append(toIndentedString(isBlockingEnabled)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" redactionReplacements: ") + .append(toIndentedString(redactionReplacements)) + .append("\n"); + sb.append(" scfwFindings: ").append(toIndentedString(scfwFindings)).append("\n"); + sb.append(" sdsFindings: ").append(toIndentedString(sdsFindings)).append("\n"); + sb.append(" tagProbs: ").append(toIndentedString(tagProbs)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).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/AIGuardEvaluateDataResponse.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateDataResponse.java new file mode 100644 index 00000000000..84e266cec94 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateDataResponse.java @@ -0,0 +1,214 @@ +/* + * 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.JsonCreator; +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; + +/** The JSON:API evaluation resource. */ +@JsonPropertyOrder({ + AIGuardEvaluateDataResponse.JSON_PROPERTY_ATTRIBUTES, + AIGuardEvaluateDataResponse.JSON_PROPERTY_ID, + AIGuardEvaluateDataResponse.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateDataResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private AIGuardEvaluateAttributesResponse attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private AIGuardEvaluationType type; + + public AIGuardEvaluateDataResponse() {} + + @JsonCreator + public AIGuardEvaluateDataResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + AIGuardEvaluateAttributesResponse attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) AIGuardEvaluationType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public AIGuardEvaluateDataResponse attributes(AIGuardEvaluateAttributesResponse attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * The evaluation result with the recommended action and detected threat information. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluateAttributesResponse getAttributes() { + return attributes; + } + + public void setAttributes(AIGuardEvaluateAttributesResponse attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public AIGuardEvaluateDataResponse id(String id) { + this.id = id; + return this; + } + + /** + * The unique identifier of the evaluation. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public AIGuardEvaluateDataResponse type(AIGuardEvaluationType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * 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. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluationType getType() { + return type; + } + + public void setType(AIGuardEvaluationType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 AIGuardEvaluateDataResponse + */ + @JsonAnySetter + public AIGuardEvaluateDataResponse putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateDataResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateDataResponse aiGuardEvaluateDataResponse = (AIGuardEvaluateDataResponse) o; + return Objects.equals(this.attributes, aiGuardEvaluateDataResponse.attributes) + && Objects.equals(this.id, aiGuardEvaluateDataResponse.id) + && Objects.equals(this.type, aiGuardEvaluateDataResponse.type) + && Objects.equals( + this.additionalProperties, aiGuardEvaluateDataResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateDataResponse {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/AIGuardEvaluateRequest.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequest.java new file mode 100644 index 00000000000..adba89b0fbe --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequest.java @@ -0,0 +1,148 @@ +/* + * 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.JsonCreator; +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; + +/** The request to evaluate a conversation for security threats. */ +@JsonPropertyOrder({AIGuardEvaluateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private AIGuardEvaluateRequestData data; + + public AIGuardEvaluateRequest() {} + + @JsonCreator + public AIGuardEvaluateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) AIGuardEvaluateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public AIGuardEvaluateRequest data(AIGuardEvaluateRequestData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The JSON:API request envelope for an AI Guard evaluation. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluateRequestData getData() { + return data; + } + + public void setData(AIGuardEvaluateRequestData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * 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 AIGuardEvaluateRequest + */ + @JsonAnySetter + public AIGuardEvaluateRequest putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateRequest aiGuardEvaluateRequest = (AIGuardEvaluateRequest) o; + return Objects.equals(this.data, aiGuardEvaluateRequest.data) + && Objects.equals(this.additionalProperties, aiGuardEvaluateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).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/AIGuardEvaluateRequestData.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestData.java new file mode 100644 index 00000000000..9e83833ca16 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestData.java @@ -0,0 +1,186 @@ +/* + * 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.JsonCreator; +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; + +/** The JSON:API request envelope for an AI Guard evaluation. */ +@JsonPropertyOrder({ + AIGuardEvaluateRequestData.JSON_PROPERTY_ATTRIBUTES, + AIGuardEvaluateRequestData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateRequestData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private AIGuardEvaluateRequestDataAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private AIGuardEvaluationType type; + + public AIGuardEvaluateRequestData() {} + + @JsonCreator + public AIGuardEvaluateRequestData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + AIGuardEvaluateRequestDataAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) AIGuardEvaluationType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public AIGuardEvaluateRequestData attributes(AIGuardEvaluateRequestDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * The conversation to evaluate and its metadata. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluateRequestDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(AIGuardEvaluateRequestDataAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public AIGuardEvaluateRequestData type(AIGuardEvaluationType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * 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. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluationType getType() { + return type; + } + + public void setType(AIGuardEvaluationType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * 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 AIGuardEvaluateRequestData + */ + @JsonAnySetter + public AIGuardEvaluateRequestData putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateRequestData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateRequestData aiGuardEvaluateRequestData = (AIGuardEvaluateRequestData) o; + return Objects.equals(this.attributes, aiGuardEvaluateRequestData.attributes) + && Objects.equals(this.type, aiGuardEvaluateRequestData.type) + && Objects.equals( + this.additionalProperties, aiGuardEvaluateRequestData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateRequestData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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/AIGuardEvaluateRequestDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestDataAttributes.java new file mode 100644 index 00000000000..1167092ced9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateRequestDataAttributes.java @@ -0,0 +1,198 @@ +/* + * 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.JsonCreator; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The conversation to evaluate and its metadata. */ +@JsonPropertyOrder({ + AIGuardEvaluateRequestDataAttributes.JSON_PROPERTY_MESSAGES, + AIGuardEvaluateRequestDataAttributes.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateRequestDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_MESSAGES = "messages"; + private List messages = new ArrayList<>(); + + public static final String JSON_PROPERTY_META = "meta"; + private AIGuardMeta meta; + + public AIGuardEvaluateRequestDataAttributes() {} + + @JsonCreator + public AIGuardEvaluateRequestDataAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_MESSAGES) + List messages) { + this.messages = messages; + for (AIGuardMessage item : messages) { + this.unparsed |= item.unparsed; + } + } + + public AIGuardEvaluateRequestDataAttributes messages(List messages) { + this.messages = messages; + for (AIGuardMessage item : messages) { + this.unparsed |= item.unparsed; + } + return this; + } + + public AIGuardEvaluateRequestDataAttributes addMessagesItem(AIGuardMessage messagesItem) { + this.messages.add(messagesItem); + this.unparsed |= messagesItem.unparsed; + return this; + } + + /** + * The messages of the conversation to evaluate, in order. Must contain at least one message. + * + * @return messages + */ + @JsonProperty(JSON_PROPERTY_MESSAGES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getMessages() { + return messages; + } + + public void setMessages(List messages) { + this.messages = messages; + if (messages != null) { + for (AIGuardMessage item : messages) { + this.unparsed |= item.unparsed; + } + } + } + + public AIGuardEvaluateRequestDataAttributes meta(AIGuardMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Metadata about the evaluated conversation, used to select the policy and evaluator behavior. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AIGuardMeta getMeta() { + return meta; + } + + public void setMeta(AIGuardMeta meta) { + this.meta = meta; + if (meta != null) { + this.unparsed |= meta.unparsed; + } + } + + /** + * 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 AIGuardEvaluateRequestDataAttributes + */ + @JsonAnySetter + public AIGuardEvaluateRequestDataAttributes putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateRequestDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateRequestDataAttributes aiGuardEvaluateRequestDataAttributes = + (AIGuardEvaluateRequestDataAttributes) o; + return Objects.equals(this.messages, aiGuardEvaluateRequestDataAttributes.messages) + && Objects.equals(this.meta, aiGuardEvaluateRequestDataAttributes.meta) + && Objects.equals( + this.additionalProperties, aiGuardEvaluateRequestDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(messages, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateRequestDataAttributes {\n"); + sb.append(" messages: ").append(toIndentedString(messages)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).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/AIGuardEvaluateResponse.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateResponse.java new file mode 100644 index 00000000000..b5e5dd3307f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluateResponse.java @@ -0,0 +1,148 @@ +/* + * 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.JsonCreator; +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; + +/** The response containing the evaluation result. */ +@JsonPropertyOrder({AIGuardEvaluateResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardEvaluateResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private AIGuardEvaluateDataResponse data; + + public AIGuardEvaluateResponse() {} + + @JsonCreator + public AIGuardEvaluateResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) AIGuardEvaluateDataResponse data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public AIGuardEvaluateResponse data(AIGuardEvaluateDataResponse data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * The JSON:API evaluation resource. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardEvaluateDataResponse getData() { + return data; + } + + public void setData(AIGuardEvaluateDataResponse data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * 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 AIGuardEvaluateResponse + */ + @JsonAnySetter + public AIGuardEvaluateResponse putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardEvaluateResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardEvaluateResponse aiGuardEvaluateResponse = (AIGuardEvaluateResponse) o; + return Objects.equals(this.data, aiGuardEvaluateResponse.data) + && Objects.equals(this.additionalProperties, aiGuardEvaluateResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardEvaluateResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).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/AIGuardEvaluationType.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluationType.java new file mode 100644 index 00000000000..4c3e6e24ddf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardEvaluationType.java @@ -0,0 +1,58 @@ +/* + * 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 JSON:API resource type for AI Guard evaluation requests and responses. Its value is + * evaluations for the action endpoint /api/v2/ai-guard/evaluate. + */ +@JsonSerialize(using = AIGuardEvaluationType.AIGuardEvaluationTypeSerializer.class) +public class AIGuardEvaluationType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("evaluations")); + + public static final AIGuardEvaluationType EVALUATIONS = new AIGuardEvaluationType("evaluations"); + + AIGuardEvaluationType(String value) { + super(value, allowedValues); + } + + public static class AIGuardEvaluationTypeSerializer extends StdSerializer { + public AIGuardEvaluationTypeSerializer(Class t) { + super(t); + } + + public AIGuardEvaluationTypeSerializer() { + this(null); + } + + @Override + public void serialize( + AIGuardEvaluationType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AIGuardEvaluationType fromValue(String value) { + return new AIGuardEvaluationType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardImageURL.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardImageURL.java new file mode 100644 index 00000000000..98a166b661f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardImageURL.java @@ -0,0 +1,143 @@ +/* + * 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.JsonCreator; +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; + +/** An image referenced by URL in a message content part. */ +@JsonPropertyOrder({AIGuardImageURL.JSON_PROPERTY_URL}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardImageURL { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_URL = "url"; + private String url; + + public AIGuardImageURL() {} + + @JsonCreator + public AIGuardImageURL(@JsonProperty(required = true, value = JSON_PROPERTY_URL) String url) { + this.url = url; + } + + public AIGuardImageURL url(String url) { + this.url = url; + return this; + } + + /** + * The image URL or a data URI with an image/png, image/jpeg, + * image/gif, or image/webp MIME type. + * + * @return url + */ + @JsonProperty(JSON_PROPERTY_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + /** + * 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 AIGuardImageURL + */ + @JsonAnySetter + public AIGuardImageURL putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardImageURL object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardImageURL aiGuardImageUrl = (AIGuardImageURL) o; + return Objects.equals(this.url, aiGuardImageUrl.url) + && Objects.equals(this.additionalProperties, aiGuardImageUrl.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(url, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardImageURL {\n"); + sb.append(" url: ").append(toIndentedString(url)).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/AIGuardMessage.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessage.java new file mode 100644 index 00000000000..63e8af3f071 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessage.java @@ -0,0 +1,263 @@ +/* + * 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.JsonCreator; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 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. + */ +@JsonPropertyOrder({ + AIGuardMessage.JSON_PROPERTY_CONTENT, + AIGuardMessage.JSON_PROPERTY_ROLE, + AIGuardMessage.JSON_PROPERTY_TOOL_CALL_ID, + AIGuardMessage.JSON_PROPERTY_TOOL_CALLS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardMessage { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONTENT = "content"; + private AIGuardMessageContent content; + + public static final String JSON_PROPERTY_ROLE = "role"; + private AIGuardMessageRole role; + + public static final String JSON_PROPERTY_TOOL_CALL_ID = "tool_call_id"; + private String toolCallId; + + public static final String JSON_PROPERTY_TOOL_CALLS = "tool_calls"; + private List toolCalls = null; + + public AIGuardMessage() {} + + @JsonCreator + public AIGuardMessage( + @JsonProperty(required = true, value = JSON_PROPERTY_ROLE) AIGuardMessageRole role) { + this.role = role; + this.unparsed |= !role.isValid(); + } + + public AIGuardMessage content(AIGuardMessageContent content) { + this.content = content; + this.unparsed |= content.unparsed; + return this; + } + + /** + * The content of a message, either a plain string or a list of OpenAI-style content parts. + * + * @return content + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONTENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AIGuardMessageContent getContent() { + return content; + } + + public void setContent(AIGuardMessageContent content) { + this.content = content; + if (content != null) { + this.unparsed |= content.unparsed; + } + } + + public AIGuardMessage role(AIGuardMessageRole role) { + this.role = role; + this.unparsed |= !role.isValid(); + return this; + } + + /** + * The role of the message author in the conversation. + * + * @return role + */ + @JsonProperty(JSON_PROPERTY_ROLE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardMessageRole getRole() { + return role; + } + + public void setRole(AIGuardMessageRole role) { + if (!role.isValid()) { + this.unparsed = true; + } + this.role = role; + } + + public AIGuardMessage toolCallId(String toolCallId) { + this.toolCallId = toolCallId; + return this; + } + + /** + * The identifier of the tool call this message responds to, present on tool result messages. + * + * @return toolCallId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOOL_CALL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getToolCallId() { + return toolCallId; + } + + public void setToolCallId(String toolCallId) { + this.toolCallId = toolCallId; + } + + public AIGuardMessage toolCalls(List toolCalls) { + this.toolCalls = toolCalls; + if (toolCalls != null) { + for (AIGuardToolCall item : toolCalls) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public AIGuardMessage addToolCallsItem(AIGuardToolCall toolCallsItem) { + if (this.toolCalls == null) { + this.toolCalls = new ArrayList<>(); + } + this.toolCalls.add(toolCallsItem); + this.unparsed |= toolCallsItem.unparsed; + return this; + } + + /** + * The tool calls emitted by the assistant, present on assistant messages that call tools. + * + * @return toolCalls + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOOL_CALLS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToolCalls() { + return toolCalls; + } + + public void setToolCalls(List toolCalls) { + this.toolCalls = toolCalls; + if (toolCalls != null) { + for (AIGuardToolCall item : toolCalls) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * 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 AIGuardMessage + */ + @JsonAnySetter + public AIGuardMessage putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardMessage aiGuardMessage = (AIGuardMessage) o; + return Objects.equals(this.content, aiGuardMessage.content) + && Objects.equals(this.role, aiGuardMessage.role) + && Objects.equals(this.toolCallId, aiGuardMessage.toolCallId) + && Objects.equals(this.toolCalls, aiGuardMessage.toolCalls) + && Objects.equals(this.additionalProperties, aiGuardMessage.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(content, role, toolCallId, toolCalls, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardMessage {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" toolCallId: ").append(toIndentedString(toolCallId)).append("\n"); + sb.append(" toolCalls: ").append(toIndentedString(toolCalls)).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/AIGuardMessageContent.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessageContent.java new file mode 100644 index 00000000000..d1e7d2f580c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessageContent.java @@ -0,0 +1,286 @@ +/* + * 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.List; +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 = AIGuardMessageContent.AIGuardMessageContentDeserializer.class) +@JsonSerialize(using = AIGuardMessageContent.AIGuardMessageContentSerializer.class) +public class AIGuardMessageContent extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AIGuardMessageContent.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AIGuardMessageContentSerializer extends StdSerializer { + public AIGuardMessageContentSerializer(Class t) { + super(t); + } + + public AIGuardMessageContentSerializer() { + this(null); + } + + @Override + public void serialize( + AIGuardMessageContent value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AIGuardMessageContentDeserializer + extends StdDeserializer { + public AIGuardMessageContentDeserializer() { + this(AIGuardMessageContent.class); + } + + public AIGuardMessageContentDeserializer(Class vc) { + super(vc); + } + + @Override + public AIGuardMessageContent 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; + Object deserializedUnparsed = null; + int matchUnparsed = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize List + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (List.class.equals(Integer.class) + || List.class.equals(Long.class) + || List.class.equals(Float.class) + || List.class.equals(Double.class) + || List.class.equals(Boolean.class) + || List.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((List.class.equals(Integer.class) || List.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((List.class.equals(Float.class) || List.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (List.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(new TypeReference>() {}); + // 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. + // keep the matched list, but propagate 'unparsed' from any invalid item + boolean itemsUnparsed = false; + for (AIGuardContentPart item : (List) tmp) { + itemsUnparsed |= item.unparsed; + } + if (itemsUnparsed) { + deserializedUnparsed = tmp; + matchUnparsed++; + } else { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'List'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List'", e); + } + + AIGuardMessageContent ret = new AIGuardMessageContent(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else if (match == 0 && matchUnparsed == 1) { + ret.setActualInstance(deserializedUnparsed); + ret.unparsed = true; + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public AIGuardMessageContent getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AIGuardMessageContent cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AIGuardMessageContent() { + super("oneOf", Boolean.FALSE); + } + + public AIGuardMessageContent(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AIGuardMessageContent(List o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put("List", new GenericType>() {}); + JSON.registerDescendants(AIGuardMessageContent.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AIGuardMessageContent.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, List<AIGuardContentPart> + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(List.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException("Invalid instance type. Must be String, List"); + } + + /** + * Get the actual instance, which can be the following: String, List<AIGuardContentPart> + * + * @return The actual instance (String, List<AIGuardContentPart>) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `List<AIGuardContentPart>`. If the actual instance is not + * `List<AIGuardContentPart>`, the ClassCastException will be thrown. + * + * @return The actual instance of `List<AIGuardContentPart>` + * @throws ClassCastException if the instance is not `List<AIGuardContentPart>` + */ + public List getList() throws ClassCastException { + return (List) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardMessageRole.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessageRole.java new file mode 100644 index 00000000000..21652e5fc9d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardMessageRole.java @@ -0,0 +1,58 @@ +/* + * 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 role of the message author in the conversation. */ +@JsonSerialize(using = AIGuardMessageRole.AIGuardMessageRoleSerializer.class) +public class AIGuardMessageRole extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("user", "assistant", "system", "developer", "tool")); + + public static final AIGuardMessageRole USER = new AIGuardMessageRole("user"); + public static final AIGuardMessageRole ASSISTANT = new AIGuardMessageRole("assistant"); + public static final AIGuardMessageRole SYSTEM = new AIGuardMessageRole("system"); + public static final AIGuardMessageRole DEVELOPER = new AIGuardMessageRole("developer"); + public static final AIGuardMessageRole TOOL = new AIGuardMessageRole("tool"); + + AIGuardMessageRole(String value) { + super(value, allowedValues); + } + + public static class AIGuardMessageRoleSerializer extends StdSerializer { + public AIGuardMessageRoleSerializer(Class t) { + super(t); + } + + public AIGuardMessageRoleSerializer() { + this(null); + } + + @Override + public void serialize(AIGuardMessageRole value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AIGuardMessageRole fromValue(String value) { + return new AIGuardMessageRole(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardMeta.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardMeta.java new file mode 100644 index 00000000000..1a7c63838f5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardMeta.java @@ -0,0 +1,304 @@ +/* + * 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; + +/** Metadata about the evaluated conversation, used to select the policy and evaluator behavior. */ +@JsonPropertyOrder({ + AIGuardMeta.JSON_PROPERTY_CODING_AGENT, + AIGuardMeta.JSON_PROPERTY_CONFIDENCE_THRESHOLD, + AIGuardMeta.JSON_PROPERTY_ENV, + AIGuardMeta.JSON_PROPERTY_IS_SDS_ENABLED_OVERRIDE, + AIGuardMeta.JSON_PROPERTY_SERVICE, + AIGuardMeta.JSON_PROPERTY_TOOL_POLICIES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CODING_AGENT = "coding_agent"; + private String codingAgent; + + public static final String JSON_PROPERTY_CONFIDENCE_THRESHOLD = "confidence_threshold"; + private AIGuardConfidenceThresholdOverride confidenceThreshold; + + public static final String JSON_PROPERTY_ENV = "env"; + private String env; + + public static final String JSON_PROPERTY_IS_SDS_ENABLED_OVERRIDE = "is_sds_enabled_override"; + private Boolean isSdsEnabledOverride; + + public static final String JSON_PROPERTY_SERVICE = "service"; + private String service; + + public static final String JSON_PROPERTY_TOOL_POLICIES = "tool_policies"; + private Map toolPolicies = null; + + public AIGuardMeta codingAgent(String codingAgent) { + this.codingAgent = codingAgent; + return this; + } + + /** + * 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. + * + * @return codingAgent + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CODING_AGENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodingAgent() { + return codingAgent; + } + + public void setCodingAgent(String codingAgent) { + this.codingAgent = codingAgent; + } + + public AIGuardMeta confidenceThreshold(AIGuardConfidenceThresholdOverride confidenceThreshold) { + this.confidenceThreshold = confidenceThreshold; + this.unparsed |= confidenceThreshold.unparsed; + return this; + } + + /** + * 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. + * + * @return confidenceThreshold + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONFIDENCE_THRESHOLD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public AIGuardConfidenceThresholdOverride getConfidenceThreshold() { + return confidenceThreshold; + } + + public void setConfidenceThreshold(AIGuardConfidenceThresholdOverride confidenceThreshold) { + this.confidenceThreshold = confidenceThreshold; + if (confidenceThreshold != null) { + this.unparsed |= confidenceThreshold.unparsed; + } + } + + public AIGuardMeta env(String env) { + this.env = env; + return this; + } + + /** + * The environment the conversation belongs to. + * + * @return env + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENV) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEnv() { + return env; + } + + public void setEnv(String env) { + this.env = env; + } + + public AIGuardMeta isSdsEnabledOverride(Boolean isSdsEnabledOverride) { + this.isSdsEnabledOverride = isSdsEnabledOverride; + return this; + } + + /** + * Whether to run the Sensitive Data Scanner for this request, overriding the stored policy. + * + * @return isSdsEnabledOverride + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_IS_SDS_ENABLED_OVERRIDE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getIsSdsEnabledOverride() { + return isSdsEnabledOverride; + } + + public void setIsSdsEnabledOverride(Boolean isSdsEnabledOverride) { + this.isSdsEnabledOverride = isSdsEnabledOverride; + } + + public AIGuardMeta service(String service) { + this.service = service; + return this; + } + + /** + * The name of the service the conversation belongs to. + * + * @return service + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SERVICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getService() { + return service; + } + + public void setService(String service) { + this.service = service; + } + + public AIGuardMeta toolPolicies(Map toolPolicies) { + this.toolPolicies = toolPolicies; + return this; + } + + public AIGuardMeta putToolPoliciesItem(String key, AIGuardToolPolicyAction toolPoliciesItem) { + if (this.toolPolicies == null) { + this.toolPolicies = new HashMap<>(); + } + this.toolPolicies.put(key, toolPoliciesItem); + return this; + } + + /** + * 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. + * + * @return toolPolicies + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOOL_POLICIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getToolPolicies() { + return toolPolicies; + } + + public void setToolPolicies(Map toolPolicies) { + this.toolPolicies = toolPolicies; + } + + /** + * 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 AIGuardMeta + */ + @JsonAnySetter + public AIGuardMeta putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardMeta aiGuardMeta = (AIGuardMeta) o; + return Objects.equals(this.codingAgent, aiGuardMeta.codingAgent) + && Objects.equals(this.confidenceThreshold, aiGuardMeta.confidenceThreshold) + && Objects.equals(this.env, aiGuardMeta.env) + && Objects.equals(this.isSdsEnabledOverride, aiGuardMeta.isSdsEnabledOverride) + && Objects.equals(this.service, aiGuardMeta.service) + && Objects.equals(this.toolPolicies, aiGuardMeta.toolPolicies) + && Objects.equals(this.additionalProperties, aiGuardMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + codingAgent, + confidenceThreshold, + env, + isSdsEnabledOverride, + service, + toolPolicies, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardMeta {\n"); + sb.append(" codingAgent: ").append(toIndentedString(codingAgent)).append("\n"); + sb.append(" confidenceThreshold: ") + .append(toIndentedString(confidenceThreshold)) + .append("\n"); + sb.append(" env: ").append(toIndentedString(env)).append("\n"); + sb.append(" isSdsEnabledOverride: ") + .append(toIndentedString(isSdsEnabledOverride)) + .append("\n"); + sb.append(" service: ").append(toIndentedString(service)).append("\n"); + sb.append(" toolPolicies: ").append(toIndentedString(toolPolicies)).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/AIGuardRedactionReplacement.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardRedactionReplacement.java new file mode 100644 index 00000000000..99994b3e2cf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardRedactionReplacement.java @@ -0,0 +1,174 @@ +/* + * 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.JsonCreator; +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; + +/** The fully redacted content for one path in the request. */ +@JsonPropertyOrder({ + AIGuardRedactionReplacement.JSON_PROPERTY_PATH, + AIGuardRedactionReplacement.JSON_PROPERTY_REPLACEMENT +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardRedactionReplacement { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PATH = "path"; + private String path; + + public static final String JSON_PROPERTY_REPLACEMENT = "replacement"; + private String replacement; + + public AIGuardRedactionReplacement() {} + + @JsonCreator + public AIGuardRedactionReplacement( + @JsonProperty(required = true, value = JSON_PROPERTY_PATH) String path, + @JsonProperty(required = true, value = JSON_PROPERTY_REPLACEMENT) String replacement) { + this.path = path; + this.replacement = replacement; + } + + public AIGuardRedactionReplacement path(String path) { + this.path = path; + return this; + } + + /** + * The path of the redacted content relative to the request attributes. + * + * @return path + */ + @JsonProperty(JSON_PROPERTY_PATH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public AIGuardRedactionReplacement replacement(String replacement) { + this.replacement = replacement; + return this; + } + + /** + * The redacted replacement content. + * + * @return replacement + */ + @JsonProperty(JSON_PROPERTY_REPLACEMENT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getReplacement() { + return replacement; + } + + public void setReplacement(String replacement) { + this.replacement = replacement; + } + + /** + * 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 AIGuardRedactionReplacement + */ + @JsonAnySetter + public AIGuardRedactionReplacement putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardRedactionReplacement object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardRedactionReplacement aiGuardRedactionReplacement = (AIGuardRedactionReplacement) o; + return Objects.equals(this.path, aiGuardRedactionReplacement.path) + && Objects.equals(this.replacement, aiGuardRedactionReplacement.replacement) + && Objects.equals( + this.additionalProperties, aiGuardRedactionReplacement.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(path, replacement, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardRedactionReplacement {\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" replacement: ").append(toIndentedString(replacement)).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/AIGuardScfwFindings.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwFindings.java new file mode 100644 index 00000000000..c6fa37ca721 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwFindings.java @@ -0,0 +1,212 @@ +/* + * 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.JsonCreator; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 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. + */ +@JsonPropertyOrder({ + AIGuardScfwFindings.JSON_PROPERTY_PACKAGES, + AIGuardScfwFindings.JSON_PROPERTY_RECOMMENDED_ACTION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardScfwFindings { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PACKAGES = "packages"; + private List packages = null; + + public static final String JSON_PROPERTY_RECOMMENDED_ACTION = "recommended_action"; + private AIGuardScfwOutcome recommendedAction; + + public AIGuardScfwFindings() {} + + @JsonCreator + public AIGuardScfwFindings( + @JsonProperty(required = true, value = JSON_PROPERTY_RECOMMENDED_ACTION) + AIGuardScfwOutcome recommendedAction) { + this.recommendedAction = recommendedAction; + this.unparsed |= !recommendedAction.isValid(); + } + + public AIGuardScfwFindings packages(List packages) { + this.packages = packages; + if (packages != null) { + for (AIGuardScfwPackageFinding item : packages) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public AIGuardScfwFindings addPackagesItem(AIGuardScfwPackageFinding packagesItem) { + if (this.packages == null) { + this.packages = new ArrayList<>(); + } + this.packages.add(packagesItem); + this.unparsed |= packagesItem.unparsed; + return this; + } + + /** + * The packages the firewall evaluated, ALLOW ones included. + * + * @return packages + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PACKAGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getPackages() { + return packages; + } + + public void setPackages(List packages) { + this.packages = packages; + if (packages != null) { + for (AIGuardScfwPackageFinding item : packages) { + this.unparsed |= item.unparsed; + } + } + } + + public AIGuardScfwFindings recommendedAction(AIGuardScfwOutcome recommendedAction) { + this.recommendedAction = recommendedAction; + this.unparsed |= !recommendedAction.isValid(); + return this; + } + + /** + * The Supply Chain Firewall outcome for a package, a matched rule, or the whole request. + * + * @return recommendedAction + */ + @JsonProperty(JSON_PROPERTY_RECOMMENDED_ACTION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardScfwOutcome getRecommendedAction() { + return recommendedAction; + } + + public void setRecommendedAction(AIGuardScfwOutcome recommendedAction) { + if (!recommendedAction.isValid()) { + this.unparsed = true; + } + this.recommendedAction = recommendedAction; + } + + /** + * 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 AIGuardScfwFindings + */ + @JsonAnySetter + public AIGuardScfwFindings putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardScfwFindings object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardScfwFindings aiGuardScfwFindings = (AIGuardScfwFindings) o; + return Objects.equals(this.packages, aiGuardScfwFindings.packages) + && Objects.equals(this.recommendedAction, aiGuardScfwFindings.recommendedAction) + && Objects.equals(this.additionalProperties, aiGuardScfwFindings.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(packages, recommendedAction, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardScfwFindings {\n"); + sb.append(" packages: ").append(toIndentedString(packages)).append("\n"); + sb.append(" recommendedAction: ").append(toIndentedString(recommendedAction)).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/AIGuardScfwMatchedRule.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwMatchedRule.java new file mode 100644 index 00000000000..2e2c176feb7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwMatchedRule.java @@ -0,0 +1,178 @@ +/* + * 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.JsonCreator; +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; + +/** One rule the Supply Chain Firewall matched on a package, with the outcome the rule reached. */ +@JsonPropertyOrder({ + AIGuardScfwMatchedRule.JSON_PROPERTY_OUTCOME, + AIGuardScfwMatchedRule.JSON_PROPERTY_RULE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardScfwMatchedRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OUTCOME = "outcome"; + private AIGuardScfwOutcome outcome; + + public static final String JSON_PROPERTY_RULE = "rule"; + private String rule; + + public AIGuardScfwMatchedRule() {} + + @JsonCreator + public AIGuardScfwMatchedRule( + @JsonProperty(required = true, value = JSON_PROPERTY_OUTCOME) AIGuardScfwOutcome outcome, + @JsonProperty(required = true, value = JSON_PROPERTY_RULE) String rule) { + this.outcome = outcome; + this.unparsed |= !outcome.isValid(); + this.rule = rule; + } + + public AIGuardScfwMatchedRule outcome(AIGuardScfwOutcome outcome) { + this.outcome = outcome; + this.unparsed |= !outcome.isValid(); + return this; + } + + /** + * The Supply Chain Firewall outcome for a package, a matched rule, or the whole request. + * + * @return outcome + */ + @JsonProperty(JSON_PROPERTY_OUTCOME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardScfwOutcome getOutcome() { + return outcome; + } + + public void setOutcome(AIGuardScfwOutcome outcome) { + if (!outcome.isValid()) { + this.unparsed = true; + } + this.outcome = outcome; + } + + public AIGuardScfwMatchedRule rule(String rule) { + this.rule = rule; + return this; + } + + /** + * The rule text the firewall reported, or the policy type when no text was reported. + * + * @return rule + */ + @JsonProperty(JSON_PROPERTY_RULE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRule() { + return rule; + } + + public void setRule(String rule) { + this.rule = rule; + } + + /** + * 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 AIGuardScfwMatchedRule + */ + @JsonAnySetter + public AIGuardScfwMatchedRule putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardScfwMatchedRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardScfwMatchedRule aiGuardScfwMatchedRule = (AIGuardScfwMatchedRule) o; + return Objects.equals(this.outcome, aiGuardScfwMatchedRule.outcome) + && Objects.equals(this.rule, aiGuardScfwMatchedRule.rule) + && Objects.equals(this.additionalProperties, aiGuardScfwMatchedRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(outcome, rule, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardScfwMatchedRule {\n"); + sb.append(" outcome: ").append(toIndentedString(outcome)).append("\n"); + sb.append(" rule: ").append(toIndentedString(rule)).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/AIGuardScfwOutcome.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwOutcome.java new file mode 100644 index 00000000000..7a6f23c5cbf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwOutcome.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 Supply Chain Firewall outcome for a package, a matched rule, or the whole request. */ +@JsonSerialize(using = AIGuardScfwOutcome.AIGuardScfwOutcomeSerializer.class) +public class AIGuardScfwOutcome extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("ALLOW", "WARN", "BLOCK")); + + public static final AIGuardScfwOutcome ALLOW = new AIGuardScfwOutcome("ALLOW"); + public static final AIGuardScfwOutcome WARN = new AIGuardScfwOutcome("WARN"); + public static final AIGuardScfwOutcome BLOCK = new AIGuardScfwOutcome("BLOCK"); + + AIGuardScfwOutcome(String value) { + super(value, allowedValues); + } + + public static class AIGuardScfwOutcomeSerializer extends StdSerializer { + public AIGuardScfwOutcomeSerializer(Class t) { + super(t); + } + + public AIGuardScfwOutcomeSerializer() { + this(null); + } + + @Override + public void serialize(AIGuardScfwOutcome value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AIGuardScfwOutcome fromValue(String value) { + return new AIGuardScfwOutcome(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwPackageFinding.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwPackageFinding.java new file mode 100644 index 00000000000..059d981831a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardScfwPackageFinding.java @@ -0,0 +1,284 @@ +/* + * 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.JsonCreator; +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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** One package the Supply Chain Firewall evaluated, with the outcome and every matched rule. */ +@JsonPropertyOrder({ + AIGuardScfwPackageFinding.JSON_PROPERTY_ECOSYSTEM, + AIGuardScfwPackageFinding.JSON_PROPERTY_MATCHED_RULES, + AIGuardScfwPackageFinding.JSON_PROPERTY_NAME, + AIGuardScfwPackageFinding.JSON_PROPERTY_OUTCOME, + AIGuardScfwPackageFinding.JSON_PROPERTY_VERSION +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardScfwPackageFinding { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ECOSYSTEM = "ecosystem"; + private String ecosystem; + + public static final String JSON_PROPERTY_MATCHED_RULES = "matched_rules"; + private List matchedRules = null; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_OUTCOME = "outcome"; + private AIGuardScfwOutcome outcome; + + public static final String JSON_PROPERTY_VERSION = "version"; + private String version; + + public AIGuardScfwPackageFinding() {} + + @JsonCreator + public AIGuardScfwPackageFinding( + @JsonProperty(required = true, value = JSON_PROPERTY_ECOSYSTEM) String ecosystem, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_OUTCOME) AIGuardScfwOutcome outcome, + @JsonProperty(required = true, value = JSON_PROPERTY_VERSION) String version) { + this.ecosystem = ecosystem; + this.name = name; + this.outcome = outcome; + this.unparsed |= !outcome.isValid(); + this.version = version; + } + + public AIGuardScfwPackageFinding ecosystem(String ecosystem) { + this.ecosystem = ecosystem; + return this; + } + + /** + * The package ecosystem the firewall evaluated, such as PyPI, npm, or + * crates.io. + * + * @return ecosystem + */ + @JsonProperty(JSON_PROPERTY_ECOSYSTEM) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getEcosystem() { + return ecosystem; + } + + public void setEcosystem(String ecosystem) { + this.ecosystem = ecosystem; + } + + public AIGuardScfwPackageFinding matchedRules(List matchedRules) { + this.matchedRules = matchedRules; + if (matchedRules != null) { + for (AIGuardScfwMatchedRule item : matchedRules) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public AIGuardScfwPackageFinding addMatchedRulesItem(AIGuardScfwMatchedRule matchedRulesItem) { + if (this.matchedRules == null) { + this.matchedRules = new ArrayList<>(); + } + this.matchedRules.add(matchedRulesItem); + this.unparsed |= matchedRulesItem.unparsed; + return this; + } + + /** + * Every rule the firewall matched on the package. + * + * @return matchedRules + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MATCHED_RULES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getMatchedRules() { + return matchedRules; + } + + public void setMatchedRules(List matchedRules) { + this.matchedRules = matchedRules; + if (matchedRules != null) { + for (AIGuardScfwMatchedRule item : matchedRules) { + this.unparsed |= item.unparsed; + } + } + } + + public AIGuardScfwPackageFinding name(String name) { + this.name = name; + return this; + } + + /** + * The name of the package. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public AIGuardScfwPackageFinding outcome(AIGuardScfwOutcome outcome) { + this.outcome = outcome; + this.unparsed |= !outcome.isValid(); + return this; + } + + /** + * The Supply Chain Firewall outcome for a package, a matched rule, or the whole request. + * + * @return outcome + */ + @JsonProperty(JSON_PROPERTY_OUTCOME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardScfwOutcome getOutcome() { + return outcome; + } + + public void setOutcome(AIGuardScfwOutcome outcome) { + if (!outcome.isValid()) { + this.unparsed = true; + } + this.outcome = outcome; + } + + public AIGuardScfwPackageFinding version(String version) { + this.version = version; + return this; + } + + /** + * The version of the package. + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + /** + * 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 AIGuardScfwPackageFinding + */ + @JsonAnySetter + public AIGuardScfwPackageFinding putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardScfwPackageFinding object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardScfwPackageFinding aiGuardScfwPackageFinding = (AIGuardScfwPackageFinding) o; + return Objects.equals(this.ecosystem, aiGuardScfwPackageFinding.ecosystem) + && Objects.equals(this.matchedRules, aiGuardScfwPackageFinding.matchedRules) + && Objects.equals(this.name, aiGuardScfwPackageFinding.name) + && Objects.equals(this.outcome, aiGuardScfwPackageFinding.outcome) + && Objects.equals(this.version, aiGuardScfwPackageFinding.version) + && Objects.equals( + this.additionalProperties, aiGuardScfwPackageFinding.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ecosystem, matchedRules, name, outcome, version, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardScfwPackageFinding {\n"); + sb.append(" ecosystem: ").append(toIndentedString(ecosystem)).append("\n"); + sb.append(" matchedRules: ").append(toIndentedString(matchedRules)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" outcome: ").append(toIndentedString(outcome)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).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/AIGuardSdsFinding.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFinding.java new file mode 100644 index 00000000000..4c533b9e772 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFinding.java @@ -0,0 +1,236 @@ +/* + * 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.JsonCreator; +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; + +/** A sensitive data finding from the Sensitive Data Scanner. */ +@JsonPropertyOrder({ + AIGuardSdsFinding.JSON_PROPERTY_CATEGORY, + AIGuardSdsFinding.JSON_PROPERTY_LOCATION, + AIGuardSdsFinding.JSON_PROPERTY_RULE_DISPLAY_NAME, + AIGuardSdsFinding.JSON_PROPERTY_RULE_TAG +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardSdsFinding { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CATEGORY = "category"; + private String category; + + public static final String JSON_PROPERTY_LOCATION = "location"; + private AIGuardSdsFindingLocation location; + + public static final String JSON_PROPERTY_RULE_DISPLAY_NAME = "rule_display_name"; + private String ruleDisplayName; + + public static final String JSON_PROPERTY_RULE_TAG = "rule_tag"; + private String ruleTag; + + public AIGuardSdsFinding() {} + + @JsonCreator + public AIGuardSdsFinding( + @JsonProperty(required = true, value = JSON_PROPERTY_CATEGORY) String category, + @JsonProperty(required = true, value = JSON_PROPERTY_LOCATION) + AIGuardSdsFindingLocation location, + @JsonProperty(required = true, value = JSON_PROPERTY_RULE_DISPLAY_NAME) + String ruleDisplayName, + @JsonProperty(required = true, value = JSON_PROPERTY_RULE_TAG) String ruleTag) { + this.category = category; + this.location = location; + this.unparsed |= location.unparsed; + this.ruleDisplayName = ruleDisplayName; + this.ruleTag = ruleTag; + } + + public AIGuardSdsFinding category(String category) { + this.category = category; + return this; + } + + /** + * The category of the sensitive data found. + * + * @return category + */ + @JsonProperty(JSON_PROPERTY_CATEGORY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public AIGuardSdsFinding location(AIGuardSdsFindingLocation location) { + this.location = location; + this.unparsed |= location.unparsed; + return this; + } + + /** + * The location of a sensitive data match within the request. + * + * @return location + */ + @JsonProperty(JSON_PROPERTY_LOCATION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardSdsFindingLocation getLocation() { + return location; + } + + public void setLocation(AIGuardSdsFindingLocation location) { + this.location = location; + if (location != null) { + this.unparsed |= location.unparsed; + } + } + + public AIGuardSdsFinding ruleDisplayName(String ruleDisplayName) { + this.ruleDisplayName = ruleDisplayName; + return this; + } + + /** + * The display name of the SDS rule that matched. + * + * @return ruleDisplayName + */ + @JsonProperty(JSON_PROPERTY_RULE_DISPLAY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRuleDisplayName() { + return ruleDisplayName; + } + + public void setRuleDisplayName(String ruleDisplayName) { + this.ruleDisplayName = ruleDisplayName; + } + + public AIGuardSdsFinding ruleTag(String ruleTag) { + this.ruleTag = ruleTag; + return this; + } + + /** + * The tag of the SDS rule that matched. + * + * @return ruleTag + */ + @JsonProperty(JSON_PROPERTY_RULE_TAG) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRuleTag() { + return ruleTag; + } + + public void setRuleTag(String ruleTag) { + this.ruleTag = ruleTag; + } + + /** + * 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 AIGuardSdsFinding + */ + @JsonAnySetter + public AIGuardSdsFinding putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardSdsFinding object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardSdsFinding aiGuardSdsFinding = (AIGuardSdsFinding) o; + return Objects.equals(this.category, aiGuardSdsFinding.category) + && Objects.equals(this.location, aiGuardSdsFinding.location) + && Objects.equals(this.ruleDisplayName, aiGuardSdsFinding.ruleDisplayName) + && Objects.equals(this.ruleTag, aiGuardSdsFinding.ruleTag) + && Objects.equals(this.additionalProperties, aiGuardSdsFinding.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, location, ruleDisplayName, ruleTag, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardSdsFinding {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" ruleDisplayName: ").append(toIndentedString(ruleDisplayName)).append("\n"); + sb.append(" ruleTag: ").append(toIndentedString(ruleTag)).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/AIGuardSdsFindingLocation.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFindingLocation.java new file mode 100644 index 00000000000..9ad8655c788 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardSdsFindingLocation.java @@ -0,0 +1,203 @@ +/* + * 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.JsonCreator; +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; + +/** The location of a sensitive data match within the request. */ +@JsonPropertyOrder({ + AIGuardSdsFindingLocation.JSON_PROPERTY_END_INDEX_EXCLUSIVE, + AIGuardSdsFindingLocation.JSON_PROPERTY_PATH, + AIGuardSdsFindingLocation.JSON_PROPERTY_START_INDEX +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardSdsFindingLocation { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_END_INDEX_EXCLUSIVE = "end_index_exclusive"; + private Long endIndexExclusive; + + public static final String JSON_PROPERTY_PATH = "path"; + private String path; + + public static final String JSON_PROPERTY_START_INDEX = "start_index"; + private Long startIndex; + + public AIGuardSdsFindingLocation() {} + + @JsonCreator + public AIGuardSdsFindingLocation( + @JsonProperty(required = true, value = JSON_PROPERTY_END_INDEX_EXCLUSIVE) + Long endIndexExclusive, + @JsonProperty(required = true, value = JSON_PROPERTY_PATH) String path, + @JsonProperty(required = true, value = JSON_PROPERTY_START_INDEX) Long startIndex) { + this.endIndexExclusive = endIndexExclusive; + this.path = path; + this.startIndex = startIndex; + } + + public AIGuardSdsFindingLocation endIndexExclusive(Long endIndexExclusive) { + this.endIndexExclusive = endIndexExclusive; + return this; + } + + /** + * The exclusive end index of the match within the located content. + * + * @return endIndexExclusive + */ + @JsonProperty(JSON_PROPERTY_END_INDEX_EXCLUSIVE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getEndIndexExclusive() { + return endIndexExclusive; + } + + public void setEndIndexExclusive(Long endIndexExclusive) { + this.endIndexExclusive = endIndexExclusive; + } + + public AIGuardSdsFindingLocation path(String path) { + this.path = path; + return this; + } + + /** + * The path of the match relative to the request attributes. + * + * @return path + */ + @JsonProperty(JSON_PROPERTY_PATH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public AIGuardSdsFindingLocation startIndex(Long startIndex) { + this.startIndex = startIndex; + return this; + } + + /** + * The start index of the match within the located content. + * + * @return startIndex + */ + @JsonProperty(JSON_PROPERTY_START_INDEX) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getStartIndex() { + return startIndex; + } + + public void setStartIndex(Long startIndex) { + this.startIndex = startIndex; + } + + /** + * 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 AIGuardSdsFindingLocation + */ + @JsonAnySetter + public AIGuardSdsFindingLocation putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardSdsFindingLocation object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardSdsFindingLocation aiGuardSdsFindingLocation = (AIGuardSdsFindingLocation) o; + return Objects.equals(this.endIndexExclusive, aiGuardSdsFindingLocation.endIndexExclusive) + && Objects.equals(this.path, aiGuardSdsFindingLocation.path) + && Objects.equals(this.startIndex, aiGuardSdsFindingLocation.startIndex) + && Objects.equals( + this.additionalProperties, aiGuardSdsFindingLocation.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endIndexExclusive, path, startIndex, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardSdsFindingLocation {\n"); + sb.append(" endIndexExclusive: ").append(toIndentedString(endIndexExclusive)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" startIndex: ").append(toIndentedString(startIndex)).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/AIGuardToolCall.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolCall.java new file mode 100644 index 00000000000..d33d1d32bb2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolCall.java @@ -0,0 +1,176 @@ +/* + * 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.JsonCreator; +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; + +/** A tool call emitted by the assistant. */ +@JsonPropertyOrder({AIGuardToolCall.JSON_PROPERTY_FUNCTION, AIGuardToolCall.JSON_PROPERTY_ID}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardToolCall { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FUNCTION = "function"; + private AIGuardToolCallFunction function; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public AIGuardToolCall() {} + + @JsonCreator + public AIGuardToolCall( + @JsonProperty(required = true, value = JSON_PROPERTY_FUNCTION) + AIGuardToolCallFunction function, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id) { + this.function = function; + this.unparsed |= function.unparsed; + this.id = id; + } + + public AIGuardToolCall function(AIGuardToolCallFunction function) { + this.function = function; + this.unparsed |= function.unparsed; + return this; + } + + /** + * The function invoked by a tool call. + * + * @return function + */ + @JsonProperty(JSON_PROPERTY_FUNCTION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public AIGuardToolCallFunction getFunction() { + return function; + } + + public void setFunction(AIGuardToolCallFunction function) { + this.function = function; + if (function != null) { + this.unparsed |= function.unparsed; + } + } + + public AIGuardToolCall id(String id) { + this.id = id; + return this; + } + + /** + * The identifier of the tool call. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + /** + * 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 AIGuardToolCall + */ + @JsonAnySetter + public AIGuardToolCall putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardToolCall object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardToolCall aiGuardToolCall = (AIGuardToolCall) o; + return Objects.equals(this.function, aiGuardToolCall.function) + && Objects.equals(this.id, aiGuardToolCall.id) + && Objects.equals(this.additionalProperties, aiGuardToolCall.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(function, id, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardToolCall {\n"); + sb.append(" function: ").append(toIndentedString(function)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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/AIGuardToolCallFunction.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolCallFunction.java new file mode 100644 index 00000000000..da1f82c1532 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolCallFunction.java @@ -0,0 +1,173 @@ +/* + * 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.JsonCreator; +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; + +/** The function invoked by a tool call. */ +@JsonPropertyOrder({ + AIGuardToolCallFunction.JSON_PROPERTY_ARGUMENTS, + AIGuardToolCallFunction.JSON_PROPERTY_NAME +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class AIGuardToolCallFunction { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ARGUMENTS = "arguments"; + private String arguments; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public AIGuardToolCallFunction() {} + + @JsonCreator + public AIGuardToolCallFunction( + @JsonProperty(required = true, value = JSON_PROPERTY_ARGUMENTS) String arguments, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name) { + this.arguments = arguments; + this.name = name; + } + + public AIGuardToolCallFunction arguments(String arguments) { + this.arguments = arguments; + return this; + } + + /** + * The arguments of the function call, serialized as a JSON string. + * + * @return arguments + */ + @JsonProperty(JSON_PROPERTY_ARGUMENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getArguments() { + return arguments; + } + + public void setArguments(String arguments) { + this.arguments = arguments; + } + + public AIGuardToolCallFunction name(String name) { + this.name = name; + return this; + } + + /** + * The name of the function to call. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * 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 AIGuardToolCallFunction + */ + @JsonAnySetter + public AIGuardToolCallFunction putAdditionalProperty(String key, Object 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 Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this AIGuardToolCallFunction object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIGuardToolCallFunction aiGuardToolCallFunction = (AIGuardToolCallFunction) o; + return Objects.equals(this.arguments, aiGuardToolCallFunction.arguments) + && Objects.equals(this.name, aiGuardToolCallFunction.name) + && Objects.equals(this.additionalProperties, aiGuardToolCallFunction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(arguments, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIGuardToolCallFunction {\n"); + sb.append(" arguments: ").append(toIndentedString(arguments)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/AIGuardToolPolicyAction.java b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolPolicyAction.java new file mode 100644 index 00000000000..40f000e281d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AIGuardToolPolicyAction.java @@ -0,0 +1,62 @@ +/* + * 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 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. + */ +@JsonSerialize(using = AIGuardToolPolicyAction.AIGuardToolPolicyActionSerializer.class) +public class AIGuardToolPolicyAction extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("PASS", "BLOCK", "EVALUATE")); + + public static final AIGuardToolPolicyAction PASS = new AIGuardToolPolicyAction("PASS"); + public static final AIGuardToolPolicyAction BLOCK = new AIGuardToolPolicyAction("BLOCK"); + public static final AIGuardToolPolicyAction EVALUATE = new AIGuardToolPolicyAction("EVALUATE"); + + AIGuardToolPolicyAction(String value) { + super(value, allowedValues); + } + + public static class AIGuardToolPolicyActionSerializer + extends StdSerializer { + public AIGuardToolPolicyActionSerializer(Class t) { + super(t); + } + + public AIGuardToolPolicyActionSerializer() { + this(null); + } + + @Override + public void serialize( + AIGuardToolPolicyAction value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static AIGuardToolPolicyAction fromValue(String value) { + return new AIGuardToolPolicyAction(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/ai_guard.feature b/src/test/resources/com/datadog/api/client/v2/api/ai_guard.feature new file mode 100644 index 00000000000..b205d90c095 --- /dev/null +++ b/src/test/resources/com/datadog/api/client/v2/api/ai_guard.feature @@ -0,0 +1,71 @@ +@endpoint(ai-guard) @endpoint(ai-guard-v2) +Feature: AI Guard + Evaluate LLM interactions for security threats such as prompt injection + and jailbreak attempts. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "AIGuard" API + And operation "EvaluateAIGuardRequest" enabled + And new "EvaluateAIGuardRequest" request + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request rejects empty multipart user content + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[]}]}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request rejects image parts without a URL + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[{"type":"image_url","image_url":{"url":""}}]}]}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request rejects text parts without text + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":[{"type":"text"}]}]}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "Bad Request" response + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user"}]}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "OK" response + Given body with value {"data": {"type": "evaluations", "attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "Payload Too Large" response + Given body with value {"data": {"attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}, "type": "evaluations"}} + When the request is sent + Then the response status is 413 Payload Too Large + + @generated @skip @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request returns "Request Timeout" response + Given body with value {"data": {"attributes": {"messages": [{"content": "Hello world!", "role": "user"}], "meta": {"confidence_threshold": 0.8}}, "type": "evaluations"}} + When the request is sent + Then the response status is 408 Request Timeout + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request with a numeric confidence threshold + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":"Hello world!"}],"meta":{"confidence_threshold":0.8}}}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "evaluations" + And the response "data.attributes" has field "action" + And the response "data.attributes" has field "is_blocking_enabled" + + @team:ddoghq/k9-ai-guard + Scenario: Evaluate an AI Guard request with per-category confidence thresholds + Given body with value {"data":{"type":"evaluations","attributes":{"messages":[{"role":"user","content":"Hello world!"}],"meta":{"confidence_threshold":{"flagging_global":0.6,"policy-evasion":0.9,"indirect-prompt-injection":0.4}}}}} + When the request is sent + Then the response status is 200 OK + And the response "data.type" is equal to "evaluations" + And the response "data.attributes" has field "action" + And the response "data.attributes" has field "is_blocking_enabled" diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 45b82eb3cd7..c644e09b577 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -374,6 +374,12 @@ "type": "safe" } }, + "EvaluateAIGuardRequest": { + "tag": "AI Guard", + "undo": { + "type": "safe" + } + }, "CreateAIImpactUserActivity": { "tag": "Delivery Performance", "undo": { diff --git a/src/test/resources/generated-test/test-runner-data/manifest.json b/src/test/resources/generated-test/test-runner-data/manifest.json index 49d84fde6c0..c443bfebb24 100644 --- a/src/test/resources/generated-test/test-runner-data/manifest.json +++ b/src/test/resources/generated-test/test-runner-data/manifest.json @@ -2793,6 +2793,55 @@ "scenario": "Update GCP scan options returns \"OK\" response", "version": "v2" }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json", + "scenario": "Evaluate an AI Guard request rejects empty multipart user content", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json", + "scenario": "Evaluate an AI Guard request rejects image parts without a URL", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json", + "scenario": "Evaluate an AI Guard request rejects text parts without text", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json", + "scenario": "Evaluate an AI Guard request returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json", + "scenario": "Evaluate an AI Guard request returns \"OK\" response", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json", + "scenario": "Evaluate an AI Guard request with a numeric confidence threshold", + "version": "v2" + }, + { + "feature": "AI Guard", + "feature_file": "../../com/datadog/api/client/v2/api/ai_guard.feature", + "file": "v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json", + "scenario": "Evaluate an AI Guard request with per-category confidence thresholds", + "version": "v2" + }, { "feature": "Annotations", "feature_file": "../../com/datadog/api/client/v2/api/annotations.feature", diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json new file mode 100644 index 00000000000..b9b5a8a692c --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-empty-multipart-user-content.json @@ -0,0 +1,38 @@ +{ + "api": "AIGuard", + "expected_status": 400, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request rejects empty multipart user content", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request rejects empty multipart user content", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json new file mode 100644 index 00000000000..b756f693b08 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-image-parts-without-a-url.json @@ -0,0 +1,45 @@ +{ + "api": "AIGuard", + "expected_status": 400, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request rejects image parts without a URL", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [ + { + "image_url": { + "url": "" + }, + "type": "image_url" + } + ], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request rejects image parts without a URL", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json new file mode 100644 index 00000000000..19f085b53e6 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-rejects-text-parts-without-text.json @@ -0,0 +1,42 @@ +{ + "api": "AIGuard", + "expected_status": 400, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request rejects text parts without text", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [ + { + "type": "text" + } + ], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request rejects text parts without text", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json new file mode 100644 index 00000000000..120e864d709 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-bad-request-response.json @@ -0,0 +1,37 @@ +{ + "api": "AIGuard", + "expected_status": 400, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request returns \"Bad Request\" response", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request returns \"Bad Request\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json new file mode 100644 index 00000000000..b28a509acd1 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-returns-ok-response.json @@ -0,0 +1,41 @@ +{ + "api": "AIGuard", + "expected_status": 200, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request returns \"OK\" response", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": "Hello world!", + "role": "user" + } + ], + "meta": { + "confidence_threshold": 0.8 + } + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request returns \"OK\" response", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json new file mode 100644 index 00000000000..e59b768e8df --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-a-numeric-confidence-threshold.json @@ -0,0 +1,41 @@ +{ + "api": "AIGuard", + "expected_status": 200, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request with a numeric confidence threshold", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": "Hello world!", + "role": "user" + } + ], + "meta": { + "confidence_threshold": 0.8 + } + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request with a numeric confidence threshold", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json new file mode 100644 index 00000000000..1c7389f696c --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/ai-guard/evaluate-an-ai-guard-request-with-per-category-confidence-thresholds.json @@ -0,0 +1,45 @@ +{ + "api": "AIGuard", + "expected_status": 200, + "feature": "AI Guard", + "id": "v2/AI Guard/Evaluate an AI Guard request with per-category confidence thresholds", + "operation_id": "EvaluateAIGuardRequest", + "request": { + "body": { + "schema": { + "format": null, + "ref": "AIGuardEvaluateRequest", + "type": "object" + }, + "source": "inline", + "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" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/ai-guard/evaluate" + }, + "scenario": "Evaluate an AI Guard request with per-category confidence thresholds", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-server-data/manifest.json b/src/test/resources/generated-test/test-server-data/manifest.json index b57e8c66bce..563b35eb133 100644 --- a/src/test/resources/generated-test/test-server-data/manifest.json +++ b/src/test/resources/generated-test/test-server-data/manifest.json @@ -115,6 +115,11 @@ "file": "v1/webhooks-integration.json", "version": "v1" }, + { + "feature": "AI Guard", + "file": "v2/ai-guard.json", + "version": "v2" + }, { "feature": "APM Retention Filters", "file": "v2/apm-retention-filters.json", diff --git a/src/test/resources/generated-test/test-server-data/v2/ai-guard.json b/src/test/resources/generated-test/test-server-data/v2/ai-guard.json new file mode 100644 index 00000000000..269a7e0d2bd --- /dev/null +++ b/src/test/resources/generated-test/test-server-data/v2/ai-guard.json @@ -0,0 +1,331 @@ +{ + "feature": "AI Guard", + "recordings": [ + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.575Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"content parts cannot be empty array for user messages\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Evaluate an AI Guard request rejects empty multipart user content", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.682Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [ + { + "image_url": { + "url": "" + }, + "type": "image_url" + } + ], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"content part 0: image_url is required when type is 'image_url'\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Evaluate an AI Guard request rejects image parts without a URL", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.732Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": [ + { + "type": "text" + } + ], + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"content part 0: text is required when type is 'text'\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Evaluate an AI Guard request rejects text parts without text", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.777Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "role": "user" + } + ] + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"content is required for user messages\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Evaluate an AI Guard request returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.830Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": "Hello world!", + "role": "user" + } + ], + "meta": { + "confidence_threshold": 0.8 + } + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"a76a703c-324f-42ed-af33-9b17d65e28af\",\"type\":\"evaluations\",\"attributes\":{\"action\":\"ALLOW\",\"global_prob\":0.005218505859375,\"is_blocking_enabled\":false,\"reason\":\"No rule match.\",\"tag_probs\":null,\"tags\":[]}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Evaluate an AI Guard request returns \"OK\" response", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.905Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "messages": [ + { + "content": "Hello world!", + "role": "user" + } + ], + "meta": { + "confidence_threshold": 0.8 + } + }, + "type": "evaluations" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"645e547e-1430-41df-a7e5-7cee63a8110e\",\"type\":\"evaluations\",\"attributes\":{\"action\":\"ALLOW\",\"global_prob\":0.005218505859375,\"is_blocking_enabled\":false,\"reason\":\"No rule match.\",\"tag_probs\":null,\"tags\":[]}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Evaluate an AI Guard request with a numeric confidence threshold", + "version": "v2" + }, + { + "feature": "AI Guard", + "frozen_at": "2026-10-26T11:41:08.982Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "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" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/ai-guard/evaluate", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"aeeb0cb1-32e2-4efa-82d9-3d8ce357ec72\",\"type\":\"evaluations\",\"attributes\":{\"action\":\"ALLOW\",\"global_prob\":0.005218505859375,\"is_blocking_enabled\":false,\"reason\":\"No rule match.\",\"tag_probs\":null,\"tags\":[]}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Evaluate an AI Guard request with per-category confidence thresholds", + "version": "v2" + } + ], + "schema_version": 1, + "version": "v2" +}