Skip to content

Commit 420a0ee

Browse files
feat(api): api update
1 parent e022f45 commit 420a0ee

5 files changed

Lines changed: 149 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 139
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb/orb-b13a08bfebe7b2efc4a5f8aa0b69015e2d58435a581b1578e3e67d76fdfb8cb0.yml
3-
openapi_spec_hash: bba0e6257d3d2f8612c5ad14b95839e2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb/orb-7f97a69f22372b818e8d24a72f6020bcf2f0c6d6b3ad07abb8395c87ec4a72ee.yml
3+
openapi_spec_hash: a6261e730c54d08ad36f1b946e663fc3
44
config_hash: c01c1191b1cd696c7ca855ff6d28a8df

src/orb/resources/alerts.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ def create_for_subscription(
357357
type: Literal["usage_exceeded", "cost_exceeded"],
358358
grouping_keys: Optional[SequenceNotStr[str]] | Omit = omit,
359359
metric_id: Optional[str] | Omit = omit,
360+
price_filters: Optional[Iterable[alert_create_for_subscription_params.PriceFilter]] | Omit = omit,
360361
pricing_unit_id: Optional[str] | Omit = omit,
362+
threshold_overrides: Optional[Iterable[alert_create_for_subscription_params.ThresholdOverride]] | Omit = omit,
361363
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
362364
# The extra values given here take precedence over values defined on the client or passed to this method.
363365
extra_headers: Headers | None = None,
@@ -389,9 +391,19 @@ def create_for_subscription(
389391
390392
metric_id: The metric to track usage for.
391393
394+
price_filters: Filters to scope which prices are included in grouped cost alert evaluation.
395+
Supports filtering by price_id, item_id, or price_type with includes/excludes
396+
operators. Only applicable when grouping_keys is set.
397+
392398
pricing_unit_id: The pricing unit to use for grouped cost alerts. Required when grouping_keys is
393399
set.
394400
401+
threshold_overrides: Per-group threshold overrides. Each override maps a specific combination of
402+
grouping_keys values to a list of thresholds that fully replaces the default
403+
thresholds for that group. An empty thresholds list silences the group. Groups
404+
without an override use the default thresholds. Only applicable when
405+
grouping_keys is set.
406+
395407
extra_headers: Send extra headers
396408
397409
extra_query: Add additional query parameters to the request
@@ -412,7 +424,9 @@ def create_for_subscription(
412424
"type": type,
413425
"grouping_keys": grouping_keys,
414426
"metric_id": metric_id,
427+
"price_filters": price_filters,
415428
"pricing_unit_id": pricing_unit_id,
429+
"threshold_overrides": threshold_overrides,
416430
},
417431
alert_create_for_subscription_params.AlertCreateForSubscriptionParams,
418432
),
@@ -851,7 +865,9 @@ async def create_for_subscription(
851865
type: Literal["usage_exceeded", "cost_exceeded"],
852866
grouping_keys: Optional[SequenceNotStr[str]] | Omit = omit,
853867
metric_id: Optional[str] | Omit = omit,
868+
price_filters: Optional[Iterable[alert_create_for_subscription_params.PriceFilter]] | Omit = omit,
854869
pricing_unit_id: Optional[str] | Omit = omit,
870+
threshold_overrides: Optional[Iterable[alert_create_for_subscription_params.ThresholdOverride]] | Omit = omit,
855871
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
856872
# The extra values given here take precedence over values defined on the client or passed to this method.
857873
extra_headers: Headers | None = None,
@@ -883,9 +899,19 @@ async def create_for_subscription(
883899
884900
metric_id: The metric to track usage for.
885901
902+
price_filters: Filters to scope which prices are included in grouped cost alert evaluation.
903+
Supports filtering by price_id, item_id, or price_type with includes/excludes
904+
operators. Only applicable when grouping_keys is set.
905+
886906
pricing_unit_id: The pricing unit to use for grouped cost alerts. Required when grouping_keys is
887907
set.
888908
909+
threshold_overrides: Per-group threshold overrides. Each override maps a specific combination of
910+
grouping_keys values to a list of thresholds that fully replaces the default
911+
thresholds for that group. An empty thresholds list silences the group. Groups
912+
without an override use the default thresholds. Only applicable when
913+
grouping_keys is set.
914+
889915
extra_headers: Send extra headers
890916
891917
extra_query: Add additional query parameters to the request
@@ -906,7 +932,9 @@ async def create_for_subscription(
906932
"type": type,
907933
"grouping_keys": grouping_keys,
908934
"metric_id": metric_id,
935+
"price_filters": price_filters,
909936
"pricing_unit_id": pricing_unit_id,
937+
"threshold_overrides": threshold_overrides,
910938
},
911939
alert_create_for_subscription_params.AlertCreateForSubscriptionParams,
912940
),

src/orb/types/alert.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .shared.customer_minified import CustomerMinified
1010
from .shared.subscription_minified import SubscriptionMinified
1111

12-
__all__ = ["Alert", "Metric", "Plan", "BalanceAlertStatus", "LicenseType"]
12+
__all__ = ["Alert", "Metric", "Plan", "BalanceAlertStatus", "LicenseType", "PriceFilter", "ThresholdOverride"]
1313

1414

1515
class Metric(BaseModel):
@@ -51,6 +51,37 @@ class LicenseType(BaseModel):
5151
id: str
5252

5353

54+
class PriceFilter(BaseModel):
55+
field: Literal["price_id", "item_id", "price_type", "currency", "pricing_unit_id"]
56+
"""The property of the price to filter on."""
57+
58+
operator: Literal["includes", "excludes"]
59+
"""Should prices that match the filter be included or excluded."""
60+
61+
values: List[str]
62+
"""The IDs or values that match this filter."""
63+
64+
65+
class ThresholdOverride(BaseModel):
66+
"""A per-group threshold override on a grouped cost alert.
67+
68+
An empty `thresholds` list means the group is silenced (never fires).
69+
A non-empty list fully replaces the default thresholds for that group.
70+
"""
71+
72+
group_values: List[str]
73+
"""The values of the grouping keys that identify this group.
74+
75+
The list length matches the alert's grouping_keys.
76+
"""
77+
78+
thresholds: List[Threshold]
79+
"""The thresholds applied to this group.
80+
81+
An empty list means the group is silenced.
82+
"""
83+
84+
5485
class Alert(BaseModel):
5586
"""
5687
[Alerts within Orb](/product-catalog/configuring-alerts) monitor spending,
@@ -113,3 +144,14 @@ class Alert(BaseModel):
113144

114145
license_type: Optional[LicenseType] = None
115146
"""Minified license type for alert serialization."""
147+
148+
price_filters: Optional[List[PriceFilter]] = None
149+
"""Filters scoping which prices are included in grouped cost alert evaluation."""
150+
151+
threshold_overrides: Optional[List[ThresholdOverride]] = None
152+
"""Per-group threshold overrides.
153+
154+
Each override maps a specific combination of grouping_keys values to a
155+
replacement threshold list. Only present for grouped cost alerts that have at
156+
least one override.
157+
"""

src/orb/types/alert_create_for_subscription_params.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .._types import SequenceNotStr
99
from .threshold_param import ThresholdParam
1010

11-
__all__ = ["AlertCreateForSubscriptionParams"]
11+
__all__ = ["AlertCreateForSubscriptionParams", "PriceFilter", "ThresholdOverride"]
1212

1313

1414
class AlertCreateForSubscriptionParams(TypedDict, total=False):
@@ -27,8 +27,57 @@ class AlertCreateForSubscriptionParams(TypedDict, total=False):
2727
metric_id: Optional[str]
2828
"""The metric to track usage for."""
2929

30+
price_filters: Optional[Iterable[PriceFilter]]
31+
"""Filters to scope which prices are included in grouped cost alert evaluation.
32+
33+
Supports filtering by price_id, item_id, or price_type with includes/excludes
34+
operators. Only applicable when grouping_keys is set.
35+
"""
36+
3037
pricing_unit_id: Optional[str]
3138
"""The pricing unit to use for grouped cost alerts.
3239
3340
Required when grouping_keys is set.
3441
"""
42+
43+
threshold_overrides: Optional[Iterable[ThresholdOverride]]
44+
"""Per-group threshold overrides.
45+
46+
Each override maps a specific combination of grouping_keys values to a list of
47+
thresholds that fully replaces the default thresholds for that group. An empty
48+
thresholds list silences the group. Groups without an override use the default
49+
thresholds. Only applicable when grouping_keys is set.
50+
"""
51+
52+
53+
class PriceFilter(TypedDict, total=False):
54+
field: Required[Literal["price_id", "item_id", "price_type", "currency", "pricing_unit_id"]]
55+
"""The property of the price to filter on."""
56+
57+
operator: Required[Literal["includes", "excludes"]]
58+
"""Should prices that match the filter be included or excluded."""
59+
60+
values: Required[SequenceNotStr[str]]
61+
"""The IDs or values that match this filter."""
62+
63+
64+
class ThresholdOverride(TypedDict, total=False):
65+
"""Per-group threshold override on a grouped cost alert.
66+
67+
- An empty `thresholds` list silences alerts for this group (never fires).
68+
- A non-empty list fully replaces the default thresholds for this group.
69+
"""
70+
71+
group_values: Required[SequenceNotStr[str]]
72+
"""The values of the grouping keys that identify this group.
73+
74+
The list length must match the alert's grouping_keys, and values appear in the
75+
same order as grouping_keys.
76+
"""
77+
78+
thresholds: Required[Iterable[ThresholdParam]]
79+
"""The thresholds to apply to this group.
80+
81+
An empty list silences alerts for this group. A non-empty list fully replaces
82+
the default thresholds for this group.
83+
"""

tests/api_resources/test_alerts.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,20 @@ def test_method_create_for_subscription_with_all_params(self, client: Orb) -> No
276276
type="usage_exceeded",
277277
grouping_keys=["string"],
278278
metric_id="metric_id",
279+
price_filters=[
280+
{
281+
"field": "price_id",
282+
"operator": "includes",
283+
"values": ["string"],
284+
}
285+
],
279286
pricing_unit_id="pricing_unit_id",
287+
threshold_overrides=[
288+
{
289+
"group_values": ["string"],
290+
"thresholds": [{"value": 0}],
291+
}
292+
],
280293
)
281294
assert_matches_type(Alert, alert, path=["response"])
282295

@@ -674,7 +687,20 @@ async def test_method_create_for_subscription_with_all_params(self, async_client
674687
type="usage_exceeded",
675688
grouping_keys=["string"],
676689
metric_id="metric_id",
690+
price_filters=[
691+
{
692+
"field": "price_id",
693+
"operator": "includes",
694+
"values": ["string"],
695+
}
696+
],
677697
pricing_unit_id="pricing_unit_id",
698+
threshold_overrides=[
699+
{
700+
"group_values": ["string"],
701+
"thresholds": [{"value": 0}],
702+
}
703+
],
678704
)
679705
assert_matches_type(Alert, alert, path=["response"])
680706

0 commit comments

Comments
 (0)