Skip to content

Commit f8d96a9

Browse files
feat(api): api update
1 parent cf2dd82 commit f8d96a9

File tree

6 files changed

+111
-2
lines changed

6 files changed

+111
-2
lines changed

.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%2Forb-87e16688d40cde735bc36efd40d8c12a7918919b18268d9c40b46d0cdf2f6251.yml
3-
openapi_spec_hash: 83f1f5a6fa7a07db4af09426232d0786
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml
3+
openapi_spec_hash: 82df33badf54d0c7087a61145d379f58
44
config_hash: 3279841440b02d4e8303c961d6983492

src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ public void FieldRoundtrip_Works()
1717
SubscriptionID = "subscription_id",
1818
Thresholds = [new(0)],
1919
Type = AlertCreateForSubscriptionParamsType.UsageExceeded,
20+
GroupingKeys = ["string"],
2021
MetricID = "metric_id",
22+
PricingUnitID = "pricing_unit_id",
2123
};
2224

2325
string expectedSubscriptionID = "subscription_id";
2426
List<Threshold> expectedThresholds = [new(0)];
2527
ApiEnum<string, AlertCreateForSubscriptionParamsType> expectedType =
2628
AlertCreateForSubscriptionParamsType.UsageExceeded;
29+
List<string> expectedGroupingKeys = ["string"];
2730
string expectedMetricID = "metric_id";
31+
string expectedPricingUnitID = "pricing_unit_id";
2832

2933
Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID);
3034
Assert.Equal(expectedThresholds.Count, parameters.Thresholds.Count);
@@ -33,7 +37,14 @@ public void FieldRoundtrip_Works()
3337
Assert.Equal(expectedThresholds[i], parameters.Thresholds[i]);
3438
}
3539
Assert.Equal(expectedType, parameters.Type);
40+
Assert.NotNull(parameters.GroupingKeys);
41+
Assert.Equal(expectedGroupingKeys.Count, parameters.GroupingKeys.Count);
42+
for (int i = 0; i < expectedGroupingKeys.Count; i++)
43+
{
44+
Assert.Equal(expectedGroupingKeys[i], parameters.GroupingKeys[i]);
45+
}
3646
Assert.Equal(expectedMetricID, parameters.MetricID);
47+
Assert.Equal(expectedPricingUnitID, parameters.PricingUnitID);
3748
}
3849

3950
[Fact]
@@ -46,8 +57,12 @@ public void OptionalNullableParamsUnsetAreNotSet_Works()
4657
Type = AlertCreateForSubscriptionParamsType.UsageExceeded,
4758
};
4859

60+
Assert.Null(parameters.GroupingKeys);
61+
Assert.False(parameters.RawBodyData.ContainsKey("grouping_keys"));
4962
Assert.Null(parameters.MetricID);
5063
Assert.False(parameters.RawBodyData.ContainsKey("metric_id"));
64+
Assert.Null(parameters.PricingUnitID);
65+
Assert.False(parameters.RawBodyData.ContainsKey("pricing_unit_id"));
5166
}
5267

5368
[Fact]
@@ -59,11 +74,17 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works()
5974
Thresholds = [new(0)],
6075
Type = AlertCreateForSubscriptionParamsType.UsageExceeded,
6176

77+
GroupingKeys = null,
6278
MetricID = null,
79+
PricingUnitID = null,
6380
};
6481

82+
Assert.Null(parameters.GroupingKeys);
83+
Assert.True(parameters.RawBodyData.ContainsKey("grouping_keys"));
6584
Assert.Null(parameters.MetricID);
6685
Assert.True(parameters.RawBodyData.ContainsKey("metric_id"));
86+
Assert.Null(parameters.PricingUnitID);
87+
Assert.True(parameters.RawBodyData.ContainsKey("pricing_unit_id"));
6788
}
6889

6990
[Fact]
@@ -92,7 +113,9 @@ public void CopyConstructor_Works()
92113
SubscriptionID = "subscription_id",
93114
Thresholds = [new(0)],
94115
Type = AlertCreateForSubscriptionParamsType.UsageExceeded,
116+
GroupingKeys = ["string"],
95117
MetricID = "metric_id",
118+
PricingUnitID = "pricing_unit_id",
96119
};
97120

98121
AlertCreateForSubscriptionParams copied = new(parameters);

