Skip to content

Commit 8daddaa

Browse files
authored
refactor: thresholds for balance threshold events (#3269)
1 parent 13f1f4b commit 8daddaa

File tree

11 files changed

+2340
-1646
lines changed

11 files changed

+2340
-1646
lines changed

api/api.gen.go

Lines changed: 673 additions & 663 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/go/client.gen.go

Lines changed: 702 additions & 692 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/client/javascript/src/client/schemas.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7604,16 +7604,26 @@ export interface components {
76047604
value: number
76057605
/**
76067606
* @description Type of the threshold.
7607-
* @example NUMBER
7607+
* @example usage_value
76087608
*/
76097609
type: components['schemas']['NotificationRuleBalanceThresholdValueType']
76107610
}
76117611
/**
76127612
* Notification balance threshold type
7613-
* @description Type of the rule in the balance threshold specification.
7613+
* @description Type of the rule in the balance threshold specification:
7614+
* * `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period
7615+
* * `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period
7616+
* * `usage_value`: threshold defined by the usage value in the current usage period
7617+
* * `NUMBER` (**deprecated**): see `usage_value`
7618+
* * `PERCENT` (**deprecated**): see `usage_percentage`
76147619
* @enum {string}
76157620
*/
7616-
NotificationRuleBalanceThresholdValueType: 'PERCENT' | 'NUMBER'
7621+
NotificationRuleBalanceThresholdValueType:
7622+
| 'PERCENT'
7623+
| 'NUMBER'
7624+
| 'balance_value'
7625+
| 'usage_percentage'
7626+
| 'usage_value'
76177627
/** @description Union type for requests creating new notification rule with certain type. */
76187628
NotificationRuleCreateRequest:
76197629
| components['schemas']['NotificationRuleBalanceThresholdCreateRequest']

api/client/javascript/src/zod/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9851,9 +9851,15 @@ export const createNotificationRuleBody = zod
98519851
zod
98529852
.object({
98539853
type: zod
9854-
.enum(['PERCENT', 'NUMBER'])
9854+
.enum([
9855+
'PERCENT',
9856+
'NUMBER',
9857+
'balance_value',
9858+
'usage_percentage',
9859+
'usage_value',
9860+
])
98559861
.describe(
9856-
'Type of the rule in the balance threshold specification.'
9862+
'Type of the rule in the balance threshold specification:\n* `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period\n* `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period\n* `usage_value`: threshold defined by the usage value in the current usage period\n* `NUMBER` (**deprecated**): see `usage_value`\n* `PERCENT` (**deprecated**): see `usage_percentage`'
98579863
)
98589864
.describe('Type of the threshold.'),
98599865
value: zod.coerce.number().describe('Value of the threshold.'),
@@ -10047,9 +10053,15 @@ export const updateNotificationRuleBody = zod
1004710053
zod
1004810054
.object({
1004910055
type: zod
10050-
.enum(['PERCENT', 'NUMBER'])
10056+
.enum([
10057+
'PERCENT',
10058+
'NUMBER',
10059+
'balance_value',
10060+
'usage_percentage',
10061+
'usage_value',
10062+
])
1005110063
.describe(
10052-
'Type of the rule in the balance threshold specification.'
10064+
'Type of the rule in the balance threshold specification:\n* `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period\n* `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period\n* `usage_value`: threshold defined by the usage value in the current usage period\n* `NUMBER` (**deprecated**): see `usage_value`\n* `PERCENT` (**deprecated**): see `usage_percentage`'
1005310065
)
1005410066
.describe('Type of the threshold.'),
1005510067
value: zod.coerce.number().describe('Value of the threshold.'),

api/openapi.cloud.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19454,18 +19454,30 @@ components:
1945419454
allOf:
1945519455
- $ref: '#/components/schemas/NotificationRuleBalanceThresholdValueType'
1945619456
description: Type of the threshold.
19457-
example: NUMBER
19457+
example: usage_value
1945819458
description: Threshold value with multiple supported types.
1945919459
NotificationRuleBalanceThresholdValueType:
1946019460
type: string
1946119461
enum:
1946219462
- PERCENT
1946319463
- NUMBER
19464-
description: Type of the rule in the balance threshold specification.
19464+
- balance_value
19465+
- usage_percentage
19466+
- usage_value
19467+
description: |-
19468+
Type of the rule in the balance threshold specification:
19469+
* `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period
19470+
* `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period
19471+
* `usage_value`: threshold defined by the usage value in the current usage period
19472+
* `NUMBER` (**deprecated**): see `usage_value`
19473+
* `PERCENT` (**deprecated**): see `usage_percentage`
1946519474
title: Notification balance threshold type
1946619475
x-enum-varnames:
1946719476
- Percent
1946819477
- Number
19478+
- BalanceValue
19479+
- UsagePercentage
19480+
- UsageValue
1946919481
NotificationRuleCreateRequest:
1947019482
type: object
1947119483
oneOf:

api/openapi.yaml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20035,18 +20035,30 @@ components:
2003520035
allOf:
2003620036
- $ref: '#/components/schemas/NotificationRuleBalanceThresholdValueType'
2003720037
description: Type of the threshold.
20038-
example: NUMBER
20038+
example: usage_value
2003920039
description: Threshold value with multiple supported types.
2004020040
NotificationRuleBalanceThresholdValueType:
2004120041
type: string
2004220042
enum:
2004320043
- PERCENT
2004420044
- NUMBER
20045-
description: Type of the rule in the balance threshold specification.
20045+
- balance_value
20046+
- usage_percentage
20047+
- usage_value
20048+
description: |-
20049+
Type of the rule in the balance threshold specification:
20050+
* `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period
20051+
* `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period
20052+
* `usage_value`: threshold defined by the usage value in the current usage period
20053+
* `NUMBER` (**deprecated**): see `usage_value`
20054+
* `PERCENT` (**deprecated**): see `usage_percentage`
2004620055
title: Notification balance threshold type
2004720056
x-enum-varnames:
2004820057
- Percent
2004920058
- Number
20059+
- BalanceValue
20060+
- UsagePercentage
20061+
- UsageValue
2005020062
NotificationRuleCreateRequest:
2005120063
type: object
2005220064
oneOf:

api/spec/src/notification/entitlements.tsp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,30 @@ model NotificationRuleBalanceThresholdValue {
130130
* Type of the threshold.
131131
*/
132132
@visibility(Lifecycle.Read, Lifecycle.Create, Lifecycle.Update)
133-
@example(NotificationRuleBalanceThresholdValueType.NUMBER)
133+
@example(NotificationRuleBalanceThresholdValueType.usage_value)
134134
type: NotificationRuleBalanceThresholdValueType;
135135
}
136136

137137
/**
138-
* Type of the rule in the balance threshold specification.
138+
* Type of the rule in the balance threshold specification:
139+
* * `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period
140+
* * `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period
141+
* * `usage_value`: threshold defined by the usage value in the current usage period
142+
* * `NUMBER` (**deprecated**): see `usage_value`
143+
* * `PERCENT` (**deprecated**): see `usage_percentage`
139144
*/
140145
@summary("Notification balance threshold type")
141146
@friendlyName("NotificationRuleBalanceThresholdValueType")
142-
@extension("x-enum-varnames", #["Percent", "Number"])
147+
@extension(
148+
"x-enum-varnames",
149+
#["Percent", "Number", "BalanceValue", "UsagePercentage", "UsageValue"]
150+
)
143151
enum NotificationRuleBalanceThresholdValueType {
144152
PERCENT,
145153
NUMBER,
154+
balance_value,
155+
usage_percentage,
156+
usage_value,
146157
}
147158

148159
/**

openmeter/notification/consumer/balancethreshold_test.go

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)