Skip to content

Commit ebe83bc

Browse files
feat(api): api update
1 parent 5c9d8d7 commit ebe83bc

24 files changed

+2060
-3
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-77e112caf7b2a2c7b0248b7245b5730bc72ab0ea84ba5d0777e7d0604ae04d26.yml
3-
openapi_spec_hash: 966568dd08f34db64ba0ebace678268a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-3c7ee3ec9931aaeeb5e015a598812cde9edc09f114adb8759ef4c2054c90f7dc.yml
3+
openapi_spec_hash: a14720041156fe4f353449142edacf0d
44
config_hash: 3279841440b02d4e8303c961d6983492

src/Orb.Tests/Models/Metrics/BillableMetricTest.cs

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public void FieldRoundtrip_Works()
3737
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
3838
Name = "name",
3939
Status = Status.Active,
40+
ParameterDefinitions =
41+
[
42+
new Dictionary<string, JsonElement>()
43+
{
44+
{ "foo", JsonSerializer.SerializeToElement("bar") },
45+
},
46+
],
4047
};
4148

4249
string expectedID = "id";
@@ -60,6 +67,13 @@ public void FieldRoundtrip_Works()
6067
Dictionary<string, string> expectedMetadata = new() { { "foo", "string" } };
6168
string expectedName = "name";
6269
ApiEnum<string, Status> expectedStatus = Status.Active;
70+
List<Dictionary<string, JsonElement>> expectedParameterDefinitions =
71+
[
72+
new Dictionary<string, JsonElement>()
73+
{
74+
{ "foo", JsonSerializer.SerializeToElement("bar") },
75+
},
76+
];
6377

6478
Assert.Equal(expectedID, model.ID);
6579
Assert.Equal(expectedDescription, model.Description);
@@ -73,6 +87,21 @@ public void FieldRoundtrip_Works()
7387
}
7488
Assert.Equal(expectedName, model.Name);
7589
Assert.Equal(expectedStatus, model.Status);
90+
Assert.NotNull(model.ParameterDefinitions);
91+
Assert.Equal(expectedParameterDefinitions.Count, model.ParameterDefinitions.Count);
92+
for (int i = 0; i < expectedParameterDefinitions.Count; i++)
93+
{
94+
Assert.Equal(
95+
expectedParameterDefinitions[i].Count,
96+
model.ParameterDefinitions[i].Count
97+
);
98+
foreach (var item in expectedParameterDefinitions[i])
99+
{
100+
Assert.True(model.ParameterDefinitions[i].TryGetValue(item.Key, out var value));
101+
102+
Assert.True(JsonElement.DeepEquals(value, model.ParameterDefinitions[i][item.Key]));
103+
}
104+
}
76105
}
77106

78107
[Fact]
@@ -102,6 +131,13 @@ public void SerializationRoundtrip_Works()
102131
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
103132
Name = "name",
104133
Status = Status.Active,
134+
ParameterDefinitions =
135+
[
136+
new Dictionary<string, JsonElement>()
137+
{
138+
{ "foo", JsonSerializer.SerializeToElement("bar") },
139+
},
140+
],
105141
};
106142

107143
string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -140,6 +176,13 @@ public void FieldRoundtripThroughSerialization_Works()
140176
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
141177
Name = "name",
142178
Status = Status.Active,
179+
ParameterDefinitions =
180+
[
181+
new Dictionary<string, JsonElement>()
182+
{
183+
{ "foo", JsonSerializer.SerializeToElement("bar") },
184+
},
185+
],
143186
};
144187

145188
string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions);
@@ -170,6 +213,13 @@ public void FieldRoundtripThroughSerialization_Works()
170213
Dictionary<string, string> expectedMetadata = new() { { "foo", "string" } };
171214
string expectedName = "name";
172215
ApiEnum<string, Status> expectedStatus = Status.Active;
216+
List<Dictionary<string, JsonElement>> expectedParameterDefinitions =
217+
[
218+
new Dictionary<string, JsonElement>()
219+
{
220+
{ "foo", JsonSerializer.SerializeToElement("bar") },
221+
},
222+
];
173223

