Skip to content

return 422 response code for logs indexes creation when max limit is reached #2762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .generated-info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"spec_repo_commit": "d02c8a3",
"generated": "2025-08-08 12:07:20.979"
"spec_repo_commit": "872cf6d",
"generated": "2025-08-12 14:43:31.361"
}
12 changes: 12 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5123,6 +5123,12 @@ components:
error:
$ref: '#/components/schemas/LogsAPIError'
type: object
LogsAPILimitReachedResponse:
description: Response returned by the Logs API when the max limit has been reached.
properties:
error:
$ref: '#/components/schemas/LogsAPIError'
type: object
LogsArithmeticProcessor:
description: "Use the Arithmetic Processor to add a new attribute (without spaces
or special characters\nin the new attribute name) to a log with the result
Expand Down Expand Up @@ -29444,6 +29450,12 @@ paths:
schema:
$ref: '#/components/schemas/APIErrorResponse'
description: Forbidden
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/LogsAPILimitReachedResponse'
description: Unprocessable Entity
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
summary: Create an index
Expand Down
7 changes: 7 additions & 0 deletions docs/datadog_api_client.v1.model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1558,6 +1558,13 @@ datadog\_api\_client.v1.model.logs\_api\_error\_response module
:members:
:show-inheritance:

datadog\_api\_client.v1.model.logs\_api\_limit\_reached\_response module
------------------------------------------------------------------------

.. automodule:: datadog_api_client.v1.model.logs_api_limit_reached_response
:members:
:show-inheritance:

datadog\_api\_client.v1.model.logs\_arithmetic\_processor module
----------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.
from __future__ import annotations

from typing import Union, TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
unset,
UnsetType,
)


if TYPE_CHECKING:
from datadog_api_client.v1.model.logs_api_error import LogsAPIError


class LogsAPILimitReachedResponse(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v1.model.logs_api_error import LogsAPIError

return {
"error": (LogsAPIError,),
}

attribute_map = {
"error": "error",
}

def __init__(self_, error: Union[LogsAPIError, UnsetType] = unset, **kwargs):
"""
Response returned by the Logs API when the max limit has been reached.

:param error: Error returned by the Logs API
:type error: LogsAPIError, optional
"""
if error is not unset:
kwargs["error"] = error
super().__init__(kwargs)
2 changes: 2 additions & 0 deletions src/datadog_api_client/v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
from datadog_api_client.v1.model.log_stream_widget_definition_type import LogStreamWidgetDefinitionType
from datadog_api_client.v1.model.logs_api_error import LogsAPIError
from datadog_api_client.v1.model.logs_api_error_response import LogsAPIErrorResponse
from datadog_api_client.v1.model.logs_api_limit_reached_response import LogsAPILimitReachedResponse
from datadog_api_client.v1.model.logs_arithmetic_processor import LogsArithmeticProcessor
from datadog_api_client.v1.model.logs_arithmetic_processor_type import LogsArithmeticProcessorType
from datadog_api_client.v1.model.logs_array_processor import LogsArrayProcessor
Expand Down Expand Up @@ -1326,6 +1327,7 @@
"LogStreamWidgetDefinitionType",
"LogsAPIError",
"LogsAPIErrorResponse",
"LogsAPILimitReachedResponse",
"LogsArithmeticProcessor",
"LogsArithmeticProcessorType",
"LogsArrayProcessor",
Expand Down
7 changes: 7 additions & 0 deletions tests/v1/features/logs_indexes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ Feature: Logs Indexes
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
Scenario: Create an index returns "Unprocessable Entity" response
Given new "CreateLogsIndex" request
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}
When the request is sent
Then the response status is 422 Unprocessable Entity

@generated @skip @team:DataDog/logs-backend @team:DataDog/logs-core
Scenario: Delete an index returns "Not Found" response
Given new "DeleteLogsIndex" request
Expand Down
Loading