From 64823d5aaac5e82846ed5d17bdf82e640a43059e Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 16 Nov 2026 17:36:18 +0000 Subject: [PATCH] Regenerate client from commit 28b85e0 of spec repo --- .generator/schemas/v1/openapi.yaml | 78 ++++++++- .generator/schemas/v2/openapi.yaml | 104 +++++++++-- .../v1/monitors/CreateMonitor_1267012748.py | 62 +++++++ .../v1/monitors/CreateMonitor_1302731819.py | 53 ++++++ .../v2/ai-gateway/CreateAiGatewayRateLimit.py | 10 ++ .../v2/ai-gateway/UpdateAiGatewayRateLimit.py | 10 ++ src/datadog_api_client/v1/api/monitors_api.py | 16 ++ ..._and_function_data_jobs_monitor_options.py | 39 +++++ ...and_function_data_jobs_query_definition.py | 49 +++++- ...nd_function_data_quality_detection_type.py | 39 +++++ ...d_function_data_quality_monitor_options.py | 30 ++++ ..._function_data_quality_query_definition.py | 12 +- ...r_formula_and_function_query_definition.py | 17 +- src/datadog_api_client/v1/models/__init__.py | 8 + .../v2/api/ai_gateway_api.py | 6 +- .../model/ai_gateway_rate_limit_attributes.py | 14 +- ...ai_gateway_rate_limit_create_attributes.py | 18 +- ..._gateway_rate_limit_instance_attributes.py | 6 +- ...rate_limit_instances_summary_attributes.py | 2 +- ...ai_gateway_rate_limit_update_attributes.py | 24 ++- .../ai_gateway_rate_limit_usage_attributes.py | 2 +- .../ai_gateway_rate_limit_window_limit.py | 74 ++++++++ ..._gateway_rate_limit_window_limit_metric.py | 44 +++++ ..._gateway_rate_limit_window_limit_window.py | 56 ++++++ src/datadog_api_client/v2/models/__init__.py | 6 + .../test-runner-data/manifest.json | 14 ++ ...-duration-monitor-returns-ok-response.json | 56 ++++++ ...tra-query-dialect-returns-ok-response.json | 52 ++++++ .../test-server-data/v1/monitors.json | 164 ++++++++++++++++++ tests/v1/features/monitors.feature | 24 +++ tests/v2/features/ai_gateway.feature | 14 +- 31 files changed, 1045 insertions(+), 58 deletions(-) create mode 100644 examples/v1/monitors/CreateMonitor_1267012748.py create mode 100644 examples/v1/monitors/CreateMonitor_1302731819.py create mode 100644 src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_monitor_options.py create mode 100644 src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_detection_type.py create mode 100644 src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit.py create mode 100644 src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_metric.py create mode 100644 src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_window.py create mode 100644 tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json create mode 100644 tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a0bee37b64..f2d8715f87 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -9793,30 +9793,53 @@ components: - data_source - query type: object + MonitorFormulaAndFunctionDataJobsMonitorOptions: + description: Monitor configuration options for data jobs queries. + properties: + alert_on_every_failure: + description: |- + Alert separately for each failed run instead of on the count of trailing failures. + Only supported for `failed_runs` monitors with the `aastra` query dialect. It requires + a `> 0` threshold with no warning threshold, an evaluation window of at most two days, + and renotification disabled. + example: true + type: boolean + type: object MonitorFormulaAndFunctionDataJobsQueryDefinition: description: A formula and functions data jobs query. properties: job_type: description: |- The type of job being monitored. Valid values include: - `databricks.job`, `spark.application`, `airflow.dag`, - `dbt.job`, `dbt.model`, `dbt.test`, `glue.job`. + `databricks.job`, `spark.application`, `airflow.dag`, `dbt.job`, `glue.job`, `adf.pipeline`. + The `aastra` dialect also accepts `airflow.job`, `dbt.model`, and `dbt.test`. Custom job types are supported with the `custom.ol.` prefix. example: "databricks.job" type: string jobs_query: - description: Filter expression used to select the jobs to monitor. + description: |- + Filter expression used to select the jobs to monitor. Its syntax depends on `query_dialect`: + a metric tag filter such as `job_name:smoke*` for `metric`, or an Aastra entity search + such as ``search for databricks_job where `@team:data-eng` `` for `aastra`. example: "job_name:smoke*" type: string + monitor_options: + $ref: "#/components/schemas/MonitorFormulaAndFunctionDataJobsMonitorOptions" name: description: Name of the query for use in formulas. Must be `run_query`. example: "run_query" type: string query_dialect: description: |- - Query dialect for data jobs queries. Currently only `metric` is supported. + Query dialect for data jobs queries. Valid values are `metric` and `aastra`. example: "metric" type: string + run_filter: + description: |- + Optional filter on individual runs, using metrics filter syntax. + Only supported with the `aastra` query dialect. + example: "env:prod" + type: string required: - name - jobs_query @@ -9831,6 +9854,18 @@ components: type: string x-enum-varnames: - DATA_QUALITY_METRICS + MonitorFormulaAndFunctionDataQualityDetectionType: + description: |- + How a `data-jobs alert` job duration monitor detects a breach. Must match the + `.detection()` call in the monitor query. Required for job duration monitors. + enum: + - static + - anomaly + example: "anomaly" + type: string + x-enum-varnames: + - STATIC + - ANOMALY MonitorFormulaAndFunctionDataQualityDiffFunction: description: |- Function applied to the measure before it is compared against the predicted bounds. @@ -9891,7 +9926,8 @@ components: The data quality measure to query. Common values include: `bytes`, `cardinality`, `custom`, `freshness`, `max`, `mean`, `min`, `nullness`, `percent_negative`, `percent_zero`, `row_count`, `stddev`, - `sum`, `uniqueness`. Additional values may be supported. + `sum`, `uniqueness`. `data-jobs alert` job duration monitors use `duration`. + Additional values may be supported. example: "row_count" type: string MonitorFormulaAndFunctionDataQualityModelBoundsOverride: @@ -9961,6 +9997,14 @@ components: MonitorFormulaAndFunctionDataQualityMonitorOptions: description: Monitor configuration options for data quality queries. properties: + consecutive_runs: + description: |- + Number of consecutive runs that must breach before the monitor alerts. + Only supported by `data-jobs alert` job duration monitors. Defaults to `1`. + example: 1 + format: int64 + minimum: 1 + type: integer crontab_override: description: Crontab expression to override the default schedule. example: "* * * 10" @@ -9973,6 +10017,8 @@ components: description: Custom WHERE clause for the query. example: "USER_ID = 123" type: string + detection_type: + $ref: "#/components/schemas/MonitorFormulaAndFunctionDataQualityDetectionType" group_by_columns: description: Columns to group results by. example: ["col1", "col2"] @@ -10020,6 +10066,12 @@ components: description: Name of the query for use in formulas. example: "query1" type: string + run_filter: + description: |- + Optional filter on individual runs, using metrics filter syntax. + Only supported by `data-jobs alert` job duration monitors. + example: "env:prod" + type: string schema_version: description: Schema version for the data quality query. example: "0.0.1" @@ -37279,6 +37331,22 @@ paths: - `time_window` #m (between 1 and 2880), #h (between 1 and 48). - `operator` `<`, `<=`, `>`, `>=`, `==`, or `!=`. - `#` an integer or decimal number used to set the threshold. + + **Data Jobs Alert Query** + + Job status example: `formula("failed_runs(run_query)").by(group_keys).last(time_window) > #` + + Job duration examples: `formula("job_duration(run_query)").detection(static).by(group_keys) > duration` + and `formula("job_duration(run_query)").detection(anomaly).by(group_keys) > 0` + + - `run_query`: The name of the single query variable in `options.variables`. Job status monitors + use a data jobs query; job duration monitors use a data quality query with the `duration` measure. + - `group_keys`: The tags to group by, such as `entity_id,name,workspace_name`. + - `time_window`: Number of minutes (#m), hours (#h), or days (#d), up to `10d`. + - `#`: The number of trailing failed runs to alert above, as a non-negative integer. + - `duration`: The duration to alert above, such as `2h`, `30m`, or a number of seconds. + - `options.thresholds.critical`: Must equal the query threshold, in seconds for job duration. + Anomaly job duration monitors omit `options.thresholds`. operationId: CreateMonitor requestBody: content: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 583d0d86f5..7a9926c3d3 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -11380,7 +11380,6 @@ components: description: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each, shared by all matching traffic, or per counter for a template rate limit. Null when this rule does not limit cost. example: 100000000 format: int64 - maximum: 10000000000000 minimum: 1 nullable: true type: integer @@ -11483,6 +11482,12 @@ components: format: uuid nullable: true type: string + window_limits: + description: Limits over rolling windows longer than a minute. Each limit counts the rule's matching traffic, or each counter of a template rate limit, over its window. Per-minute limits are in the `*_per_minute` fields. This list is empty when the rule has no window limits. + items: + $ref: "#/components/schemas/AiGatewayRateLimitWindowLimit" + maxItems: 4 + type: array required: - scope_restricted - name @@ -11501,10 +11506,9 @@ components: description: Attributes used to create an AI Gateway rate limit. properties: cost_microcents_per_minute: - description: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. At most 10000000000000, that is $100,000. In `ENFORCE` mode, requests to a model with no pricing are rejected, because their cost can't be counted. + description: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. In `ENFORCE` mode, the gateway rejects requests to models with no pricing because their cost can't be counted. example: 100000000 format: int64 - maximum: 10000000000000 minimum: 1 nullable: true type: integer @@ -11529,7 +11533,7 @@ components: nullable: true type: integer requests_per_minute: - description: Maximum requests per rolling minute. At least one of `requests_per_minute`, `input_tokens_per_minute`, `output_tokens_per_minute`, and `cost_microcents_per_minute` is required. + description: Maximum requests per rolling minute. At least one of `requests_per_minute`, `input_tokens_per_minute`, `output_tokens_per_minute`, `cost_microcents_per_minute`, or a non-empty `window_limits` is required. example: 600 format: int64 maximum: 10000000 @@ -11553,6 +11557,12 @@ components: example: 00000000-0000-4000-8000-000000000001 format: uuid type: string + window_limits: + description: Limits over rolling windows longer than a minute, such as $20 of spend per 24 hours. This field is available only to organizations with the feature enabled. Other organizations receive a 400 Bad Request response for a non-empty list. Each limit counts the rule's matching traffic, or each counter of a template rate limit, over its window. Set per-minute limits in the `*_per_minute` fields. A rule can have at most four limits in total, including any per-minute limits that are set. Each metric and window pair can appear only once, and for the same metric, a longer window must have a larger amount. In `ENFORCE` mode, the gateway rejects a request that exceeds any limit with HTTP 429 and a `Retry-After` header. If the list includes a `cost` limit, the gateway also rejects requests to models with no pricing because their cost can't be counted. + items: + $ref: "#/components/schemas/AiGatewayRateLimitWindowLimit" + maxItems: 4 + type: array required: - name type: object @@ -11579,12 +11589,12 @@ components: description: One counter of a template rate limit and its live usage. properties: cost_microcents: - description: Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + description: Priced spend, in microcents, counted in the rolling one-minute window. The value is 0 when the rate limit doesn't limit cost. example: 25000000 format: int64 type: integer cost_microcents_per_minute: - description: The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + description: The rate limit's per-counter spend limit, in microcents. Null when the rate limit doesn't limit cost. example: 100000000 format: int64 nullable: true @@ -11610,7 +11620,7 @@ components: example: "v1|7:user_id=36:11111111-1111-1111-1111-111111111111" type: string last_seen: - description: When the gateway last saw this counter hot, that is near or at a limit or limiting; up to a few minutes behind live traffic. + description: When the gateway last recorded this counter as hot, meaning it was at 80% or more of a limit, or it limited or would have limited a request. This value can lag live traffic by a few minutes. example: "2026-10-28T10:05:00Z" format: date-time type: string @@ -11733,7 +11743,7 @@ components: description: Aggregate of a template rate limit's counters. properties: instance_count: - description: Number of counters that were near or at a limit, or limited a request, in the last hour. Counters with room to spare aren't recorded. + description: Number of counters that were at 80% or more of a limit, or that limited or would have limited a request, in the last hour. Other counters aren't recorded. example: 14 format: int64 type: integer @@ -11915,9 +11925,8 @@ components: description: Attributes used to update an AI Gateway rate limit. Only sent fields are changed. properties: cost_microcents_per_minute: - description: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + description: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. format: int64 - maximum: 10000000000000 minimum: 0 nullable: true type: integer @@ -11925,7 +11934,7 @@ components: description: Whether this rate limit is active. type: boolean input_tokens_per_minute: - description: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + description: Set to 0 to remove the input token limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. format: int64 maximum: 100000000000 minimum: 0 @@ -11937,14 +11946,14 @@ components: description: Rate limit name. type: string output_tokens_per_minute: - description: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + description: Set to 0 to remove the output token limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. format: int64 maximum: 100000000000 minimum: 0 nullable: true type: integer requests_per_minute: - description: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + description: Set to 0 to remove the request limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. format: int64 maximum: 10000000 minimum: 0 @@ -11964,6 +11973,13 @@ components: description: Replaces the user scope. An empty string clears it. Null is ignored. nullable: true type: string + window_limits: + description: Replaces all limits over rolling windows longer than a minute. If `window_limits` is null or omitted, the existing limits are unchanged. An empty array removes them all. This field is available only to organizations with the feature enabled. Other organizations receive a 400 Bad Request response for a non-empty list. The same rules as on create apply. A rule can have at most four limits in total, including any per-minute limits that are set. Each metric and window pair can appear only once, and for the same metric, a longer window must have a larger amount. In `ENFORCE` mode, if the list includes a `cost` limit, the gateway rejects requests to models with no pricing because their cost can't be counted. + items: + $ref: "#/components/schemas/AiGatewayRateLimitWindowLimit" + maxItems: 4 + nullable: true + type: array type: object AiGatewayRateLimitUpdateData: description: Data used to update an AI Gateway rate limit. @@ -11994,7 +12010,7 @@ components: description: Live consumption of one AI Gateway rate limit. properties: cost_microcents: - description: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count it, so it is 0 for other rules and for the untracked and total entries. + description: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count spend, so the value is 0 for other rules and for the untracked and total entries. example: 25000000 format: int64 type: integer @@ -12065,6 +12081,60 @@ components: type: string x-enum-varnames: - RATE_LIMIT_USAGE + AiGatewayRateLimitWindowLimit: + description: A limit on one metric over a rolling window longer than a minute. + properties: + amount: + description: Maximum amount of the metric over the window. For `cost`, the amount is priced spend in microcents of 1e-8 USD each, as in `cost_microcents_per_minute`. For the same metric, a longer window must have a larger amount. + example: 2000000000 + format: int64 + minimum: 1 + type: integer + metric: + $ref: "#/components/schemas/AiGatewayRateLimitWindowLimitMetric" + window: + $ref: "#/components/schemas/AiGatewayRateLimitWindowLimitWindow" + required: + - metric + - window + - amount + type: object + AiGatewayRateLimitWindowLimitMetric: + description: The metric that a window limit counts. `cost` counts priced spend in microcents. + enum: + - requests + - input_tokens + - output_tokens + - cost + example: cost + type: string + x-enum-varnames: + - REQUESTS + - INPUT_TOKENS + - OUTPUT_TOKENS + - COST + AiGatewayRateLimitWindowLimitWindow: + description: The rolling window that a limit applies to. For per-minute limits, use the `*_per_minute` fields instead. + enum: + - 5m + - 15m + - 30m + - 1h + - 3h + - 6h + - 12h + - 24h + example: 24h + type: string + x-enum-varnames: + - FIVE_MINUTES + - FIFTEEN_MINUTES + - THIRTY_MINUTES + - ONE_HOUR + - THREE_HOURS + - SIX_HOURS + - TWELVE_HOURS + - TWENTY_FOUR_HOURS AiGatewayRestrictedDetailsMeta: description: Visibility information for identifying instance details. properties: @@ -231840,7 +231910,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/instances/summary: get: - description: Aggregate the counters of every template rate limit in the organization in one call, with one summary per template in the order the rate limit list returns them. Each summary is the one the single-template counter summary endpoint returns without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance are left out. Summaries are cached for up to 15 seconds. + description: Aggregate the counters of every template rate limit in the organization in one call. The response has one summary per template, in the same order as the rate limit list. Each summary matches the response of the single-template counter summary endpoint without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance aren't included. Summaries are cached for up to 15 seconds. operationId: ListAiGatewayRateLimitInstancesSummaries responses: "200": @@ -232097,7 +232167,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/{id}/instances: get: - description: List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. Only counters at 80% or more of a limit, or that limited or would have limited a request, in the last hour are listed. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. + description: List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. The list includes only counters that, in the last hour, reached 80% or more of a limit or limited or would have limited a request. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. operationId: ListAiGatewayRateLimitInstances parameters: - $ref: "#/components/parameters/AiGatewayRateLimitID" @@ -232158,7 +232228,7 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/rate-limits/{id}/instances/summary: get: - description: Aggregate a template rate limit's hot counters (those near or at a limit, or limiting, in the last hour), including how many there are, how many are near or at their limit, and the fullest counter's utilization. Use split_dim to aggregate only counters that match every given dimension value. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. + description: Aggregate a template rate limit's hot counters, including how many there are, how many are near or at their limit, and the fullest counter's utilization. Hot counters are those that reached 80% or more of a limit, or that limited or would have limited a request, in the last hour. Use split_dim to aggregate only counters that match every given dimension value. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. operationId: GetAiGatewayRateLimitInstancesSummary parameters: - $ref: "#/components/parameters/AiGatewayRateLimitID" diff --git a/examples/v1/monitors/CreateMonitor_1267012748.py b/examples/v1/monitors/CreateMonitor_1267012748.py new file mode 100644 index 0000000000..cbffcecde0 --- /dev/null +++ b/examples/v1/monitors/CreateMonitor_1267012748.py @@ -0,0 +1,62 @@ +""" +Create a Data Jobs duration monitor returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.monitors_api import MonitorsApi +from datadog_api_client.v1.model.monitor import Monitor +from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_data_source import ( + MonitorFormulaAndFunctionDataQualityDataSource, +) +from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_detection_type import ( + MonitorFormulaAndFunctionDataQualityDetectionType, +) +from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_monitor_options import ( + MonitorFormulaAndFunctionDataQualityMonitorOptions, +) +from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_query_definition import ( + MonitorFormulaAndFunctionDataQualityQueryDefinition, +) +from datadog_api_client.v1.model.monitor_options import MonitorOptions +from datadog_api_client.v1.model.monitor_type import MonitorType + +body = Monitor( + name="Example-Monitor", + type=MonitorType.DATA_JOBS_ALERT, + query='formula("job_duration(run_query)").detection(anomaly).by(name,workspace_name,entity_id) > 0', + message="Data jobs duration alert triggered", + tags=[ + "test:examplemonitor", + "env:ci", + ], + options=MonitorOptions( + variables=[ + MonitorFormulaAndFunctionDataQualityQueryDefinition( + name="run_query", + data_source=MonitorFormulaAndFunctionDataQualityDataSource.DATA_QUALITY_METRICS, + schema_version="0.0.1", + measure="duration", + filter="search for databricks_job", + run_filter="env:prod", + group_by=[ + "name", + "workspace_name", + "entity_id", + ], + monitor_options=MonitorFormulaAndFunctionDataQualityMonitorOptions( + detection_type=MonitorFormulaAndFunctionDataQualityDetectionType.ANOMALY, + consecutive_runs=2, + ), + ), + ], + ), +) + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.create_monitor(body=body) + + print(response) diff --git a/examples/v1/monitors/CreateMonitor_1302731819.py b/examples/v1/monitors/CreateMonitor_1302731819.py new file mode 100644 index 0000000000..da9748f655 --- /dev/null +++ b/examples/v1/monitors/CreateMonitor_1302731819.py @@ -0,0 +1,53 @@ +""" +Create a Data Jobs monitor with the aastra query dialect returns "OK" response +""" + +from os import environ +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v1.api.monitors_api import MonitorsApi +from datadog_api_client.v1.model.monitor import Monitor +from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_monitor_options import ( + MonitorFormulaAndFunctionDataJobsMonitorOptions, +) +from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import ( + MonitorFormulaAndFunctionDataJobsQueryDefinition, +) +from datadog_api_client.v1.model.monitor_options import MonitorOptions +from datadog_api_client.v1.model.monitor_thresholds import MonitorThresholds +from datadog_api_client.v1.model.monitor_type import MonitorType + +body = Monitor( + name="Example-Monitor", + type=MonitorType.DATA_JOBS_ALERT, + query='formula("failed_runs(run_query)").by(name,workspace_name,entity_id).last(1d) > 0', + message="Data jobs alert triggered", + tags=[ + "test:examplemonitor", + "env:ci", + ], + options=MonitorOptions( + thresholds=MonitorThresholds( + critical=0.0, + ), + variables=[ + MonitorFormulaAndFunctionDataJobsQueryDefinition( + name="run_query", + jobs_query="search for databricks_job", + job_type="databricks.job", + query_dialect="aastra", + run_filter="env:prod", + monitor_options=MonitorFormulaAndFunctionDataJobsMonitorOptions( + alert_on_every_failure=True, + ), + ), + ], + ), +) + +configuration = Configuration() +configuration.access_token = environ["DD_BEARER_TOKEN"] +with ApiClient(configuration) as api_client: + api_instance = MonitorsApi(api_client) + response = api_instance.create_monitor(body=body) + + print(response) diff --git a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py index 54fd16891f..729139fcaf 100644 --- a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py +++ b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.py @@ -11,6 +11,9 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry from datadog_api_client.v2.model.ai_gateway_rate_limit_type import AiGatewayRateLimitType +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_metric import AiGatewayRateLimitWindowLimitMetric +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_window import AiGatewayRateLimitWindowLimitWindow from uuid import UUID body = AiGatewayRateLimitCreateRequest( @@ -33,6 +36,13 @@ ], team_id=UUID("00000000-0000-4000-8000-000000000002"), user_id=UUID("00000000-0000-4000-8000-000000000001"), + window_limits=[ + AiGatewayRateLimitWindowLimit( + amount=2000000000, + metric=AiGatewayRateLimitWindowLimitMetric.COST, + window=AiGatewayRateLimitWindowLimitWindow.TWENTY_FOUR_HOURS, + ), + ], ), type=AiGatewayRateLimitType.RATE_LIMITS, ), diff --git a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py index 8bea2ae767..fd118c5f42 100644 --- a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py +++ b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.py @@ -10,6 +10,9 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_update_attributes import AiGatewayRateLimitUpdateAttributes from datadog_api_client.v2.model.ai_gateway_rate_limit_update_data import AiGatewayRateLimitUpdateData from datadog_api_client.v2.model.ai_gateway_rate_limit_update_request import AiGatewayRateLimitUpdateRequest +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_metric import AiGatewayRateLimitWindowLimitMetric +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_window import AiGatewayRateLimitWindowLimitWindow from uuid import UUID body = AiGatewayRateLimitUpdateRequest( @@ -23,6 +26,13 @@ tags=None, team_id=None, user_id=None, + window_limits=[ + AiGatewayRateLimitWindowLimit( + amount=2000000000, + metric=AiGatewayRateLimitWindowLimitMetric.COST, + window=AiGatewayRateLimitWindowLimitWindow.TWENTY_FOUR_HOURS, + ), + ], ), id=UUID("11111111-1111-1111-1111-111111111111"), type=AiGatewayRateLimitType.RATE_LIMITS, diff --git a/src/datadog_api_client/v1/api/monitors_api.py b/src/datadog_api_client/v1/api/monitors_api.py index 47bbf4cded..4e94af9f88 100644 --- a/src/datadog_api_client/v1/api/monitors_api.py +++ b/src/datadog_api_client/v1/api/monitors_api.py @@ -623,6 +623,22 @@ def create_monitor( * ``operator`` ``<`` , ``<=`` , ``>`` , ``>=`` , ``==`` , or ``!=``. * ``#`` an integer or decimal number used to set the threshold. + **Data Jobs Alert Query** + + Job status example: ``formula("failed_runs(run_query)").by(group_keys).last(time_window) > #`` + + Job duration examples: ``formula("job_duration(run_query)").detection(static).by(group_keys) > duration`` + and ``formula("job_duration(run_query)").detection(anomaly).by(group_keys) > 0`` + + * ``run_query`` : The name of the single query variable in ``options.variables``. Job status monitors + use a data jobs query; job duration monitors use a data quality query with the ``duration`` measure. + * ``group_keys`` : The tags to group by, such as ``entity_id,name,workspace_name``. + * ``time_window`` : Number of minutes (#m), hours (#h), or days (#d), up to ``10d``. + * ``#`` : The number of trailing failed runs to alert above, as a non-negative integer. + * ``duration`` : The duration to alert above, such as ``2h`` , ``30m`` , or a number of seconds. + * ``options.thresholds.critical`` : Must equal the query threshold, in seconds for job duration. + Anomaly job duration monitors omit ``options.thresholds``. + :param body: Create a monitor request body. :type body: Monitor :rtype: Monitor diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_monitor_options.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_monitor_options.py new file mode 100644 index 0000000000..44194f5a82 --- /dev/null +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_monitor_options.py @@ -0,0 +1,39 @@ +# 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 + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class MonitorFormulaAndFunctionDataJobsMonitorOptions(ModelNormal): + @cached_property + def openapi_types(_): + return { + "alert_on_every_failure": (bool,), + } + + attribute_map = { + "alert_on_every_failure": "alert_on_every_failure", + } + + def __init__(self_, alert_on_every_failure: Union[bool, UnsetType] = unset, **kwargs): + """ + Monitor configuration options for data jobs queries. + + :param alert_on_every_failure: Alert separately for each failed run instead of on the count of trailing failures. + Only supported for ``failed_runs`` monitors with the ``aastra`` query dialect. It requires + a ``> 0`` threshold with no warning threshold, an evaluation window of at most two days, + and renotification disabled. + :type alert_on_every_failure: bool, optional + """ + if alert_on_every_failure is not unset: + kwargs["alert_on_every_failure"] = alert_on_every_failure + super().__init__(kwargs) diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_query_definition.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_query_definition.py index cad58de6f0..8b0c95eb60 100644 --- a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_query_definition.py +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_jobs_query_definition.py @@ -3,49 +3,88 @@ # 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.monitor_formula_and_function_data_jobs_monitor_options import ( + MonitorFormulaAndFunctionDataJobsMonitorOptions, + ) + + class MonitorFormulaAndFunctionDataJobsQueryDefinition(ModelNormal): @cached_property def openapi_types(_): + from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_monitor_options import ( + MonitorFormulaAndFunctionDataJobsMonitorOptions, + ) + return { "job_type": (str,), "jobs_query": (str,), + "monitor_options": (MonitorFormulaAndFunctionDataJobsMonitorOptions,), "name": (str,), "query_dialect": (str,), + "run_filter": (str,), } attribute_map = { "job_type": "job_type", "jobs_query": "jobs_query", + "monitor_options": "monitor_options", "name": "name", "query_dialect": "query_dialect", + "run_filter": "run_filter", } - def __init__(self_, job_type: str, jobs_query: str, name: str, query_dialect: str, **kwargs): + def __init__( + self_, + job_type: str, + jobs_query: str, + name: str, + query_dialect: str, + monitor_options: Union[MonitorFormulaAndFunctionDataJobsMonitorOptions, UnsetType] = unset, + run_filter: Union[str, UnsetType] = unset, + **kwargs, + ): """ A formula and functions data jobs query. :param job_type: The type of job being monitored. Valid values include: - ``databricks.job`` , ``spark.application`` , ``airflow.dag`` , - ``dbt.job`` , ``dbt.model`` , ``dbt.test`` , ``glue.job``. + ``databricks.job`` , ``spark.application`` , ``airflow.dag`` , ``dbt.job`` , ``glue.job`` , ``adf.pipeline``. + The ``aastra`` dialect also accepts ``airflow.job`` , ``dbt.model`` , and ``dbt.test``. Custom job types are supported with the ``custom.ol.`` prefix. :type job_type: str - :param jobs_query: Filter expression used to select the jobs to monitor. + :param jobs_query: Filter expression used to select the jobs to monitor. Its syntax depends on ``query_dialect`` : + a metric tag filter such as ``job_name:smoke*`` for ``metric`` , or an Aastra entity search + such as ``search for databricks_job where `@team:data-eng` `` for ``aastra``. :type jobs_query: str + :param monitor_options: Monitor configuration options for data jobs queries. + :type monitor_options: MonitorFormulaAndFunctionDataJobsMonitorOptions, optional + :param name: Name of the query for use in formulas. Must be ``run_query``. :type name: str - :param query_dialect: Query dialect for data jobs queries. Currently only ``metric`` is supported. + :param query_dialect: Query dialect for data jobs queries. Valid values are ``metric`` and ``aastra``. :type query_dialect: str + + :param run_filter: Optional filter on individual runs, using metrics filter syntax. + Only supported with the ``aastra`` query dialect. + :type run_filter: str, optional """ + if monitor_options is not unset: + kwargs["monitor_options"] = monitor_options + if run_filter is not unset: + kwargs["run_filter"] = run_filter super().__init__(kwargs) self_.job_type = job_type diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_detection_type.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_detection_type.py new file mode 100644 index 0000000000..bd3bb5e5d1 --- /dev/null +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_detection_type.py @@ -0,0 +1,39 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class MonitorFormulaAndFunctionDataQualityDetectionType(ModelSimple): + """ + How a `data-jobs alert` job duration monitor detects a breach. Must match the + `.detection()` call in the monitor query. Required for job duration monitors. + + :param value: Must be one of ["static", "anomaly"]. + :type value: str + """ + + allowed_values = { + "static", + "anomaly", + } + STATIC: ClassVar["MonitorFormulaAndFunctionDataQualityDetectionType"] + ANOMALY: ClassVar["MonitorFormulaAndFunctionDataQualityDetectionType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +MonitorFormulaAndFunctionDataQualityDetectionType.STATIC = MonitorFormulaAndFunctionDataQualityDetectionType("static") +MonitorFormulaAndFunctionDataQualityDetectionType.ANOMALY = MonitorFormulaAndFunctionDataQualityDetectionType("anomaly") diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_monitor_options.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_monitor_options.py index e457b56c12..b5a7d592c8 100644 --- a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_monitor_options.py +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_monitor_options.py @@ -14,6 +14,9 @@ if TYPE_CHECKING: + from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_detection_type import ( + MonitorFormulaAndFunctionDataQualityDetectionType, + ) from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_model_configuration import ( MonitorFormulaAndFunctionDataQualityModelConfiguration, ) @@ -26,8 +29,17 @@ class MonitorFormulaAndFunctionDataQualityMonitorOptions(ModelNormal): + validations = { + "consecutive_runs": { + "inclusive_minimum": 1, + }, + } + @cached_property def openapi_types(_): + from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_detection_type import ( + MonitorFormulaAndFunctionDataQualityDetectionType, + ) from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_model_configuration import ( MonitorFormulaAndFunctionDataQualityModelConfiguration, ) @@ -39,9 +51,11 @@ def openapi_types(_): ) return { + "consecutive_runs": (int,), "crontab_override": (str,), "custom_sql": (str,), "custom_where": (str,), + "detection_type": (MonitorFormulaAndFunctionDataQualityDetectionType,), "group_by_columns": ([str],), "model_configuration": (MonitorFormulaAndFunctionDataQualityModelConfiguration,), "model_type_override": (MonitorFormulaAndFunctionDataQualityModelTypeOverride,), @@ -50,9 +64,11 @@ def openapi_types(_): } attribute_map = { + "consecutive_runs": "consecutive_runs", "crontab_override": "crontab_override", "custom_sql": "custom_sql", "custom_where": "custom_where", + "detection_type": "detection_type", "group_by_columns": "group_by_columns", "model_configuration": "model_configuration", "model_type_override": "model_type_override", @@ -62,9 +78,11 @@ def openapi_types(_): def __init__( self_, + consecutive_runs: Union[int, UnsetType] = unset, crontab_override: Union[str, UnsetType] = unset, custom_sql: Union[str, UnsetType] = unset, custom_where: Union[str, UnsetType] = unset, + detection_type: Union[MonitorFormulaAndFunctionDataQualityDetectionType, UnsetType] = unset, group_by_columns: Union[List[str], UnsetType] = unset, model_configuration: Union[MonitorFormulaAndFunctionDataQualityModelConfiguration, UnsetType] = unset, model_type_override: Union[MonitorFormulaAndFunctionDataQualityModelTypeOverride, UnsetType] = unset, @@ -75,6 +93,10 @@ def __init__( """ Monitor configuration options for data quality queries. + :param consecutive_runs: Number of consecutive runs that must breach before the monitor alerts. + Only supported by ``data-jobs alert`` job duration monitors. Defaults to ``1``. + :type consecutive_runs: int, optional + :param crontab_override: Crontab expression to override the default schedule. :type crontab_override: str, optional @@ -84,6 +106,10 @@ def __init__( :param custom_where: Custom WHERE clause for the query. :type custom_where: str, optional + :param detection_type: How a ``data-jobs alert`` job duration monitor detects a breach. Must match the + ``.detection()`` call in the monitor query. Required for job duration monitors. + :type detection_type: MonitorFormulaAndFunctionDataQualityDetectionType, optional + :param group_by_columns: Columns to group results by. :type group_by_columns: [str], optional @@ -102,12 +128,16 @@ def __init__( across two data entities and alerts on the difference between them. :type source_to_target_config: MonitorFormulaAndFunctionDataQualitySourceToTargetConfig, optional """ + if consecutive_runs is not unset: + kwargs["consecutive_runs"] = consecutive_runs if crontab_override is not unset: kwargs["crontab_override"] = crontab_override if custom_sql is not unset: kwargs["custom_sql"] = custom_sql if custom_where is not unset: kwargs["custom_where"] = custom_where + if detection_type is not unset: + kwargs["detection_type"] = detection_type if group_by_columns is not unset: kwargs["group_by_columns"] = group_by_columns if model_configuration is not unset: diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_query_definition.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_query_definition.py index ef57341eaa..7958de3ca6 100644 --- a/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_query_definition.py +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_data_quality_query_definition.py @@ -39,6 +39,7 @@ def openapi_types(_): "measure": (str,), "monitor_options": (MonitorFormulaAndFunctionDataQualityMonitorOptions,), "name": (str,), + "run_filter": (str,), "schema_version": (str,), "scope": (str,), } @@ -50,6 +51,7 @@ def openapi_types(_): "measure": "measure", "monitor_options": "monitor_options", "name": "name", + "run_filter": "run_filter", "schema_version": "schema_version", "scope": "scope", } @@ -62,6 +64,7 @@ def __init__( name: str, group_by: Union[List[str], UnsetType] = unset, monitor_options: Union[MonitorFormulaAndFunctionDataQualityMonitorOptions, UnsetType] = unset, + run_filter: Union[str, UnsetType] = unset, schema_version: Union[str, UnsetType] = unset, scope: Union[str, UnsetType] = unset, **kwargs, @@ -81,7 +84,8 @@ def __init__( :param measure: The data quality measure to query. Common values include: ``bytes`` , ``cardinality`` , ``custom`` , ``freshness`` , ``max`` , ``mean`` , ``min`` , ``nullness`` , ``percent_negative`` , ``percent_zero`` , ``row_count`` , ``stddev`` , - ``sum`` , ``uniqueness``. Additional values may be supported. + ``sum`` , ``uniqueness``. ``data-jobs alert`` job duration monitors use ``duration``. + Additional values may be supported. :type measure: str :param monitor_options: Monitor configuration options for data quality queries. @@ -90,6 +94,10 @@ def __init__( :param name: Name of the query for use in formulas. :type name: str + :param run_filter: Optional filter on individual runs, using metrics filter syntax. + Only supported by ``data-jobs alert`` job duration monitors. + :type run_filter: str, optional + :param schema_version: Schema version for the data quality query. :type schema_version: str, optional @@ -101,6 +109,8 @@ def __init__( kwargs["group_by"] = group_by if monitor_options is not unset: kwargs["monitor_options"] = monitor_options + if run_filter is not unset: + kwargs["run_filter"] = run_filter if schema_version is not unset: kwargs["schema_version"] = schema_version if scope is not unset: diff --git a/src/datadog_api_client/v1/model/monitor_formula_and_function_query_definition.py b/src/datadog_api_client/v1/model/monitor_formula_and_function_query_definition.py index ce4c3bbda6..07eb35e8a3 100644 --- a/src/datadog_api_client/v1/model/monitor_formula_and_function_query_definition.py +++ b/src/datadog_api_client/v1/model/monitor_formula_and_function_query_definition.py @@ -45,12 +45,17 @@ def __init__(self, **kwargs): :param measure: The data quality measure to query. Common values include: `bytes`, `cardinality`, `custom`, `freshness`, `max`, `mean`, `min`, `nullness`, `percent_negative`, `percent_zero`, `row_count`, `stddev`, - `sum`, `uniqueness`. Additional values may be supported. + `sum`, `uniqueness`. `data-jobs alert` job duration monitors use `duration`. + Additional values may be supported. :type measure: str :param monitor_options: Monitor configuration options for data quality queries. :type monitor_options: MonitorFormulaAndFunctionDataQualityMonitorOptions, optional + :param run_filter: Optional filter on individual runs, using metrics filter syntax. + Only supported by `data-jobs alert` job duration monitors. + :type run_filter: str, optional + :param schema_version: Schema version for the data quality query. :type schema_version: str, optional @@ -59,15 +64,17 @@ def __init__(self, **kwargs): :type scope: str, optional :param job_type: The type of job being monitored. Valid values include: - `databricks.job`, `spark.application`, `airflow.dag`, - `dbt.job`, `dbt.model`, `dbt.test`, `glue.job`. + `databricks.job`, `spark.application`, `airflow.dag`, `dbt.job`, `glue.job`, `adf.pipeline`. + The `aastra` dialect also accepts `airflow.job`, `dbt.model`, and `dbt.test`. Custom job types are supported with the `custom.ol.` prefix. :type job_type: str - :param jobs_query: Filter expression used to select the jobs to monitor. + :param jobs_query: Filter expression used to select the jobs to monitor. Its syntax depends on `query_dialect`: + a metric tag filter such as `job_name:smoke*` for `metric`, or an Aastra entity search + such as ``search for databricks_job where `@team:data-eng` `` for `aastra`. :type jobs_query: str - :param query_dialect: Query dialect for data jobs queries. Currently only `metric` is supported. + :param query_dialect: Query dialect for data jobs queries. Valid values are `metric` and `aastra`. :type query_dialect: str :param augment_query: Augment query for aggregate augmented queries. Can be an events query or a reference table query. diff --git a/src/datadog_api_client/v1/models/__init__.py b/src/datadog_api_client/v1/models/__init__.py index 135ebf6b1f..85954dfc40 100644 --- a/src/datadog_api_client/v1/models/__init__.py +++ b/src/datadog_api_client/v1/models/__init__.py @@ -558,12 +558,18 @@ from datadog_api_client.v1.model.monitor_formula_and_function_cost_query_definition import ( MonitorFormulaAndFunctionCostQueryDefinition, ) +from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_monitor_options import ( + MonitorFormulaAndFunctionDataJobsMonitorOptions, +) from datadog_api_client.v1.model.monitor_formula_and_function_data_jobs_query_definition import ( MonitorFormulaAndFunctionDataJobsQueryDefinition, ) from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_data_source import ( MonitorFormulaAndFunctionDataQualityDataSource, ) +from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_detection_type import ( + MonitorFormulaAndFunctionDataQualityDetectionType, +) from datadog_api_client.v1.model.monitor_formula_and_function_data_quality_diff_function import ( MonitorFormulaAndFunctionDataQualityDiffFunction, ) @@ -2017,8 +2023,10 @@ "MonitorFormulaAndFunctionCostAggregator", "MonitorFormulaAndFunctionCostDataSource", "MonitorFormulaAndFunctionCostQueryDefinition", + "MonitorFormulaAndFunctionDataJobsMonitorOptions", "MonitorFormulaAndFunctionDataJobsQueryDefinition", "MonitorFormulaAndFunctionDataQualityDataSource", + "MonitorFormulaAndFunctionDataQualityDetectionType", "MonitorFormulaAndFunctionDataQualityDiffFunction", "MonitorFormulaAndFunctionDataQualityDiffType", "MonitorFormulaAndFunctionDataQualityEntityMetricConfig", diff --git a/src/datadog_api_client/v2/api/ai_gateway_api.py b/src/datadog_api_client/v2/api/ai_gateway_api.py index 3534f21310..216d0d48e2 100644 --- a/src/datadog_api_client/v2/api/ai_gateway_api.py +++ b/src/datadog_api_client/v2/api/ai_gateway_api.py @@ -2104,7 +2104,7 @@ def get_ai_gateway_rate_limit_instances_summary( ) -> AiGatewayRateLimitInstancesSummaryResponse: """Get an AI Gateway rate limit counter summary. - Aggregate a template rate limit's hot counters (those near or at a limit, or limiting, in the last hour), including how many there are, how many are near or at their limit, and the fullest counter's utilization. Use split_dim to aggregate only counters that match every given dimension value. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. + Aggregate a template rate limit's hot counters, including how many there are, how many are near or at their limit, and the fullest counter's utilization. Hot counters are those that reached 80% or more of a limit, or that limited or would have limited a request, in the last hour. Use split_dim to aggregate only counters that match every given dimension value. When the caller can't see the template's selector, every count is zero and scope_restricted is true. Summaries are cached for up to 15 seconds. Returns 503 when counter usage can't be read. :param id: Rate limit UUID. :type id: UUID @@ -2393,7 +2393,7 @@ def list_ai_gateway_rate_limit_instances( ) -> AiGatewayRateLimitInstanceListResponse: """List AI Gateway rate limit counters. - List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. Only counters at 80% or more of a limit, or that limited or would have limited a request, in the last hour are listed. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. + List the hot counters of a template rate limit, one per matched user, Team, or value, with their live usage. The list includes only counters that, in the last hour, reached 80% or more of a limit or limited or would have limited a request. A counter appears within a few minutes of becoming hot. Usage is read for at most 200 counters per request; past that, rows carry usage_known false. Counters for a provider or model the caller can't see are left out, and when the caller can't see the template's selector, the list is empty. A rate limit with one shared allowance, including one whose selector has no per_value entry, returns an empty list. Returns 503 when counter usage can't be read. :param id: Rate limit UUID. :type id: UUID @@ -2429,7 +2429,7 @@ def list_ai_gateway_rate_limit_instances_summaries( ) -> AiGatewayRateLimitInstancesSummaryListResponse: """List AI Gateway rate limit counter summaries. - Aggregate the counters of every template rate limit in the organization in one call, with one summary per template in the order the rate limit list returns them. Each summary is the one the single-template counter summary endpoint returns without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance are left out. Summaries are cached for up to 15 seconds. + Aggregate the counters of every template rate limit in the organization in one call. The response has one summary per template, in the same order as the rate limit list. Each summary matches the response of the single-template counter summary endpoint without split_dim, including scope_restricted and truncated. Rate limits with one shared allowance aren't included. Summaries are cached for up to 15 seconds. :rtype: AiGatewayRateLimitInstancesSummaryListResponse """ diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py index ca6afd5c15..91e3757892 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_attributes.py @@ -19,12 +19,12 @@ if TYPE_CHECKING: from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit class AiGatewayRateLimitAttributes(ModelNormal): validations = { "cost_microcents_per_minute": { - "inclusive_maximum": 10000000000000, "inclusive_minimum": 1, }, "input_tokens_per_minute": { @@ -39,12 +39,16 @@ class AiGatewayRateLimitAttributes(ModelNormal): "inclusive_maximum": 10000000, "inclusive_minimum": 1, }, + "window_limits": { + "max_items": 4, + }, } @cached_property def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit return { "cost_microcents_per_minute": (int, none_type), @@ -67,6 +71,7 @@ def openapi_types(_): "updated_at": (datetime,), "updated_by": (str,), "user_id": (UUID, none_type), + "window_limits": ([AiGatewayRateLimitWindowLimit],), } attribute_map = { @@ -90,6 +95,7 @@ def openapi_types(_): "updated_at": "updated_at", "updated_by": "updated_by", "user_id": "user_id", + "window_limits": "window_limits", } def __init__( @@ -114,6 +120,7 @@ def __init__( selector: Union[List[AiGatewayRateLimitSelectorEntry], none_type, UnsetType] = unset, team_id: Union[UUID, none_type, UnsetType] = unset, user_id: Union[UUID, none_type, UnsetType] = unset, + window_limits: Union[List[AiGatewayRateLimitWindowLimit], UnsetType] = unset, **kwargs, ): """ @@ -178,6 +185,9 @@ def __init__( :param user_id: Optional user UUID. Count only this user's requests. :type user_id: UUID, none_type, optional + + :param window_limits: Limits over rolling windows longer than a minute. Each limit counts the rule's matching traffic, or each counter of a template rate limit, over its window. Per-minute limits are in the ``*_per_minute`` fields. This list is empty when the rule has no window limits. + :type window_limits: [AiGatewayRateLimitWindowLimit], optional """ if cost_microcents_per_minute is not unset: kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute @@ -195,6 +205,8 @@ def __init__( kwargs["team_id"] = team_id if user_id is not unset: kwargs["user_id"] = user_id + if window_limits is not unset: + kwargs["window_limits"] = window_limits super().__init__(kwargs) self_.created_at = created_at diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py index e5c1f86f3d..5120114f10 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_create_attributes.py @@ -18,12 +18,12 @@ if TYPE_CHECKING: from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit class AiGatewayRateLimitCreateAttributes(ModelNormal): validations = { "cost_microcents_per_minute": { - "inclusive_maximum": 10000000000000, "inclusive_minimum": 1, }, "input_tokens_per_minute": { @@ -38,12 +38,16 @@ class AiGatewayRateLimitCreateAttributes(ModelNormal): "inclusive_maximum": 10000000, "inclusive_minimum": 1, }, + "window_limits": { + "max_items": 4, + }, } @cached_property def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode from datadog_api_client.v2.model.ai_gateway_rate_limit_selector_entry import AiGatewayRateLimitSelectorEntry + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit return { "cost_microcents_per_minute": (int, none_type), @@ -56,6 +60,7 @@ def openapi_types(_): "tags": ({str: (str,)},), "team_id": (UUID,), "user_id": (UUID,), + "window_limits": ([AiGatewayRateLimitWindowLimit],), } attribute_map = { @@ -69,6 +74,7 @@ def openapi_types(_): "tags": "tags", "team_id": "team_id", "user_id": "user_id", + "window_limits": "window_limits", } def __init__( @@ -83,12 +89,13 @@ def __init__( tags: Union[Dict[str, str], UnsetType] = unset, team_id: Union[UUID, UnsetType] = unset, user_id: Union[UUID, UnsetType] = unset, + window_limits: Union[List[AiGatewayRateLimitWindowLimit], UnsetType] = unset, **kwargs, ): """ Attributes used to create an AI Gateway rate limit. - :param cost_microcents_per_minute: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. At most 10000000000000, that is $100,000. In ``ENFORCE`` mode, requests to a model with no pricing are rejected, because their cost can't be counted. + :param cost_microcents_per_minute: Maximum priced spend per rolling minute, in microcents of 1e-8 USD each. In ``ENFORCE`` mode, the gateway rejects requests to models with no pricing because their cost can't be counted. :type cost_microcents_per_minute: int, none_type, optional :param input_tokens_per_minute: Maximum input tokens per rolling minute. @@ -103,7 +110,7 @@ def __init__( :param output_tokens_per_minute: Maximum output tokens per rolling minute. :type output_tokens_per_minute: int, none_type, optional - :param requests_per_minute: Maximum requests per rolling minute. At least one of ``requests_per_minute`` , ``input_tokens_per_minute`` , ``output_tokens_per_minute`` , and ``cost_microcents_per_minute`` is required. + :param requests_per_minute: Maximum requests per rolling minute. At least one of ``requests_per_minute`` , ``input_tokens_per_minute`` , ``output_tokens_per_minute`` , ``cost_microcents_per_minute`` , or a non-empty ``window_limits`` is required. :type requests_per_minute: int, none_type, optional :param selector: Dimension rules for a template rate limit, which gives each matched user, Team, or value its own allowance with the rule's limits. Can't be combined with user_id, team_id, or tags, and can't be changed after creation. Omit for a rule with one shared allowance. @@ -117,6 +124,9 @@ def __init__( :param user_id: Optional UUID. Count only this user's requests. :type user_id: UUID, optional + + :param window_limits: Limits over rolling windows longer than a minute, such as $20 of spend per 24 hours. This field is available only to organizations with the feature enabled. Other organizations receive a 400 Bad Request response for a non-empty list. Each limit counts the rule's matching traffic, or each counter of a template rate limit, over its window. Set per-minute limits in the ``*_per_minute`` fields. A rule can have at most four limits in total, including any per-minute limits that are set. Each metric and window pair can appear only once, and for the same metric, a longer window must have a larger amount. In ``ENFORCE`` mode, the gateway rejects a request that exceeds any limit with HTTP 429 and a ``Retry-After`` header. If the list includes a ``cost`` limit, the gateway also rejects requests to models with no pricing because their cost can't be counted. + :type window_limits: [AiGatewayRateLimitWindowLimit], optional """ if cost_microcents_per_minute is not unset: kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute @@ -136,6 +146,8 @@ def __init__( kwargs["team_id"] = team_id if user_id is not unset: kwargs["user_id"] = user_id + if window_limits is not unset: + kwargs["window_limits"] = window_limits super().__init__(kwargs) self_.name = name diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py index 3aa2d07b61..2038ac5ba5 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instance_attributes.py @@ -83,10 +83,10 @@ def __init__( """ One counter of a template rate limit and its live usage. - :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. The value is 0 when the rate limit doesn't limit cost. :type cost_microcents: int, optional - :param cost_microcents_per_minute: The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + :param cost_microcents_per_minute: The rate limit's per-counter spend limit, in microcents. Null when the rate limit doesn't limit cost. :type cost_microcents_per_minute: int, none_type, optional :param first_seen: When the gateway first recorded a request for this counter. @@ -101,7 +101,7 @@ def __init__( :param instance_key: Opaque canonical key identifying the counter. :type instance_key: str - :param last_seen: When the gateway last saw this counter hot, that is near or at a limit or limiting; up to a few minutes behind live traffic. + :param last_seen: When the gateway last recorded this counter as hot, meaning it was at 80% or more of a limit, or it limited or would have limited a request. This value can lag live traffic by a few minutes. :type last_seen: datetime :param limited_requests: Requests this counter rejected in the last 15 minutes (ENFORCE). diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py index b1329ec42f..d35335ef7a 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_instances_summary_attributes.py @@ -57,7 +57,7 @@ def __init__( """ Aggregate of a template rate limit's counters. - :param instance_count: Number of counters that were near or at a limit, or limited a request, in the last hour. Counters with room to spare aren't recorded. + :param instance_count: Number of counters that were at 80% or more of a limit, or that limited or would have limited a request, in the last hour. Other counters aren't recorded. :type instance_count: int :param limited_requests: Requests the counters rejected in the last 15 minutes (ENFORCE), totaled over the counters whose usage was read. diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py index 1867be2075..9daa06ce03 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_update_attributes.py @@ -3,7 +3,7 @@ # Copyright 2019-Present Datadog, Inc. from __future__ import annotations -from typing import Dict, Union, TYPE_CHECKING +from typing import Dict, List, Union, TYPE_CHECKING from datadog_api_client.model_utils import ( ModelNormal, @@ -16,12 +16,12 @@ if TYPE_CHECKING: from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit class AiGatewayRateLimitUpdateAttributes(ModelNormal): validations = { "cost_microcents_per_minute": { - "inclusive_maximum": 10000000000000, "inclusive_minimum": 0, }, "input_tokens_per_minute": { @@ -36,11 +36,15 @@ class AiGatewayRateLimitUpdateAttributes(ModelNormal): "inclusive_maximum": 10000000, "inclusive_minimum": 0, }, + "window_limits": { + "max_items": 4, + }, } @cached_property def openapi_types(_): from datadog_api_client.v2.model.ai_gateway_rate_limit_mode import AiGatewayRateLimitMode + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit return { "cost_microcents_per_minute": (int, none_type), @@ -53,6 +57,7 @@ def openapi_types(_): "tags": ({str: (str,)}, none_type), "team_id": (str, none_type), "user_id": (str, none_type), + "window_limits": ([AiGatewayRateLimitWindowLimit], none_type), } attribute_map = { @@ -66,6 +71,7 @@ def openapi_types(_): "tags": "tags", "team_id": "team_id", "user_id": "user_id", + "window_limits": "window_limits", } def __init__( @@ -80,18 +86,19 @@ def __init__( tags: Union[Dict[str, str], none_type, UnsetType] = unset, team_id: Union[str, none_type, UnsetType] = unset, user_id: Union[str, none_type, UnsetType] = unset, + window_limits: Union[List[AiGatewayRateLimitWindowLimit], none_type, UnsetType] = unset, **kwargs, ): """ Attributes used to update an AI Gateway rate limit. Only sent fields are changed. - :param cost_microcents_per_minute: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + :param cost_microcents_per_minute: Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit, per-minute or in ``window_limits`` , must remain. :type cost_microcents_per_minute: int, none_type, optional :param enabled: Whether this rate limit is active. :type enabled: bool, optional - :param input_tokens_per_minute: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + :param input_tokens_per_minute: Set to 0 to remove the input token limit. Null is ignored. At least one limit, per-minute or in ``window_limits`` , must remain. :type input_tokens_per_minute: int, none_type, optional :param mode: Action taken when request rate exceeds the limit. @@ -100,10 +107,10 @@ def __init__( :param name: Rate limit name. :type name: str, optional - :param output_tokens_per_minute: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + :param output_tokens_per_minute: Set to 0 to remove the output token limit. Null is ignored. At least one limit, per-minute or in ``window_limits`` , must remain. :type output_tokens_per_minute: int, none_type, optional - :param requests_per_minute: Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + :param requests_per_minute: Set to 0 to remove the request limit. Null is ignored. At least one limit, per-minute or in ``window_limits`` , must remain. :type requests_per_minute: int, none_type, optional :param tags: Replaces all scope tags. An empty object clears them. Null is ignored. @@ -114,6 +121,9 @@ def __init__( :param user_id: Replaces the user scope. An empty string clears it. Null is ignored. :type user_id: str, none_type, optional + + :param window_limits: Replaces all limits over rolling windows longer than a minute. If ``window_limits`` is null or omitted, the existing limits are unchanged. An empty array removes them all. This field is available only to organizations with the feature enabled. Other organizations receive a 400 Bad Request response for a non-empty list. The same rules as on create apply. A rule can have at most four limits in total, including any per-minute limits that are set. Each metric and window pair can appear only once, and for the same metric, a longer window must have a larger amount. In ``ENFORCE`` mode, if the list includes a ``cost`` limit, the gateway rejects requests to models with no pricing because their cost can't be counted. + :type window_limits: [AiGatewayRateLimitWindowLimit], none_type, optional """ if cost_microcents_per_minute is not unset: kwargs["cost_microcents_per_minute"] = cost_microcents_per_minute @@ -135,4 +145,6 @@ def __init__( kwargs["team_id"] = team_id if user_id is not unset: kwargs["user_id"] = user_id + if window_limits is not unset: + kwargs["window_limits"] = window_limits super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py index 63ac2a4bb0..dbcc89d323 100644 --- a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_usage_attributes.py @@ -47,7 +47,7 @@ def __init__( """ Live consumption of one AI Gateway rate limit. - :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count it, so it is 0 for other rules and for the untracked and total entries. + :param cost_microcents: Priced spend, in microcents, counted in the rolling one-minute window. Only rules with a cost limit count spend, so the value is 0 for other rules and for the untracked and total entries. :type cost_microcents: int, optional :param input_tokens: Input tokens counted in the rolling one-minute window. diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit.py new file mode 100644 index 0000000000..9674be3138 --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit.py @@ -0,0 +1,74 @@ +# 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 TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_metric import ( + AiGatewayRateLimitWindowLimitMetric, + ) + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_window import ( + AiGatewayRateLimitWindowLimitWindow, + ) + + +class AiGatewayRateLimitWindowLimit(ModelNormal): + validations = { + "amount": { + "inclusive_minimum": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_metric import ( + AiGatewayRateLimitWindowLimitMetric, + ) + from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_window import ( + AiGatewayRateLimitWindowLimitWindow, + ) + + return { + "amount": (int,), + "metric": (AiGatewayRateLimitWindowLimitMetric,), + "window": (AiGatewayRateLimitWindowLimitWindow,), + } + + attribute_map = { + "amount": "amount", + "metric": "metric", + "window": "window", + } + + def __init__( + self_, + amount: int, + metric: AiGatewayRateLimitWindowLimitMetric, + window: AiGatewayRateLimitWindowLimitWindow, + **kwargs, + ): + """ + A limit on one metric over a rolling window longer than a minute. + + :param amount: Maximum amount of the metric over the window. For ``cost`` , the amount is priced spend in microcents of 1e-8 USD each, as in ``cost_microcents_per_minute``. For the same metric, a longer window must have a larger amount. + :type amount: int + + :param metric: The metric that a window limit counts. ``cost`` counts priced spend in microcents. + :type metric: AiGatewayRateLimitWindowLimitMetric + + :param window: The rolling window that a limit applies to. For per-minute limits, use the ``*_per_minute`` fields instead. + :type window: AiGatewayRateLimitWindowLimitWindow + """ + super().__init__(kwargs) + + self_.amount = amount + self_.metric = metric + self_.window = window diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_metric.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_metric.py new file mode 100644 index 0000000000..9ccf02b583 --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_metric.py @@ -0,0 +1,44 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class AiGatewayRateLimitWindowLimitMetric(ModelSimple): + """ + The metric that a window limit counts. `cost` counts priced spend in microcents. + + :param value: Must be one of ["requests", "input_tokens", "output_tokens", "cost"]. + :type value: str + """ + + allowed_values = { + "requests", + "input_tokens", + "output_tokens", + "cost", + } + REQUESTS: ClassVar["AiGatewayRateLimitWindowLimitMetric"] + INPUT_TOKENS: ClassVar["AiGatewayRateLimitWindowLimitMetric"] + OUTPUT_TOKENS: ClassVar["AiGatewayRateLimitWindowLimitMetric"] + COST: ClassVar["AiGatewayRateLimitWindowLimitMetric"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AiGatewayRateLimitWindowLimitMetric.REQUESTS = AiGatewayRateLimitWindowLimitMetric("requests") +AiGatewayRateLimitWindowLimitMetric.INPUT_TOKENS = AiGatewayRateLimitWindowLimitMetric("input_tokens") +AiGatewayRateLimitWindowLimitMetric.OUTPUT_TOKENS = AiGatewayRateLimitWindowLimitMetric("output_tokens") +AiGatewayRateLimitWindowLimitMetric.COST = AiGatewayRateLimitWindowLimitMetric("cost") diff --git a/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_window.py b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_window.py new file mode 100644 index 0000000000..695fc20abe --- /dev/null +++ b/src/datadog_api_client/v2/model/ai_gateway_rate_limit_window_limit_window.py @@ -0,0 +1,56 @@ +# 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 datadog_api_client.model_utils import ( + ModelSimple, + cached_property, +) + +from typing import ClassVar + + +class AiGatewayRateLimitWindowLimitWindow(ModelSimple): + """ + The rolling window that a limit applies to. For per-minute limits, use the `*_per_minute` fields instead. + + :param value: Must be one of ["5m", "15m", "30m", "1h", "3h", "6h", "12h", "24h"]. + :type value: str + """ + + allowed_values = { + "5m", + "15m", + "30m", + "1h", + "3h", + "6h", + "12h", + "24h", + } + FIVE_MINUTES: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + FIFTEEN_MINUTES: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + THIRTY_MINUTES: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + ONE_HOUR: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + THREE_HOURS: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + SIX_HOURS: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + TWELVE_HOURS: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + TWENTY_FOUR_HOURS: ClassVar["AiGatewayRateLimitWindowLimitWindow"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +AiGatewayRateLimitWindowLimitWindow.FIVE_MINUTES = AiGatewayRateLimitWindowLimitWindow("5m") +AiGatewayRateLimitWindowLimitWindow.FIFTEEN_MINUTES = AiGatewayRateLimitWindowLimitWindow("15m") +AiGatewayRateLimitWindowLimitWindow.THIRTY_MINUTES = AiGatewayRateLimitWindowLimitWindow("30m") +AiGatewayRateLimitWindowLimitWindow.ONE_HOUR = AiGatewayRateLimitWindowLimitWindow("1h") +AiGatewayRateLimitWindowLimitWindow.THREE_HOURS = AiGatewayRateLimitWindowLimitWindow("3h") +AiGatewayRateLimitWindowLimitWindow.SIX_HOURS = AiGatewayRateLimitWindowLimitWindow("6h") +AiGatewayRateLimitWindowLimitWindow.TWELVE_HOURS = AiGatewayRateLimitWindowLimitWindow("12h") +AiGatewayRateLimitWindowLimitWindow.TWENTY_FOUR_HOURS = AiGatewayRateLimitWindowLimitWindow("24h") diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index f64e232c78..24dc39251c 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -652,6 +652,9 @@ from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_list_response import AiGatewayRateLimitUsageListResponse from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_resource import AiGatewayRateLimitUsageResource from datadog_api_client.v2.model.ai_gateway_rate_limit_usage_type import AiGatewayRateLimitUsageType +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit import AiGatewayRateLimitWindowLimit +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_metric import AiGatewayRateLimitWindowLimitMetric +from datadog_api_client.v2.model.ai_gateway_rate_limit_window_limit_window import AiGatewayRateLimitWindowLimitWindow from datadog_api_client.v2.model.ai_gateway_restricted_details_meta import AiGatewayRestrictedDetailsMeta from datadog_api_client.v2.model.ai_gateway_routing_classifier import AiGatewayRoutingClassifier from datadog_api_client.v2.model.ai_gateway_routing_classifier_request import AiGatewayRoutingClassifierRequest @@ -14520,6 +14523,9 @@ "AiGatewayRateLimitUsageListResponse", "AiGatewayRateLimitUsageResource", "AiGatewayRateLimitUsageType", + "AiGatewayRateLimitWindowLimit", + "AiGatewayRateLimitWindowLimitMetric", + "AiGatewayRateLimitWindowLimitWindow", "AiGatewayRestrictedDetailsMeta", "AiGatewayRoutingClassifier", "AiGatewayRoutingClassifierRequest", diff --git a/tests/generated-test/test-runner-data/manifest.json b/tests/generated-test/test-runner-data/manifest.json index b91b970e14..794126606b 100644 --- a/tests/generated-test/test-runner-data/manifest.json +++ b/tests/generated-test/test-runner-data/manifest.json @@ -1435,6 +1435,13 @@ "scenario": "Create a Cost Monitor returns \"OK\" response", "version": "v1" }, + { + "feature": "Monitors", + "feature_file": "../../v1/features/monitors.feature", + "file": "v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json", + "scenario": "Create a Data Jobs duration monitor returns \"OK\" response", + "version": "v1" + }, { "feature": "Monitors", "feature_file": "../../v1/features/monitors.feature", @@ -1442,6 +1449,13 @@ "scenario": "Create a Data Jobs monitor returns \"OK\" response", "version": "v1" }, + { + "feature": "Monitors", + "feature_file": "../../v1/features/monitors.feature", + "file": "v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json", + "scenario": "Create a Data Jobs monitor with the aastra query dialect returns \"OK\" response", + "version": "v1" + }, { "feature": "Monitors", "feature_file": "../../v1/features/monitors.feature", diff --git a/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json b/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json new file mode 100644 index 0000000000..97b89686c1 --- /dev/null +++ b/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-duration-monitor-returns-ok-response.json @@ -0,0 +1,56 @@ +{ + "api": "Monitors", + "expected_status": 200, + "feature": "Monitors", + "id": "v1/Monitors/Create a Data Jobs duration monitor returns \"OK\" response", + "operation_id": "CreateMonitor", + "request": { + "body": { + "schema": { + "format": null, + "ref": "Monitor", + "type": "object" + }, + "source": "inline", + "value": { + "message": "Data jobs duration alert triggered", + "name": "{{ unique }}", + "options": { + "variables": [ + { + "data_source": "data_quality_metrics", + "filter": "search for databricks_job", + "group_by": [ + "name", + "workspace_name", + "entity_id" + ], + "measure": "duration", + "monitor_options": { + "consecutive_runs": 2, + "detection_type": "anomaly" + }, + "name": "run_query", + "run_filter": "env:prod", + "schema_version": "0.0.1" + } + ] + }, + "query": "formula(\"job_duration(run_query)\").detection(anomaly).by(name,workspace_name,entity_id) > 0", + "tags": [ + "test:{{ unique_lower_alnum }}", + "env:ci" + ], + "type": "data-jobs alert" + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v1/monitor" + }, + "scenario": "Create a Data Jobs duration monitor returns \"OK\" response", + "schema_version": 1, + "version": "v1" +} diff --git a/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json b/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json new file mode 100644 index 0000000000..9f662996b9 --- /dev/null +++ b/tests/generated-test/test-runner-data/v1/monitors/create-a-data-jobs-monitor-with-the-aastra-query-dialect-returns-ok-response.json @@ -0,0 +1,52 @@ +{ + "api": "Monitors", + "expected_status": 200, + "feature": "Monitors", + "id": "v1/Monitors/Create a Data Jobs monitor with the aastra query dialect returns \"OK\" response", + "operation_id": "CreateMonitor", + "request": { + "body": { + "schema": { + "format": null, + "ref": "Monitor", + "type": "object" + }, + "source": "inline", + "value": { + "message": "Data jobs alert triggered", + "name": "{{ unique }}", + "options": { + "thresholds": { + "critical": 0 + }, + "variables": [ + { + "job_type": "databricks.job", + "jobs_query": "search for databricks_job", + "monitor_options": { + "alert_on_every_failure": true + }, + "name": "run_query", + "query_dialect": "aastra", + "run_filter": "env:prod" + } + ] + }, + "query": "formula(\"failed_runs(run_query)\").by(name,workspace_name,entity_id).last(1d) > 0", + "tags": [ + "test:{{ unique_lower_alnum }}", + "env:ci" + ], + "type": "data-jobs alert" + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v1/monitor" + }, + "scenario": "Create a Data Jobs monitor with the aastra query dialect returns \"OK\" response", + "schema_version": 1, + "version": "v1" +} diff --git a/tests/generated-test/test-server-data/v1/monitors.json b/tests/generated-test/test-server-data/v1/monitors.json index 1242fc1f2c..b1fd4a2ab7 100644 --- a/tests/generated-test/test-server-data/v1/monitors.json +++ b/tests/generated-test/test-server-data/v1/monitors.json @@ -192,6 +192,90 @@ "scenario": "Create a Cost Monitor returns \"OK\" response", "version": "v1" }, + { + "feature": "Monitors", + "frozen_at": "2026-11-06T16:42:00.361Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "message": "Data jobs duration alert triggered", + "name": "Test-Create_a_Data_Jobs_duration_monitor_returns_OK_response-1793983320", + "options": { + "variables": [ + { + "data_source": "data_quality_metrics", + "filter": "search for databricks_job", + "group_by": [ + "name", + "workspace_name", + "entity_id" + ], + "measure": "duration", + "monitor_options": { + "consecutive_runs": 2, + "detection_type": "anomaly" + }, + "name": "run_query", + "run_filter": "env:prod", + "schema_version": "0.0.1" + } + ] + }, + "query": "formula(\"job_duration(run_query)\").detection(anomaly).by(name,workspace_name,entity_id) > 0", + "tags": [ + "test:testcreateadatajobsdurationmonitorreturnsokresponse1793983320", + "env:ci" + ], + "type": "data-jobs alert" + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v1/monitor", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"id\":341751249,\"org_id\":321813,\"type\":\"data-jobs alert\",\"name\":\"Test-Create_a_Data_Jobs_duration_monitor_returns_OK_response-1793983320\",\"message\":\"Data jobs duration alert triggered\",\"tags\":[\"test:testcreateadatajobsdurationmonitorreturnsokresponse1793983320\",\"env:ci\"],\"query\":\"formula(\\\"job_duration(run_query)\\\").detection(anomaly).by(name,workspace_name,entity_id) > 0\",\"options\":{\"variables\":[{\"data_source\":\"data_quality_metrics\",\"filter\":\"search for databricks_job\",\"group_by\":[\"name\",\"workspace_name\",\"entity_id\"],\"measure\":\"duration\",\"monitor_options\":{\"consecutive_runs\":2,\"detection_type\":\"anomaly\"},\"name\":\"run_query\",\"run_filter\":\"env:prod\",\"schema_version\":\"0.0.1\"}],\"notify_no_data\":false,\"notify_audit\":false,\"new_host_delay\":300,\"include_tags\":true,\"silenced\":{}},\"multi\":true,\"created_at\":1793983320000,\"created\":\"2026-11-06T16:42:00.590725+00:00\",\"modified\":\"2026-11-06T16:42:00.590725+00:00\",\"deleted\":null,\"priority\":null,\"restricted_roles\":null,\"restriction_policy\":null,\"draft_status\":\"published\",\"assets\":[],\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"C\\u00e9dric Van Rompay\",\"handle\":\"cedric.vanrompay@datadoghq.com\",\"email\":\"cedric.vanrompay@datadoghq.com\",\"id\":68397867}}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v1/monitor/341751249", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"deleted_monitor_id\":341751249}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Create a Data Jobs duration monitor returns \"OK\" response", + "version": "v1" + }, { "feature": "Monitors", "frozen_at": "2026-05-14T10:58:54.153Z", @@ -268,6 +352,86 @@ "scenario": "Create a Data Jobs monitor returns \"OK\" response", "version": "v1" }, + { + "feature": "Monitors", + "frozen_at": "2026-11-06T16:42:01.032Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "message": "Data jobs alert triggered", + "name": "Test-Create_a_Data_Jobs_monitor_with_the_aastra_query_dialect_returns_OK_response-1793983321", + "options": { + "thresholds": { + "critical": 0 + }, + "variables": [ + { + "job_type": "databricks.job", + "jobs_query": "search for databricks_job", + "monitor_options": { + "alert_on_every_failure": true + }, + "name": "run_query", + "query_dialect": "aastra", + "run_filter": "env:prod" + } + ] + }, + "query": "formula(\"failed_runs(run_query)\").by(name,workspace_name,entity_id).last(1d) > 0", + "tags": [ + "test:testcreateadatajobsmonitorwiththeaastraquerydialectreturnsokresponse1793983321", + "env:ci" + ], + "type": "data-jobs alert" + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v1/monitor", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"id\":341751253,\"org_id\":321813,\"type\":\"data-jobs alert\",\"name\":\"Test-Create_a_Data_Jobs_monitor_with_the_aastra_query_dialect_returns_OK_response-1793983321\",\"message\":\"Data jobs alert triggered\",\"tags\":[\"test:testcreateadatajobsmonitorwiththeaastraquerydialectreturnsokresponse1793983321\",\"env:ci\"],\"query\":\"formula(\\\"failed_runs(run_query)\\\").by(name,workspace_name,entity_id).last(1d) > 0\",\"options\":{\"thresholds\":{\"critical\":0.0},\"variables\":[{\"job_type\":\"databricks.job\",\"jobs_query\":\"search for databricks_job\",\"monitor_options\":{\"alert_on_every_failure\":true},\"name\":\"run_query\",\"query_dialect\":\"aastra\",\"run_filter\":\"env:prod\"}],\"notify_no_data\":false,\"notify_audit\":false,\"new_host_delay\":300,\"include_tags\":true,\"silenced\":{}},\"multi\":true,\"created_at\":1793983321000,\"created\":\"2026-11-06T16:42:01.177378+00:00\",\"modified\":\"2026-11-06T16:42:01.177378+00:00\",\"deleted\":null,\"priority\":null,\"restricted_roles\":null,\"restriction_policy\":null,\"draft_status\":\"published\",\"assets\":[],\"overall_state_modified\":null,\"overall_state\":\"No Data\",\"creator\":{\"name\":\"C\\u00e9dric Van Rompay\",\"handle\":\"cedric.vanrompay@datadoghq.com\",\"email\":\"cedric.vanrompay@datadoghq.com\",\"id\":68397867}}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v1/monitor/341751253", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"deleted_monitor_id\":341751253}\n" + }, + "headers": { + "content-type": "application/json" + }, + "reason": "OK", + "status": 200 + } + } + ], + "scenario": "Create a Data Jobs monitor with the aastra query dialect returns \"OK\" response", + "version": "v1" + }, { "feature": "Monitors", "frozen_at": "2026-01-12T17:23:49.629Z", diff --git a/tests/v1/features/monitors.feature b/tests/v1/features/monitors.feature index 5584472ab2..ef8d3d387b 100644 --- a/tests/v1/features/monitors.feature +++ b/tests/v1/features/monitors.feature @@ -42,6 +42,18 @@ Feature: Monitors When the request is sent Then the response status is 200 OK + @team:ddoghq/monitor-app + Scenario: Create a Data Jobs duration monitor returns "OK" response + Given new "CreateMonitor" request + And body with value {"name": "{{ unique }}", "type": "data-jobs alert", "query": "formula(\"job_duration(run_query)\").detection(anomaly).by(name,workspace_name,entity_id) > 0", "message": "Data jobs duration alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "options": {"variables": [{"name": "run_query", "data_source": "data_quality_metrics", "schema_version": "0.0.1", "measure": "duration", "filter": "search for databricks_job", "run_filter": "env:prod", "group_by": ["name", "workspace_name", "entity_id"], "monitor_options": {"detection_type": "anomaly", "consecutive_runs": 2}}]}} + When the request is sent + Then the response status is 200 OK + And the response "name" is equal to "{{ unique }}" + And the response "type" is equal to "data-jobs alert" + And the response "options.variables[0].run_filter" is equal to "env:prod" + And the response "options.variables[0].monitor_options.detection_type" is equal to "anomaly" + And the response "options.variables[0].monitor_options.consecutive_runs" is equal to 2 + @team:ddoghq/monitor-app Scenario: Create a Data Jobs monitor returns "OK" response Given new "CreateMonitor" request @@ -51,6 +63,18 @@ Feature: Monitors And the response "name" is equal to "{{ unique }}" And the response "type" is equal to "data-jobs alert" + @team:ddoghq/monitor-app + Scenario: Create a Data Jobs monitor with the aastra query dialect returns "OK" response + Given new "CreateMonitor" request + And body with value {"name": "{{ unique }}", "type": "data-jobs alert", "query": "formula(\"failed_runs(run_query)\").by(name,workspace_name,entity_id).last(1d) > 0", "message": "Data jobs alert triggered", "tags": ["test:{{ unique_lower_alnum }}", "env:ci"], "options": {"thresholds": {"critical": 0}, "variables": [{"name": "run_query", "jobs_query": "search for databricks_job", "job_type": "databricks.job", "query_dialect": "aastra", "run_filter": "env:prod", "monitor_options": {"alert_on_every_failure": true}}]}} + When the request is sent + Then the response status is 200 OK + And the response "name" is equal to "{{ unique }}" + And the response "type" is equal to "data-jobs alert" + And the response "options.variables[0].query_dialect" is equal to "aastra" + And the response "options.variables[0].run_filter" is equal to "env:prod" + And the response "options.variables[0].monitor_options.alert_on_every_failure" is equal to true + @team:ddoghq/monitor-app Scenario: Create a Data Quality monitor returns "OK" response Given new "CreateMonitor" request diff --git a/tests/v2/features/ai_gateway.feature b/tests/v2/features/ai_gateway.feature index b9312a5721..c829d11282 100644 --- a/tests/v2/features/ai_gateway.feature +++ b/tests/v2/features/ai_gateway.feature @@ -184,7 +184,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Bad Request" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001", "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "type": "rate-limits"}} When the request is sent Then the response status is 400 Bad Request @@ -192,7 +192,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Conflict" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001", "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "type": "rate-limits"}} When the request is sent Then the response status is 409 Conflict @@ -200,7 +200,7 @@ Feature: AI Gateway Scenario: Create an AI Gateway rate limit returns "Created" response Given operation "CreateAiGatewayRateLimit" enabled And new "CreateAiGatewayRateLimit" request - And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001"}, "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": 100000000, "input_tokens_per_minute": null, "mode": "ALERT", "name": "Default rate limit", "output_tokens_per_minute": null, "requests_per_minute": 600, "selector": [{"dim": "user_id", "per_value": true, "values": ["11111111-1111-1111-1111-111111111111"]}], "team_id": "00000000-0000-4000-8000-000000000002", "user_id": "00000000-0000-4000-8000-000000000001", "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "type": "rate-limits"}} When the request is sent Then the response status is 201 Created @@ -1068,7 +1068,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null, "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 400 Bad Request @@ -1077,7 +1077,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null, "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 409 Conflict @@ -1086,7 +1086,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null, "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 404 Not Found @@ -1095,7 +1095,7 @@ Feature: AI Gateway Given operation "UpdateAiGatewayRateLimit" enabled And new "UpdateAiGatewayRateLimit" request And request contains "id" parameter from "REPLACE.ME" - And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} + And body with value {"data": {"attributes": {"cost_microcents_per_minute": null, "input_tokens_per_minute": null, "mode": "ALERT", "output_tokens_per_minute": null, "requests_per_minute": null, "tags": null, "team_id": null, "user_id": null, "window_limits": [{"amount": 2000000000, "metric": "cost", "window": "24h"}]}, "id": "11111111-1111-1111-1111-111111111111", "type": "rate-limits"}} When the request is sent Then the response status is 200 OK