diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index dad178ca22d..70cb1fd3b9e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -17075,6 +17075,12 @@ components: required: - id type: object + DeploymentGateRulesResponse: + description: Response for a deployment gate rules. + properties: + data: + $ref: '#/components/schemas/ListDeploymentRuleResponseData' + type: object DeploymentMetadata: description: Metadata object containing the publication creation information. properties: @@ -30199,6 +30205,37 @@ components: type: string x-enum-varnames: - LIST_CONNECTIONS_RESPONSE + ListDeploymentRuleResponseData: + description: Data for a list of deployment rules. + properties: + attributes: + $ref: '#/components/schemas/ListDeploymentRulesResponseDataAttributes' + id: + description: Unique identifier of the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + type: + $ref: '#/components/schemas/ListDeploymentRulesDataType' + required: + - type + - attributes + - id + type: object + ListDeploymentRulesDataType: + description: List deployment rule resource type. + enum: + - list_deployment_rules + example: list_deployment_rules + type: string + x-enum-varnames: + - LIST_DEPLOYMENT_RULES + ListDeploymentRulesResponseDataAttributes: + properties: + rules: + items: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributes' + type: array + type: object ListDevicesResponse: description: List devices response. properties: @@ -66236,6 +66273,50 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/deployment_gates/{gate_id}/rules: + get: + description: Endpoint to get rules for a deployment gate. + operationId: GetDeploymentGateRules + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentGateRulesResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get rules for a deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' post: description: Endpoint to create a deployment rule. A gate for the rule must already exist. diff --git a/examples/v2/deployment-gates/GetDeploymentGateRules.java b/examples/v2/deployment-gates/GetDeploymentGateRules.java new file mode 100644 index 00000000000..5bbc8bcba31 --- /dev/null +++ b/examples/v2/deployment-gates/GetDeploymentGateRules.java @@ -0,0 +1,29 @@ +// Get rules for a deployment gate returns "OK" response + +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.DeploymentGateRulesResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getDeploymentGateRules", true); + DeploymentGatesApi apiInstance = new DeploymentGatesApi(defaultClient); + + // there is a valid "deployment_gate" in the system + String DEPLOYMENT_GATE_DATA_ID = System.getenv("DEPLOYMENT_GATE_DATA_ID"); + + try { + DeploymentGateRulesResponse result = + apiInstance.getDeploymentGateRules(DEPLOYMENT_GATE_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DeploymentGatesApi#getDeploymentGateRules"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index 5131c7ae601..b18c1d29ca9 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -740,6 +740,7 @@ public class ApiClient { put("v2.deleteDeploymentGate", false); put("v2.deleteDeploymentRule", false); put("v2.getDeploymentGate", false); + put("v2.getDeploymentGateRules", false); put("v2.getDeploymentRule", false); put("v2.updateDeploymentGate", false); put("v2.updateDeploymentRule", false); 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 7779295194d..5da77c2a5eb 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 @@ -7,6 +7,7 @@ import com.datadog.api.client.v2.model.CreateDeploymentGateParams; import com.datadog.api.client.v2.model.CreateDeploymentRuleParams; import com.datadog.api.client.v2.model.DeploymentGateResponse; +import com.datadog.api.client.v2.model.DeploymentGateRulesResponse; import com.datadog.api.client.v2.model.DeploymentRuleResponse; import com.datadog.api.client.v2.model.UpdateDeploymentGateParams; import com.datadog.api.client.v2.model.UpdateDeploymentRuleParams; @@ -857,6 +858,163 @@ public CompletableFuture> getDeploymentGateW new GenericType() {}); } + /** + * Get rules for a deployment gate. + * + *