174224
Assert.Equal(expectedID, deserialized.ID);
175225
Assert.Equal(expectedDescription, deserialized.Description);
@@ -183,6 +233,25 @@ public void FieldRoundtripThroughSerialization_Works()
183233
}
184234
Assert.Equal(expectedName, deserialized.Name);
185235
Assert.Equal(expectedStatus, deserialized.Status);
236+
Assert.NotNull(deserialized.ParameterDefinitions);
237+
Assert.Equal(expectedParameterDefinitions.Count, deserialized.ParameterDefinitions.Count);
238+
for (int i = 0; i < expectedParameterDefinitions.Count; i++)
239+
{
240+
Assert.Equal(
241+
expectedParameterDefinitions[i].Count,
242+
deserialized.ParameterDefinitions[i].Count
243+
);
244+
foreach (var item in expectedParameterDefinitions[i])
245+
{
246+
Assert.True(
247+
deserialized.ParameterDefinitions[i].TryGetValue(item.Key, out var value)
248+
);
249+
250+
Assert.True(
251+
JsonElement.DeepEquals(value, deserialized.ParameterDefinitions[i][item.Key])
252+
);
253+
}
254+
}
186255
}
187256

188257
[Fact]
@@ -212,6 +281,147 @@ public void Validation_Works()
212281
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
213282
Name = "name",
214283
Status = Status.Active,
284+
ParameterDefinitions =
285+
[
286+
new Dictionary<string, JsonElement>()
287+
{
288+
{ "foo", JsonSerializer.SerializeToElement("bar") },
289+
},
290+
],
291+
};
292+
293+
model.Validate();
294+
}
295+
296+
[Fact]
297+
public void OptionalNullablePropertiesUnsetAreNotSet_Works()
298+
{
299+
var model = new BillableMetric
300+
{
301+
ID = "id",
302+
Description = "description",
303+
Item = new()
304+
{
305+
ID = "id",
306+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
307+
ExternalConnections =
308+
[
309+
new()
310+
{
311+
ExternalConnectionName =
312+
ItemExternalConnectionExternalConnectionName.Stripe,
313+
ExternalEntityID = "external_entity_id",
314+
},
315+
],
316+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
317+
Name = "name",
318+
ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
319+
},
320+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
321+
Name = "name",
322+
Status = Status.Active,
323+
};
324+
325+
Assert.Null(model.ParameterDefinitions);
326+
Assert.False(model.RawData.ContainsKey("parameter_definitions"));
327+
}
328+
329+
[Fact]
330+
public void OptionalNullablePropertiesUnsetValidation_Works()
331+
{
332+
var model = new BillableMetric
333+
{
334+
ID = "id",
335+
Description = "description",
336+
Item = new()
337+
{
338+
ID = "id",
339+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
340+
ExternalConnections =
341+
[
342+
new()
343+
{
344+
ExternalConnectionName =
345+
ItemExternalConnectionExternalConnectionName.Stripe,
346+
ExternalEntityID = "external_entity_id",
347+
},
348+
],
349+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
350+
Name = "name",
351+
ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
352+
},
353+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
354+
Name = "name",
355+
Status = Status.Active,
356+
};
357+
358+
model.Validate();
359+
}
360+
361+
[Fact]
362+
public void OptionalNullablePropertiesSetToNullAreSetToNull_Works()
363+
{
364+
var model = new BillableMetric
365+
{
366+
ID = "id",
367+
Description = "description",
368+
Item = new()
369+
{
370+
ID = "id",
371+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
372+
ExternalConnections =
373+
[
374+
new()
375+
{
376+
ExternalConnectionName =
377+
ItemExternalConnectionExternalConnectionName.Stripe,
378+
ExternalEntityID = "external_entity_id",
379+
},
380+
],
381+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
382+
Name = "name",
383+
ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
384+
},
385+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
386+
Name = "name",
387+
Status = Status.Active,
388+
389+
ParameterDefinitions = null,
390+
};
391+
392+
Assert.Null(model.ParameterDefinitions);
393+
Assert.True(model.RawData.ContainsKey("parameter_definitions"));
394+
}
395+
396+
[Fact]
397+
public void OptionalNullablePropertiesSetToNullValidation_Works()
398+
{
399+
var model = new BillableMetric
400+
{
401+
ID = "id",
402+
Description = "description",
403+
Item = new()
404+
{
405+
ID = "id",
406+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
407+
ExternalConnections =
408+
[
409+
new()
410+
{
411+
ExternalConnectionName =
412+
ItemExternalConnectionExternalConnectionName.Stripe,
413+
ExternalEntityID = "external_entity_id",
414+
},
415+
],
416+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
417+
Name = "name",
418+
ArchivedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
419+
},
420+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
421+
Name = "name",
422+
Status = Status.Active,
423+
424+
ParameterDefinitions = null,
215425
};
216426

217427
model.Validate();
@@ -244,6 +454,13 @@ public void CopyConstructor_Works()
244454
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
245455
Name = "name",
246456
Status = Status.Active,
457+
ParameterDefinitions =
458+
[
459+
new Dictionary<string, JsonElement>()
460+
{
461+
{ "foo", JsonSerializer.SerializeToElement("bar") },
462+
},
463+
],
247464
};
248465

