From 87f1ff8b0c6138933c1b6506a09ffa5da0ce826a Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 16 Oct 2026 15:31:14 +0000 Subject: [PATCH] Regenerate client from commit 58990e3 of spec repo --- .generator/schemas/v2/openapi.yaml | 134 +------ examples/v2/bits-ai/TriggerInvestigation.java | 18 +- ...DemInferredJourneyCandidateAttributes.java | 68 +--- .../DemInferredJourneyIgnoredAttributes.java | 68 +--- .../v2/model/DemInferredJourneyItem.java | 288 ++++++++++++++ .../DemSearchInferredJourneysResponse.java | 25 +- ...archInferredJourneysResponse_dataItem.java | 108 ----- .../client/v2/model/LLMObsContentBlock.java | 19 +- .../v2/model/LLMObsContentBlockType.java | 4 +- .../v2/model/LLMObsFrontendContentBlock.java | 177 --------- .../model/LLMObsFrontendContentBlockType.java | 57 --- .../v2/model/LLMObsLegacyContentBlock.java | 139 ------- .../model/LLMObsLegacyContentBlockType.java | 68 ---- .../client/v2/model/TriggerAttributes.java | 376 +++++++++++------- .../api/client/v2/model/TriggerType.java | 55 --- 15 files changed, 566 insertions(+), 1038 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyItem.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse_dataItem.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlock.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlockType.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlock.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlockType.java delete mode 100644 src/main/java/com/datadog/api/client/v2/model/TriggerType.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 8e540e2cff5..6a21801011a 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -34831,6 +34831,7 @@ components: x-enum-varnames: - CREATE_TEST_SUITE_FOR_JOURNEY_REQUEST DemInferredJourneyCandidateAttributes: + additionalProperties: false description: Attributes of an inferred journey candidate. properties: created_at: @@ -34896,6 +34897,7 @@ components: - attributes type: object DemInferredJourneyIgnoredAttributes: + additionalProperties: false description: Attributes of an ignored inferred journey. properties: created_at: @@ -34960,6 +34962,11 @@ components: - type - attributes type: object + DemInferredJourneyItem: + description: A single inferred journey item, either a candidate or an ignored journey. + oneOf: + - $ref: "#/components/schemas/DemInferredJourneyCandidateData" + - $ref: "#/components/schemas/DemInferredJourneyIgnoredData" DemInferredJourneyStatus: default: candidate description: The status of an inferred DEM journey. @@ -35389,10 +35396,7 @@ components: data: description: List of inferred journey items matching the search criteria. items: - anyOf: - - $ref: "#/components/schemas/DemInferredJourneyCandidateData" - - $ref: "#/components/schemas/DemInferredJourneyIgnoredData" - description: A single inferred journey item, either a candidate or an ignored journey. + $ref: "#/components/schemas/DemInferredJourneyItem" type: array required: - data @@ -36294,11 +36298,6 @@ components: - DEPLOYMENT_GATES_EVALUATION_RESULT_RESPONSE DeploymentGatesEvaluationRule: description: A rule to evaluate as part of a deployment gate evaluation. - discriminator: - mapping: - faulty_deployment_detection: "#/components/schemas/DeploymentGatesFDDRule" - monitor: "#/components/schemas/DeploymentGatesMonitorRule" - propertyName: type oneOf: - $ref: "#/components/schemas/DeploymentGatesMonitorRule" - $ref: "#/components/schemas/DeploymentGatesFDDRule" @@ -67853,9 +67852,6 @@ components: type: string type: object LLMObsContentBlock: - anyOf: - - $ref: "#/components/schemas/LLMObsFrontendContentBlock" - - $ref: "#/components/schemas/LLMObsLegacyContentBlock" description: |- A single content block rendered inside a `display_block` interaction. `type` discriminates which other fields are meaningful: @@ -67864,7 +67860,7 @@ components: - `header`: `content` must be a string; `level`, when set, must be one of `sm`, `md`, `lg`, `xl`. - `json`: `content` must be a well-formed JSON value (object, array, or scalar). - `image`: `url` is required. - - `widget`: `tileDef` is required (any well-formed JSON; the frontend owns the renderable schema). + - `univiz`: `tileDef` is required (any well-formed JSON; the frontend owns the renderable schema). - `llmobs_trace`: `traceId` is required; `interactionType`, when set, must be `trace` or `experiment_trace`. - `frontend`: `code` is required and must be a non-empty string; `label` is optional. @@ -67880,7 +67876,7 @@ components: description: |- Block payload. A string for `markdown`, `header`, and `text`; an arbitrary JSON value (object, array, or scalar) for `json`. Omitted - for `image`, `widget`, `llmobs_trace`, and `frontend`. + for `image`, `univiz`, `llmobs_trace`, and `frontend`. example: "## Triage Instructions" height: description: Optional rendered height. Must be positive when set. @@ -67897,7 +67893,7 @@ components: $ref: "#/components/schemas/LLMObsContentBlockHeaderLevel" tileDef: description: |- - Tile definition for a `widget` block. Required for `widget`. The + Tile definition for a `univiz` block. Required for `univiz`. The schema is owned by the frontend renderer. example: requests: @@ -67920,8 +67916,6 @@ components: description: URL of the image. Required for `image` blocks. example: "https://example.com/image.png" type: string - required: - - type type: object LLMObsContentBlockHeaderLevel: description: Visual size for a `header` block. @@ -67976,7 +67970,7 @@ components: - text - json - image - - widget + - univiz - llmobs_trace - frontend example: markdown @@ -67987,7 +67981,7 @@ components: - TEXT - JSON - IMAGE - - WIDGET + - UNIVIZ - LLMOBS_TRACE - FRONTEND LLMObsContentBlocks: @@ -70917,29 +70911,11 @@ components: required: - data type: object - LLMObsFrontendContentBlock: - description: Validation requirements for a `frontend` display block. - properties: - code: - $ref: "#/components/schemas/LLMObsFrontendContentBlockCode" - type: - $ref: "#/components/schemas/LLMObsFrontendContentBlockType" - required: - - code - type: object LLMObsFrontendContentBlockCode: description: HTML code rendered by a `frontend` block. Required for `frontend` blocks. example: '
Ready for review
' minLength: 1 type: string - LLMObsFrontendContentBlockType: - description: Type discriminator for a `frontend` display block. - enum: - - frontend - example: frontend - type: string - x-enum-varnames: - - FRONTEND LLMObsInferenceCode: description: A generated code snippet for running an inference request programmatically. properties: @@ -71545,32 +71521,6 @@ components: - CATEGORICAL - BOOLEAN - TEXT - LLMObsLegacyContentBlock: - description: Validation requirements for an existing non-frontend display block. - properties: - type: - $ref: "#/components/schemas/LLMObsLegacyContentBlockType" - type: object - LLMObsLegacyContentBlockType: - description: Type discriminator for an existing non-frontend display block. - enum: - - markdown - - header - - text - - json - - image - - widget - - llmobs_trace - example: markdown - type: string - x-enum-varnames: - - MARKDOWN - - HEADER - - TEXT - - JSON - - IMAGE - - WIDGET - - LLMOBS_TRACE LLMObsMetricAssessment: description: Assessment result for an Agent Observability experiment metric. enum: @@ -112235,16 +112185,6 @@ components: description: |- Type-specific details for a content pack state. The set of fields present depends on the content pack's `type`. When Cloud SIEM is inactive for the requesting organization, `onboarding` is returned instead of the content pack's usual type, such as `logs` or `vulnerability`.` - discriminator: - mapping: - appsec: "#/components/schemas/SecurityMonitoringContentPackAppSecDetails" - audit: "#/components/schemas/SecurityMonitoringContentPackAuditDetails" - entity: "#/components/schemas/SecurityMonitoringContentPackEntityDetails" - logs: "#/components/schemas/SecurityMonitoringContentPackLogsDetails" - onboarding: "#/components/schemas/SecurityMonitoringContentPackOnboardingDetails" - threat_intel: "#/components/schemas/SecurityMonitoringContentPackThreatIntelDetails" - vulnerability: "#/components/schemas/SecurityMonitoringContentPackVulnerabilityDetails" - propertyName: type oneOf: - $ref: "#/components/schemas/SecurityMonitoringContentPackLogsDetails" - $ref: "#/components/schemas/SecurityMonitoringContentPackThreatIntelDetails" @@ -113461,14 +113401,6 @@ components: type: object SecurityMonitoringIntegrationConfigCreateAttributes: description: The attributes of the entity context sync configuration to create. - discriminator: - mapping: - CROWDSTRIKE: "#/components/schemas/SecurityMonitoringCrowdStrikeIntegrationConfigCreateAttributes" - ENTRA_ID: "#/components/schemas/SecurityMonitoringEntraIdIntegrationConfigCreateAttributes" - GOOGLE_WORKSPACE: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationConfigCreateAttributes" - OKTA: "#/components/schemas/SecurityMonitoringOktaIntegrationConfigCreateAttributes" - SENTINELONE: "#/components/schemas/SecurityMonitoringSentinelOneIntegrationConfigCreateAttributes" - propertyName: integration_type oneOf: - $ref: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationConfigCreateAttributes" - $ref: "#/components/schemas/SecurityMonitoringOktaIntegrationConfigCreateAttributes" @@ -113620,14 +113552,6 @@ components: - INITIALIZING SecurityMonitoringIntegrationConfigUpdateAttributes: description: Fields to update on the entity context sync configuration. All fields other than the integration type are optional. - discriminator: - mapping: - CROWDSTRIKE: "#/components/schemas/SecurityMonitoringCrowdStrikeIntegrationConfigUpdateAttributes" - ENTRA_ID: "#/components/schemas/SecurityMonitoringEntraIdIntegrationConfigUpdateAttributes" - GOOGLE_WORKSPACE: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationConfigUpdateAttributes" - OKTA: "#/components/schemas/SecurityMonitoringOktaIntegrationConfigUpdateAttributes" - SENTINELONE: "#/components/schemas/SecurityMonitoringSentinelOneIntegrationConfigUpdateAttributes" - propertyName: integration_type oneOf: - $ref: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationConfigUpdateAttributes" - $ref: "#/components/schemas/SecurityMonitoringOktaIntegrationConfigUpdateAttributes" @@ -113666,14 +113590,6 @@ components: type: object SecurityMonitoringIntegrationCredentialsValidateAttributes: description: The credentials to validate against the external entity source. - discriminator: - mapping: - CROWDSTRIKE: "#/components/schemas/SecurityMonitoringCrowdStrikeIntegrationCredentialsValidateAttributes" - ENTRA_ID: "#/components/schemas/SecurityMonitoringEntraIdIntegrationCredentialsValidateAttributes" - GOOGLE_WORKSPACE: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationCredentialsValidateAttributes" - OKTA: "#/components/schemas/SecurityMonitoringOktaIntegrationCredentialsValidateAttributes" - SENTINELONE: "#/components/schemas/SecurityMonitoringSentinelOneIntegrationCredentialsValidateAttributes" - propertyName: integration_type oneOf: - $ref: "#/components/schemas/SecurityMonitoringGoogleWorkspaceIntegrationCredentialsValidateAttributes" - $ref: "#/components/schemas/SecurityMonitoringOktaIntegrationCredentialsValidateAttributes" @@ -134242,9 +134158,6 @@ components: - $ref: "#/components/schemas/SoftwareCatalogTriggerWrapper" - $ref: "#/components/schemas/WorkflowTriggerWrapper" TriggerAttributes: - anyOf: - - $ref: "#/components/schemas/MonitorAlertTrigger" - - $ref: "#/components/schemas/GeneralInvestigationTrigger" description: The trigger definition for starting an investigation. example: monitor_alert_trigger: @@ -134252,14 +134165,9 @@ components: event_ts: 1700000000000 monitor_id: 12345678 type: monitor_alert_trigger - properties: - general_investigation: - $ref: "#/components/schemas/GeneralInvestigationAttributes" - monitor_alert_trigger: - $ref: "#/components/schemas/MonitorAlertTriggerAttributes" - type: - $ref: "#/components/schemas/TriggerType" - type: object + oneOf: + - $ref: "#/components/schemas/MonitorAlertTrigger" + - $ref: "#/components/schemas/GeneralInvestigationTrigger" TriggerInvestigationRequest: description: Request to trigger a new investigation. properties: @@ -134360,16 +134268,6 @@ components: x-enum-varnames: - SECURITY_FINDINGS - SECURITY_SIGNALS - TriggerType: - description: The type of trigger for the investigation. - enum: - - monitor_alert_trigger - - general_investigation - example: monitor_alert_trigger - type: string - x-enum-varnames: - - MONITOR_ALERT_TRIGGER - - GENERAL_INVESTIGATION TriggerWorkflowAutomationAction: description: "Triggers a Workflow Automation." properties: diff --git a/examples/v2/bits-ai/TriggerInvestigation.java b/examples/v2/bits-ai/TriggerInvestigation.java index 8cb9b331273..fbc7f5bdc96 100644 --- a/examples/v2/bits-ai/TriggerInvestigation.java +++ b/examples/v2/bits-ai/TriggerInvestigation.java @@ -3,14 +3,15 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.v2.api.BitsAiApi; +import com.datadog.api.client.v2.model.MonitorAlertTrigger; import com.datadog.api.client.v2.model.MonitorAlertTriggerAttributes; +import com.datadog.api.client.v2.model.MonitorAlertTriggerType; import com.datadog.api.client.v2.model.TriggerAttributes; import com.datadog.api.client.v2.model.TriggerInvestigationRequest; import com.datadog.api.client.v2.model.TriggerInvestigationRequestData; import com.datadog.api.client.v2.model.TriggerInvestigationRequestDataAttributes; import com.datadog.api.client.v2.model.TriggerInvestigationRequestType; import com.datadog.api.client.v2.model.TriggerInvestigationResponse; -import com.datadog.api.client.v2.model.TriggerType; public class Example { public static void main(String[] args) { @@ -25,13 +26,14 @@ public static void main(String[] args) { .attributes( new TriggerInvestigationRequestDataAttributes() .trigger( - new TriggerAttributes() - .monitorAlertTrigger( - new MonitorAlertTriggerAttributes() - .eventId("1234567890123456789") - .eventTs(1700000000000L) - .monitorId(12345678L)) - .type(TriggerType.MONITOR_ALERT_TRIGGER))) + new TriggerAttributes( + new MonitorAlertTrigger() + .monitorAlertTrigger( + new MonitorAlertTriggerAttributes() + .eventId("1234567890123456789") + .eventTs(1700000000000L) + .monitorId(12345678L)) + .type(MonitorAlertTriggerType.MONITOR_ALERT_TRIGGER)))) .type(TriggerInvestigationRequestType.TRIGGER_INVESTIGATION_REQUEST)); try { diff --git a/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyCandidateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyCandidateAttributes.java index f83a4d4df19..e77c71064bb 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyCandidateAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyCandidateAttributes.java @@ -6,8 +6,6 @@ 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; @@ -15,9 +13,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import java.time.OffsetDateTime; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; import org.openapitools.jackson.nullable.JsonNullable; @@ -293,52 +289,6 @@ public void setVariants(List variants) { } } - /** - * 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 DemInferredJourneyCandidateAttributes - */ - @JsonAnySetter - public DemInferredJourneyCandidateAttributes 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 DemInferredJourneyCandidateAttributes object is equal to o. */ @Override public boolean equals(Object o) { @@ -358,24 +308,13 @@ public boolean equals(Object o) { && Objects.equals(this.rank, demInferredJourneyCandidateAttributes.rank) && Objects.equals(this.tags, demInferredJourneyCandidateAttributes.tags) && Objects.equals(this.testSuite, demInferredJourneyCandidateAttributes.testSuite) - && Objects.equals(this.variants, demInferredJourneyCandidateAttributes.variants) - && Objects.equals( - this.additionalProperties, demInferredJourneyCandidateAttributes.additionalProperties); + && Objects.equals(this.variants, demInferredJourneyCandidateAttributes.variants); } @Override public int hashCode() { return Objects.hash( - createdAt, - description, - journeyRum, - name, - orgId, - rank, - tags, - testSuite, - variants, - additionalProperties); + createdAt, description, journeyRum, name, orgId, rank, tags, testSuite, variants); } @Override @@ -391,9 +330,6 @@ public String toString() { sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" testSuite: ").append(toIndentedString(testSuite)).append("\n"); sb.append(" variants: ").append(toIndentedString(variants)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); sb.append('}'); return sb.toString(); } diff --git a/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyIgnoredAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyIgnoredAttributes.java index 7f4a815d7e9..ee535aba6c7 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyIgnoredAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyIgnoredAttributes.java @@ -6,8 +6,6 @@ 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; @@ -15,9 +13,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import java.time.OffsetDateTime; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Objects; import org.openapitools.jackson.nullable.JsonNullable; @@ -280,52 +276,6 @@ public void setVariants(List variants) { } } - /** - * 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 DemInferredJourneyIgnoredAttributes - */ - @JsonAnySetter - public DemInferredJourneyIgnoredAttributes 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 DemInferredJourneyIgnoredAttributes object is equal to o. */ @Override public boolean equals(Object o) { @@ -345,24 +295,13 @@ public boolean equals(Object o) { && Objects.equals(this.orgId, demInferredJourneyIgnoredAttributes.orgId) && Objects.equals(this.tags, demInferredJourneyIgnoredAttributes.tags) && Objects.equals(this.testSuite, demInferredJourneyIgnoredAttributes.testSuite) - && Objects.equals(this.variants, demInferredJourneyIgnoredAttributes.variants) - && Objects.equals( - this.additionalProperties, demInferredJourneyIgnoredAttributes.additionalProperties); + && Objects.equals(this.variants, demInferredJourneyIgnoredAttributes.variants); } @Override public int hashCode() { return Objects.hash( - createdAt, - description, - ignoredAt, - journeyRum, - name, - orgId, - tags, - testSuite, - variants, - additionalProperties); + createdAt, description, ignoredAt, journeyRum, name, orgId, tags, testSuite, variants); } @Override @@ -378,9 +317,6 @@ public String toString() { sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" testSuite: ").append(toIndentedString(testSuite)).append("\n"); sb.append(" variants: ").append(toIndentedString(variants)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); sb.append('}'); return sb.toString(); } diff --git a/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyItem.java b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyItem.java new file mode 100644 index 00000000000..66907c2f391 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DemInferredJourneyItem.java @@ -0,0 +1,288 @@ +/* + * 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 = DemInferredJourneyItem.DemInferredJourneyItemDeserializer.class) +@JsonSerialize(using = DemInferredJourneyItem.DemInferredJourneyItemSerializer.class) +public class DemInferredJourneyItem extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DemInferredJourneyItem.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DemInferredJourneyItemSerializer + extends StdSerializer { + public DemInferredJourneyItemSerializer(Class t) { + super(t); + } + + public DemInferredJourneyItemSerializer() { + this(null); + } + + @Override + public void serialize( + DemInferredJourneyItem value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DemInferredJourneyItemDeserializer + extends StdDeserializer { + public DemInferredJourneyItemDeserializer() { + this(DemInferredJourneyItem.class); + } + + public DemInferredJourneyItemDeserializer(Class vc) { + super(vc); + } + + @Override + public DemInferredJourneyItem 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 DemInferredJourneyCandidateData + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DemInferredJourneyCandidateData.class.equals(Integer.class) + || DemInferredJourneyCandidateData.class.equals(Long.class) + || DemInferredJourneyCandidateData.class.equals(Float.class) + || DemInferredJourneyCandidateData.class.equals(Double.class) + || DemInferredJourneyCandidateData.class.equals(Boolean.class) + || DemInferredJourneyCandidateData.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DemInferredJourneyCandidateData.class.equals(Integer.class) + || DemInferredJourneyCandidateData.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DemInferredJourneyCandidateData.class.equals(Float.class) + || DemInferredJourneyCandidateData.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DemInferredJourneyCandidateData.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DemInferredJourneyCandidateData.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DemInferredJourneyCandidateData.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 (!((DemInferredJourneyCandidateData) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DemInferredJourneyCandidateData'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'DemInferredJourneyCandidateData'", e); + } + + // deserialize DemInferredJourneyIgnoredData + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DemInferredJourneyIgnoredData.class.equals(Integer.class) + || DemInferredJourneyIgnoredData.class.equals(Long.class) + || DemInferredJourneyIgnoredData.class.equals(Float.class) + || DemInferredJourneyIgnoredData.class.equals(Double.class) + || DemInferredJourneyIgnoredData.class.equals(Boolean.class) + || DemInferredJourneyIgnoredData.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DemInferredJourneyIgnoredData.class.equals(Integer.class) + || DemInferredJourneyIgnoredData.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DemInferredJourneyIgnoredData.class.equals(Float.class) + || DemInferredJourneyIgnoredData.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DemInferredJourneyIgnoredData.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DemInferredJourneyIgnoredData.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DemInferredJourneyIgnoredData.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 (!((DemInferredJourneyIgnoredData) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DemInferredJourneyIgnoredData'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DemInferredJourneyIgnoredData'", e); + } + + DemInferredJourneyItem ret = new DemInferredJourneyItem(); + 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 DemInferredJourneyItem getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DemInferredJourneyItem cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DemInferredJourneyItem() { + super("oneOf", Boolean.FALSE); + } + + public DemInferredJourneyItem(DemInferredJourneyCandidateData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DemInferredJourneyItem(DemInferredJourneyIgnoredData o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "DemInferredJourneyCandidateData", new GenericType() {}); + schemas.put( + "DemInferredJourneyIgnoredData", new GenericType() {}); + JSON.registerDescendants(DemInferredJourneyItem.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DemInferredJourneyItem.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DemInferredJourneyCandidateData, DemInferredJourneyIgnoredData + * + *

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( + DemInferredJourneyCandidateData.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(DemInferredJourneyIgnoredData.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 DemInferredJourneyCandidateData," + + " DemInferredJourneyIgnoredData"); + } + + /** + * Get the actual instance, which can be the following: DemInferredJourneyCandidateData, + * DemInferredJourneyIgnoredData + * + * @return The actual instance (DemInferredJourneyCandidateData, DemInferredJourneyIgnoredData) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DemInferredJourneyCandidateData`. If the actual instance is not + * `DemInferredJourneyCandidateData`, the ClassCastException will be thrown. + * + * @return The actual instance of `DemInferredJourneyCandidateData` + * @throws ClassCastException if the instance is not `DemInferredJourneyCandidateData` + */ + public DemInferredJourneyCandidateData getDemInferredJourneyCandidateData() + throws ClassCastException { + return (DemInferredJourneyCandidateData) super.getActualInstance(); + } + + /** + * Get the actual instance of `DemInferredJourneyIgnoredData`. If the actual instance is not + * `DemInferredJourneyIgnoredData`, the ClassCastException will be thrown. + * + * @return The actual instance of `DemInferredJourneyIgnoredData` + * @throws ClassCastException if the instance is not `DemInferredJourneyIgnoredData` + */ + public DemInferredJourneyIgnoredData getDemInferredJourneyIgnoredData() + throws ClassCastException { + return (DemInferredJourneyIgnoredData) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse.java b/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse.java index fe2f94d333b..46405348fa4 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse.java @@ -29,23 +29,31 @@ public class DemSearchInferredJourneysResponse { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_DATA = "data"; - private List data = new ArrayList<>(); + private List data = new ArrayList<>(); public DemSearchInferredJourneysResponse() {} @JsonCreator public DemSearchInferredJourneysResponse( - @JsonProperty(required = true, value = JSON_PROPERTY_DATA) List data) { + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + List data) { this.data = data; + for (DemInferredJourneyItem item : data) { + this.unparsed |= item.unparsed; + } } - public DemSearchInferredJourneysResponse data(List data) { + public DemSearchInferredJourneysResponse data(List data) { this.data = data; + for (DemInferredJourneyItem item : data) { + this.unparsed |= item.unparsed; + } return this; } - public DemSearchInferredJourneysResponse addDataItem(Object dataItem) { + public DemSearchInferredJourneysResponse addDataItem(DemInferredJourneyItem dataItem) { this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; return this; } @@ -56,12 +64,17 @@ public DemSearchInferredJourneysResponse addDataItem(Object dataItem) { */ @JsonProperty(JSON_PROPERTY_DATA) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public List getData() { + public List getData() { return data; } - public void setData(List data) { + public void setData(List data) { this.data = data; + if (data != null) { + for (DemInferredJourneyItem item : data) { + this.unparsed |= item.unparsed; + } + } } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse_dataItem.java b/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse_dataItem.java deleted file mode 100644 index 062faf75c07..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/DemSearchInferredJourneysResponse_dataItem.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.JsonPropertyOrder; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** A single inferred journey item, either a candidate or an ignored journey. */ -@JsonPropertyOrder({}) -@jakarta.annotation.Generated( - value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") -public class DemSearchInferredJourneysResponse_dataItem { - @JsonIgnore public boolean unparsed = false; - - /** - * 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 DemSearchInferredJourneysResponse_dataItem - */ - @JsonAnySetter - public DemSearchInferredJourneysResponse_dataItem 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 DemSearchInferredJourneysResponse_dataItem object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DemSearchInferredJourneysResponse_dataItem {\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/LLMObsContentBlock.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlock.java index e57253cb2c5..7cb3589bab2 100644 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlock.java +++ b/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlock.java @@ -8,7 +8,6 @@ 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; @@ -28,7 +27,7 @@ *
  • json: content must be a well-formed JSON value (object, array, or * scalar). *
  • image: url is required. - *
  • widget: tileDef is required (any well-formed JSON; the frontend + *
  • univiz: tileDef is required (any well-formed JSON; the frontend * owns the renderable schema). *
  • llmobs_trace: traceId is required; interactionType, * when set, must be trace or experiment_trace. @@ -92,15 +91,6 @@ public class LLMObsContentBlock { public static final String JSON_PROPERTY_URL = "url"; private String url; - public LLMObsContentBlock() {} - - @JsonCreator - public LLMObsContentBlock( - @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LLMObsContentBlockType type) { - this.type = type; - this.unparsed |= !type.isValid(); - } - public LLMObsContentBlock alt(String alt) { this.alt = alt; return this; @@ -151,7 +141,7 @@ public LLMObsContentBlock content(Object content) { /** * Block payload. A string for markdown, header, and text; * an arbitrary JSON value (object, array, or scalar) for json. Omitted for - * image, widget, llmobs_trace, and frontend. + * image, univiz, llmobs_trace, and frontend. * * @return content */ @@ -266,7 +256,7 @@ public LLMObsContentBlock tileDef(Object tileDef) { } /** - * Tile definition for a widget block. Required for widget. The schema + * Tile definition for a univiz block. Required for univiz. The schema * is owned by the frontend renderer. * * @return tileDef @@ -340,8 +330,9 @@ public LLMObsContentBlock type(LLMObsContentBlockType type) { * * @return type */ + @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public LLMObsContentBlockType getType() { return type; } diff --git a/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlockType.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlockType.java index e65cf323892..cfc6831daf9 100644 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlockType.java +++ b/src/main/java/com/datadog/api/client/v2/model/LLMObsContentBlockType.java @@ -28,14 +28,14 @@ public class LLMObsContentBlockType extends ModelEnum { private static final Set allowedValues = new HashSet( Arrays.asList( - "markdown", "header", "text", "json", "image", "widget", "llmobs_trace", "frontend")); + "markdown", "header", "text", "json", "image", "univiz", "llmobs_trace", "frontend")); public static final LLMObsContentBlockType MARKDOWN = new LLMObsContentBlockType("markdown"); public static final LLMObsContentBlockType HEADER = new LLMObsContentBlockType("header"); public static final LLMObsContentBlockType TEXT = new LLMObsContentBlockType("text"); public static final LLMObsContentBlockType JSON = new LLMObsContentBlockType("json"); public static final LLMObsContentBlockType IMAGE = new LLMObsContentBlockType("image"); - public static final LLMObsContentBlockType WIDGET = new LLMObsContentBlockType("widget"); + public static final LLMObsContentBlockType UNIVIZ = new LLMObsContentBlockType("univiz"); public static final LLMObsContentBlockType LLMOBS_TRACE = new LLMObsContentBlockType("llmobs_trace"); public static final LLMObsContentBlockType FRONTEND = new LLMObsContentBlockType("frontend"); diff --git a/src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlock.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlock.java deleted file mode 100644 index 9ee7d2e68a3..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlock.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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; - -/** Validation requirements for a frontend display block. */ -@JsonPropertyOrder({ - LLMObsFrontendContentBlock.JSON_PROPERTY_CODE, - LLMObsFrontendContentBlock.JSON_PROPERTY_TYPE -}) -@jakarta.annotation.Generated( - value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") -public class LLMObsFrontendContentBlock { - @JsonIgnore public boolean unparsed = false; - public static final String JSON_PROPERTY_CODE = "code"; - private String code; - - public static final String JSON_PROPERTY_TYPE = "type"; - private LLMObsFrontendContentBlockType type; - - public LLMObsFrontendContentBlock() {} - - @JsonCreator - public LLMObsFrontendContentBlock( - @JsonProperty(required = true, value = JSON_PROPERTY_CODE) String code) { - this.code = code; - } - - public LLMObsFrontendContentBlock code(String code) { - this.code = code; - return this; - } - - /** - * HTML code rendered by a frontend block. Required for frontend blocks. - * - * @return code - */ - @JsonProperty(JSON_PROPERTY_CODE) - @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public LLMObsFrontendContentBlock type(LLMObsFrontendContentBlockType type) { - this.type = type; - this.unparsed |= !type.isValid(); - return this; - } - - /** - * Type discriminator for a frontend display block. - * - * @return type - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public LLMObsFrontendContentBlockType getType() { - return type; - } - - public void setType(LLMObsFrontendContentBlockType 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 LLMObsFrontendContentBlock - */ - @JsonAnySetter - public LLMObsFrontendContentBlock 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 LLMObsFrontendContentBlock object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - LLMObsFrontendContentBlock llmObsFrontendContentBlock = (LLMObsFrontendContentBlock) o; - return Objects.equals(this.code, llmObsFrontendContentBlock.code) - && Objects.equals(this.type, llmObsFrontendContentBlock.type) - && Objects.equals( - this.additionalProperties, llmObsFrontendContentBlock.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(code, type, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class LLMObsFrontendContentBlock {\n"); - sb.append(" code: ").append(toIndentedString(code)).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/LLMObsFrontendContentBlockType.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlockType.java deleted file mode 100644 index 632bc0a458b..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsFrontendContentBlockType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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; - -/** Type discriminator for a frontend display block. */ -@JsonSerialize( - using = LLMObsFrontendContentBlockType.LLMObsFrontendContentBlockTypeSerializer.class) -public class LLMObsFrontendContentBlockType extends ModelEnum { - - private static final Set allowedValues = new HashSet(Arrays.asList("frontend")); - - public static final LLMObsFrontendContentBlockType FRONTEND = - new LLMObsFrontendContentBlockType("frontend"); - - LLMObsFrontendContentBlockType(String value) { - super(value, allowedValues); - } - - public static class LLMObsFrontendContentBlockTypeSerializer - extends StdSerializer { - public LLMObsFrontendContentBlockTypeSerializer(Class t) { - super(t); - } - - public LLMObsFrontendContentBlockTypeSerializer() { - this(null); - } - - @Override - public void serialize( - LLMObsFrontendContentBlockType value, JsonGenerator jgen, SerializerProvider provider) - throws IOException, JsonProcessingException { - jgen.writeObject(value.value); - } - } - - @JsonCreator - public static LLMObsFrontendContentBlockType fromValue(String value) { - return new LLMObsFrontendContentBlockType(value); - } -} diff --git a/src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlock.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlock.java deleted file mode 100644 index b2f68514cd1..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlock.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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; - -/** Validation requirements for an existing non-frontend display block. */ -@JsonPropertyOrder({LLMObsLegacyContentBlock.JSON_PROPERTY_TYPE}) -@jakarta.annotation.Generated( - value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") -public class LLMObsLegacyContentBlock { - @JsonIgnore public boolean unparsed = false; - public static final String JSON_PROPERTY_TYPE = "type"; - private LLMObsLegacyContentBlockType type; - - public LLMObsLegacyContentBlock type(LLMObsLegacyContentBlockType type) { - this.type = type; - this.unparsed |= !type.isValid(); - return this; - } - - /** - * Type discriminator for an existing non-frontend display block. - * - * @return type - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public LLMObsLegacyContentBlockType getType() { - return type; - } - - public void setType(LLMObsLegacyContentBlockType 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 LLMObsLegacyContentBlock - */ - @JsonAnySetter - public LLMObsLegacyContentBlock 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 LLMObsLegacyContentBlock object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - LLMObsLegacyContentBlock llmObsLegacyContentBlock = (LLMObsLegacyContentBlock) o; - return Objects.equals(this.type, llmObsLegacyContentBlock.type) - && Objects.equals(this.additionalProperties, llmObsLegacyContentBlock.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(type, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class LLMObsLegacyContentBlock {\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/LLMObsLegacyContentBlockType.java b/src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlockType.java deleted file mode 100644 index db5ab192002..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/LLMObsLegacyContentBlockType.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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; - -/** Type discriminator for an existing non-frontend display block. */ -@JsonSerialize(using = LLMObsLegacyContentBlockType.LLMObsLegacyContentBlockTypeSerializer.class) -public class LLMObsLegacyContentBlockType extends ModelEnum { - - private static final Set allowedValues = - new HashSet( - Arrays.asList("markdown", "header", "text", "json", "image", "widget", "llmobs_trace")); - - public static final LLMObsLegacyContentBlockType MARKDOWN = - new LLMObsLegacyContentBlockType("markdown"); - public static final LLMObsLegacyContentBlockType HEADER = - new LLMObsLegacyContentBlockType("header"); - public static final LLMObsLegacyContentBlockType TEXT = new LLMObsLegacyContentBlockType("text"); - public static final LLMObsLegacyContentBlockType JSON = new LLMObsLegacyContentBlockType("json"); - public static final LLMObsLegacyContentBlockType IMAGE = - new LLMObsLegacyContentBlockType("image"); - public static final LLMObsLegacyContentBlockType WIDGET = - new LLMObsLegacyContentBlockType("widget"); - public static final LLMObsLegacyContentBlockType LLMOBS_TRACE = - new LLMObsLegacyContentBlockType("llmobs_trace"); - - LLMObsLegacyContentBlockType(String value) { - super(value, allowedValues); - } - - public static class LLMObsLegacyContentBlockTypeSerializer - extends StdSerializer { - public LLMObsLegacyContentBlockTypeSerializer(Class t) { - super(t); - } - - public LLMObsLegacyContentBlockTypeSerializer() { - this(null); - } - - @Override - public void serialize( - LLMObsLegacyContentBlockType value, JsonGenerator jgen, SerializerProvider provider) - throws IOException, JsonProcessingException { - jgen.writeObject(value.value); - } - } - - @JsonCreator - public static LLMObsLegacyContentBlockType fromValue(String value) { - return new LLMObsLegacyContentBlockType(value); - } -} diff --git a/src/main/java/com/datadog/api/client/v2/model/TriggerAttributes.java b/src/main/java/com/datadog/api/client/v2/model/TriggerAttributes.java index 9d13edc9135..e740fbd3351 100644 --- a/src/main/java/com/datadog/api/client/v2/model/TriggerAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/TriggerAttributes.java @@ -6,203 +6,271 @@ package com.datadog.api.client.v2.model; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; +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.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; +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.Objects; - -/** The trigger definition for starting an investigation. */ -@JsonPropertyOrder({ - TriggerAttributes.JSON_PROPERTY_GENERAL_INVESTIGATION, - TriggerAttributes.JSON_PROPERTY_MONITOR_ALERT_TRIGGER, - TriggerAttributes.JSON_PROPERTY_TYPE -}) +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") -public class TriggerAttributes { +@JsonDeserialize(using = TriggerAttributes.TriggerAttributesDeserializer.class) +@JsonSerialize(using = TriggerAttributes.TriggerAttributesSerializer.class) +public class TriggerAttributes extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(TriggerAttributes.class.getName()); + @JsonIgnore public boolean unparsed = false; - public static final String JSON_PROPERTY_GENERAL_INVESTIGATION = "general_investigation"; - private GeneralInvestigationAttributes generalInvestigation; - public static final String JSON_PROPERTY_MONITOR_ALERT_TRIGGER = "monitor_alert_trigger"; - private MonitorAlertTriggerAttributes monitorAlertTrigger; + public static class TriggerAttributesSerializer extends StdSerializer { + public TriggerAttributesSerializer(Class t) { + super(t); + } - public static final String JSON_PROPERTY_TYPE = "type"; - private TriggerType type; + public TriggerAttributesSerializer() { + this(null); + } - public TriggerAttributes generalInvestigation( - GeneralInvestigationAttributes generalInvestigation) { - this.generalInvestigation = generalInvestigation; - this.unparsed |= generalInvestigation.unparsed; - return this; + @Override + public void serialize(TriggerAttributes value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } } - /** - * Attributes for a general investigation, not tied to a specific monitor alert. - * - * @return generalInvestigation - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_GENERAL_INVESTIGATION) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public GeneralInvestigationAttributes getGeneralInvestigation() { - return generalInvestigation; - } + public static class TriggerAttributesDeserializer extends StdDeserializer { + public TriggerAttributesDeserializer() { + this(TriggerAttributes.class); + } - public void setGeneralInvestigation(GeneralInvestigationAttributes generalInvestigation) { - this.generalInvestigation = generalInvestigation; - if (generalInvestigation != null) { - this.unparsed |= generalInvestigation.unparsed; + public TriggerAttributesDeserializer(Class vc) { + super(vc); } - } - public TriggerAttributes monitorAlertTrigger(MonitorAlertTriggerAttributes monitorAlertTrigger) { - this.monitorAlertTrigger = monitorAlertTrigger; - this.unparsed |= monitorAlertTrigger.unparsed; - return this; - } + @Override + public TriggerAttributes 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 MonitorAlertTrigger + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MonitorAlertTrigger.class.equals(Integer.class) + || MonitorAlertTrigger.class.equals(Long.class) + || MonitorAlertTrigger.class.equals(Float.class) + || MonitorAlertTrigger.class.equals(Double.class) + || MonitorAlertTrigger.class.equals(Boolean.class) + || MonitorAlertTrigger.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MonitorAlertTrigger.class.equals(Integer.class) + || MonitorAlertTrigger.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MonitorAlertTrigger.class.equals(Float.class) + || MonitorAlertTrigger.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (MonitorAlertTrigger.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MonitorAlertTrigger.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(MonitorAlertTrigger.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 (!((MonitorAlertTrigger) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'MonitorAlertTrigger'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MonitorAlertTrigger'", e); + } - /** - * Attributes for a monitor alert trigger. - * - * @return monitorAlertTrigger - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_MONITOR_ALERT_TRIGGER) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public MonitorAlertTriggerAttributes getMonitorAlertTrigger() { - return monitorAlertTrigger; - } + // deserialize GeneralInvestigationTrigger + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (GeneralInvestigationTrigger.class.equals(Integer.class) + || GeneralInvestigationTrigger.class.equals(Long.class) + || GeneralInvestigationTrigger.class.equals(Float.class) + || GeneralInvestigationTrigger.class.equals(Double.class) + || GeneralInvestigationTrigger.class.equals(Boolean.class) + || GeneralInvestigationTrigger.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((GeneralInvestigationTrigger.class.equals(Integer.class) + || GeneralInvestigationTrigger.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((GeneralInvestigationTrigger.class.equals(Float.class) + || GeneralInvestigationTrigger.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (GeneralInvestigationTrigger.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (GeneralInvestigationTrigger.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(GeneralInvestigationTrigger.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 (!((GeneralInvestigationTrigger) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'GeneralInvestigationTrigger'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'GeneralInvestigationTrigger'", e); + } - public void setMonitorAlertTrigger(MonitorAlertTriggerAttributes monitorAlertTrigger) { - this.monitorAlertTrigger = monitorAlertTrigger; - if (monitorAlertTrigger != null) { - this.unparsed |= monitorAlertTrigger.unparsed; + TriggerAttributes ret = new TriggerAttributes(); + 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; } - } - public TriggerAttributes type(TriggerType type) { - this.type = type; - this.unparsed |= !type.isValid(); - return this; + /** Handle deserialization of the 'null' value. */ + @Override + public TriggerAttributes getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "TriggerAttributes cannot be null"); + } } - /** - * The type of trigger for the investigation. - * - * @return type - */ - @jakarta.annotation.Nullable - @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public TriggerType getType() { - return type; + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public TriggerAttributes() { + super("oneOf", Boolean.FALSE); } - public void setType(TriggerType type) { - if (!type.isValid()) { - this.unparsed = true; - } - this.type = type; + public TriggerAttributes(MonitorAlertTrigger o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); } - /** - * 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; + public TriggerAttributes(GeneralInvestigationTrigger o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } - /** - * 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 TriggerAttributes - */ - @JsonAnySetter - public TriggerAttributes putAdditionalProperty(String key, Object value) { - if (this.additionalProperties == null) { - this.additionalProperties = new HashMap(); - } - this.additionalProperties.put(key, value); - return this; + static { + schemas.put("MonitorAlertTrigger", new GenericType() {}); + schemas.put("GeneralInvestigationTrigger", new GenericType() {}); + JSON.registerDescendants(TriggerAttributes.class, Collections.unmodifiableMap(schemas)); } - /** - * Return the additional (undeclared) property. - * - * @return The additional properties - */ - @JsonAnyGetter - public Map getAdditionalProperties() { - return additionalProperties; + @Override + public Map getSchemas() { + return TriggerAttributes.schemas; } /** - * Return the additional (undeclared) property with the specified name. + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MonitorAlertTrigger, GeneralInvestigationTrigger * - * @param key The arbitrary key to get - * @return The specific additional property for the given key + *

    It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). */ - public Object getAdditionalProperty(String key) { - if (this.additionalProperties == null) { - return null; - } - return this.additionalProperties.get(key); - } - - /** Return true if this TriggerAttributes object is equal to o. */ @Override - public boolean equals(Object o) { - if (this == o) { - return true; + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(MonitorAlertTrigger.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(GeneralInvestigationTrigger.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; } - if (o == null || getClass() != o.getClass()) { - return false; + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; } - TriggerAttributes triggerAttributes = (TriggerAttributes) o; - return Objects.equals(this.generalInvestigation, triggerAttributes.generalInvestigation) - && Objects.equals(this.monitorAlertTrigger, triggerAttributes.monitorAlertTrigger) - && Objects.equals(this.type, triggerAttributes.type) - && Objects.equals(this.additionalProperties, triggerAttributes.additionalProperties); + throw new RuntimeException( + "Invalid instance type. Must be MonitorAlertTrigger, GeneralInvestigationTrigger"); } + /** + * Get the actual instance, which can be the following: MonitorAlertTrigger, + * GeneralInvestigationTrigger + * + * @return The actual instance (MonitorAlertTrigger, GeneralInvestigationTrigger) + */ @Override - public int hashCode() { - return Objects.hash(generalInvestigation, monitorAlertTrigger, type, additionalProperties); + public Object getActualInstance() { + return super.getActualInstance(); } - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TriggerAttributes {\n"); - sb.append(" generalInvestigation: ") - .append(toIndentedString(generalInvestigation)) - .append("\n"); - sb.append(" monitorAlertTrigger: ") - .append(toIndentedString(monitorAlertTrigger)) - .append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); - sb.append('}'); - return sb.toString(); + /** + * Get the actual instance of `MonitorAlertTrigger`. If the actual instance is not + * `MonitorAlertTrigger`, the ClassCastException will be thrown. + * + * @return The actual instance of `MonitorAlertTrigger` + * @throws ClassCastException if the instance is not `MonitorAlertTrigger` + */ + public MonitorAlertTrigger getMonitorAlertTrigger() throws ClassCastException { + return (MonitorAlertTrigger) super.getActualInstance(); } /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). + * Get the actual instance of `GeneralInvestigationTrigger`. If the actual instance is not + * `GeneralInvestigationTrigger`, the ClassCastException will be thrown. + * + * @return The actual instance of `GeneralInvestigationTrigger` + * @throws ClassCastException if the instance is not `GeneralInvestigationTrigger` */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); + public GeneralInvestigationTrigger getGeneralInvestigationTrigger() throws ClassCastException { + return (GeneralInvestigationTrigger) super.getActualInstance(); } } diff --git a/src/main/java/com/datadog/api/client/v2/model/TriggerType.java b/src/main/java/com/datadog/api/client/v2/model/TriggerType.java deleted file mode 100644 index 37160d724f9..00000000000 --- a/src/main/java/com/datadog/api/client/v2/model/TriggerType.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 trigger for the investigation. */ -@JsonSerialize(using = TriggerType.TriggerTypeSerializer.class) -public class TriggerType extends ModelEnum { - - private static final Set allowedValues = - new HashSet(Arrays.asList("monitor_alert_trigger", "general_investigation")); - - public static final TriggerType MONITOR_ALERT_TRIGGER = new TriggerType("monitor_alert_trigger"); - public static final TriggerType GENERAL_INVESTIGATION = new TriggerType("general_investigation"); - - TriggerType(String value) { - super(value, allowedValues); - } - - public static class TriggerTypeSerializer extends StdSerializer { - public TriggerTypeSerializer(Class t) { - super(t); - } - - public TriggerTypeSerializer() { - this(null); - } - - @Override - public void serialize(TriggerType value, JsonGenerator jgen, SerializerProvider provider) - throws IOException, JsonProcessingException { - jgen.writeObject(value.value); - } - } - - @JsonCreator - public static TriggerType fromValue(String value) { - return new TriggerType(value); - } -}