From a215ae982f55bbdcb5f2bfe43390b77fcf5b96e2 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 5 Jun 2026 18:53:56 +0000 Subject: [PATCH] Regenerate client from commit 6905dc7 of spec repo --- .generator/schemas/v1/openapi.yaml | 70 +++++ .../api/client/v1/model/Dashboard.java | 41 +++ .../DashboardDefaultTimeframeSetting.java | 290 ++++++++++++++++++ .../v1/model/DashboardFixedTimeframe.java | 206 +++++++++++++ .../v1/model/DashboardFixedTimeframeType.java | 55 ++++ .../v1/model/DashboardLiveTimeframe.java | 211 +++++++++++++ .../v1/model/DashboardLiveTimeframeType.java | 55 ++++ .../api/client/v1/api/dashboards.feature | 6 +- 8 files changed, 931 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardDefaultTimeframeSetting.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframe.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframeType.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframe.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframeType.java diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e922a2a26ab..a6d35cbd212 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1443,6 +1443,8 @@ components: format: date-time readOnly: true type: string + default_timeframe: + $ref: "#/components/schemas/DashboardDefaultTimeframeSetting" description: description: Description of the dashboard. nullable: true @@ -1557,6 +1559,18 @@ components: required: - data type: object + DashboardDefaultTimeframeSetting: + description: The default timeframe applied when opening the dashboard. Set to `null` to clear the dashboard's default timeframe. + discriminator: + mapping: + fixed: "#/components/schemas/DashboardFixedTimeframe" + live: "#/components/schemas/DashboardLiveTimeframe" + propertyName: type + nullable: true + oneOf: + - $ref: "#/components/schemas/DashboardLiveTimeframe" + - $ref: "#/components/schemas/DashboardFixedTimeframe" + type: object DashboardDeleteResponse: description: Response from the delete dashboard call. properties: @@ -1564,6 +1578,36 @@ components: description: ID of the deleted dashboard. type: string type: object + DashboardFixedTimeframe: + description: A fixed dashboard timeframe. + properties: + from: + description: Start time in milliseconds since epoch. + example: 1712080128000 + format: int64 + minimum: 0 + type: integer + to: + description: End time in milliseconds since epoch. + example: 1712083128000 + format: int64 + minimum: 0 + type: integer + type: + $ref: "#/components/schemas/DashboardFixedTimeframeType" + required: + - type + - from + - to + type: object + DashboardFixedTimeframeType: + description: Type of fixed timeframe. + enum: + - fixed + example: fixed + type: string + x-enum-varnames: + - FIXED DashboardGlobalTime: description: Object containing the live span selection for the dashboard. properties: @@ -1672,6 +1716,32 @@ components: $ref: "#/components/schemas/DashboardList" type: array type: object + DashboardLiveTimeframe: + description: A live dashboard timeframe. + properties: + type: + $ref: "#/components/schemas/DashboardLiveTimeframeType" + unit: + $ref: "#/components/schemas/WidgetLiveSpanUnit" + value: + description: Value of the live timeframe span. + example: 4 + format: int64 + minimum: 1 + type: integer + required: + - type + - value + - unit + type: object + DashboardLiveTimeframeType: + description: Type of live timeframe. + enum: + - live + example: live + type: string + x-enum-varnames: + - LIVE DashboardReflowType: description: |- Reflow type for a **new dashboard layout** dashboard. Set this only when layout type is 'ordered'. diff --git a/src/main/java/com/datadog/api/client/v1/model/Dashboard.java b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java index eed5de68911..02ae1d89259 100644 --- a/src/main/java/com/datadog/api/client/v1/model/Dashboard.java +++ b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java @@ -29,6 +29,7 @@ Dashboard.JSON_PROPERTY_AUTHOR_HANDLE, Dashboard.JSON_PROPERTY_AUTHOR_NAME, Dashboard.JSON_PROPERTY_CREATED_AT, + Dashboard.JSON_PROPERTY_DEFAULT_TIMEFRAME, Dashboard.JSON_PROPERTY_DESCRIPTION, Dashboard.JSON_PROPERTY_ID, Dashboard.JSON_PROPERTY_IS_READ_ONLY, @@ -58,6 +59,10 @@ public class Dashboard { public static final String JSON_PROPERTY_CREATED_AT = "created_at"; private OffsetDateTime createdAt; + public static final String JSON_PROPERTY_DEFAULT_TIMEFRAME = "default_timeframe"; + private JsonNullable defaultTimeframe = + JsonNullable.undefined(); + public static final String JSON_PROPERTY_DESCRIPTION = "description"; private JsonNullable description = JsonNullable.undefined(); @@ -169,6 +174,39 @@ public OffsetDateTime getCreatedAt() { return createdAt; } + public Dashboard defaultTimeframe(DashboardDefaultTimeframeSetting defaultTimeframe) { + this.defaultTimeframe = JsonNullable.of(defaultTimeframe); + return this; + } + + /** + * The default timeframe applied when opening the dashboard. Set to null to clear the + * dashboard's default timeframe. + * + * @return defaultTimeframe + */ + @jakarta.annotation.Nullable + @JsonIgnore + public DashboardDefaultTimeframeSetting getDefaultTimeframe() { + return defaultTimeframe.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DEFAULT_TIMEFRAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDefaultTimeframe_JsonNullable() { + return defaultTimeframe; + } + + @JsonProperty(JSON_PROPERTY_DEFAULT_TIMEFRAME) + public void setDefaultTimeframe_JsonNullable( + JsonNullable defaultTimeframe) { + this.defaultTimeframe = defaultTimeframe; + } + + public void setDefaultTimeframe(DashboardDefaultTimeframeSetting defaultTimeframe) { + this.defaultTimeframe = JsonNullable.of(defaultTimeframe); + } + public Dashboard description(String description) { this.description = JsonNullable.of(description); return this; @@ -678,6 +716,7 @@ public boolean equals(Object o) { return Objects.equals(this.authorHandle, dashboard.authorHandle) && Objects.equals(this.authorName, dashboard.authorName) && Objects.equals(this.createdAt, dashboard.createdAt) + && Objects.equals(this.defaultTimeframe, dashboard.defaultTimeframe) && Objects.equals(this.description, dashboard.description) && Objects.equals(this.id, dashboard.id) && Objects.equals(this.isReadOnly, dashboard.isReadOnly) @@ -702,6 +741,7 @@ public int hashCode() { authorHandle, authorName, createdAt, + defaultTimeframe, description, id, isReadOnly, @@ -727,6 +767,7 @@ public String toString() { sb.append(" authorHandle: ").append(toIndentedString(authorHandle)).append("\n"); sb.append(" authorName: ").append(toIndentedString(authorName)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" defaultTimeframe: ").append(toIndentedString(defaultTimeframe)).append("\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" isReadOnly: ").append(toIndentedString(isReadOnly)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardDefaultTimeframeSetting.java b/src/main/java/com/datadog/api/client/v1/model/DashboardDefaultTimeframeSetting.java new file mode 100644 index 00000000000..6ce680d4c28 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardDefaultTimeframeSetting.java @@ -0,0 +1,290 @@ +/* + * 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.v1.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 = DashboardDefaultTimeframeSetting.DashboardDefaultTimeframeSettingDeserializer.class) +@JsonSerialize( + using = DashboardDefaultTimeframeSetting.DashboardDefaultTimeframeSettingSerializer.class) +public class DashboardDefaultTimeframeSetting extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(DashboardDefaultTimeframeSetting.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DashboardDefaultTimeframeSettingSerializer + extends StdSerializer { + public DashboardDefaultTimeframeSettingSerializer(Class t) { + super(t); + } + + public DashboardDefaultTimeframeSettingSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardDefaultTimeframeSetting value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DashboardDefaultTimeframeSettingDeserializer + extends StdDeserializer { + public DashboardDefaultTimeframeSettingDeserializer() { + this(DashboardDefaultTimeframeSetting.class); + } + + public DashboardDefaultTimeframeSettingDeserializer(Class vc) { + super(vc); + } + + @Override + public DashboardDefaultTimeframeSetting 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 DashboardLiveTimeframe + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DashboardLiveTimeframe.class.equals(Integer.class) + || DashboardLiveTimeframe.class.equals(Long.class) + || DashboardLiveTimeframe.class.equals(Float.class) + || DashboardLiveTimeframe.class.equals(Double.class) + || DashboardLiveTimeframe.class.equals(Boolean.class) + || DashboardLiveTimeframe.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DashboardLiveTimeframe.class.equals(Integer.class) + || DashboardLiveTimeframe.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DashboardLiveTimeframe.class.equals(Float.class) + || DashboardLiveTimeframe.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DashboardLiveTimeframe.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DashboardLiveTimeframe.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DashboardLiveTimeframe.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 (!((DashboardLiveTimeframe) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DashboardLiveTimeframe'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DashboardLiveTimeframe'", e); + } + + // deserialize DashboardFixedTimeframe + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DashboardFixedTimeframe.class.equals(Integer.class) + || DashboardFixedTimeframe.class.equals(Long.class) + || DashboardFixedTimeframe.class.equals(Float.class) + || DashboardFixedTimeframe.class.equals(Double.class) + || DashboardFixedTimeframe.class.equals(Boolean.class) + || DashboardFixedTimeframe.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DashboardFixedTimeframe.class.equals(Integer.class) + || DashboardFixedTimeframe.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DashboardFixedTimeframe.class.equals(Float.class) + || DashboardFixedTimeframe.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DashboardFixedTimeframe.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DashboardFixedTimeframe.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DashboardFixedTimeframe.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 (!((DashboardFixedTimeframe) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DashboardFixedTimeframe'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DashboardFixedTimeframe'", e); + } + + DashboardDefaultTimeframeSetting ret = new DashboardDefaultTimeframeSetting(); + 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 DashboardDefaultTimeframeSetting getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DashboardDefaultTimeframeSetting() { + super("oneOf", Boolean.TRUE); + } + + public DashboardDefaultTimeframeSetting(DashboardLiveTimeframe o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + public DashboardDefaultTimeframeSetting(DashboardFixedTimeframe o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("DashboardLiveTimeframe", new GenericType() {}); + schemas.put("DashboardFixedTimeframe", new GenericType() {}); + JSON.registerDescendants( + DashboardDefaultTimeframeSetting.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DashboardDefaultTimeframeSetting.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DashboardLiveTimeframe, DashboardFixedTimeframe + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(DashboardLiveTimeframe.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(DashboardFixedTimeframe.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 DashboardLiveTimeframe, DashboardFixedTimeframe"); + } + + /** + * Get the actual instance, which can be the following: DashboardLiveTimeframe, + * DashboardFixedTimeframe + * + * @return The actual instance (DashboardLiveTimeframe, DashboardFixedTimeframe) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DashboardLiveTimeframe`. If the actual instance is not + * `DashboardLiveTimeframe`, the ClassCastException will be thrown. + * + * @return The actual instance of `DashboardLiveTimeframe` + * @throws ClassCastException if the instance is not `DashboardLiveTimeframe` + */ + public DashboardLiveTimeframe getDashboardLiveTimeframe() throws ClassCastException { + return (DashboardLiveTimeframe) super.getActualInstance(); + } + + /** + * Get the actual instance of `DashboardFixedTimeframe`. If the actual instance is not + * `DashboardFixedTimeframe`, the ClassCastException will be thrown. + * + * @return The actual instance of `DashboardFixedTimeframe` + * @throws ClassCastException if the instance is not `DashboardFixedTimeframe` + */ + public DashboardFixedTimeframe getDashboardFixedTimeframe() throws ClassCastException { + return (DashboardFixedTimeframe) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframe.java b/src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframe.java new file mode 100644 index 00000000000..f453f7ec851 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframe.java @@ -0,0 +1,206 @@ +/* + * 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.v1.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 fixed dashboard timeframe. */ +@JsonPropertyOrder({ + DashboardFixedTimeframe.JSON_PROPERTY_FROM, + DashboardFixedTimeframe.JSON_PROPERTY_TO, + DashboardFixedTimeframe.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardFixedTimeframe { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FROM = "from"; + private Long from; + + public static final String JSON_PROPERTY_TO = "to"; + private Long to; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DashboardFixedTimeframeType type; + + public DashboardFixedTimeframe() {} + + @JsonCreator + public DashboardFixedTimeframe( + @JsonProperty(required = true, value = JSON_PROPERTY_FROM) Long from, + @JsonProperty(required = true, value = JSON_PROPERTY_TO) Long to, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DashboardFixedTimeframeType type) { + this.from = from; + this.to = to; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DashboardFixedTimeframe from(Long from) { + this.from = from; + return this; + } + + /** + * Start time in milliseconds since epoch. minimum: 0 + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getFrom() { + return from; + } + + public void setFrom(Long from) { + this.from = from; + } + + public DashboardFixedTimeframe to(Long to) { + this.to = to; + return this; + } + + /** + * End time in milliseconds since epoch. minimum: 0 + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getTo() { + return to; + } + + public void setTo(Long to) { + this.to = to; + } + + public DashboardFixedTimeframe type(DashboardFixedTimeframeType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of fixed timeframe. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DashboardFixedTimeframeType getType() { + return type; + } + + public void setType(DashboardFixedTimeframeType 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 DashboardFixedTimeframe + */ + @JsonAnySetter + public DashboardFixedTimeframe 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 DashboardFixedTimeframe object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardFixedTimeframe dashboardFixedTimeframe = (DashboardFixedTimeframe) o; + return Objects.equals(this.from, dashboardFixedTimeframe.from) + && Objects.equals(this.to, dashboardFixedTimeframe.to) + && Objects.equals(this.type, dashboardFixedTimeframe.type) + && Objects.equals(this.additionalProperties, dashboardFixedTimeframe.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(from, to, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardFixedTimeframe {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).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/v1/model/DashboardFixedTimeframeType.java b/src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframeType.java new file mode 100644 index 00000000000..56ccf7a28ab --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardFixedTimeframeType.java @@ -0,0 +1,55 @@ +/* + * 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.v1.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 of fixed timeframe. */ +@JsonSerialize(using = DashboardFixedTimeframeType.DashboardFixedTimeframeTypeSerializer.class) +public class DashboardFixedTimeframeType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("fixed")); + + public static final DashboardFixedTimeframeType FIXED = new DashboardFixedTimeframeType("fixed"); + + DashboardFixedTimeframeType(String value) { + super(value, allowedValues); + } + + public static class DashboardFixedTimeframeTypeSerializer + extends StdSerializer { + public DashboardFixedTimeframeTypeSerializer(Class t) { + super(t); + } + + public DashboardFixedTimeframeTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardFixedTimeframeType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DashboardFixedTimeframeType fromValue(String value) { + return new DashboardFixedTimeframeType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframe.java b/src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframe.java new file mode 100644 index 00000000000..e3c326df4bb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframe.java @@ -0,0 +1,211 @@ +/* + * 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.v1.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 live dashboard timeframe. */ +@JsonPropertyOrder({ + DashboardLiveTimeframe.JSON_PROPERTY_TYPE, + DashboardLiveTimeframe.JSON_PROPERTY_UNIT, + DashboardLiveTimeframe.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardLiveTimeframe { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TYPE = "type"; + private DashboardLiveTimeframeType type; + + public static final String JSON_PROPERTY_UNIT = "unit"; + private WidgetLiveSpanUnit unit; + + public static final String JSON_PROPERTY_VALUE = "value"; + private Long value; + + public DashboardLiveTimeframe() {} + + @JsonCreator + public DashboardLiveTimeframe( + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DashboardLiveTimeframeType type, + @JsonProperty(required = true, value = JSON_PROPERTY_UNIT) WidgetLiveSpanUnit unit, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) Long value) { + this.type = type; + this.unparsed |= !type.isValid(); + this.unit = unit; + this.unparsed |= !unit.isValid(); + this.value = value; + } + + public DashboardLiveTimeframe type(DashboardLiveTimeframeType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Type of live timeframe. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DashboardLiveTimeframeType getType() { + return type; + } + + public void setType(DashboardLiveTimeframeType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + public DashboardLiveTimeframe unit(WidgetLiveSpanUnit unit) { + this.unit = unit; + this.unparsed |= !unit.isValid(); + return this; + } + + /** + * Unit of the time span. + * + * @return unit + */ + @JsonProperty(JSON_PROPERTY_UNIT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public WidgetLiveSpanUnit getUnit() { + return unit; + } + + public void setUnit(WidgetLiveSpanUnit unit) { + if (!unit.isValid()) { + this.unparsed = true; + } + this.unit = unit; + } + + public DashboardLiveTimeframe value(Long value) { + this.value = value; + return this; + } + + /** + * Value of the live timeframe span. minimum: 1 + * + * @return value + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Long getValue() { + return value; + } + + public void setValue(Long value) { + this.value = value; + } + + /** + * 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 DashboardLiveTimeframe + */ + @JsonAnySetter + public DashboardLiveTimeframe 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 DashboardLiveTimeframe object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardLiveTimeframe dashboardLiveTimeframe = (DashboardLiveTimeframe) o; + return Objects.equals(this.type, dashboardLiveTimeframe.type) + && Objects.equals(this.unit, dashboardLiveTimeframe.unit) + && Objects.equals(this.value, dashboardLiveTimeframe.value) + && Objects.equals(this.additionalProperties, dashboardLiveTimeframe.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, unit, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardLiveTimeframe {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" unit: ").append(toIndentedString(unit)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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/v1/model/DashboardLiveTimeframeType.java b/src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframeType.java new file mode 100644 index 00000000000..61651c435bd --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardLiveTimeframeType.java @@ -0,0 +1,55 @@ +/* + * 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.v1.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 of live timeframe. */ +@JsonSerialize(using = DashboardLiveTimeframeType.DashboardLiveTimeframeTypeSerializer.class) +public class DashboardLiveTimeframeType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("live")); + + public static final DashboardLiveTimeframeType LIVE = new DashboardLiveTimeframeType("live"); + + DashboardLiveTimeframeType(String value) { + super(value, allowedValues); + } + + public static class DashboardLiveTimeframeTypeSerializer + extends StdSerializer { + public DashboardLiveTimeframeTypeSerializer(Class t) { + super(t); + } + + public DashboardLiveTimeframeTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardLiveTimeframeType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DashboardLiveTimeframeType fromValue(String value) { + return new DashboardLiveTimeframeType(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature index 932dc22b0b3..2fb06cd716e 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature @@ -90,7 +90,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards-backend Scenario: Create a new dashboard returns "Bad Request" response Given new "CreateDashboard" request - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1463,7 +1463,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Bad Request" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1471,7 +1471,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Item Not Found" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"default_timeframe": {"type": "live", "unit": "minute", "value": 4}, "description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 404 Item Not Found