Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-24 13:19:24.897822",
"spec_repo_commit": "8772660e"
"regenerated": "2025-06-25 11:39:38.389684",
"spec_repo_commit": "5d86661b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-06-24 13:19:24.915653",
"spec_repo_commit": "8772660e"
"regenerated": "2025-06-25 11:39:38.406037",
"spec_repo_commit": "5d86661b"
}
}
}
15 changes: 14 additions & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17201,8 +17201,8 @@ components:
description: DNS server to use for DNS tests.
type: string
dnsServerPort:
$ref: '#/components/schemas/SyntheticsTestRequestDNSServerPort'
description: DNS server port to use for DNS tests.
type: string
files:
description: Files to be used as part of the request in the test. Only valid
if `bodyType` is `multipart/form-data`.
Expand Down Expand Up @@ -17356,6 +17356,15 @@ components:
description: Date of update of the certificate or key, ISO format.
type: string
type: object
SyntheticsTestRequestDNSServerPort:
description: DNS server port to use for DNS tests.
oneOf:
- $ref: '#/components/schemas/SyntheticsTestRequestNumericalDNSServerPort'
- $ref: '#/components/schemas/SyntheticsTestRequestVariableDNSServerPort'
SyntheticsTestRequestNumericalDNSServerPort:
description: Integer DNS server port number to use when performing the test.
format: int64
type: integer
SyntheticsTestRequestNumericalPort:
description: Integer Port number to use when performing the test.
format: int64
Expand All @@ -17377,6 +17386,10 @@ components:
required:
- url
type: object
SyntheticsTestRequestVariableDNSServerPort:
description: String DNS server port number to use when performing the test.
Supports templated variables.
type: string
SyntheticsTestRequestVariablePort:
description: String Port number to use when performing the test. Supports templated
variables.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.datadog.api.client.v1.model.SyntheticsTestOptionsHTTPVersion;
import com.datadog.api.client.v1.model.SyntheticsTestOptionsRetry;
import com.datadog.api.client.v1.model.SyntheticsTestRequest;
import com.datadog.api.client.v1.model.SyntheticsTestRequestDNSServerPort;
import com.datadog.api.client.v1.model.SyntheticsTestRequestPort;
import com.datadog.api.client.v1.model.SyntheticsVariableParser;
import java.util.Arrays;
Expand Down Expand Up @@ -170,7 +171,8 @@ public static void main(String[] args) {
new SyntheticsTestRequest()
.host("troisdizaines.com")
.dnsServer("8.8.8.8")
.dnsServerPort("53"))),
.dnsServerPort(
new SyntheticsTestRequestDNSServerPort("53")))),
new SyntheticsAPIStep(
new SyntheticsAPITestStep()
.name("TCP step")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class SyntheticsTestRequest {
private String dnsServer;

public static final String JSON_PROPERTY_DNS_SERVER_PORT = "dnsServerPort";
private String dnsServerPort;
private SyntheticsTestRequestDNSServerPort dnsServerPort;

public static final String JSON_PROPERTY_FILES = "files";
private List<SyntheticsTestRequestBodyFile> files = null;
Expand Down Expand Up @@ -409,8 +409,9 @@ public void setDnsServer(String dnsServer) {
this.dnsServer = dnsServer;
}

public SyntheticsTestRequest dnsServerPort(String dnsServerPort) {
public SyntheticsTestRequest dnsServerPort(SyntheticsTestRequestDNSServerPort dnsServerPort) {
this.dnsServerPort = dnsServerPort;
this.unparsed |= dnsServerPort.unparsed;
return this;
}

Expand All @@ -422,11 +423,11 @@ public SyntheticsTestRequest dnsServerPort(String dnsServerPort) {
@jakarta.annotation.Nullable
@JsonProperty(JSON_PROPERTY_DNS_SERVER_PORT)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDnsServerPort() {
public SyntheticsTestRequestDNSServerPort getDnsServerPort() {
return dnsServerPort;
}

public void setDnsServerPort(String dnsServerPort) {
public void setDnsServerPort(SyntheticsTestRequestDNSServerPort dnsServerPort) {
this.dnsServerPort = dnsServerPort;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
/*
* 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 = SyntheticsTestRequestDNSServerPort.SyntheticsTestRequestDNSServerPortDeserializer.class)
@JsonSerialize(
using = SyntheticsTestRequestDNSServerPort.SyntheticsTestRequestDNSServerPortSerializer.class)
public class SyntheticsTestRequestDNSServerPort extends AbstractOpenApiSchema {
private static final Logger log =
Logger.getLogger(SyntheticsTestRequestDNSServerPort.class.getName());

@JsonIgnore public boolean unparsed = false;

public static class SyntheticsTestRequestDNSServerPortSerializer
extends StdSerializer<SyntheticsTestRequestDNSServerPort> {
public SyntheticsTestRequestDNSServerPortSerializer(
Class<SyntheticsTestRequestDNSServerPort> t) {
super(t);
}

public SyntheticsTestRequestDNSServerPortSerializer() {
this(null);
}

@Override
public void serialize(
SyntheticsTestRequestDNSServerPort value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeObject(value.getActualInstance());
}
}

public static class SyntheticsTestRequestDNSServerPortDeserializer
extends StdDeserializer<SyntheticsTestRequestDNSServerPort> {
public SyntheticsTestRequestDNSServerPortDeserializer() {
this(SyntheticsTestRequestDNSServerPort.class);
}

public SyntheticsTestRequestDNSServerPortDeserializer(Class<?> vc) {
super(vc);
}

@Override
public SyntheticsTestRequestDNSServerPort 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 Long
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (Long.class.equals(Integer.class)
|| Long.class.equals(Long.class)
|| Long.class.equals(Float.class)
|| Long.class.equals(Double.class)
|| Long.class.equals(Boolean.class)
|| Long.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((Long.class.equals(Integer.class) || Long.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((Long.class.equals(Float.class) || Long.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(Long.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (Long.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(Long.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
deserialized = tmp;
match++;

log.log(Level.FINER, "Input data matches schema 'Long'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'Long'", e);
}

// deserialize String
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (String.class.equals(Integer.class)
|| String.class.equals(Long.class)
|| String.class.equals(Float.class)
|| String.class.equals(Double.class)
|| String.class.equals(Boolean.class)
|| String.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((String.class.equals(Integer.class) || String.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((String.class.equals(Float.class) || String.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(String.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(String.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(String.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
deserialized = tmp;
match++;

log.log(Level.FINER, "Input data matches schema 'String'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'String'", e);
}

SyntheticsTestRequestDNSServerPort ret = new SyntheticsTestRequestDNSServerPort();
if (match == 1) {
ret.setActualInstance(deserialized);
} else {
Map<String, Object> res =
new ObjectMapper()
.readValue(
tree.traverse(jp.getCodec()).readValueAsTree().toString(),
new TypeReference<Map<String, Object>>() {});
ret.setActualInstance(new UnparsedObject(res));
}
return ret;
}

/** Handle deserialization of the 'null' value. */
@Override
public SyntheticsTestRequestDNSServerPort getNullValue(DeserializationContext ctxt)
throws JsonMappingException {
throw new JsonMappingException(
ctxt.getParser(), "SyntheticsTestRequestDNSServerPort cannot be null");
}
}

// store a list of schema names defined in oneOf
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();

public SyntheticsTestRequestDNSServerPort() {
super("oneOf", Boolean.FALSE);
}

public SyntheticsTestRequestDNSServerPort(Long o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

public SyntheticsTestRequestDNSServerPort(String o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

static {
schemas.put("Long", new GenericType<Long>() {});
schemas.put("String", new GenericType<String>() {});
JSON.registerDescendants(
SyntheticsTestRequestDNSServerPort.class, Collections.unmodifiableMap(schemas));
}

@Override
public Map<String, GenericType> getSchemas() {
return SyntheticsTestRequestDNSServerPort.schemas;
}

/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: Long, String
*
* <p>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(Long.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(String.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}

if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException("Invalid instance type. Must be Long, String");
}

/**
* Get the actual instance, which can be the following: Long, String
*
* @return The actual instance (Long, String)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}

/**
* Get the actual instance of `Long`. If the actual instance is not `Long`, the ClassCastException
* will be thrown.
*
* @return The actual instance of `Long`
* @throws ClassCastException if the instance is not `Long`
*/
public Long getLong() throws ClassCastException {
return (Long) super.getActualInstance();
}

/**
* Get the actual instance of `String`. If the actual instance is not `String`, the
* ClassCastException will be thrown.
*
* @return The actual instance of `String`
* @throws ClassCastException if the instance is not `String`
*/
public String getString() throws ClassCastException {
return (String) super.getActualInstance();
}
}