Skip to content

Commit 922938f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
return 422 response code for logs indexes creation when max limit is reached (#3060)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 70dd89d commit 922938f

File tree

5 files changed

+159
-2
lines changed

5 files changed

+159
-2
lines changed

.generated-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"spec_repo_commit": "205813d",
3-
"generated": "2025-08-25 08:43:17.545"
2+
"spec_repo_commit": "c3b2b7d",
3+
"generated": "2025-08-25 10:19:34.863"
44
}

.generator/schemas/v1/openapi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5123,6 +5123,12 @@ components:
51235123
error:
51245124
$ref: '#/components/schemas/LogsAPIError'
51255125
type: object
5126+
LogsAPILimitReachedResponse:
5127+
description: Response returned by the Logs API when the max limit has been reached.
5128+
properties:
5129+
error:
5130+
$ref: '#/components/schemas/LogsAPIError'
5131+
type: object
51265132
LogsArithmeticProcessor:
51275133
description: "Use the Arithmetic Processor to add a new attribute (without spaces
51285134
or special characters\nin the new attribute name) to a log with the result
@@ -29444,6 +29450,12 @@ paths:
2944429450
schema:
2944529451
$ref: '#/components/schemas/APIErrorResponse'
2944629452
description: Forbidden
29453+
'422':
29454+
content:
29455+
application/json:
29456+
schema:
29457+
$ref: '#/components/schemas/LogsAPILimitReachedResponse'
29458+
description: Unprocessable Entity
2944729459
'429':
2944829460
$ref: '#/components/responses/TooManyRequestsResponse'
2944929461
summary: Create an index

src/main/java/com/datadog/api/client/v1/api/LogsIndexesApi.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public CompletableFuture<LogsIndex> createLogsIndexAsync(LogsIndex body) {
8989
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
9090
* <tr><td> 400 </td><td> Invalid Parameter Error </td><td> - </td></tr>
9191
* <tr><td> 403 </td><td> Forbidden </td><td> - </td></tr>
92+
* <tr><td> 422 </td><td> Unprocessable Entity </td><td> - </td></tr>
9293
* <tr><td> 429 </td><td> Too many requests </td><td> - </td></tr>
9394
* </table>
9495
*/
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v1.model;
8+
9+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
10+
import com.fasterxml.jackson.annotation.JsonAnySetter;
11+
import com.fasterxml.jackson.annotation.JsonIgnore;
12+
import com.fasterxml.jackson.annotation.JsonInclude;
13+
import com.fasterxml.jackson.annotation.JsonProperty;
14+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
15+
import java.util.HashMap;
16+
import java.util.Map;
17+
import java.util.Objects;
18+
19+
/** Response returned by the Logs API when the max limit has been reached. */
20+
@JsonPropertyOrder({LogsAPILimitReachedResponse.JSON_PROPERTY_ERROR})
21+
@jakarta.annotation.Generated(
22+
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
23+
public class LogsAPILimitReachedResponse {
24+
@JsonIgnore public boolean unparsed = false;
25+
public static final String JSON_PROPERTY_ERROR = "error";
26+
private LogsAPIError error;
27+
28+
public LogsAPILimitReachedResponse error(LogsAPIError error) {
29+
this.error = error;
30+
this.unparsed |= error.unparsed;
31+
return this;
32+
}
33+
34+
/**
35+
* Error returned by the Logs API
36+
*
37+
* @return error
38+
*/
39+
@jakarta.annotation.Nullable
40+
@JsonProperty(JSON_PROPERTY_ERROR)
41+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
42+
public LogsAPIError getError() {
43+
return error;
44+
}
45+
46+
public void setError(LogsAPIError error) {
47+
this.error = error;
48+
}
49+
50+
/**
51+
* A container for additional, undeclared properties. This is a holder for any undeclared
52+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
53+
*/
54+
private Map<String, Object> additionalProperties;
55+
56+
/**
57+
* Set the additional (undeclared) property with the specified name and value. If the property
58+
* does not already exist, create it otherwise replace it.
59+
*
60+
* @param key The arbitrary key to set
61+
* @param value The associated value
62+
* @return LogsAPILimitReachedResponse
63+
*/
64+
@JsonAnySetter
65+
public LogsAPILimitReachedResponse putAdditionalProperty(String key, Object value) {
66+
if (this.additionalProperties == null) {
67+
this.additionalProperties = new HashMap<String, Object>();
68+
}
69+
this.additionalProperties.put(key, value);
70+
return this;
71+
}
72+
73+
/**
74+
* Return the additional (undeclared) property.
75+
*
76+
* @return The additional properties
77+
*/
78+
@JsonAnyGetter
79+
public Map<String, Object> getAdditionalProperties() {
80+
return additionalProperties;
81+
}
82+
83+
/**
84+
* Return the additional (undeclared) property with the specified name.
85+
*
86+
* @param key The arbitrary key to get
87+
* @return The specific additional property for the given key
88+
*/
89+
public Object getAdditionalProperty(String key) {
90+
if (this.additionalProperties == null) {
91+
return null;
92+
}
93+
return this.additionalProperties.get(key);
94+
}
95+
96+
/** Return true if this LogsAPILimitReachedResponse object is equal to o. */
97+
@Override
98+
public boolean equals(Object o) {
99+
if (this == o) {
100+
return true;
101+
}
102+
if (o == null || getClass() != o.getClass()) {
103+
return false;
104+
}
105+
LogsAPILimitReachedResponse logsApiLimitReachedResponse = (LogsAPILimitReachedResponse) o;
106+
return Objects.equals(this.error, logsApiLimitReachedResponse.error)
107+
&& Objects.equals(
108+
this.additionalProperties, logsApiLimitReachedResponse.additionalProperties);
109+
}
110+
111+
@Override
112+
public int hashCode() {
113+
return Objects.hash(error, additionalProperties);
114+
}
115+
116+
@Override
117+
public String toString() {
118+
StringBuilder sb = new StringBuilder();
119+
sb.append("class LogsAPILimitReachedResponse {\n");
120+
sb.append(" error: ").append(toIndentedString(error)).append("\n");
121+
sb.append(" additionalProperties: ")
122+
.append(toIndentedString(additionalProperties))
123+
.append("\n");
124+
sb.append('}');
125+
return sb.toString();
126+
}
127+
128+
/**
129+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
130+
*/
131+
private String toIndentedString(Object o) {
132+
if (o == null) {
133+
return "null";
134+
}
135+
return o.toString().replace("\n", "\n ");
136+
}
137+
}

src/test/resources/com/datadog/api/client/v1/api/logs_indexes.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ Feature: Logs Indexes
2222
When the request is sent
2323
Then the response status is 200 OK
2424

25+
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
26+
Scenario: Create an index returns "Unprocessable Entity" response
27+
Given new "CreateLogsIndex" request
28+
And body with value {"daily_limit": 300000000, "daily_limit_reset": {"reset_time": "14:00", "reset_utc_offset": "+02:00"}, "daily_limit_warning_threshold_percentage": 70, "exclusion_filters": [{"filter": {"query": "*", "sample_rate": 1.0}, "name": "payment"}], "filter": {"query": "source:python"}, "name": "main", "num_flex_logs_retention_days": 360, "num_retention_days": 15}
29+
When the request is sent
30+
Then the response status is 422 Unprocessable Entity
31+
2532
@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
2633
Scenario: Delete an index returns "Not Found" response
2734
Given new "DeleteLogsIndex" request

0 commit comments

Comments
 (0)