From 936d017389bacd2acf5de202b3cb5fdaf2f696d4 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 8 Jun 2026 13:20:11 +0000 Subject: [PATCH] Regenerate client from commit 4f95357 of spec repo --- .generator/schemas/v2/openapi.yaml | 153 +++++++++- .../TriggerDeploymentGatesEvaluation.java | 23 ++ .../api/client/v2/api/DeploymentGatesApi.java | 5 + ...eploymentGatesEvaluationConfiguration.java | 192 ++++++++++++ ...ymentGatesEvaluationRequestAttributes.java | 43 ++- .../DeploymentGatesEvaluationRequestData.java | 4 +- .../model/DeploymentGatesEvaluationRule.java | 284 ++++++++++++++++++ .../v2/model/DeploymentGatesFDDRule.java | 234 +++++++++++++++ .../model/DeploymentGatesFDDRuleOptions.java | 175 +++++++++++ .../v2/model/DeploymentGatesFDDRuleType.java | 57 ++++ .../v2/model/DeploymentGatesMonitorRule.java | 236 +++++++++++++++ .../DeploymentGatesMonitorRuleOptions.java | 174 +++++++++++ .../model/DeploymentGatesMonitorRuleType.java | 57 ++++ .../client/v2/api/deployment_gates.feature | 6 +- 14 files changed, 1635 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationConfiguration.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleOptions.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRule.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleOptions.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleType.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 122c27ff508..cc2d8329b08 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -29382,6 +29382,25 @@ components: data: $ref: "#/components/schemas/ListDeploymentRuleResponseData" type: object + DeploymentGatesEvaluationConfiguration: + description: |- + Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + directly from this configuration instead of using the pre-configured gate rules. + At least one rule is required. + properties: + dry_run: + description: Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + rules: + description: The list of rules to evaluate. At least one rule is required. + items: + $ref: "#/components/schemas/DeploymentGatesEvaluationRule" + minItems: 1 + type: array + required: + - rules + type: object DeploymentGatesEvaluationRequest: description: Request body for triggering a deployment gate evaluation. properties: @@ -29391,8 +29410,13 @@ components: - data type: object DeploymentGatesEvaluationRequestAttributes: - description: Attributes for a deployment gate evaluation request. + description: |- + Attributes for a deployment gate evaluation request. + When `configuration` is provided, rules are evaluated inline from that configuration. + When omitted, rules are resolved from the pre-configured gate for the given service and environment. properties: + configuration: + $ref: "#/components/schemas/DeploymentGatesEvaluationConfiguration" env: description: The environment of the deployment. example: "staging" @@ -29562,6 +29586,60 @@ components: type: string x-enum-varnames: - DEPLOYMENT_GATES_EVALUATION_RESULT_RESPONSE + DeploymentGatesEvaluationRule: + description: A rule to evaluate as part of a deployment gate evaluation. + discriminator: + mapping: + faulty_deployment_detection: "#/components/schemas/DeploymentGatesFDDRule" + monitor: "#/components/schemas/DeploymentGatesMonitorRule" + propertyName: type + oneOf: + - $ref: "#/components/schemas/DeploymentGatesMonitorRule" + - $ref: "#/components/schemas/DeploymentGatesFDDRule" + DeploymentGatesFDDRule: + description: A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "apm faulty deployment" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesFDDRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesFDDRuleType" + required: + - type + - name + type: object + DeploymentGatesFDDRuleOptions: + description: Options for a `faulty_deployment_detection` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 900 + format: int64 + maximum: 7200 + type: integer + excluded_resources: + description: APM resource names to exclude from analysis. + example: + - "GET /healthcheck" + items: + type: string + type: array + type: object + DeploymentGatesFDDRuleType: + description: The type identifier for a faulty deployment detection rule. + enum: + - faulty_deployment_detection + example: faulty_deployment_detection + type: string + x-enum-varnames: + - FAULTY_DEPLOYMENT_DETECTION DeploymentGatesListResponse: description: Response containing a paginated list of deployment gates. properties: @@ -29596,6 +29674,49 @@ components: minimum: 1 type: integer type: object + DeploymentGatesMonitorRule: + description: A monitor rule to evaluate as part of a deployment gate evaluation. + properties: + dry_run: + description: Rule-level dry run. When enabled, the rule is evaluated normally but it always returns `pass`. The real result is visible in the Datadog UI. + example: false + type: boolean + name: + description: Human-readable name for this rule. + example: "error rate monitors" + type: string + options: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleOptions" + type: + $ref: "#/components/schemas/DeploymentGatesMonitorRuleType" + required: + - type + - name + type: object + DeploymentGatesMonitorRuleOptions: + description: Options for a `monitor` rule. + properties: + duration: + description: Evaluation window in seconds. Maximum 7200 (2 hours). + example: 300 + format: int64 + maximum: 7200 + type: integer + query: + description: Monitor search query. + example: "service:transaction-backend env:production" + type: string + required: + - query + type: object + DeploymentGatesMonitorRuleType: + description: The type identifier for a monitor rule. + enum: + - monitor + example: monitor + type: string + x-enum-varnames: + - MONITOR DeploymentGatesRuleResponse: description: The result of a single rule evaluation. properties: @@ -121740,12 +121861,17 @@ paths: Triggers an asynchronous deployment gate evaluation for the given service and environment. Returns an evaluation ID that can be used to poll for the result via the `GET /api/v2/deployments/gates/evaluation/{id}` endpoint. + + When the `configuration` attribute is provided, rules are evaluated inline from that configuration + and no pre-configured gate is required. When `configuration` is omitted, rules are resolved from the + gate pre-configured for the given service and environment via the Datadog UI, API, or Terraform. operationId: TriggerDeploymentGatesEvaluation requestBody: content: application/json: examples: default: + summary: Evaluate a pre-configured gate value: data: attributes: @@ -121755,6 +121881,31 @@ paths: service: transaction-backend version: v1.2.3 type: deployment_gates_evaluation_request + with-configuration: + summary: Evaluate with inline rule configuration + value: + data: + attributes: + configuration: + dry_run: false + rules: + - dry_run: false + name: error rate monitors + options: + duration: 300 + query: "service:transaction-backend env:production" + type: monitor + - dry_run: false + name: apm faulty deployment + options: + duration: 900 + excluded_resources: + - "GET /healthcheck" + type: faulty_deployment_detection + env: production + service: transaction-backend + version: 1.2.3 + type: deployment_gates_evaluation_request schema: $ref: "#/components/schemas/DeploymentGatesEvaluationRequest" required: true diff --git a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.java b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.java index e0068e2ffd5..0d3b4826826 100644 --- a/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.java +++ b/examples/v2/deployment-gates/TriggerDeploymentGatesEvaluation.java @@ -3,11 +3,17 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.v2.api.DeploymentGatesApi; +import com.datadog.api.client.v2.model.DeploymentGatesEvaluationConfiguration; import com.datadog.api.client.v2.model.DeploymentGatesEvaluationRequest; import com.datadog.api.client.v2.model.DeploymentGatesEvaluationRequestAttributes; import com.datadog.api.client.v2.model.DeploymentGatesEvaluationRequestData; import com.datadog.api.client.v2.model.DeploymentGatesEvaluationRequestDataType; import com.datadog.api.client.v2.model.DeploymentGatesEvaluationResponse; +import com.datadog.api.client.v2.model.DeploymentGatesEvaluationRule; +import com.datadog.api.client.v2.model.DeploymentGatesMonitorRule; +import com.datadog.api.client.v2.model.DeploymentGatesMonitorRuleOptions; +import com.datadog.api.client.v2.model.DeploymentGatesMonitorRuleType; +import java.util.Collections; public class Example { public static void main(String[] args) { @@ -21,6 +27,23 @@ public static void main(String[] args) { new DeploymentGatesEvaluationRequestData() .attributes( new DeploymentGatesEvaluationRequestAttributes() + .configuration( + new DeploymentGatesEvaluationConfiguration() + .dryRun(false) + .rules( + Collections.singletonList( + new DeploymentGatesEvaluationRule( + new DeploymentGatesMonitorRule() + .dryRun(false) + .name("error rate monitors") + .options( + new DeploymentGatesMonitorRuleOptions() + .duration(300L) + .query( + "service:transaction-backend" + + " env:production")) + .type( + DeploymentGatesMonitorRuleType.MONITOR))))) .env("staging") .identifier("pre-deploy") .primaryTag("region:us-east-1") diff --git a/src/main/java/com/datadog/api/client/v2/api/DeploymentGatesApi.java b/src/main/java/com/datadog/api/client/v2/api/DeploymentGatesApi.java index 787c6492a68..e8915879127 100644 --- a/src/main/java/com/datadog/api/client/v2/api/DeploymentGatesApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/DeploymentGatesApi.java @@ -1610,6 +1610,11 @@ public CompletableFuture triggerDeploymentGat * Returns an evaluation ID that can be used to poll for the result via the * GET /api/v2/deployments/gates/evaluation/{id} endpoint. * + *

When the configuration attribute is provided, rules are evaluated inline from + * that configuration and no pre-configured gate is required. When configuration is + * omitted, rules are resolved from the gate pre-configured for the given service and environment + * via the Datadog UI, API, or Terraform. + * * @param body (required) * @return ApiResponse<DeploymentGatesEvaluationResponse> * @throws ApiException if fails to make API call diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationConfiguration.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationConfiguration.java new file mode 100644 index 00000000000..f502a49de74 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationConfiguration.java @@ -0,0 +1,192 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + * directly from this configuration instead of using the pre-configured gate rules. At least one + * rule is required. + */ +@JsonPropertyOrder({ + DeploymentGatesEvaluationConfiguration.JSON_PROPERTY_DRY_RUN, + DeploymentGatesEvaluationConfiguration.JSON_PROPERTY_RULES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGatesEvaluationConfiguration { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DRY_RUN = "dry_run"; + private Boolean dryRun; + + public static final String JSON_PROPERTY_RULES = "rules"; + private List rules = new ArrayList<>(); + + public DeploymentGatesEvaluationConfiguration() {} + + @JsonCreator + public DeploymentGatesEvaluationConfiguration( + @JsonProperty(required = true, value = JSON_PROPERTY_RULES) + List rules) { + this.rules = rules; + } + + public DeploymentGatesEvaluationConfiguration dryRun(Boolean dryRun) { + this.dryRun = dryRun; + return this; + } + + /** + * Gate-level dry run. When enabled, the rules are evaluated normally but the gate always returns + * pass. The real result is visible in the Datadog UI. + * + * @return dryRun + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DRY_RUN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getDryRun() { + return dryRun; + } + + public void setDryRun(Boolean dryRun) { + this.dryRun = dryRun; + } + + public DeploymentGatesEvaluationConfiguration rules(List rules) { + this.rules = rules; + for (DeploymentGatesEvaluationRule item : rules) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DeploymentGatesEvaluationConfiguration addRulesItem( + DeploymentGatesEvaluationRule rulesItem) { + this.rules.add(rulesItem); + this.unparsed |= rulesItem.unparsed; + return this; + } + + /** + * The list of rules to evaluate. At least one rule is required. + * + * @return rules + */ + @JsonProperty(JSON_PROPERTY_RULES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + /** + * 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 DeploymentGatesEvaluationConfiguration + */ + @JsonAnySetter + public DeploymentGatesEvaluationConfiguration 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 DeploymentGatesEvaluationConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGatesEvaluationConfiguration deploymentGatesEvaluationConfiguration = + (DeploymentGatesEvaluationConfiguration) o; + return Objects.equals(this.dryRun, deploymentGatesEvaluationConfiguration.dryRun) + && Objects.equals(this.rules, deploymentGatesEvaluationConfiguration.rules) + && Objects.equals( + this.additionalProperties, deploymentGatesEvaluationConfiguration.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dryRun, rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGatesEvaluationConfiguration {\n"); + sb.append(" dryRun: ").append(toIndentedString(dryRun)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).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/DeploymentGatesEvaluationRequestAttributes.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestAttributes.java index c80c21c82be..6112914524a 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestAttributes.java @@ -17,8 +17,13 @@ import java.util.Map; import java.util.Objects; -/** Attributes for a deployment gate evaluation request. */ +/** + * Attributes for a deployment gate evaluation request. When configuration is provided, + * rules are evaluated inline from that configuration. When omitted, rules are resolved from the + * pre-configured gate for the given service and environment. + */ @JsonPropertyOrder({ + DeploymentGatesEvaluationRequestAttributes.JSON_PROPERTY_CONFIGURATION, DeploymentGatesEvaluationRequestAttributes.JSON_PROPERTY_ENV, DeploymentGatesEvaluationRequestAttributes.JSON_PROPERTY_IDENTIFIER, DeploymentGatesEvaluationRequestAttributes.JSON_PROPERTY_PRIMARY_TAG, @@ -29,6 +34,9 @@ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class DeploymentGatesEvaluationRequestAttributes { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONFIGURATION = "configuration"; + private DeploymentGatesEvaluationConfiguration configuration; + public static final String JSON_PROPERTY_ENV = "env"; private String env; @@ -54,6 +62,31 @@ public DeploymentGatesEvaluationRequestAttributes( this.service = service; } + public DeploymentGatesEvaluationRequestAttributes configuration( + DeploymentGatesEvaluationConfiguration configuration) { + this.configuration = configuration; + this.unparsed |= configuration.unparsed; + return this; + } + + /** + * Inline rule definitions for a deployment gate evaluation. When provided, rules are evaluated + * directly from this configuration instead of using the pre-configured gate rules. At least one + * rule is required. + * + * @return configuration + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DeploymentGatesEvaluationConfiguration getConfiguration() { + return configuration; + } + + public void setConfiguration(DeploymentGatesEvaluationConfiguration configuration) { + this.configuration = configuration; + } + public DeploymentGatesEvaluationRequestAttributes env(String env) { this.env = env; return this; @@ -215,7 +248,9 @@ public boolean equals(Object o) { } DeploymentGatesEvaluationRequestAttributes deploymentGatesEvaluationRequestAttributes = (DeploymentGatesEvaluationRequestAttributes) o; - return Objects.equals(this.env, deploymentGatesEvaluationRequestAttributes.env) + return Objects.equals( + this.configuration, deploymentGatesEvaluationRequestAttributes.configuration) + && Objects.equals(this.env, deploymentGatesEvaluationRequestAttributes.env) && Objects.equals(this.identifier, deploymentGatesEvaluationRequestAttributes.identifier) && Objects.equals(this.primaryTag, deploymentGatesEvaluationRequestAttributes.primaryTag) && Objects.equals(this.service, deploymentGatesEvaluationRequestAttributes.service) @@ -227,13 +262,15 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(env, identifier, primaryTag, service, version, additionalProperties); + return Objects.hash( + configuration, env, identifier, primaryTag, service, version, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DeploymentGatesEvaluationRequestAttributes {\n"); + sb.append(" configuration: ").append(toIndentedString(configuration)).append("\n"); sb.append(" env: ").append(toIndentedString(env)).append("\n"); sb.append(" identifier: ").append(toIndentedString(identifier)).append("\n"); sb.append(" primaryTag: ").append(toIndentedString(primaryTag)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestData.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestData.java index 2bc3584b112..09fab9e2a9f 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestData.java +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRequestData.java @@ -55,7 +55,9 @@ public DeploymentGatesEvaluationRequestData attributes( } /** - * Attributes for a deployment gate evaluation request. + * Attributes for a deployment gate evaluation request. When configuration is + * provided, rules are evaluated inline from that configuration. When omitted, rules are resolved + * from the pre-configured gate for the given service and environment. * * @return attributes */ diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRule.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRule.java new file mode 100644 index 00000000000..009c97e8583 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesEvaluationRule.java @@ -0,0 +1,284 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = DeploymentGatesEvaluationRule.DeploymentGatesEvaluationRuleDeserializer.class) +@JsonSerialize(using = DeploymentGatesEvaluationRule.DeploymentGatesEvaluationRuleSerializer.class) +public class DeploymentGatesEvaluationRule extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DeploymentGatesEvaluationRule.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DeploymentGatesEvaluationRuleSerializer + extends StdSerializer { + public DeploymentGatesEvaluationRuleSerializer(Class t) { + super(t); + } + + public DeploymentGatesEvaluationRuleSerializer() { + this(null); + } + + @Override + public void serialize( + DeploymentGatesEvaluationRule value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DeploymentGatesEvaluationRuleDeserializer + extends StdDeserializer { + public DeploymentGatesEvaluationRuleDeserializer() { + this(DeploymentGatesEvaluationRule.class); + } + + public DeploymentGatesEvaluationRuleDeserializer(Class vc) { + super(vc); + } + + @Override + public DeploymentGatesEvaluationRule 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 DeploymentGatesMonitorRule + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DeploymentGatesMonitorRule.class.equals(Integer.class) + || DeploymentGatesMonitorRule.class.equals(Long.class) + || DeploymentGatesMonitorRule.class.equals(Float.class) + || DeploymentGatesMonitorRule.class.equals(Double.class) + || DeploymentGatesMonitorRule.class.equals(Boolean.class) + || DeploymentGatesMonitorRule.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DeploymentGatesMonitorRule.class.equals(Integer.class) + || DeploymentGatesMonitorRule.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DeploymentGatesMonitorRule.class.equals(Float.class) + || DeploymentGatesMonitorRule.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DeploymentGatesMonitorRule.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DeploymentGatesMonitorRule.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DeploymentGatesMonitorRule.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 (!((DeploymentGatesMonitorRule) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DeploymentGatesMonitorRule'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DeploymentGatesMonitorRule'", e); + } + + // deserialize DeploymentGatesFDDRule + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DeploymentGatesFDDRule.class.equals(Integer.class) + || DeploymentGatesFDDRule.class.equals(Long.class) + || DeploymentGatesFDDRule.class.equals(Float.class) + || DeploymentGatesFDDRule.class.equals(Double.class) + || DeploymentGatesFDDRule.class.equals(Boolean.class) + || DeploymentGatesFDDRule.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DeploymentGatesFDDRule.class.equals(Integer.class) + || DeploymentGatesFDDRule.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DeploymentGatesFDDRule.class.equals(Float.class) + || DeploymentGatesFDDRule.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DeploymentGatesFDDRule.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DeploymentGatesFDDRule.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DeploymentGatesFDDRule.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 (!((DeploymentGatesFDDRule) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DeploymentGatesFDDRule'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DeploymentGatesFDDRule'", e); + } + + DeploymentGatesEvaluationRule ret = new DeploymentGatesEvaluationRule(); + 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 DeploymentGatesEvaluationRule getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DeploymentGatesEvaluationRule cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DeploymentGatesEvaluationRule() { + super("oneOf", Boolean.FALSE); + } + + public DeploymentGatesEvaluationRule(DeploymentGatesMonitorRule o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DeploymentGatesEvaluationRule(DeploymentGatesFDDRule o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("DeploymentGatesMonitorRule", new GenericType() {}); + schemas.put("DeploymentGatesFDDRule", new GenericType() {}); + JSON.registerDescendants( + DeploymentGatesEvaluationRule.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DeploymentGatesEvaluationRule.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DeploymentGatesMonitorRule, DeploymentGatesFDDRule + * + *

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(DeploymentGatesMonitorRule.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(DeploymentGatesFDDRule.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 DeploymentGatesMonitorRule, DeploymentGatesFDDRule"); + } + + /** + * Get the actual instance, which can be the following: DeploymentGatesMonitorRule, + * DeploymentGatesFDDRule + * + * @return The actual instance (DeploymentGatesMonitorRule, DeploymentGatesFDDRule) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DeploymentGatesMonitorRule`. If the actual instance is not + * `DeploymentGatesMonitorRule`, the ClassCastException will be thrown. + * + * @return The actual instance of `DeploymentGatesMonitorRule` + * @throws ClassCastException if the instance is not `DeploymentGatesMonitorRule` + */ + public DeploymentGatesMonitorRule getDeploymentGatesMonitorRule() throws ClassCastException { + return (DeploymentGatesMonitorRule) super.getActualInstance(); + } + + /** + * Get the actual instance of `DeploymentGatesFDDRule`. If the actual instance is not + * `DeploymentGatesFDDRule`, the ClassCastException will be thrown. + * + * @return The actual instance of `DeploymentGatesFDDRule` + * @throws ClassCastException if the instance is not `DeploymentGatesFDDRule` + */ + public DeploymentGatesFDDRule getDeploymentGatesFDDRule() throws ClassCastException { + return (DeploymentGatesFDDRule) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRule.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRule.java new file mode 100644 index 00000000000..fd04de4eccf --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRule.java @@ -0,0 +1,234 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A faulty deployment detection rule to evaluate as part of a deployment gate evaluation. */ +@JsonPropertyOrder({ + DeploymentGatesFDDRule.JSON_PROPERTY_DRY_RUN, + DeploymentGatesFDDRule.JSON_PROPERTY_NAME, + DeploymentGatesFDDRule.JSON_PROPERTY_OPTIONS, + DeploymentGatesFDDRule.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGatesFDDRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DRY_RUN = "dry_run"; + private Boolean dryRun; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_OPTIONS = "options"; + private DeploymentGatesFDDRuleOptions options; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DeploymentGatesFDDRuleType type; + + public DeploymentGatesFDDRule() {} + + @JsonCreator + public DeploymentGatesFDDRule( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DeploymentGatesFDDRuleType type) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DeploymentGatesFDDRule dryRun(Boolean dryRun) { + this.dryRun = dryRun; + return this; + } + + /** + * Rule-level dry run. When enabled, the rule is evaluated normally but it always returns + * pass. The real result is visible in the Datadog UI. + * + * @return dryRun + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DRY_RUN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getDryRun() { + return dryRun; + } + + public void setDryRun(Boolean dryRun) { + this.dryRun = dryRun; + } + + public DeploymentGatesFDDRule name(String name) { + this.name = name; + return this; + } + + /** + * Human-readable name for this rule. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DeploymentGatesFDDRule options(DeploymentGatesFDDRuleOptions options) { + this.options = options; + this.unparsed |= options.unparsed; + return this; + } + + /** + * Options for a faulty_deployment_detection rule. + * + * @return options + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DeploymentGatesFDDRuleOptions getOptions() { + return options; + } + + public void setOptions(DeploymentGatesFDDRuleOptions options) { + this.options = options; + } + + public DeploymentGatesFDDRule type(DeploymentGatesFDDRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type identifier for a faulty deployment detection rule. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DeploymentGatesFDDRuleType getType() { + return type; + } + + public void setType(DeploymentGatesFDDRuleType 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 DeploymentGatesFDDRule + */ + @JsonAnySetter + public DeploymentGatesFDDRule 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 DeploymentGatesFDDRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGatesFDDRule deploymentGatesFddRule = (DeploymentGatesFDDRule) o; + return Objects.equals(this.dryRun, deploymentGatesFddRule.dryRun) + && Objects.equals(this.name, deploymentGatesFddRule.name) + && Objects.equals(this.options, deploymentGatesFddRule.options) + && Objects.equals(this.type, deploymentGatesFddRule.type) + && Objects.equals(this.additionalProperties, deploymentGatesFddRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dryRun, name, options, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGatesFDDRule {\n"); + sb.append(" dryRun: ").append(toIndentedString(dryRun)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleOptions.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleOptions.java new file mode 100644 index 00000000000..961afd52db2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleOptions.java @@ -0,0 +1,175 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Options for a faulty_deployment_detection rule. */ +@JsonPropertyOrder({ + DeploymentGatesFDDRuleOptions.JSON_PROPERTY_DURATION, + DeploymentGatesFDDRuleOptions.JSON_PROPERTY_EXCLUDED_RESOURCES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGatesFDDRuleOptions { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DURATION = "duration"; + private Long duration; + + public static final String JSON_PROPERTY_EXCLUDED_RESOURCES = "excluded_resources"; + private List excludedResources = null; + + public DeploymentGatesFDDRuleOptions duration(Long duration) { + this.duration = duration; + return this; + } + + /** + * Evaluation window in seconds. Maximum 7200 (2 hours). maximum: 7200 + * + * @return duration + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDuration() { + return duration; + } + + public void setDuration(Long duration) { + this.duration = duration; + } + + public DeploymentGatesFDDRuleOptions excludedResources(List excludedResources) { + this.excludedResources = excludedResources; + return this; + } + + public DeploymentGatesFDDRuleOptions addExcludedResourcesItem(String excludedResourcesItem) { + if (this.excludedResources == null) { + this.excludedResources = new ArrayList<>(); + } + this.excludedResources.add(excludedResourcesItem); + return this; + } + + /** + * APM resource names to exclude from analysis. + * + * @return excludedResources + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXCLUDED_RESOURCES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getExcludedResources() { + return excludedResources; + } + + public void setExcludedResources(List excludedResources) { + this.excludedResources = excludedResources; + } + + /** + * 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 DeploymentGatesFDDRuleOptions + */ + @JsonAnySetter + public DeploymentGatesFDDRuleOptions 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 DeploymentGatesFDDRuleOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGatesFDDRuleOptions deploymentGatesFddRuleOptions = (DeploymentGatesFDDRuleOptions) o; + return Objects.equals(this.duration, deploymentGatesFddRuleOptions.duration) + && Objects.equals(this.excludedResources, deploymentGatesFddRuleOptions.excludedResources) + && Objects.equals( + this.additionalProperties, deploymentGatesFddRuleOptions.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(duration, excludedResources, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGatesFDDRuleOptions {\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" excludedResources: ").append(toIndentedString(excludedResources)).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/DeploymentGatesFDDRuleType.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleType.java new file mode 100644 index 00000000000..980effc01fe --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesFDDRuleType.java @@ -0,0 +1,57 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The type identifier for a faulty deployment detection rule. */ +@JsonSerialize(using = DeploymentGatesFDDRuleType.DeploymentGatesFDDRuleTypeSerializer.class) +public class DeploymentGatesFDDRuleType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("faulty_deployment_detection")); + + public static final DeploymentGatesFDDRuleType FAULTY_DEPLOYMENT_DETECTION = + new DeploymentGatesFDDRuleType("faulty_deployment_detection"); + + DeploymentGatesFDDRuleType(String value) { + super(value, allowedValues); + } + + public static class DeploymentGatesFDDRuleTypeSerializer + extends StdSerializer { + public DeploymentGatesFDDRuleTypeSerializer(Class t) { + super(t); + } + + public DeploymentGatesFDDRuleTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DeploymentGatesFDDRuleType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DeploymentGatesFDDRuleType fromValue(String value) { + return new DeploymentGatesFDDRuleType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRule.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRule.java new file mode 100644 index 00000000000..d2d8b079f39 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRule.java @@ -0,0 +1,236 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A monitor rule to evaluate as part of a deployment gate evaluation. */ +@JsonPropertyOrder({ + DeploymentGatesMonitorRule.JSON_PROPERTY_DRY_RUN, + DeploymentGatesMonitorRule.JSON_PROPERTY_NAME, + DeploymentGatesMonitorRule.JSON_PROPERTY_OPTIONS, + DeploymentGatesMonitorRule.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGatesMonitorRule { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DRY_RUN = "dry_run"; + private Boolean dryRun; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_OPTIONS = "options"; + private DeploymentGatesMonitorRuleOptions options; + + public static final String JSON_PROPERTY_TYPE = "type"; + private DeploymentGatesMonitorRuleType type; + + public DeploymentGatesMonitorRule() {} + + @JsonCreator + public DeploymentGatesMonitorRule( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + DeploymentGatesMonitorRuleType type) { + this.name = name; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public DeploymentGatesMonitorRule dryRun(Boolean dryRun) { + this.dryRun = dryRun; + return this; + } + + /** + * Rule-level dry run. When enabled, the rule is evaluated normally but it always returns + * pass. The real result is visible in the Datadog UI. + * + * @return dryRun + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DRY_RUN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getDryRun() { + return dryRun; + } + + public void setDryRun(Boolean dryRun) { + this.dryRun = dryRun; + } + + public DeploymentGatesMonitorRule name(String name) { + this.name = name; + return this; + } + + /** + * Human-readable name for this rule. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DeploymentGatesMonitorRule options(DeploymentGatesMonitorRuleOptions options) { + this.options = options; + this.unparsed |= options.unparsed; + return this; + } + + /** + * Options for a monitor rule. + * + * @return options + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DeploymentGatesMonitorRuleOptions getOptions() { + return options; + } + + public void setOptions(DeploymentGatesMonitorRuleOptions options) { + this.options = options; + } + + public DeploymentGatesMonitorRule type(DeploymentGatesMonitorRuleType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The type identifier for a monitor rule. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DeploymentGatesMonitorRuleType getType() { + return type; + } + + public void setType(DeploymentGatesMonitorRuleType 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 DeploymentGatesMonitorRule + */ + @JsonAnySetter + public DeploymentGatesMonitorRule 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 DeploymentGatesMonitorRule object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGatesMonitorRule deploymentGatesMonitorRule = (DeploymentGatesMonitorRule) o; + return Objects.equals(this.dryRun, deploymentGatesMonitorRule.dryRun) + && Objects.equals(this.name, deploymentGatesMonitorRule.name) + && Objects.equals(this.options, deploymentGatesMonitorRule.options) + && Objects.equals(this.type, deploymentGatesMonitorRule.type) + && Objects.equals( + this.additionalProperties, deploymentGatesMonitorRule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(dryRun, name, options, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGatesMonitorRule {\n"); + sb.append(" dryRun: ").append(toIndentedString(dryRun)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleOptions.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleOptions.java new file mode 100644 index 00000000000..154b135e6be --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleOptions.java @@ -0,0 +1,174 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Options for a monitor rule. */ +@JsonPropertyOrder({ + DeploymentGatesMonitorRuleOptions.JSON_PROPERTY_DURATION, + DeploymentGatesMonitorRuleOptions.JSON_PROPERTY_QUERY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGatesMonitorRuleOptions { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DURATION = "duration"; + private Long duration; + + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public DeploymentGatesMonitorRuleOptions() {} + + @JsonCreator + public DeploymentGatesMonitorRuleOptions( + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) { + this.query = query; + } + + public DeploymentGatesMonitorRuleOptions duration(Long duration) { + this.duration = duration; + return this; + } + + /** + * Evaluation window in seconds. Maximum 7200 (2 hours). maximum: 7200 + * + * @return duration + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDuration() { + return duration; + } + + public void setDuration(Long duration) { + this.duration = duration; + } + + public DeploymentGatesMonitorRuleOptions query(String query) { + this.query = query; + return this; + } + + /** + * Monitor search query. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** + * 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 DeploymentGatesMonitorRuleOptions + */ + @JsonAnySetter + public DeploymentGatesMonitorRuleOptions 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 DeploymentGatesMonitorRuleOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGatesMonitorRuleOptions deploymentGatesMonitorRuleOptions = + (DeploymentGatesMonitorRuleOptions) o; + return Objects.equals(this.duration, deploymentGatesMonitorRuleOptions.duration) + && Objects.equals(this.query, deploymentGatesMonitorRuleOptions.query) + && Objects.equals( + this.additionalProperties, deploymentGatesMonitorRuleOptions.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(duration, query, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGatesMonitorRuleOptions {\n"); + sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); + sb.append(" query: ").append(toIndentedString(query)).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/DeploymentGatesMonitorRuleType.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleType.java new file mode 100644 index 00000000000..421e597ce54 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGatesMonitorRuleType.java @@ -0,0 +1,57 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The type identifier for a monitor rule. */ +@JsonSerialize( + using = DeploymentGatesMonitorRuleType.DeploymentGatesMonitorRuleTypeSerializer.class) +public class DeploymentGatesMonitorRuleType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("monitor")); + + public static final DeploymentGatesMonitorRuleType MONITOR = + new DeploymentGatesMonitorRuleType("monitor"); + + DeploymentGatesMonitorRuleType(String value) { + super(value, allowedValues); + } + + public static class DeploymentGatesMonitorRuleTypeSerializer + extends StdSerializer { + public DeploymentGatesMonitorRuleTypeSerializer(Class t) { + super(t); + } + + public DeploymentGatesMonitorRuleTypeSerializer() { + this(null); + } + + @Override + public void serialize( + DeploymentGatesMonitorRuleType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DeploymentGatesMonitorRuleType fromValue(String value) { + return new DeploymentGatesMonitorRuleType(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/deployment_gates.feature b/src/test/resources/com/datadog/api/client/v2/api/deployment_gates.feature index df9494d2aed..de5ceaeaa3d 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/deployment_gates.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/deployment_gates.feature @@ -286,7 +286,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Accepted" response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 202 Accepted @@ -294,7 +294,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Bad request." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 400 Bad request. @@ -302,7 +302,7 @@ Feature: Deployment Gates Scenario: Trigger a deployment gate evaluation returns "Deployment gate not found." response Given operation "TriggerDeploymentGatesEvaluation" enabled And new "TriggerDeploymentGatesEvaluation" request - And body with value {"data": {"attributes": {"env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} + And body with value {"data": {"attributes": {"configuration": {"dry_run": false, "rules": [{"dry_run": false, "name": "error rate monitors", "options": {"duration": 300, "query": "service:transaction-backend env:production"}, "type": "monitor"}]}, "env": "staging", "identifier": "pre-deploy", "primary_tag": "region:us-east-1", "service": "transaction-backend", "version": "v1.2.3"}, "type": "deployment_gates_evaluation_request"}} When the request is sent Then the response status is 404 Deployment gate not found.