src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void FieldRoundtrip_Works()
3535
Thresholds = [new(0)],
3636
Type = AlertType.CreditBalanceDepleted,
3737
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
38+
GroupingKeys = ["string"],
3839
LicenseType = new("id"),
3940
},
4041
],
@@ -62,6 +63,7 @@ public void FieldRoundtrip_Works()
6263
Thresholds = [new(0)],
6364
Type = AlertType.CreditBalanceDepleted,
6465
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
66+
GroupingKeys = ["string"],
6567
LicenseType = new("id"),
6668
},
6769
];
@@ -105,6 +107,7 @@ public void SerializationRoundtrip_Works()
105107
Thresholds = [new(0)],
106108
Type = AlertType.CreditBalanceDepleted,
107109
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
110+
GroupingKeys = ["string"],
108111
LicenseType = new("id"),
109112
},
110113
],
@@ -146,6 +149,7 @@ public void FieldRoundtripThroughSerialization_Works()
146149
Thresholds = [new(0)],
147150
Type = AlertType.CreditBalanceDepleted,
148151
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
152+
GroupingKeys = ["string"],
149153
LicenseType = new("id"),
150154
},
151155
],
@@ -180,6 +184,7 @@ public void FieldRoundtripThroughSerialization_Works()
180184
Thresholds = [new(0)],
181185
Type = AlertType.CreditBalanceDepleted,
182186
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
187+
GroupingKeys = ["string"],
183188
LicenseType = new("id"),
184189
},
185190
];
@@ -223,6 +228,7 @@ public void Validation_Works()
223228
Thresholds = [new(0)],
224229
Type = AlertType.CreditBalanceDepleted,
225230
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
231+
GroupingKeys = ["string"],
226232
LicenseType = new("id"),
227233
},
228234
],
@@ -258,6 +264,7 @@ public void CopyConstructor_Works()
258264
Thresholds = [new(0)],
259265
Type = AlertType.CreditBalanceDepleted,
260266
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
267+
GroupingKeys = ["string"],
261268
LicenseType = new("id"),
262269
},
263270
],

src/Orb.Tests/Models/Alerts/AlertTest.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void FieldRoundtrip_Works()
3232
Thresholds = [new(0)],
3333
Type = AlertType.CreditBalanceDepleted,
3434
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
35+
GroupingKeys = ["string"],
3536
LicenseType = new("id"),
3637
};
3738

@@ -59,6 +60,7 @@ public void FieldRoundtrip_Works()
5960
[
6061
new() { InAlert = true, ThresholdValue = 0 },
6162
];
63+
List<string> expectedGroupingKeys = ["string"];
6264
LicenseType expectedLicenseType = new("id");
6365

6466
Assert.Equal(expectedID, model.ID);
@@ -82,6 +84,12 @@ public void FieldRoundtrip_Works()
8284
{
8385
Assert.Equal(expectedBalanceAlertStatus[i], model.BalanceAlertStatus[i]);
8486
}
87+
Assert.NotNull(model.GroupingKeys);
88+
Assert.Equal(expectedGroupingKeys.Count, model.GroupingKeys.Count);
89+
for (int i = 0; i < expectedGroupingKeys.Count; i++)
90+
{
91+
Assert.Equal(expectedGroupingKeys[i], model.GroupingKeys[i]);
92+
}
8593
Assert.Equal(expectedLicenseType, model.LicenseType);
8694
}
8795

@@ -107,6 +115,7 @@ public void SerializationRoundtrip_Works()
107115
Thresholds = [new(0)],
108116
Type = AlertType.CreditBalanceDepleted,
109117
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
118+
GroupingKeys = ["string"],
110119
LicenseType = new("id"),
111120
};
112121

@@ -138,6 +147,7 @@ public void FieldRoundtripThroughSerialization_Works()
138147
Thresholds = [new(0)],
139148
Type = AlertType.CreditBalanceDepleted,
140149
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
150+
GroupingKeys = ["string"],
141151
LicenseType = new("id"),
142152
};
143153

@@ -169,6 +179,7 @@ public void FieldRoundtripThroughSerialization_Works()
169179
[
170180
new() { InAlert = true, ThresholdValue = 0 },
171181
];
182+
List<string> expectedGroupingKeys = ["string"];
172183
LicenseType expectedLicenseType = new("id");
173184

174185
Assert.Equal(expectedID, deserialized.ID);
@@ -192,6 +203,12 @@ public void FieldRoundtripThroughSerialization_Works()
192203
{
193204
Assert.Equal(expectedBalanceAlertStatus[i], deserialized.BalanceAlertStatus[i]);
194205
}
206+
Assert.NotNull(deserialized.GroupingKeys);
207+
Assert.Equal(expectedGroupingKeys.Count, deserialized.GroupingKeys.Count);
208+
for (int i = 0; i < expectedGroupingKeys.Count; i++)
209+
{
210+
Assert.Equal(expectedGroupingKeys[i], deserialized.GroupingKeys[i]);
211+
}
195212
Assert.Equal(expectedLicenseType, deserialized.LicenseType);
196213
}
197214

