diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 809d974e933b..379ff80d28bc 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: @@ -231610,7 +231680,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": @@ -231867,7 +231937,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" @@ -231928,7 +231998,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/v2/ai-gateway/CreateAiGatewayRateLimit.rb b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb index 7106a05b864f..ce486ced9314 100644 --- a/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb +++ b/examples/v2/ai-gateway/CreateAiGatewayRateLimit.rb @@ -27,6 +27,13 @@ ], team_id: "00000000-0000-4000-8000-000000000002", user_id: "00000000-0000-4000-8000-000000000001", + window_limits: [ + DatadogAPIClient::V2::AiGatewayRateLimitWindowLimit.new({ + amount: 2000000000, + metric: DatadogAPIClient::V2::AiGatewayRateLimitWindowLimitMetric::COST, + window: DatadogAPIClient::V2::AiGatewayRateLimitWindowLimitWindow::TWENTY_FOUR_HOURS, + }), + ], }), type: DatadogAPIClient::V2::AiGatewayRateLimitType::RATE_LIMITS, }), diff --git a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb index f83a2714c6b0..a6502ffd2d29 100644 --- a/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb +++ b/examples/v2/ai-gateway/UpdateAiGatewayRateLimit.rb @@ -18,6 +18,13 @@ tags: nil, team_id: nil, user_id: nil, + window_limits: [ + DatadogAPIClient::V2::AiGatewayRateLimitWindowLimit.new({ + amount: 2000000000, + metric: DatadogAPIClient::V2::AiGatewayRateLimitWindowLimitMetric::COST, + window: DatadogAPIClient::V2::AiGatewayRateLimitWindowLimitWindow::TWENTY_FOUR_HOURS, + }), + ], }), id: "11111111-1111-1111-1111-111111111111", type: DatadogAPIClient::V2::AiGatewayRateLimitType::RATE_LIMITS, diff --git a/features/v2/ai_gateway.feature b/features/v2/ai_gateway.feature index b9312a57212e..c829d1128209 100644 --- a/features/v2/ai_gateway.feature +++ b/features/v2/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 diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index fe09c8ecd669..b2b2f3936a5d 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1588,6 +1588,9 @@ def overrides "v2.ai_gateway_rate_limit_usage_list_response" => "AiGatewayRateLimitUsageListResponse", "v2.ai_gateway_rate_limit_usage_resource" => "AiGatewayRateLimitUsageResource", "v2.ai_gateway_rate_limit_usage_type" => "AiGatewayRateLimitUsageType", + "v2.ai_gateway_rate_limit_window_limit" => "AiGatewayRateLimitWindowLimit", + "v2.ai_gateway_rate_limit_window_limit_metric" => "AiGatewayRateLimitWindowLimitMetric", + "v2.ai_gateway_rate_limit_window_limit_window" => "AiGatewayRateLimitWindowLimitWindow", "v2.ai_gateway_restricted_details_meta" => "AiGatewayRestrictedDetailsMeta", "v2.ai_gateway_routing_classifier" => "AiGatewayRoutingClassifier", "v2.ai_gateway_routing_classifier_request" => "AiGatewayRoutingClassifierRequest", diff --git a/lib/datadog_api_client/v2/api/ai_gateway_api.rb b/lib/datadog_api_client/v2/api/ai_gateway_api.rb index ce069da7d1d8..c077d0ca7197 100644 --- a/lib/datadog_api_client/v2/api/ai_gateway_api.rb +++ b/lib/datadog_api_client/v2/api/ai_gateway_api.rb @@ -2053,7 +2053,7 @@ def get_ai_gateway_rate_limit_instances_summary(id, opts = {}) # 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 [UUID] Rate limit UUID. # @param opts [Hash] the optional parameters @@ -2948,7 +2948,7 @@ def list_ai_gateway_rate_limit_instances(id, opts = {}) # 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 [UUID] Rate limit UUID. # @param opts [Hash] the optional parameters @@ -3041,7 +3041,7 @@ def list_ai_gateway_rate_limit_instances_summaries(opts = {}) # 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. # # @param opts [Hash] the optional parameters # @return [Array<(AiGatewayRateLimitInstancesSummaryListResponse, Integer, Hash)>] AiGatewayRateLimitInstancesSummaryListResponse data, response status code and response headers diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb index adc3fa0c0b22..2cb80831902c 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_attributes.rb @@ -81,6 +81,9 @@ class AiGatewayRateLimitAttributes # Optional user UUID. Count only this user's requests. attr_accessor :user_id + # 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. + attr_reader :window_limits + attr_accessor :additional_properties # Attribute mapping from ruby-style variable name to JSON key. @@ -106,7 +109,8 @@ def self.attribute_map :'template_split_dims' => :'template_split_dims', :'updated_at' => :'updated_at', :'updated_by' => :'updated_by', - :'user_id' => :'user_id' + :'user_id' => :'user_id', + :'window_limits' => :'window_limits' } end @@ -133,7 +137,8 @@ def self.openapi_types :'template_split_dims' => :'Array', :'updated_at' => :'Time', :'updated_by' => :'String', - :'user_id' => :'UUID' + :'user_id' => :'UUID', + :'window_limits' => :'Array' } end @@ -253,13 +258,18 @@ def initialize(attributes = {}) if attributes.key?(:'user_id') self.user_id = attributes[:'user_id'] end + + if attributes.key?(:'window_limits') + if (value = attributes[:'window_limits']).is_a?(Array) + self.window_limits = value + end + end end # Check to see if the all the properties in the model are valid # @return true if the model is valid # @!visibility private def valid? - return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 1 return false if @created_at.nil? return false if @created_by.nil? @@ -279,6 +289,7 @@ def valid? return false if @template_split_dims.nil? return false if @updated_at.nil? return false if @updated_by.nil? + return false if !@window_limits.nil? && @window_limits.length > 4 true end @@ -286,9 +297,6 @@ def valid? # @param cost_microcents_per_minute [Object] Object to be assigned # @!visibility private def cost_microcents_per_minute=(cost_microcents_per_minute) - if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 - fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' - end if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 1 fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 1.' end @@ -454,6 +462,16 @@ def updated_by=(updated_by) @updated_by = updated_by end + # Custom attribute writer method with validation + # @param window_limits [Object] Object to be assigned + # @!visibility private + def window_limits=(window_limits) + if !window_limits.nil? && window_limits.length > 4 + fail ArgumentError, 'invalid value for "window_limits", number of items must be less than or equal to 4.' + end + @window_limits = window_limits + end + # Returns the object in the form of hash, with additionalProperties support. # @return [Hash] Returns the object in the form of hash # @!visibility private @@ -500,6 +518,7 @@ def ==(o) updated_at == o.updated_at && updated_by == o.updated_by && user_id == o.user_id && + window_limits == o.window_limits && additional_properties == o.additional_properties end @@ -507,7 +526,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [cost_microcents_per_minute, created_at, created_by, enabled, input_tokens_per_minute, is_template, mode, monitor_id, name, output_tokens_per_minute, requests_per_minute, revision, scope_restricted, selector, tags, team_id, template_split_dims, updated_at, updated_by, user_id, additional_properties].hash + [cost_microcents_per_minute, created_at, created_by, enabled, input_tokens_per_minute, is_template, mode, monitor_id, name, output_tokens_per_minute, requests_per_minute, revision, scope_restricted, selector, tags, team_id, template_split_dims, updated_at, updated_by, user_id, window_limits, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb index 0007b1c0aa70..18910db1c7ce 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_create_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitCreateAttributes include BaseGenericModel - # 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. + # 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. attr_reader :cost_microcents_per_minute # Maximum input tokens per rolling minute. @@ -36,7 +36,7 @@ class AiGatewayRateLimitCreateAttributes # Maximum output tokens per rolling minute. attr_reader :output_tokens_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. + # 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. attr_reader :requests_per_minute # 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. @@ -51,6 +51,9 @@ class AiGatewayRateLimitCreateAttributes # Optional UUID. Count only this user's requests. attr_accessor :user_id + # 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. + attr_reader :window_limits + attr_accessor :additional_properties # Attribute mapping from ruby-style variable name to JSON key. @@ -66,7 +69,8 @@ def self.attribute_map :'selector' => :'selector', :'tags' => :'tags', :'team_id' => :'team_id', - :'user_id' => :'user_id' + :'user_id' => :'user_id', + :'window_limits' => :'window_limits' } end @@ -83,7 +87,8 @@ def self.openapi_types :'selector' => :'Array', :'tags' => :'Hash', :'team_id' => :'UUID', - :'user_id' => :'UUID' + :'user_id' => :'UUID', + :'window_limits' => :'Array' } end @@ -158,13 +163,18 @@ def initialize(attributes = {}) if attributes.key?(:'user_id') self.user_id = attributes[:'user_id'] end + + if attributes.key?(:'window_limits') + if (value = attributes[:'window_limits']).is_a?(Array) + self.window_limits = value + end + end end # Check to see if the all the properties in the model are valid # @return true if the model is valid # @!visibility private def valid? - return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 1 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute > 100000000000 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute < 1 @@ -173,6 +183,7 @@ def valid? return false if !@output_tokens_per_minute.nil? && @output_tokens_per_minute < 1 return false if !@requests_per_minute.nil? && @requests_per_minute > 10000000 return false if !@requests_per_minute.nil? && @requests_per_minute < 1 + return false if !@window_limits.nil? && @window_limits.length > 4 true end @@ -180,9 +191,6 @@ def valid? # @param cost_microcents_per_minute [Object] Object to be assigned # @!visibility private def cost_microcents_per_minute=(cost_microcents_per_minute) - if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 - fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' - end if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 1 fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 1.' end @@ -238,6 +246,16 @@ def requests_per_minute=(requests_per_minute) @requests_per_minute = requests_per_minute end + # Custom attribute writer method with validation + # @param window_limits [Object] Object to be assigned + # @!visibility private + def window_limits=(window_limits) + if !window_limits.nil? && window_limits.length > 4 + fail ArgumentError, 'invalid value for "window_limits", number of items must be less than or equal to 4.' + end + @window_limits = window_limits + end + # Returns the object in the form of hash, with additionalProperties support. # @return [Hash] Returns the object in the form of hash # @!visibility private @@ -274,6 +292,7 @@ def ==(o) tags == o.tags && team_id == o.team_id && user_id == o.user_id && + window_limits == o.window_limits && additional_properties == o.additional_properties end @@ -281,7 +300,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [cost_microcents_per_minute, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, selector, tags, team_id, user_id, additional_properties].hash + [cost_microcents_per_minute, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, selector, tags, team_id, user_id, window_limits, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb index f412e2b6748e..fa07c7aa6844 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instance_attributes.rb @@ -21,10 +21,10 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitInstanceAttributes include BaseGenericModel - # Priced spend, in microcents, counted in the rolling one-minute window. 0 when the rate limit doesn't limit cost. + # Priced spend, in microcents, counted in the rolling one-minute window. The value is 0 when the rate limit doesn't limit cost. attr_accessor :cost_microcents - # The rate limit's per-counter spend limit, in microcents. Null when it doesn't limit cost. + # The rate limit's per-counter spend limit, in microcents. Null when the rate limit doesn't limit cost. attr_accessor :cost_microcents_per_minute # When the gateway first recorded a request for this counter. @@ -39,7 +39,7 @@ class AiGatewayRateLimitInstanceAttributes # Opaque canonical key identifying the counter. attr_reader :instance_key - # 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. + # 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. attr_reader :last_seen # Requests this counter rejected in the last 15 minutes (ENFORCE). diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb index 7a934b954d3f..280fd473e46e 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_instances_summary_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitInstancesSummaryAttributes include BaseGenericModel - # 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. + # 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. attr_reader :instance_count # Requests the counters rejected in the last 15 minutes (ENFORCE), totaled over the counters whose usage was read. diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb index 4d2d4f7c442a..49c8f034f855 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_update_attributes.rb @@ -21,13 +21,13 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitUpdateAttributes include BaseGenericModel - # Spend limit in microcents per rolling minute. Set to 0 to remove the cost limit. Null is ignored. At least one limit must remain. + # 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. attr_reader :cost_microcents_per_minute # Whether this rate limit is active. attr_accessor :enabled - # Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + # Set to 0 to remove the input token limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. attr_reader :input_tokens_per_minute # Action taken when request rate exceeds the limit. @@ -36,10 +36,10 @@ class AiGatewayRateLimitUpdateAttributes # Rate limit name. attr_accessor :name - # Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + # Set to 0 to remove the output token limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. attr_reader :output_tokens_per_minute - # Set to 0 to remove the request limit. Null is ignored. At least one limit must remain. + # Set to 0 to remove the request limit. Null is ignored. At least one limit, per-minute or in `window_limits`, must remain. attr_reader :requests_per_minute # Replaces all scope tags. An empty object clears them. Null is ignored. @@ -51,6 +51,9 @@ class AiGatewayRateLimitUpdateAttributes # Replaces the user scope. An empty string clears it. Null is ignored. attr_accessor :user_id + # 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. + attr_reader :window_limits + attr_accessor :additional_properties # Attribute mapping from ruby-style variable name to JSON key. @@ -66,7 +69,8 @@ def self.attribute_map :'requests_per_minute' => :'requests_per_minute', :'tags' => :'tags', :'team_id' => :'team_id', - :'user_id' => :'user_id' + :'user_id' => :'user_id', + :'window_limits' => :'window_limits' } end @@ -83,7 +87,8 @@ def self.openapi_types :'requests_per_minute' => :'Integer', :'tags' => :'Hash', :'team_id' => :'String', - :'user_id' => :'String' + :'user_id' => :'String', + :'window_limits' => :'Array' } end @@ -98,6 +103,7 @@ def self.openapi_nullable :'tags', :'team_id', :'user_id', + :'window_limits', ]) end @@ -158,13 +164,18 @@ def initialize(attributes = {}) if attributes.key?(:'user_id') self.user_id = attributes[:'user_id'] end + + if attributes.key?(:'window_limits') + if (value = attributes[:'window_limits']).is_a?(Array) + self.window_limits = value + end + end end # Check to see if the all the properties in the model are valid # @return true if the model is valid # @!visibility private def valid? - return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute > 10000000000000 return false if !@cost_microcents_per_minute.nil? && @cost_microcents_per_minute < 0 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute > 100000000000 return false if !@input_tokens_per_minute.nil? && @input_tokens_per_minute < 0 @@ -172,6 +183,7 @@ def valid? return false if !@output_tokens_per_minute.nil? && @output_tokens_per_minute < 0 return false if !@requests_per_minute.nil? && @requests_per_minute > 10000000 return false if !@requests_per_minute.nil? && @requests_per_minute < 0 + return false if !@window_limits.nil? && @window_limits.length > 4 true end @@ -179,9 +191,6 @@ def valid? # @param cost_microcents_per_minute [Object] Object to be assigned # @!visibility private def cost_microcents_per_minute=(cost_microcents_per_minute) - if !cost_microcents_per_minute.nil? && cost_microcents_per_minute > 10000000000000 - fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be smaller than or equal to 10000000000000.' - end if !cost_microcents_per_minute.nil? && cost_microcents_per_minute < 0 fail ArgumentError, 'invalid value for "cost_microcents_per_minute", must be greater than or equal to 0.' end @@ -227,6 +236,16 @@ def requests_per_minute=(requests_per_minute) @requests_per_minute = requests_per_minute end + # Custom attribute writer method with validation + # @param window_limits [Object] Object to be assigned + # @!visibility private + def window_limits=(window_limits) + if !window_limits.nil? && window_limits.length > 4 + fail ArgumentError, 'invalid value for "window_limits", number of items must be less than or equal to 4.' + end + @window_limits = window_limits + end + # Returns the object in the form of hash, with additionalProperties support. # @return [Hash] Returns the object in the form of hash # @!visibility private @@ -263,6 +282,7 @@ def ==(o) tags == o.tags && team_id == o.team_id && user_id == o.user_id && + window_limits == o.window_limits && additional_properties == o.additional_properties end @@ -270,7 +290,7 @@ def ==(o) # @return [Integer] Hash code # @!visibility private def hash - [cost_microcents_per_minute, enabled, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, tags, team_id, user_id, additional_properties].hash + [cost_microcents_per_minute, enabled, input_tokens_per_minute, mode, name, output_tokens_per_minute, requests_per_minute, tags, team_id, user_id, window_limits, additional_properties].hash end end end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb index 6648aa4d18da..31f0aa98640e 100644 --- a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_usage_attributes.rb @@ -21,7 +21,7 @@ module DatadogAPIClient::V2 class AiGatewayRateLimitUsageAttributes include BaseGenericModel - # 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. + # 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. attr_accessor :cost_microcents # Input tokens counted in the rolling one-minute window. diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit.rb new file mode 100644 index 000000000000..92d6ab3f838d --- /dev/null +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit.rb @@ -0,0 +1,169 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A limit on one metric over a rolling window longer than a minute. + class AiGatewayRateLimitWindowLimit + include BaseGenericModel + + # 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. + attr_reader :amount + + # The metric that a window limit counts. `cost` counts priced spend in microcents. + attr_reader :metric + + # The rolling window that a limit applies to. For per-minute limits, use the `*_per_minute` fields instead. + attr_reader :window + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'amount' => :'amount', + :'metric' => :'metric', + :'window' => :'window' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'amount' => :'Integer', + :'metric' => :'AiGatewayRateLimitWindowLimitMetric', + :'window' => :'AiGatewayRateLimitWindowLimitWindow' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::AiGatewayRateLimitWindowLimit` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'metric') + self.metric = attributes[:'metric'] + end + + if attributes.key?(:'window') + self.window = attributes[:'window'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @amount.nil? + return false if @amount < 1 + return false if @metric.nil? + return false if @window.nil? + true + end + + # Custom attribute writer method with validation + # @param amount [Object] Object to be assigned + # @!visibility private + def amount=(amount) + if amount.nil? + fail ArgumentError, 'invalid value for "amount", amount cannot be nil.' + end + if amount < 1 + fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 1.' + end + @amount = amount + end + + # Custom attribute writer method with validation + # @param metric [Object] Object to be assigned + # @!visibility private + def metric=(metric) + if metric.nil? + fail ArgumentError, 'invalid value for "metric", metric cannot be nil.' + end + @metric = metric + end + + # Custom attribute writer method with validation + # @param window [Object] Object to be assigned + # @!visibility private + def window=(window) + if window.nil? + fail ArgumentError, 'invalid value for "window", window cannot be nil.' + end + @window = window + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + metric == o.metric && + window == o.window && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [amount, metric, window, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_metric.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_metric.rb new file mode 100644 index 000000000000..b30d78267f36 --- /dev/null +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_metric.rb @@ -0,0 +1,29 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The metric that a window limit counts. `cost` counts priced spend in microcents. + class AiGatewayRateLimitWindowLimitMetric + include BaseEnumModel + + REQUESTS = "requests".freeze + INPUT_TOKENS = "input_tokens".freeze + OUTPUT_TOKENS = "output_tokens".freeze + COST = "cost".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_window.rb b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_window.rb new file mode 100644 index 000000000000..d5f8362842de --- /dev/null +++ b/lib/datadog_api_client/v2/models/ai_gateway_rate_limit_window_limit_window.rb @@ -0,0 +1,33 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The rolling window that a limit applies to. For per-minute limits, use the `*_per_minute` fields instead. + class AiGatewayRateLimitWindowLimitWindow + include BaseEnumModel + + FIVE_MINUTES = "5m".freeze + FIFTEEN_MINUTES = "15m".freeze + THIRTY_MINUTES = "30m".freeze + ONE_HOUR = "1h".freeze + THREE_HOURS = "3h".freeze + SIX_HOURS = "6h".freeze + TWELVE_HOURS = "12h".freeze + TWENTY_FOUR_HOURS = "24h".freeze + end +end