See {@link #getDeploymentGateRulesWithHttpInfo}. + * + * @param gateId The ID of the deployment gate. (required) + * @return DeploymentGateRulesResponse + * @throws ApiException if fails to make API call + */ + public DeploymentGateRulesResponse getDeploymentGateRules(String gateId) throws ApiException { + return getDeploymentGateRulesWithHttpInfo(gateId).getData(); + } + + /** + * Get rules for a deployment gate. + * + *

See {@link #getDeploymentGateRulesWithHttpInfoAsync}. + * + * @param gateId The ID of the deployment gate. (required) + * @return CompletableFuture<DeploymentGateRulesResponse> + */ + public CompletableFuture getDeploymentGateRulesAsync(String gateId) { + return getDeploymentGateRulesWithHttpInfoAsync(gateId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Endpoint to get rules for a deployment gate. + * + * @param gateId The ID of the deployment gate. (required) + * @return ApiResponse<DeploymentGateRulesResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad request. -
401 Unauthorized -
403 Forbidden -
429 Too many requests -
500 Internal Server Error -
+ */ + public ApiResponse getDeploymentGateRulesWithHttpInfo(String gateId) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "getDeploymentGateRules"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'gateId' is set + if (gateId == null) { + throw new ApiException( + 400, "Missing the required parameter 'gateId' when calling getDeploymentGateRules"); + } + // create path and map variables + String localVarPath = + "/api/v2/deployment_gates/{gate_id}/rules" + .replaceAll("\\{" + "gate_id" + "\\}", apiClient.escapeString(gateId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.DeploymentGatesApi.getDeploymentGateRules", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get rules for a deployment gate. + * + *

See {@link #getDeploymentGateRulesWithHttpInfo}. + * + * @param gateId The ID of the deployment gate. (required) + * @return CompletableFuture<ApiResponse<DeploymentGateRulesResponse>> + */ + public CompletableFuture> + getDeploymentGateRulesWithHttpInfoAsync(String gateId) { + // Check if unstable operation is enabled + String operationId = "getDeploymentGateRules"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'gateId' is set + if (gateId == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'gateId' when calling getDeploymentGateRules")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/deployment_gates/{gate_id}/rules" + .replaceAll("\\{" + "gate_id" + "\\}", apiClient.escapeString(gateId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.DeploymentGatesApi.getDeploymentGateRules", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Get deployment rule. * diff --git a/src/main/java/com/datadog/api/client/v2/model/DeploymentGateRulesResponse.java b/src/main/java/com/datadog/api/client/v2/model/DeploymentGateRulesResponse.java new file mode 100644 index 00000000000..a4b38b9840e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DeploymentGateRulesResponse.java @@ -0,0 +1,137 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response for a deployment gate rules. */ +@JsonPropertyOrder({DeploymentGateRulesResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DeploymentGateRulesResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ListDeploymentRuleResponseData data; + + public DeploymentGateRulesResponse data(ListDeploymentRuleResponseData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Data for a list of deployment rules. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ListDeploymentRuleResponseData getData() { + return data; + } + + public void setData(ListDeploymentRuleResponseData data) { + this.data = data; + } + + /** + * 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 DeploymentGateRulesResponse + */ + @JsonAnySetter + public DeploymentGateRulesResponse 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 DeploymentGateRulesResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeploymentGateRulesResponse deploymentGateRulesResponse = (DeploymentGateRulesResponse) o; + return Objects.equals(this.data, deploymentGateRulesResponse.data) + && Objects.equals( + this.additionalProperties, deploymentGateRulesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeploymentGateRulesResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).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/ListDeploymentRuleResponseData.java b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRuleResponseData.java new file mode 100644 index 00000000000..c8c45c2e76b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRuleResponseData.java @@ -0,0 +1,212 @@ +/* + * 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; + +/** Data for a list of deployment rules. */ +@JsonPropertyOrder({ + ListDeploymentRuleResponseData.JSON_PROPERTY_ATTRIBUTES, + ListDeploymentRuleResponseData.JSON_PROPERTY_ID, + ListDeploymentRuleResponseData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListDeploymentRuleResponseData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ListDeploymentRulesResponseDataAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ListDeploymentRulesDataType type; + + public ListDeploymentRuleResponseData() {} + + @JsonCreator + public ListDeploymentRuleResponseData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + ListDeploymentRulesResponseDataAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ListDeploymentRulesDataType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ListDeploymentRuleResponseData attributes( + ListDeploymentRulesResponseDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Getattributes + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ListDeploymentRulesResponseDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ListDeploymentRulesResponseDataAttributes attributes) { + this.attributes = attributes; + } + + public ListDeploymentRuleResponseData id(String id) { + this.id = id; + return this; + } + + /** + * Unique identifier of the deployment rule. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ListDeploymentRuleResponseData type(ListDeploymentRulesDataType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * List deployment rule resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ListDeploymentRulesDataType getType() { + return type; + } + + public void setType(ListDeploymentRulesDataType 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 ListDeploymentRuleResponseData + */ + @JsonAnySetter + public ListDeploymentRuleResponseData 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 ListDeploymentRuleResponseData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListDeploymentRuleResponseData listDeploymentRuleResponseData = + (ListDeploymentRuleResponseData) o; + return Objects.equals(this.attributes, listDeploymentRuleResponseData.attributes) + && Objects.equals(this.id, listDeploymentRuleResponseData.id) + && Objects.equals(this.type, listDeploymentRuleResponseData.type) + && Objects.equals( + this.additionalProperties, listDeploymentRuleResponseData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListDeploymentRuleResponseData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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/ListDeploymentRulesDataType.java b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRulesDataType.java new file mode 100644 index 00000000000..0d85b1be22a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRulesDataType.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; + +/** List deployment rule resource type. */ +@JsonSerialize(using = ListDeploymentRulesDataType.ListDeploymentRulesDataTypeSerializer.class) +public class ListDeploymentRulesDataType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("list_deployment_rules")); + + public static final ListDeploymentRulesDataType LIST_DEPLOYMENT_RULES = + new ListDeploymentRulesDataType("list_deployment_rules"); + + ListDeploymentRulesDataType(String value) { + super(value, allowedValues); + } + + public static class ListDeploymentRulesDataTypeSerializer + extends StdSerializer { + public ListDeploymentRulesDataTypeSerializer(Class t) { + super(t); + } + + public ListDeploymentRulesDataTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ListDeploymentRulesDataType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ListDeploymentRulesDataType fromValue(String value) { + return new ListDeploymentRulesDataType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRulesResponseDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRulesResponseDataAttributes.java new file mode 100644 index 00000000000..308d734b7df --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListDeploymentRulesResponseDataAttributes.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.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; + +/** */ +@JsonPropertyOrder({ListDeploymentRulesResponseDataAttributes.JSON_PROPERTY_RULES}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListDeploymentRulesResponseDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_RULES = "rules"; + private List rules = null; + + public ListDeploymentRulesResponseDataAttributes rules( + List rules) { + this.rules = rules; + for (DeploymentRuleResponseDataAttributes item : rules) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListDeploymentRulesResponseDataAttributes addRulesItem( + DeploymentRuleResponseDataAttributes rulesItem) { + if (this.rules == null) { + this.rules = new ArrayList<>(); + } + this.rules.add(rulesItem); + this.unparsed |= rulesItem.unparsed; + return this; + } + + /** + * Getrules + * + * @return rules + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RULES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + 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 ListDeploymentRulesResponseDataAttributes + */ + @JsonAnySetter + public ListDeploymentRulesResponseDataAttributes 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 ListDeploymentRulesResponseDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListDeploymentRulesResponseDataAttributes listDeploymentRulesResponseDataAttributes = + (ListDeploymentRulesResponseDataAttributes) o; + return Objects.equals(this.rules, listDeploymentRulesResponseDataAttributes.rules) + && Objects.equals( + this.additionalProperties, + listDeploymentRulesResponseDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListDeploymentRulesResponseDataAttributes {\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/test/resources/cassettes/features/v2/Create_deployment_rule_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_Bad_Request_response.json index 9a7364b9c53..5baa1f2f55f 100644 --- a/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_Bad_Request_response.json +++ b/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_Bad_Request_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c5" + "id": "70acb264-a190-c950-4530-585b68c408c6" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_OK_response.json index 7a6d6cc150b..8b9011b44c1 100644 --- a/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Create_deployment_rule_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408bf" + "id": "70acb264-a190-c950-4530-585b68c408c0" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Delete_deployment_gate_returns_No_Content_response.json b/src/test/resources/cassettes/features/v2/Delete_deployment_gate_returns_No_Content_response.json index 18fbab71ee0..303d9f3f80b 100644 --- a/src/test/resources/cassettes/features/v2/Delete_deployment_gate_returns_No_Content_response.json +++ b/src/test/resources/cassettes/features/v2/Delete_deployment_gate_returns_No_Content_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c7" + "id": "70acb264-a190-c950-4530-585b68c408c8" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Delete_deployment_rule_returns_No_Content_response.json b/src/test/resources/cassettes/features/v2/Delete_deployment_rule_returns_No_Content_response.json index 8ad9bd9c6f7..cdbddfb1d7b 100644 --- a/src/test/resources/cassettes/features/v2/Delete_deployment_rule_returns_No_Content_response.json +++ b/src/test/resources/cassettes/features/v2/Delete_deployment_rule_returns_No_Content_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c1" + "id": "70acb264-a190-c950-4530-585b68c408c2" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_deployment_gate_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_deployment_gate_returns_OK_response.json index 0503308cb1f..62b08b9c22a 100644 --- a/src/test/resources/cassettes/features/v2/Get_deployment_gate_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Get_deployment_gate_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c6" + "id": "70acb264-a190-c950-4530-585b68c408c7" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_Bad_Request_response.json index 6ac42251bbb..74404830a7a 100644 --- a/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_Bad_Request_response.json +++ b/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_Bad_Request_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408be" + "id": "70acb264-a190-c950-4530-585b68c408bf" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_OK_response.json index 72f13792d83..21b47095b83 100644 --- a/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Get_deployment_rule_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c2" + "id": "70acb264-a190-c950-4530-585b68c408c3" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.freeze b/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.freeze new file mode 100644 index 00000000000..fef8528de80 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-12-09T13:34:21.892Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.json new file mode 100644 index 00000000000..b98b507b046 --- /dev/null +++ b/src/test/resources/cassettes/features/v2/Get_rules_for_a_deployment_gate_returns_OK_response.json @@ -0,0 +1,79 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v2/deployment_gates", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"4e020f52-06d2-4584-9bc8-4955ce5de1b8\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-12-09T13:34:22.624907Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-12-09T13:34:22.624907Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "70acb264-a190-c950-4530-585b68c408be" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v2/deployment_gates/4e020f52-06d2-4584-9bc8-4955ce5de1b8/rules", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"data\":{\"id\":\"4e020f52-06d2-4584-9bc8-4955ce5de1b8\",\"type\":\"list_deployment_rules\",\"attributes\":{\"rules\":[]}}}", + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "81c8d0b2-a998-da5d-9a00-2f821c6ac9c4" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v2/deployment_gates/4e020f52-06d2-4584-9bc8-4955ce5de1b8", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "headers": {}, + "statusCode": 204, + "reasonPhrase": "No Content" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "c3189f13-4404-4276-35b1-0ed79b16b239" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v2/Update_deployment_gate_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_deployment_gate_returns_OK_response.json index 3268e8fe4fc..a65e0a05fda 100644 --- a/src/test/resources/cassettes/features/v2/Update_deployment_gate_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Update_deployment_gate_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c0" + "id": "70acb264-a190-c950-4530-585b68c408c1" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_Bad_Request_response.json index c5929ce1c19..63cc73722ba 100644 --- a/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_Bad_Request_response.json +++ b/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_Bad_Request_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c4" + "id": "70acb264-a190-c950-4530-585b68c408c5" }, { "httpRequest": { diff --git a/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_OK_response.json b/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_OK_response.json index fe9255c2d61..8a622abac78 100644 --- a/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_OK_response.json +++ b/src/test/resources/cassettes/features/v2/Update_deployment_rule_returns_OK_response.json @@ -27,7 +27,7 @@ "timeToLive": { "unlimited": true }, - "id": "70acb264-a190-c950-4530-585b68c408c3" + "id": "70acb264-a190-c950-4530-585b68c408c4" }, { "httpRequest": { 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 e4023c5650b..cb0c5a1262d 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 @@ -207,6 +207,23 @@ Feature: Deployment Gates When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get rules for a deployment gate returns "Bad request." response + Given operation "GetDeploymentGateRules" enabled + And new "GetDeploymentGateRules" request + And request contains "gate_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @team:DataDog/ci-app-backend + Scenario: Get rules for a deployment gate returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "GetDeploymentGateRules" enabled + And new "GetDeploymentGateRules" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + When the request is sent + Then the response status is 200 OK + @team:DataDog/ci-app-backend Scenario: Update deployment gate returns "Bad Request" response Given operation "UpdateDeploymentGate" enabled diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index 71dba8f3e38..396d5238362 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -1335,6 +1335,12 @@ "type": "unsafe" } }, + "GetDeploymentGateRules": { + "tag": "Deployment Gates", + "undo": { + "type": "safe" + } + }, "CreateDeploymentRule": { "tag": "Deployment Gates", "undo": {