@@ -217,6 +234,7 @@ public void Validation_Works()
217234
Thresholds = [new(0)],
218235
Type = AlertType.CreditBalanceDepleted,
219236
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
237+
GroupingKeys = ["string"],
220238
LicenseType = new("id"),
221239
};
222240

@@ -248,6 +266,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works()
248266

249267
Assert.Null(model.BalanceAlertStatus);
250268
Assert.False(model.RawData.ContainsKey("balance_alert_status"));
269+
Assert.Null(model.GroupingKeys);
270+
Assert.False(model.RawData.ContainsKey("grouping_keys"));
251271
Assert.Null(model.LicenseType);
252272
Assert.False(model.RawData.ContainsKey("license_type"));
253273
}
@@ -301,11 +321,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works()
301321
Type = AlertType.CreditBalanceDepleted,
302322

303323
BalanceAlertStatus = null,
324+
GroupingKeys = null,
304325
LicenseType = null,
305326
};
306327

307328
Assert.Null(model.BalanceAlertStatus);
308329
Assert.True(model.RawData.ContainsKey("balance_alert_status"));
330+
Assert.Null(model.GroupingKeys);
331+
Assert.True(model.RawData.ContainsKey("grouping_keys"));
309332
Assert.Null(model.LicenseType);
310333
Assert.True(model.RawData.ContainsKey("license_type"));
311334
}
@@ -333,6 +356,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works()
333356
Type = AlertType.CreditBalanceDepleted,
334357

335358
BalanceAlertStatus = null,
359+
GroupingKeys = null,
336360
LicenseType = null,
337361
};
338362

@@ -361,6 +385,7 @@ public void CopyConstructor_Works()
361385
Thresholds = [new(0)],
362386
Type = AlertType.CreditBalanceDepleted,
363387
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
388+
GroupingKeys = ["string"],
364389
LicenseType = new("id"),
365390
};
366391

src/Orb/Models/Alerts/Alert.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,26 @@ public IReadOnlyList<BalanceAlertStatus>? BalanceAlertStatus
176176
}
177177
}
178178

179+
/// <summary>
180+
/// The property keys to group cost alerts by. Only present for cost alerts with
181+
/// grouping enabled.
182+
/// </summary>
183+
public IReadOnlyList<string>? GroupingKeys
184+
{
185+
get
186+
{
187+
this._rawData.Freeze();
188+
return this._rawData.GetNullableStruct<ImmutableArray<string>>("grouping_keys");
189+
}
190+
init
191+
{
192+
this._rawData.Set<ImmutableArray<string>?>(
193+
"grouping_keys",
194+
value == null ? null : ImmutableArray.ToImmutableArray(value)
195+
);
196+
}
197+
}
198+
179199
/// <summary>
180200
/// Minified license type for alert serialization.
181201
/// </summary>
@@ -209,6 +229,7 @@ public override void Validate()
209229
{
210230
item.Validate();
211231
}
232+
_ = this.GroupingKeys;
212233
this.LicenseType?.Validate();
213234
}
214235

src/Orb/Models/Alerts/AlertCreateForSubscriptionParams.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,25 @@ public required ApiEnum<string, AlertCreateForSubscriptionParamsType> Type
7373
init { this._rawBodyData.Set("type", value); }
7474
}
7575

76+
/// <summary>
77+
/// The property keys to group cost alerts by. Only applicable for cost_exceeded alerts.
78+
/// </summary>
79+
public IReadOnlyList<string>? GroupingKeys
80+
{
81+
get
82+
{
83+
this._rawBodyData.Freeze();
84+
return this._rawBodyData.GetNullableStruct<ImmutableArray<string>>("grouping_keys");
85+
}
86+
init
87+
{
88+
this._rawBodyData.Set<ImmutableArray<string>?>(
89+
"grouping_keys",
90+
value == null ? null : ImmutableArray.ToImmutableArray(value)
91+
);
92+
}
93+
}
94+
7695
/// <summary>
7796
/// The metric to track usage for.
7897
/// </summary>
@@ -86,6 +105,20 @@ public string? MetricID
86105
init { this._rawBodyData.Set("metric_id", value); }
87106
}
88107

108+
/// <summary>
109+
/// The pricing unit to use for grouped cost alerts. Required when grouping_keys
110+
/// is set.
111+
/// </summary>
112+
public string? PricingUnitID
113+
{
114+
get
115+
{
116+
this._rawBodyData.Freeze();
117+
return this._rawBodyData.GetNullableClass<string>("pricing_unit_id");
118+
}
119+
init { this._rawBodyData.Set("pricing_unit_id", value); }
120+
}
121+
89122
public AlertCreateForSubscriptionParams() { }
90123

91124
#pragma warning disable CS8618

0 commit comments

Comments
 (0)