249466
BillableMetric copied = new(model);

src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ public void FieldRoundtrip_Works()
4141
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
4242
Name = "name",
4343
Status = Status.Active,
44+
ParameterDefinitions =
45+
[
46+
new Dictionary<string, JsonElement>()
47+
{
48+
{ "foo", JsonSerializer.SerializeToElement("bar") },
49+
},
50+
],
4451
},
4552
],
4653
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },
@@ -72,6 +79,13 @@ public void FieldRoundtrip_Works()
7279
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
7380
Name = "name",
7481
Status = Status.Active,
82+
ParameterDefinitions =
83+
[
84+
new Dictionary<string, JsonElement>()
85+
{
86+
{ "foo", JsonSerializer.SerializeToElement("bar") },
87+
},
88+
],
7589
},
7690
];
7791
Models::PaginationMetadata expectedPaginationMetadata = new()
@@ -119,6 +133,13 @@ public void SerializationRoundtrip_Works()
119133
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
120134
Name = "name",
121135
Status = Status.Active,
136+
ParameterDefinitions =
137+
[
138+
new Dictionary<string, JsonElement>()
139+
{
140+
{ "foo", JsonSerializer.SerializeToElement("bar") },
141+
},
142+
],
122143
},
123144
],
124145
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },
@@ -164,6 +185,13 @@ public void FieldRoundtripThroughSerialization_Works()
164185
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
165186
Name = "name",
166187
Status = Status.Active,
188+
ParameterDefinitions =
189+
[
190+
new Dictionary<string, JsonElement>()
191+
{
192+
{ "foo", JsonSerializer.SerializeToElement("bar") },
193+
},
194+
],
167195
},
168196
],
169197
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },
@@ -202,6 +230,13 @@ public void FieldRoundtripThroughSerialization_Works()
202230
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
203231
Name = "name",
204232
Status = Status.Active,
233+
ParameterDefinitions =
234+
[
235+
new Dictionary<string, JsonElement>()
236+
{
237+
{ "foo", JsonSerializer.SerializeToElement("bar") },
238+
},
239+
],
205240
},
206241
];
207242
Models::PaginationMetadata expectedPaginationMetadata = new()
@@ -249,6 +284,13 @@ public void Validation_Works()
249284
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
250285
Name = "name",
251286
Status = Status.Active,
287+
ParameterDefinitions =
288+
[
289+
new Dictionary<string, JsonElement>()
290+
{
291+
{ "foo", JsonSerializer.SerializeToElement("bar") },
292+
},
293+
],
252294
},
253295
],
254296
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },
@@ -288,6 +330,13 @@ public void CopyConstructor_Works()
288330
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
289331
Name = "name",
290332
Status = Status.Active,
333+
ParameterDefinitions =
334+
[
335+
new Dictionary<string, JsonElement>()
336+
{
337+
{ "foo", JsonSerializer.SerializeToElement("bar") },
338+
},
339+
],
291340
},
292341
],
293342
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },

0 commit comments

Comments
 (0)