diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a04387a6880..77a2549ffaf 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -48659,6 +48659,16 @@ components: description: Name of the environment variable or secret that holds the username (used when `auth_strategy` is `plain`). example: HTTP_AUTH_USERNAME type: string + valid_tokens: + description: |- + A list of tokens that are accepted for authenticating incoming HTTP requests. When set, + the source rejects any request whose token does not match an enabled entry in this list. + Cannot be combined with the `plain` auth strategy. + items: + $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidToken" + maxItems: 1000 + minItems: 1 + type: array required: - id - type @@ -48684,6 +48694,55 @@ components: type: string x-enum-varnames: - HTTP_SERVER + ObservabilityPipelineHttpServerSourceValidToken: + description: An accepted token used to authenticate incoming HTTP server requests. + properties: + enabled: + default: true + description: |- + Whether this token is currently accepted. Disabled tokens are rejected without + being removed from the configuration. + example: true + type: boolean + field_to_add: + $ref: "#/components/schemas/ObservabilityPipelineSourceValidTokenFieldToAdd" + path_to_token: + $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToToken" + token_key: + description: Name of the environment variable or secret that holds the expected token value. + example: HTTP_SERVER_TOKEN + pattern: "^[A-Za-z0-9_]+$" + type: string + required: + - token_key + type: object + ObservabilityPipelineHttpServerSourceValidTokenPathToToken: + description: |- + Specifies where the worker extracts the token from in the incoming HTTP request. + Either a built-in location (`path` or `address`) or an HTTP header object. + oneOf: + - $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation" + - $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader" + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader: + description: Extract the token from a specific HTTP request header. + properties: + header: + description: The name of the HTTP header that carries the token. + example: X-Token + type: string + required: + - header + type: object + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation: + description: Built-in token location on the incoming HTTP request. + enum: + - path + - address + example: path + type: string + x-enum-varnames: + - PATH + - ADDRESS ObservabilityPipelineKafkaDestination: description: |- The `kafka` destination sends logs to Apache Kafka topics. @@ -50707,6 +50766,27 @@ components: type: string x-enum-varnames: - SOCKET + ObservabilityPipelineSourceValidTokenFieldToAdd: + description: |- + An optional metadata field that is attached to every event authenticated by the + associated token. Both `key` and `value` must match `^[A-Za-z0-9_]+$`. + properties: + key: + description: The metadata field name to add to incoming events. + example: token_name + maxLength: 256 + pattern: "^[A-Za-z0-9_]+$" + type: string + value: + description: The metadata field value to add to incoming events. + example: my_token + maxLength: 1024 + pattern: "^[A-Za-z0-9_]+$" + type: string + required: + - key + - value + type: object ObservabilityPipelineSpec: description: Input schema representing an observability pipeline configuration. Used in create and validate requests. properties: @@ -50903,6 +50983,15 @@ components: $ref: "#/components/schemas/ObservabilityPipelineTls" type: $ref: "#/components/schemas/ObservabilityPipelineSplunkHecSourceType" + valid_tokens: + description: |- + A list of tokens that are accepted for authenticating incoming HEC requests. When set, the source + rejects any request whose HEC token does not match an enabled entry in this list. + items: + $ref: "#/components/schemas/ObservabilityPipelineSplunkHecSourceValidToken" + maxItems: 1000 + minItems: 1 + type: array required: - id - type @@ -50917,6 +51006,26 @@ components: type: string x-enum-varnames: - SPLUNK_HEC + ObservabilityPipelineSplunkHecSourceValidToken: + description: An accepted HEC token used to authenticate incoming Splunk HEC requests. + properties: + enabled: + default: true + description: |- + Whether this token is currently accepted. Disabled tokens are rejected without + being removed from the configuration. + example: true + type: boolean + field_to_add: + $ref: "#/components/schemas/ObservabilityPipelineSourceValidTokenFieldToAdd" + token_key: + description: Name of the environment variable or secret that holds the expected HEC token value. + example: SPLUNK_HEC_TOKEN + pattern: "^[A-Za-z0-9_]+$" + type: string + required: + - token_key + type: object ObservabilityPipelineSplunkTcpSource: description: |- The `splunk_tcp` source receives logs from a Splunk Universal Forwarder over TCP. diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSource.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSource.java index b5c04e02620..2682a44d1ec 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSource.java +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSource.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -31,7 +33,8 @@ ObservabilityPipelineHttpServerSource.JSON_PROPERTY_PASSWORD_KEY, ObservabilityPipelineHttpServerSource.JSON_PROPERTY_TLS, ObservabilityPipelineHttpServerSource.JSON_PROPERTY_TYPE, - ObservabilityPipelineHttpServerSource.JSON_PROPERTY_USERNAME_KEY + ObservabilityPipelineHttpServerSource.JSON_PROPERTY_USERNAME_KEY, + ObservabilityPipelineHttpServerSource.JSON_PROPERTY_VALID_TOKENS }) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") @@ -65,6 +68,9 @@ public class ObservabilityPipelineHttpServerSource { public static final String JSON_PROPERTY_USERNAME_KEY = "username_key"; private String usernameKey; + public static final String JSON_PROPERTY_VALID_TOKENS = "valid_tokens"; + private List validTokens = null; + public ObservabilityPipelineHttpServerSource() {} @JsonCreator @@ -288,6 +294,43 @@ public void setUsernameKey(String usernameKey) { this.usernameKey = usernameKey; } + public ObservabilityPipelineHttpServerSource validTokens( + List validTokens) { + this.validTokens = validTokens; + for (ObservabilityPipelineHttpServerSourceValidToken item : validTokens) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ObservabilityPipelineHttpServerSource addValidTokensItem( + ObservabilityPipelineHttpServerSourceValidToken validTokensItem) { + if (this.validTokens == null) { + this.validTokens = new ArrayList<>(); + } + this.validTokens.add(validTokensItem); + this.unparsed |= validTokensItem.unparsed; + return this; + } + + /** + * A list of tokens that are accepted for authenticating incoming HTTP requests. When set, the + * source rejects any request whose token does not match an enabled entry in this list. Cannot be + * combined with the plain auth strategy. + * + * @return validTokens + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALID_TOKENS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getValidTokens() { + return validTokens; + } + + public void setValidTokens(List validTokens) { + this.validTokens = validTokens; + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -354,6 +397,7 @@ public boolean equals(Object o) { && Objects.equals(this.tls, observabilityPipelineHttpServerSource.tls) && Objects.equals(this.type, observabilityPipelineHttpServerSource.type) && Objects.equals(this.usernameKey, observabilityPipelineHttpServerSource.usernameKey) + && Objects.equals(this.validTokens, observabilityPipelineHttpServerSource.validTokens) && Objects.equals( this.additionalProperties, observabilityPipelineHttpServerSource.additionalProperties); } @@ -370,6 +414,7 @@ public int hashCode() { tls, type, usernameKey, + validTokens, additionalProperties); } @@ -386,6 +431,7 @@ public String toString() { sb.append(" tls: ").append(toIndentedString(tls)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" usernameKey: ").append(toIndentedString(usernameKey)).append("\n"); + sb.append(" validTokens: ").append(toIndentedString(validTokens)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidToken.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidToken.java new file mode 100644 index 00000000000..7e152476277 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidToken.java @@ -0,0 +1,241 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** An accepted token used to authenticate incoming HTTP server requests. */ +@JsonPropertyOrder({ + ObservabilityPipelineHttpServerSourceValidToken.JSON_PROPERTY_ENABLED, + ObservabilityPipelineHttpServerSourceValidToken.JSON_PROPERTY_FIELD_TO_ADD, + ObservabilityPipelineHttpServerSourceValidToken.JSON_PROPERTY_PATH_TO_TOKEN, + ObservabilityPipelineHttpServerSourceValidToken.JSON_PROPERTY_TOKEN_KEY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineHttpServerSourceValidToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENABLED = "enabled"; + private Boolean enabled = true; + + public static final String JSON_PROPERTY_FIELD_TO_ADD = "field_to_add"; + private ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd; + + public static final String JSON_PROPERTY_PATH_TO_TOKEN = "path_to_token"; + private ObservabilityPipelineHttpServerSourceValidTokenPathToToken pathToToken; + + public static final String JSON_PROPERTY_TOKEN_KEY = "token_key"; + private String tokenKey; + + public ObservabilityPipelineHttpServerSourceValidToken() {} + + @JsonCreator + public ObservabilityPipelineHttpServerSourceValidToken( + @JsonProperty(required = true, value = JSON_PROPERTY_TOKEN_KEY) String tokenKey) { + this.tokenKey = tokenKey; + } + + public ObservabilityPipelineHttpServerSourceValidToken enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Whether this token is currently accepted. Disabled tokens are rejected without being removed + * from the configuration. + * + * @return enabled + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public ObservabilityPipelineHttpServerSourceValidToken fieldToAdd( + ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd) { + this.fieldToAdd = fieldToAdd; + this.unparsed |= fieldToAdd.unparsed; + return this; + } + + /** + * An optional metadata field that is attached to every event authenticated by the associated + * token. Both key and value must match ^[A-Za-z0-9_]+$. + * + * @return fieldToAdd + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIELD_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObservabilityPipelineSourceValidTokenFieldToAdd getFieldToAdd() { + return fieldToAdd; + } + + public void setFieldToAdd(ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd) { + this.fieldToAdd = fieldToAdd; + } + + public ObservabilityPipelineHttpServerSourceValidToken pathToToken( + ObservabilityPipelineHttpServerSourceValidTokenPathToToken pathToToken) { + this.pathToToken = pathToToken; + this.unparsed |= pathToToken.unparsed; + return this; + } + + /** + * Specifies where the worker extracts the token from in the incoming HTTP request. Either a + * built-in location (path or address) or an HTTP header object. + * + * @return pathToToken + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PATH_TO_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObservabilityPipelineHttpServerSourceValidTokenPathToToken getPathToToken() { + return pathToToken; + } + + public void setPathToToken( + ObservabilityPipelineHttpServerSourceValidTokenPathToToken pathToToken) { + this.pathToToken = pathToToken; + } + + public ObservabilityPipelineHttpServerSourceValidToken tokenKey(String tokenKey) { + this.tokenKey = tokenKey; + return this; + } + + /** + * Name of the environment variable or secret that holds the expected token value. + * + * @return tokenKey + */ + @JsonProperty(JSON_PROPERTY_TOKEN_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTokenKey() { + return tokenKey; + } + + public void setTokenKey(String tokenKey) { + this.tokenKey = tokenKey; + } + + /** + * 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 ObservabilityPipelineHttpServerSourceValidToken + */ + @JsonAnySetter + public ObservabilityPipelineHttpServerSourceValidToken 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 ObservabilityPipelineHttpServerSourceValidToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineHttpServerSourceValidToken + observabilityPipelineHttpServerSourceValidToken = + (ObservabilityPipelineHttpServerSourceValidToken) o; + return Objects.equals(this.enabled, observabilityPipelineHttpServerSourceValidToken.enabled) + && Objects.equals( + this.fieldToAdd, observabilityPipelineHttpServerSourceValidToken.fieldToAdd) + && Objects.equals( + this.pathToToken, observabilityPipelineHttpServerSourceValidToken.pathToToken) + && Objects.equals(this.tokenKey, observabilityPipelineHttpServerSourceValidToken.tokenKey) + && Objects.equals( + this.additionalProperties, + observabilityPipelineHttpServerSourceValidToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, fieldToAdd, pathToToken, tokenKey, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineHttpServerSourceValidToken {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" fieldToAdd: ").append(toIndentedString(fieldToAdd)).append("\n"); + sb.append(" pathToToken: ").append(toIndentedString(pathToToken)).append("\n"); + sb.append(" tokenKey: ").append(toIndentedString(tokenKey)).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/ObservabilityPipelineHttpServerSourceValidTokenPathToToken.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToToken.java new file mode 100644 index 00000000000..823abc895b4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToToken.java @@ -0,0 +1,373 @@ +/* + * 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 = + ObservabilityPipelineHttpServerSourceValidTokenPathToToken + .ObservabilityPipelineHttpServerSourceValidTokenPathToTokenDeserializer.class) +@JsonSerialize( + using = + ObservabilityPipelineHttpServerSourceValidTokenPathToToken + .ObservabilityPipelineHttpServerSourceValidTokenPathToTokenSerializer.class) +public class ObservabilityPipelineHttpServerSourceValidTokenPathToToken + extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ObservabilityPipelineHttpServerSourceValidTokenPathToToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenSerializer + extends StdSerializer { + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenSerializer( + Class t) { + super(t); + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenSerializer() { + this(null); + } + + @Override + public void serialize( + ObservabilityPipelineHttpServerSourceValidTokenPathToToken value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenDeserializer + extends StdDeserializer { + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenDeserializer() { + this(ObservabilityPipelineHttpServerSourceValidTokenPathToToken.class); + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public ObservabilityPipelineHttpServerSourceValidTokenPathToToken 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 ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Integer.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Long.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Float.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Double.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Boolean.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Integer.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class + .equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Float.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class + .equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class.equals( + String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.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" + + " 'ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema" + + " 'ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation'", + e); + } + + // deserialize ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Integer.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Long.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Float.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Double.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Boolean.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Integer.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class + .equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Float.class) + || ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class + .equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.class.equals( + String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.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 (!((ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema" + + " 'ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema" + + " 'ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader'", + e); + } + + ObservabilityPipelineHttpServerSourceValidTokenPathToToken ret = + new ObservabilityPipelineHttpServerSourceValidTokenPathToToken(); + 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 ObservabilityPipelineHttpServerSourceValidTokenPathToToken getNullValue( + DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), + "ObservabilityPipelineHttpServerSourceValidTokenPathToToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ObservabilityPipelineHttpServerSourceValidTokenPathToToken() { + super("oneOf", Boolean.FALSE); + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToToken( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToToken( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation", + new GenericType() {}); + schemas.put( + "ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader", + new GenericType() {}); + JSON.registerDescendants( + ObservabilityPipelineHttpServerSourceValidTokenPathToToken.class, + Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ObservabilityPipelineHttpServerSourceValidTokenPathToToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: + * ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation, + * ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + * + *

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( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.class, + instance, + new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.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" + + " ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation," + + " ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader"); + } + + /** + * Get the actual instance, which can be the following: + * ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation, + * ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + * + * @return The actual instance + * (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation, + * ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation`. If the actual instance is + * not `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation`, the + * ClassCastException will be thrown. + * + * @return The actual instance of + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation` + * @throws ClassCastException if the instance is not + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation` + */ + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation + getObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation() + throws ClassCastException { + return (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation) + super.getActualInstance(); + } + + /** + * Get the actual instance of `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader`. + * If the actual instance is not + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader`, the ClassCastException will + * be thrown. + * + * @return The actual instance of + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader` + * @throws ClassCastException if the instance is not + * `ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader` + */ + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + getObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader() + throws ClassCastException { + return (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader) + super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.java new file mode 100644 index 00000000000..0324387936d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.java @@ -0,0 +1,154 @@ +/* + * 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; + +/** Extract the token from a specific HTTP request header. */ +@JsonPropertyOrder({ + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.JSON_PROPERTY_HEADER +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_HEADER = "header"; + private String header; + + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader() {} + + @JsonCreator + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader( + @JsonProperty(required = true, value = JSON_PROPERTY_HEADER) String header) { + this.header = header; + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader header(String header) { + this.header = header; + return this; + } + + /** + * The name of the HTTP header that carries the token. + * + * @return header + */ + @JsonProperty(JSON_PROPERTY_HEADER) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getHeader() { + return header; + } + + public void setHeader(String header) { + this.header = header; + } + + /** + * 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 ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + */ + @JsonAnySetter + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader 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 ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader object is + * equal to o. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader + observabilityPipelineHttpServerSourceValidTokenPathToTokenHeader = + (ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader) o; + return Objects.equals( + this.header, observabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.header) + && Objects.equals( + this.additionalProperties, + observabilityPipelineHttpServerSourceValidTokenPathToTokenHeader.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(header, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader {\n"); + sb.append(" header: ").append(toIndentedString(header)).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/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.java new file mode 100644 index 00000000000..7b4c3f02386 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation.java @@ -0,0 +1,67 @@ +/* + * 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; + +/** Built-in token location on the incoming HTTP request. */ +@JsonSerialize( + using = + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation + .ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocationSerializer.class) +public class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation + extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("path", "address")); + + public static final ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation PATH = + new ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation("path"); + public static final ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation ADDRESS = + new ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation("address"); + + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation(String value) { + super(value, allowedValues); + } + + public static class ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocationSerializer + extends StdSerializer { + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocationSerializer( + Class t) { + super(t); + } + + public ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocationSerializer() { + this(null); + } + + @Override + public void serialize( + ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation fromValue( + String value) { + return new ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSourceValidTokenFieldToAdd.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSourceValidTokenFieldToAdd.java new file mode 100644 index 00000000000..f03d626751e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSourceValidTokenFieldToAdd.java @@ -0,0 +1,181 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * An optional metadata field that is attached to every event authenticated by the associated token. + * Both key and value must match ^[A-Za-z0-9_]+$. + */ +@JsonPropertyOrder({ + ObservabilityPipelineSourceValidTokenFieldToAdd.JSON_PROPERTY_KEY, + ObservabilityPipelineSourceValidTokenFieldToAdd.JSON_PROPERTY_VALUE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineSourceValidTokenFieldToAdd { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_KEY = "key"; + private String key; + + public static final String JSON_PROPERTY_VALUE = "value"; + private String value; + + public ObservabilityPipelineSourceValidTokenFieldToAdd() {} + + @JsonCreator + public ObservabilityPipelineSourceValidTokenFieldToAdd( + @JsonProperty(required = true, value = JSON_PROPERTY_KEY) String key, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) String value) { + this.key = key; + this.value = value; + } + + public ObservabilityPipelineSourceValidTokenFieldToAdd key(String key) { + this.key = key; + return this; + } + + /** + * The metadata field name to add to incoming events. + * + * @return key + */ + @JsonProperty(JSON_PROPERTY_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public ObservabilityPipelineSourceValidTokenFieldToAdd value(String value) { + this.value = value; + return this; + } + + /** + * The metadata field value to add to incoming events. + * + * @return value + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getValue() { + return value; + } + + public void setValue(String 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 ObservabilityPipelineSourceValidTokenFieldToAdd + */ + @JsonAnySetter + public ObservabilityPipelineSourceValidTokenFieldToAdd 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 ObservabilityPipelineSourceValidTokenFieldToAdd object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineSourceValidTokenFieldToAdd + observabilityPipelineSourceValidTokenFieldToAdd = + (ObservabilityPipelineSourceValidTokenFieldToAdd) o; + return Objects.equals(this.key, observabilityPipelineSourceValidTokenFieldToAdd.key) + && Objects.equals(this.value, observabilityPipelineSourceValidTokenFieldToAdd.value) + && Objects.equals( + this.additionalProperties, + observabilityPipelineSourceValidTokenFieldToAdd.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(key, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineSourceValidTokenFieldToAdd {\n"); + sb.append(" key: ").append(toIndentedString(key)).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/v2/model/ObservabilityPipelineSplunkHecSource.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSource.java index 41092a8ff28..00b55b5978b 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSource.java +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSource.java @@ -13,7 +13,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; @@ -27,7 +29,8 @@ ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_ID, ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_STORE_HEC_TOKEN, ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_TLS, - ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_TYPE + ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_TYPE, + ObservabilityPipelineSplunkHecSource.JSON_PROPERTY_VALID_TOKENS }) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") @@ -49,6 +52,9 @@ public class ObservabilityPipelineSplunkHecSource { private ObservabilityPipelineSplunkHecSourceType type = ObservabilityPipelineSplunkHecSourceType.SPLUNK_HEC; + public static final String JSON_PROPERTY_VALID_TOKENS = "valid_tokens"; + private List validTokens = null; + public ObservabilityPipelineSplunkHecSource() {} @JsonCreator @@ -172,6 +178,42 @@ public void setType(ObservabilityPipelineSplunkHecSourceType type) { this.type = type; } + public ObservabilityPipelineSplunkHecSource validTokens( + List validTokens) { + this.validTokens = validTokens; + for (ObservabilityPipelineSplunkHecSourceValidToken item : validTokens) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ObservabilityPipelineSplunkHecSource addValidTokensItem( + ObservabilityPipelineSplunkHecSourceValidToken validTokensItem) { + if (this.validTokens == null) { + this.validTokens = new ArrayList<>(); + } + this.validTokens.add(validTokensItem); + this.unparsed |= validTokensItem.unparsed; + return this; + } + + /** + * A list of tokens that are accepted for authenticating incoming HEC requests. When set, the + * source rejects any request whose HEC token does not match an enabled entry in this list. + * + * @return validTokens + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VALID_TOKENS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getValidTokens() { + return validTokens; + } + + public void setValidTokens(List validTokens) { + this.validTokens = validTokens; + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -234,13 +276,15 @@ public boolean equals(Object o) { && Objects.equals(this.storeHecToken, observabilityPipelineSplunkHecSource.storeHecToken) && Objects.equals(this.tls, observabilityPipelineSplunkHecSource.tls) && Objects.equals(this.type, observabilityPipelineSplunkHecSource.type) + && Objects.equals(this.validTokens, observabilityPipelineSplunkHecSource.validTokens) && Objects.equals( this.additionalProperties, observabilityPipelineSplunkHecSource.additionalProperties); } @Override public int hashCode() { - return Objects.hash(addressKey, id, storeHecToken, tls, type, additionalProperties); + return Objects.hash( + addressKey, id, storeHecToken, tls, type, validTokens, additionalProperties); } @Override @@ -252,6 +296,7 @@ public String toString() { sb.append(" storeHecToken: ").append(toIndentedString(storeHecToken)).append("\n"); sb.append(" tls: ").append(toIndentedString(tls)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" validTokens: ").append(toIndentedString(validTokens)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSourceValidToken.java b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSourceValidToken.java new file mode 100644 index 00000000000..cd117f4f6ee --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ObservabilityPipelineSplunkHecSourceValidToken.java @@ -0,0 +1,208 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** An accepted HEC token used to authenticate incoming Splunk HEC requests. */ +@JsonPropertyOrder({ + ObservabilityPipelineSplunkHecSourceValidToken.JSON_PROPERTY_ENABLED, + ObservabilityPipelineSplunkHecSourceValidToken.JSON_PROPERTY_FIELD_TO_ADD, + ObservabilityPipelineSplunkHecSourceValidToken.JSON_PROPERTY_TOKEN_KEY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ObservabilityPipelineSplunkHecSourceValidToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ENABLED = "enabled"; + private Boolean enabled = true; + + public static final String JSON_PROPERTY_FIELD_TO_ADD = "field_to_add"; + private ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd; + + public static final String JSON_PROPERTY_TOKEN_KEY = "token_key"; + private String tokenKey; + + public ObservabilityPipelineSplunkHecSourceValidToken() {} + + @JsonCreator + public ObservabilityPipelineSplunkHecSourceValidToken( + @JsonProperty(required = true, value = JSON_PROPERTY_TOKEN_KEY) String tokenKey) { + this.tokenKey = tokenKey; + } + + public ObservabilityPipelineSplunkHecSourceValidToken enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Whether this token is currently accepted. Disabled tokens are rejected without being removed + * from the configuration. + * + * @return enabled + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public ObservabilityPipelineSplunkHecSourceValidToken fieldToAdd( + ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd) { + this.fieldToAdd = fieldToAdd; + this.unparsed |= fieldToAdd.unparsed; + return this; + } + + /** + * An optional metadata field that is attached to every event authenticated by the associated + * token. Both key and value must match ^[A-Za-z0-9_]+$. + * + * @return fieldToAdd + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_FIELD_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ObservabilityPipelineSourceValidTokenFieldToAdd getFieldToAdd() { + return fieldToAdd; + } + + public void setFieldToAdd(ObservabilityPipelineSourceValidTokenFieldToAdd fieldToAdd) { + this.fieldToAdd = fieldToAdd; + } + + public ObservabilityPipelineSplunkHecSourceValidToken tokenKey(String tokenKey) { + this.tokenKey = tokenKey; + return this; + } + + /** + * Name of the environment variable or secret that holds the expected HEC token value. + * + * @return tokenKey + */ + @JsonProperty(JSON_PROPERTY_TOKEN_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTokenKey() { + return tokenKey; + } + + public void setTokenKey(String tokenKey) { + this.tokenKey = tokenKey; + } + + /** + * 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 ObservabilityPipelineSplunkHecSourceValidToken + */ + @JsonAnySetter + public ObservabilityPipelineSplunkHecSourceValidToken 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 ObservabilityPipelineSplunkHecSourceValidToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ObservabilityPipelineSplunkHecSourceValidToken observabilityPipelineSplunkHecSourceValidToken = + (ObservabilityPipelineSplunkHecSourceValidToken) o; + return Objects.equals(this.enabled, observabilityPipelineSplunkHecSourceValidToken.enabled) + && Objects.equals( + this.fieldToAdd, observabilityPipelineSplunkHecSourceValidToken.fieldToAdd) + && Objects.equals(this.tokenKey, observabilityPipelineSplunkHecSourceValidToken.tokenKey) + && Objects.equals( + this.additionalProperties, + observabilityPipelineSplunkHecSourceValidToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, fieldToAdd, tokenKey, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ObservabilityPipelineSplunkHecSourceValidToken {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" fieldToAdd: ").append(toIndentedString(fieldToAdd)).append("\n"); + sb.append(" tokenKey: ").append(toIndentedString(tokenKey)).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 "); + } +}