diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 0e2b815d..5709eb5d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "6.1.0" + ".": "6.2.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index aec32876..6a78b67a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 48 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-diversion-a078cd16edc143e212e23ebdb4d94a3898243c4a85e10f04811eb1ccf1b90c1a.yml -openapi_spec_hash: 4cbee56647635fe750024baf5e7dad5f -config_hash: 66121ffadb78b9866f6b853f19b11f3d +configured_endpoints: 49 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc/imagekit-diversion-bb6d292886aeece83718e78fef715faf31e39ced5012e49562fb1dfdc27d5f1c.yml +openapi_spec_hash: 10766adaa4027a354b103cdfe9be7572 +config_hash: 90e338d72ae51ba55b67bb54f620e3f0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c4b7825..251685c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 6.2.0 (2026-07-14) + +Full Changelog: [v6.1.0...v6.2.0](https://github.com/imagekit-developer/imagekit-dotnet/compare/v6.1.0...v6.2.0) + +### Features + +* **api:** add usage analytics breakdown endpoint ([ea2003a](https://github.com/imagekit-developer/imagekit-dotnet/commit/ea2003a14166ed2b5d2828cc28349fa2071d308b)) + + +### Chores + +* **api:** Add title annotations to inline allOf fragments ([daac9bc](https://github.com/imagekit-developer/imagekit-dotnet/commit/daac9bcf43431f93fec66004bc7496b45f5adf77)) +* **api:** Add title annotations to inline allOf fragments ([c222cf8](https://github.com/imagekit-developer/imagekit-dotnet/commit/c222cf80c0c233e3f053b2f396957dc52a3f9ecf)) +* **api:** remove titles ([75b04c0](https://github.com/imagekit-developer/imagekit-dotnet/commit/75b04c07bd4a5cf326113b0b8bf051a7d384a80f)) + ## 6.1.0 (2026-06-18) Full Changelog: [v6.0.1...v6.1.0](https://github.com/imagekit-developer/imagekit-dotnet/compare/v6.0.1...v6.1.0) diff --git a/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/RequestBandwidthEntryTest.cs b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/RequestBandwidthEntryTest.cs new file mode 100644 index 00000000..b314f771 --- /dev/null +++ b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/RequestBandwidthEntryTest.cs @@ -0,0 +1,71 @@ +using System.Text.Json; +using Imagekit.Core; +using Imagekit.Models.Accounts.UsageAnalytics; + +namespace Imagekit.Tests.Models.Accounts.UsageAnalytics; + +public class RequestBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new RequestBandwidthEntry { BandwidthBytes = 0, RequestCount = 0 }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new RequestBandwidthEntry { BandwidthBytes = 0, RequestCount = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new RequestBandwidthEntry { BandwidthBytes = 0, RequestCount = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + } + + [Fact] + public void Validation_Works() + { + var model = new RequestBandwidthEntry { BandwidthBytes = 0, RequestCount = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new RequestBandwidthEntry { BandwidthBytes = 0, RequestCount = 0 }; + + RequestBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParamsTest.cs b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParamsTest.cs new file mode 100644 index 00000000..f1524669 --- /dev/null +++ b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParamsTest.cs @@ -0,0 +1,58 @@ +using System; +using Imagekit.Models.Accounts.UsageAnalytics; + +namespace Imagekit.Tests.Models.Accounts.UsageAnalytics; + +public class UsageAnalyticsGetParamsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var parameters = new UsageAnalyticsGetParams + { + EndDate = "2019-12-27", + StartDate = "2019-12-27", + }; + + string expectedEndDate = "2019-12-27"; + string expectedStartDate = "2019-12-27"; + + Assert.Equal(expectedEndDate, parameters.EndDate); + Assert.Equal(expectedStartDate, parameters.StartDate); + } + + [Fact] + public void Url_Works() + { + UsageAnalyticsGetParams parameters = new() + { + EndDate = "2019-12-27", + StartDate = "2019-12-27", + }; + + var url = parameters.Url(new() { PrivateKey = "My Private Key", Password = "My Password" }); + + Assert.True( + TestBase.UrisEqual( + new Uri( + "https://api.imagekit.io/v1/accounts/usage-analytics?endDate=2019-12-27&startDate=2019-12-27" + ), + url + ) + ); + } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new UsageAnalyticsGetParams + { + EndDate = "2019-12-27", + StartDate = "2019-12-27", + }; + + UsageAnalyticsGetParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} diff --git a/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsResponseTest.cs b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsResponseTest.cs new file mode 100644 index 00000000..10613c3f --- /dev/null +++ b/src/Imagekit.Tests/Models/Accounts/UsageAnalytics/UsageAnalyticsResponseTest.cs @@ -0,0 +1,9039 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using Imagekit.Core; +using Imagekit.Models.Accounts.UsageAnalytics; + +namespace Imagekit.Tests.Models.Accounts.UsageAnalytics; + +public class UsageAnalyticsResponseTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageAnalyticsResponse + { + BandwidthBytes = 0, + Browser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + Cache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }, + Country = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }, + Device = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + EndDate = "2019-12-27", + ErrorReasons = + [ + new() + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }, + ], + Extensions = [new() { Name = "remove-bg", OperationCount = 0 }], + Format = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + GeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + RequestCount = 0, + StartDate = "2019-12-27", + StatusCodes = [new() { Name = "200", RequestCount = 0 }], + Top404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ], + TopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + UrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + VideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ], + }; + + double expectedBandwidthBytes = 0; + Browser expectedBrowser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + UsageAnalyticsResponseCache expectedCache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + Country expectedCountry = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + Device expectedDevice = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + string expectedEndDate = "2019-12-27"; + List expectedErrorReasons = + [ + new() { Name = "ENOENT - Resource not found at any upstream origin", RequestCount = 0 }, + ]; + List expectedExtensions = [new() { Name = "remove-bg", OperationCount = 0 }]; + Format expectedFormat = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + DateTimeOffset expectedGeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + double expectedRequestCount = 0; + string expectedStartDate = "2019-12-27"; + List expectedStatusCodes = [new() { Name = "200", RequestCount = 0 }]; + List expectedTop404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ]; + TopImages expectedTopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopImageTransforms expectedTopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopOtherAssets expectedTopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopReferrers expectedTopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopUserAgents expectedTopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopVideos expectedTopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopVideoTransforms expectedTopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + UsageAnalyticsResponseUrlEndpoints expectedUrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + List expectedVideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ]; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedBrowser, model.Browser); + Assert.Equal(expectedCache, model.Cache); + Assert.Equal(expectedCountry, model.Country); + Assert.Equal(expectedDevice, model.Device); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedErrorReasons.Count, model.ErrorReasons.Count); + for (int i = 0; i < expectedErrorReasons.Count; i++) + { + Assert.Equal(expectedErrorReasons[i], model.ErrorReasons[i]); + } + Assert.Equal(expectedExtensions.Count, model.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], model.Extensions[i]); + } + Assert.Equal(expectedFormat, model.Format); + Assert.Equal(expectedGeneratedAt, model.GeneratedAt); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedStartDate, model.StartDate); + Assert.Equal(expectedStatusCodes.Count, model.StatusCodes.Count); + for (int i = 0; i < expectedStatusCodes.Count; i++) + { + Assert.Equal(expectedStatusCodes[i], model.StatusCodes[i]); + } + Assert.Equal(expectedTop404Assets.Count, model.Top404Assets.Count); + for (int i = 0; i < expectedTop404Assets.Count; i++) + { + Assert.Equal(expectedTop404Assets[i], model.Top404Assets[i]); + } + Assert.Equal(expectedTopImages, model.TopImages); + Assert.Equal(expectedTopImageTransforms, model.TopImageTransforms); + Assert.Equal(expectedTopOtherAssets, model.TopOtherAssets); + Assert.Equal(expectedTopReferrers, model.TopReferrers); + Assert.Equal(expectedTopUserAgents, model.TopUserAgents); + Assert.Equal(expectedTopVideos, model.TopVideos); + Assert.Equal(expectedTopVideoTransforms, model.TopVideoTransforms); + Assert.Equal(expectedUrlEndpoints, model.UrlEndpoints); + Assert.Equal(expectedVideoProcessing.Count, model.VideoProcessing.Count); + for (int i = 0; i < expectedVideoProcessing.Count; i++) + { + Assert.Equal(expectedVideoProcessing[i], model.VideoProcessing[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageAnalyticsResponse + { + BandwidthBytes = 0, + Browser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + Cache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }, + Country = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }, + Device = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + EndDate = "2019-12-27", + ErrorReasons = + [ + new() + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }, + ], + Extensions = [new() { Name = "remove-bg", OperationCount = 0 }], + Format = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + GeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + RequestCount = 0, + StartDate = "2019-12-27", + StatusCodes = [new() { Name = "200", RequestCount = 0 }], + Top404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ], + TopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + UrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + VideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageAnalyticsResponse + { + BandwidthBytes = 0, + Browser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + Cache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }, + Country = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }, + Device = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + EndDate = "2019-12-27", + ErrorReasons = + [ + new() + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }, + ], + Extensions = [new() { Name = "remove-bg", OperationCount = 0 }], + Format = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + GeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + RequestCount = 0, + StartDate = "2019-12-27", + StatusCodes = [new() { Name = "200", RequestCount = 0 }], + Top404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ], + TopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + UrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + VideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + Browser expectedBrowser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + UsageAnalyticsResponseCache expectedCache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + Country expectedCountry = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + Device expectedDevice = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + string expectedEndDate = "2019-12-27"; + List expectedErrorReasons = + [ + new() { Name = "ENOENT - Resource not found at any upstream origin", RequestCount = 0 }, + ]; + List expectedExtensions = [new() { Name = "remove-bg", OperationCount = 0 }]; + Format expectedFormat = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + DateTimeOffset expectedGeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + double expectedRequestCount = 0; + string expectedStartDate = "2019-12-27"; + List expectedStatusCodes = [new() { Name = "200", RequestCount = 0 }]; + List expectedTop404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ]; + TopImages expectedTopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopImageTransforms expectedTopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopOtherAssets expectedTopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopReferrers expectedTopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopUserAgents expectedTopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopVideos expectedTopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + TopVideoTransforms expectedTopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + UsageAnalyticsResponseUrlEndpoints expectedUrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + List expectedVideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ]; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedBrowser, deserialized.Browser); + Assert.Equal(expectedCache, deserialized.Cache); + Assert.Equal(expectedCountry, deserialized.Country); + Assert.Equal(expectedDevice, deserialized.Device); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedErrorReasons.Count, deserialized.ErrorReasons.Count); + for (int i = 0; i < expectedErrorReasons.Count; i++) + { + Assert.Equal(expectedErrorReasons[i], deserialized.ErrorReasons[i]); + } + Assert.Equal(expectedExtensions.Count, deserialized.Extensions.Count); + for (int i = 0; i < expectedExtensions.Count; i++) + { + Assert.Equal(expectedExtensions[i], deserialized.Extensions[i]); + } + Assert.Equal(expectedFormat, deserialized.Format); + Assert.Equal(expectedGeneratedAt, deserialized.GeneratedAt); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedStatusCodes.Count, deserialized.StatusCodes.Count); + for (int i = 0; i < expectedStatusCodes.Count; i++) + { + Assert.Equal(expectedStatusCodes[i], deserialized.StatusCodes[i]); + } + Assert.Equal(expectedTop404Assets.Count, deserialized.Top404Assets.Count); + for (int i = 0; i < expectedTop404Assets.Count; i++) + { + Assert.Equal(expectedTop404Assets[i], deserialized.Top404Assets[i]); + } + Assert.Equal(expectedTopImages, deserialized.TopImages); + Assert.Equal(expectedTopImageTransforms, deserialized.TopImageTransforms); + Assert.Equal(expectedTopOtherAssets, deserialized.TopOtherAssets); + Assert.Equal(expectedTopReferrers, deserialized.TopReferrers); + Assert.Equal(expectedTopUserAgents, deserialized.TopUserAgents); + Assert.Equal(expectedTopVideos, deserialized.TopVideos); + Assert.Equal(expectedTopVideoTransforms, deserialized.TopVideoTransforms); + Assert.Equal(expectedUrlEndpoints, deserialized.UrlEndpoints); + Assert.Equal(expectedVideoProcessing.Count, deserialized.VideoProcessing.Count); + for (int i = 0; i < expectedVideoProcessing.Count; i++) + { + Assert.Equal(expectedVideoProcessing[i], deserialized.VideoProcessing[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UsageAnalyticsResponse + { + BandwidthBytes = 0, + Browser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + Cache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }, + Country = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }, + Device = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + EndDate = "2019-12-27", + ErrorReasons = + [ + new() + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }, + ], + Extensions = [new() { Name = "remove-bg", OperationCount = 0 }], + Format = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + GeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + RequestCount = 0, + StartDate = "2019-12-27", + StatusCodes = [new() { Name = "200", RequestCount = 0 }], + Top404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ], + TopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + UrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + VideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageAnalyticsResponse + { + BandwidthBytes = 0, + Browser = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + Cache = new() + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }, + Country = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }, + Device = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + EndDate = "2019-12-27", + ErrorReasons = + [ + new() + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }, + ], + Extensions = [new() { Name = "remove-bg", OperationCount = 0 }], + Format = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + GeneratedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + RequestCount = 0, + StartDate = "2019-12-27", + StatusCodes = [new() { Name = "200", RequestCount = 0 }], + Top404Assets = + [ + new() + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }, + ], + TopImages = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopImageTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopOtherAssets = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopReferrers = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopUserAgents = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideos = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + TopVideoTransforms = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + UrlEndpoints = new() + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }, + VideoProcessing = + [ + new() + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }, + ], + }; + + UsageAnalyticsResponse copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BrowserTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Browser + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Browser + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Browser + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Browser + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Browser + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + Browser copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + ByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BrowserByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BrowserByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BrowserByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BrowserByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BrowserByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BrowserByBandwidthEntry { Name = "name" }; + + BrowserByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + ByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class BrowserByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BrowserByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BrowserByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BrowserByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BrowserByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BrowserByRequestsEntry { Name = "name" }; + + BrowserByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UsageAnalyticsResponseCacheTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageAnalyticsResponseCache + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + + double expectedErrorCount = 0; + double expectedHitCount = 0; + double expectedMissCount = 0; + + Assert.Equal(expectedErrorCount, model.ErrorCount); + Assert.Equal(expectedHitCount, model.HitCount); + Assert.Equal(expectedMissCount, model.MissCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageAnalyticsResponseCache + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageAnalyticsResponseCache + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedErrorCount = 0; + double expectedHitCount = 0; + double expectedMissCount = 0; + + Assert.Equal(expectedErrorCount, deserialized.ErrorCount); + Assert.Equal(expectedHitCount, deserialized.HitCount); + Assert.Equal(expectedMissCount, deserialized.MissCount); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageAnalyticsResponseCache + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageAnalyticsResponseCache + { + ErrorCount = 0, + HitCount = 0, + MissCount = 0, + }; + + UsageAnalyticsResponseCache copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CountryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Country + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Country + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Country + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Country + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Country + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }, + ], + }; + + Country copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CountryByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CountryByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedCode, model.Code); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CountryByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CountryByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedCode, deserialized.Code); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CountryByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CountryByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + CountryByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CountryByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CountryByBandwidthEntry { Code = "code", Name = "name" }; + + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedCode, model.Code); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CountryByBandwidthEntry { Code = "code", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CountryByBandwidthEntry { Code = "code", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedCode, deserialized.Code); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CountryByBandwidthEntry { Code = "code", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CountryByBandwidthEntry { Code = "code", Name = "name" }; + + CountryByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CountryByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CountryByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedCode, model.Code); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CountryByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CountryByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedCode, deserialized.Code); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CountryByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CountryByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Code = "code", + Name = "name", + }; + + CountryByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class CountryByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CountryByRequestsEntry { Code = "code", Name = "name" }; + + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedCode, model.Code); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CountryByRequestsEntry { Code = "code", Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CountryByRequestsEntry { Code = "code", Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedCode = "code"; + string expectedName = "name"; + + Assert.Equal(expectedCode, deserialized.Code); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CountryByRequestsEntry { Code = "code", Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CountryByRequestsEntry { Code = "code", Name = "name" }; + + CountryByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DeviceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Device + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Device + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Device + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Device + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Device + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + Device copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DeviceByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DeviceByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DeviceByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DeviceByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new DeviceByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DeviceByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + DeviceByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DeviceByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DeviceByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DeviceByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DeviceByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new DeviceByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DeviceByBandwidthEntry { Name = "name" }; + + DeviceByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DeviceByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DeviceByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DeviceByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DeviceByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new DeviceByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DeviceByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + DeviceByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DeviceByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DeviceByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new DeviceByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new DeviceByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new DeviceByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DeviceByRequestsEntry { Name = "name" }; + + DeviceByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ErrorReasonTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ErrorReason + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }; + + string expectedName = "ENOENT - Resource not found at any upstream origin"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedRequestCount, model.RequestCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ErrorReason + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ErrorReason + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "ENOENT - Resource not found at any upstream origin"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + } + + [Fact] + public void Validation_Works() + { + var model = new ErrorReason + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ErrorReason + { + Name = "ENOENT - Resource not found at any upstream origin", + RequestCount = 0, + }; + + ErrorReason copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ExtensionTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Extension { Name = "remove-bg", OperationCount = 0 }; + + string expectedName = "remove-bg"; + double expectedOperationCount = 0; + + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedOperationCount, model.OperationCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Extension { Name = "remove-bg", OperationCount = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Extension { Name = "remove-bg", OperationCount = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "remove-bg"; + double expectedOperationCount = 0; + + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedOperationCount, deserialized.OperationCount); + } + + [Fact] + public void Validation_Works() + { + var model = new Extension { Name = "remove-bg", OperationCount = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Extension { Name = "remove-bg", OperationCount = 0 }; + + Extension copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FormatTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Format + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Format + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Format + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new Format + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Format + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + Format copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FormatByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FormatByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FormatByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FormatByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new FormatByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FormatByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + FormatByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FormatByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FormatByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FormatByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FormatByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new FormatByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FormatByBandwidthEntry { Name = "name" }; + + FormatByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FormatByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FormatByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FormatByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FormatByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new FormatByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FormatByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + FormatByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class FormatByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new FormatByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new FormatByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new FormatByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new FormatByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new FormatByRequestsEntry { Name = "name" }; + + FormatByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class StatusCodeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new StatusCode { Name = "200", RequestCount = 0 }; + + string expectedName = "200"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedRequestCount, model.RequestCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new StatusCode { Name = "200", RequestCount = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new StatusCode { Name = "200", RequestCount = 0 }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "200"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + } + + [Fact] + public void Validation_Works() + { + var model = new StatusCode { Name = "200", RequestCount = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new StatusCode { Name = "200", RequestCount = 0 }; + + StatusCode copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class Top404AssetTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Top404Asset + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }; + + string expectedName = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedRequestCount, model.RequestCount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Top404Asset + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Top404Asset + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg"; + double expectedRequestCount = 0; + + Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + } + + [Fact] + public void Validation_Works() + { + var model = new Top404Asset + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Top404Asset + { + Name = "https://ik.imagekit.io/demo/products/discontinued-sku-4421.jpg", + RequestCount = 0, + }; + + Top404Asset copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImagesTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImages + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImages + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImages + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopImages + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImages + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopImages copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImagesByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImagesByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImagesByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImagesByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImagesByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImagesByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopImagesByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImagesByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImagesByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImagesByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImagesByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImagesByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImagesByBandwidthEntry { Name = "name" }; + + TopImagesByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImagesByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImagesByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImagesByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImagesByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImagesByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImagesByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopImagesByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImagesByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImagesByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImagesByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImagesByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImagesByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImagesByRequestsEntry { Name = "name" }; + + TopImagesByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImageTransformsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImageTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImageTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImageTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopImageTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImageTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopImageTransforms copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImageTransformsByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImageTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImageTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImageTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImageTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImageTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopImageTransformsByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImageTransformsByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImageTransformsByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImageTransformsByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImageTransformsByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImageTransformsByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImageTransformsByBandwidthEntry { Name = "name" }; + + TopImageTransformsByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImageTransformsByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImageTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImageTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImageTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImageTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImageTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopImageTransformsByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopImageTransformsByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopImageTransformsByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopImageTransformsByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopImageTransformsByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopImageTransformsByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopImageTransformsByRequestsEntry { Name = "name" }; + + TopImageTransformsByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopOtherAssetsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopOtherAssets + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopOtherAssets + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopOtherAssets + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopOtherAssets + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopOtherAssets + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopOtherAssets copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopOtherAssetsByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopOtherAssetsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopOtherAssetsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopOtherAssetsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopOtherAssetsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopOtherAssetsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopOtherAssetsByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopOtherAssetsByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopOtherAssetsByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopOtherAssetsByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopOtherAssetsByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopOtherAssetsByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopOtherAssetsByBandwidthEntry { Name = "name" }; + + TopOtherAssetsByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopOtherAssetsByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopOtherAssetsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopOtherAssetsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopOtherAssetsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopOtherAssetsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopOtherAssetsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopOtherAssetsByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopOtherAssetsByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopOtherAssetsByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopOtherAssetsByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopOtherAssetsByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopOtherAssetsByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopOtherAssetsByRequestsEntry { Name = "name" }; + + TopOtherAssetsByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopReferrersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopReferrers + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopReferrers + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopReferrers + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopReferrers + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopReferrers + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopReferrers copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopReferrersByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopReferrersByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopReferrersByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopReferrersByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopReferrersByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopReferrersByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopReferrersByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopReferrersByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopReferrersByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopReferrersByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopReferrersByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopReferrersByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopReferrersByBandwidthEntry { Name = "name" }; + + TopReferrersByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopReferrersByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopReferrersByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopReferrersByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopReferrersByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopReferrersByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopReferrersByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopReferrersByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopReferrersByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopReferrersByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopReferrersByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopReferrersByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopReferrersByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopReferrersByRequestsEntry { Name = "name" }; + + TopReferrersByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopUserAgentsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopUserAgents + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopUserAgents + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopUserAgents + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopUserAgents + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUserAgents + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopUserAgents copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopUserAgentsByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopUserAgentsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopUserAgentsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopUserAgentsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopUserAgentsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUserAgentsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopUserAgentsByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopUserAgentsByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopUserAgentsByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopUserAgentsByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopUserAgentsByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopUserAgentsByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUserAgentsByBandwidthEntry { Name = "name" }; + + TopUserAgentsByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopUserAgentsByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopUserAgentsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopUserAgentsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopUserAgentsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopUserAgentsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUserAgentsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopUserAgentsByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopUserAgentsByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopUserAgentsByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopUserAgentsByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopUserAgentsByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopUserAgentsByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopUserAgentsByRequestsEntry { Name = "name" }; + + TopUserAgentsByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideosTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideos + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideos + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideos + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideos + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideos + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopVideos copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideosByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideosByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideosByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideosByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideosByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideosByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopVideosByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideosByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideosByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideosByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideosByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideosByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideosByBandwidthEntry { Name = "name" }; + + TopVideosByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideosByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideosByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideosByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideosByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideosByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideosByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopVideosByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideosByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideosByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideosByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideosByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideosByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideosByRequestsEntry { Name = "name" }; + + TopVideosByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideoTransformsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideoTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideoTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideoTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideoTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideoTransforms + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + TopVideoTransforms copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideoTransformsByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideoTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideoTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideoTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideoTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideoTransformsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopVideoTransformsByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideoTransformsByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideoTransformsByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideoTransformsByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideoTransformsByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideoTransformsByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideoTransformsByBandwidthEntry { Name = "name" }; + + TopVideoTransformsByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideoTransformsByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideoTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideoTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideoTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideoTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideoTransformsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + TopVideoTransformsByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TopVideoTransformsByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TopVideoTransformsByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TopVideoTransformsByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TopVideoTransformsByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TopVideoTransformsByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TopVideoTransformsByRequestsEntry { Name = "name" }; + + TopVideoTransformsByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UsageAnalyticsResponseUrlEndpointsTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpoints + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, model.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], model.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, model.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], model.ByRequests[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpoints + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageAnalyticsResponseUrlEndpoints + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + List expectedByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ]; + + Assert.Equal(expectedByBandwidth.Count, deserialized.ByBandwidth.Count); + for (int i = 0; i < expectedByBandwidth.Count; i++) + { + Assert.Equal(expectedByBandwidth[i], deserialized.ByBandwidth[i]); + } + Assert.Equal(expectedByRequests.Count, deserialized.ByRequests.Count); + for (int i = 0; i < expectedByRequests.Count; i++) + { + Assert.Equal(expectedByRequests[i], deserialized.ByRequests[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new UsageAnalyticsResponseUrlEndpoints + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageAnalyticsResponseUrlEndpoints + { + ByBandwidth = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + ByRequests = + [ + new() + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }, + ], + }; + + UsageAnalyticsResponseUrlEndpoints copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UsageAnalyticsResponseUrlEndpointsByBandwidthTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByBandwidth + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + UsageAnalyticsResponseUrlEndpointsByBandwidth copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointsByBandwidthEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointsByBandwidthEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointsByBandwidthEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointsByBandwidthEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointsByBandwidthEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointsByBandwidthEntry { Name = "name" }; + + UrlEndpointsByBandwidthEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UsageAnalyticsResponseUrlEndpointsByRequestTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, model.BandwidthBytes); + Assert.Equal(expectedRequestCount, model.RequestCount); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + double expectedBandwidthBytes = 0; + double expectedRequestCount = 0; + string expectedName = "name"; + + Assert.Equal(expectedBandwidthBytes, deserialized.BandwidthBytes); + Assert.Equal(expectedRequestCount, deserialized.RequestCount); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UsageAnalyticsResponseUrlEndpointsByRequest + { + BandwidthBytes = 0, + RequestCount = 0, + Name = "name", + }; + + UsageAnalyticsResponseUrlEndpointsByRequest copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UrlEndpointsByRequestsEntryTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UrlEndpointsByRequestsEntry { Name = "name" }; + + string expectedName = "name"; + + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UrlEndpointsByRequestsEntry { Name = "name" }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UrlEndpointsByRequestsEntry { Name = "name" }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedName = "name"; + + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UrlEndpointsByRequestsEntry { Name = "name" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UrlEndpointsByRequestsEntry { Name = "name" }; + + UrlEndpointsByRequestsEntry copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class VideoProcessingTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new VideoProcessing + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }; + + string expectedCodec = "codec"; + double expectedDurationSeconds = 0; + string expectedResolution = "resolution"; + + Assert.Equal(expectedCodec, model.Codec); + Assert.Equal(expectedDurationSeconds, model.DurationSeconds); + Assert.Equal(expectedResolution, model.Resolution); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new VideoProcessing + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new VideoProcessing + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedCodec = "codec"; + double expectedDurationSeconds = 0; + string expectedResolution = "resolution"; + + Assert.Equal(expectedCodec, deserialized.Codec); + Assert.Equal(expectedDurationSeconds, deserialized.DurationSeconds); + Assert.Equal(expectedResolution, deserialized.Resolution); + } + + [Fact] + public void Validation_Works() + { + var model = new VideoProcessing + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new VideoProcessing + { + Codec = "codec", + DurationSeconds = 0, + Resolution = "resolution", + }; + + VideoProcessing copied = new(model); + + Assert.Equal(model, copied); + } +} diff --git a/src/Imagekit.Tests/Services/Accounts/UsageAnalyticsServiceTest.cs b/src/Imagekit.Tests/Services/Accounts/UsageAnalyticsServiceTest.cs new file mode 100644 index 00000000..9b086040 --- /dev/null +++ b/src/Imagekit.Tests/Services/Accounts/UsageAnalyticsServiceTest.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; + +namespace Imagekit.Tests.Services.Accounts; + +public class UsageAnalyticsServiceTest : TestBase +{ + [Fact(Skip = "Mock server tests are disabled")] + public async Task Get_Works() + { + var usageAnalyticsResponse = await this.client.Accounts.UsageAnalytics.Get( + new() { EndDate = "2019-12-27", StartDate = "2019-12-27" }, + TestContext.Current.CancellationToken + ); + usageAnalyticsResponse.Validate(); + } +} diff --git a/src/Imagekit/Imagekit.csproj b/src/Imagekit/Imagekit.csproj index 98501db0..e3a0a2c9 100644 --- a/src/Imagekit/Imagekit.csproj +++ b/src/Imagekit/Imagekit.csproj @@ -3,7 +3,7 @@ Image Kit C# Imagekit - 6.1.0 + 6.2.0 The official .NET library for the Image Kit API. Library README.md diff --git a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs index bea20afe..0c55bcec 100644 --- a/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs +++ b/src/Imagekit/Models/Accounts/Usage/UsageGetParams.cs @@ -14,6 +14,11 @@ namespace Imagekit.Models.Accounts.Usage; /// words, the data covers the period starting from the specified start date up to, /// but not including, the end date. /// +/// For an agency account, the returned usage is aggregated across the agency +/// and all of its child accounts that are billed to it. +/// +/// The response is cached for 6 hours per account, date range and requested metrics. +/// /// NOTE: Do not inherit from this type outside the SDK unless you're okay with /// breaking changes in non-major versions. We may add new methods in the future that /// cause existing derived classes to break. diff --git a/src/Imagekit/Models/Accounts/UsageAnalytics/RequestBandwidthEntry.cs b/src/Imagekit/Models/Accounts/UsageAnalytics/RequestBandwidthEntry.cs new file mode 100644 index 00000000..79d63198 --- /dev/null +++ b/src/Imagekit/Models/Accounts/UsageAnalytics/RequestBandwidthEntry.cs @@ -0,0 +1,82 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Accounts.UsageAnalytics; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RequestBandwidthEntry : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + } + + public RequestBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RequestBandwidthEntry(RequestBandwidthEntry requestBandwidthEntry) + : base(requestBandwidthEntry) { } +#pragma warning restore CS8618 + + public RequestBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + RequestBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static RequestBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class RequestBandwidthEntryFromRaw : IFromRawJson +{ + /// + public RequestBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => RequestBandwidthEntry.FromRawUnchecked(rawData); +} diff --git a/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParams.cs b/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParams.cs new file mode 100644 index 00000000..253d0a40 --- /dev/null +++ b/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsGetParams.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Imagekit.Core; + +namespace Imagekit.Models.Accounts.UsageAnalytics; + +/// +/// **Note:** This API is currently in beta. +/// +/// Get the account analytics data between two dates. The response covers the +/// period from the start date to the end date, both dates inclusive. Both dates +/// are interpreted as UTC calendar days. +/// +/// The returned data is scoped to the requesting account only. Unlike `/v1/accounts/usage`, +/// an agency account's analytics are not aggregated across its child accounts. +/// +/// The response is cached for 5 minutes per account and date range. Use `generatedAt` +/// to check how fresh the returned data is. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UsageAnalyticsGetParams : ParamsBase +{ + /// + /// Specify an `endDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar + /// day. It should be after the `startDate`. The difference between `startDate` + /// and `endDate` should be less than 90 days. + /// + public required string EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("endDate"); + } + init { this._rawQueryData.Set("endDate", value); } + } + + /// + /// Specify a `startDate` in `YYYY-MM-DD` format, interpreted as a UTC calendar + /// day. It should be before the `endDate`. The difference between `startDate` + /// and `endDate` should be less than 90 days. + /// + public required string StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("startDate"); + } + init { this._rawQueryData.Set("startDate", value); } + } + + public UsageAnalyticsGetParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsGetParams(UsageAnalyticsGetParams usageAnalyticsGetParams) + : base(usageAnalyticsGetParams) { } +#pragma warning restore CS8618 + + public UsageAnalyticsGetParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsGetParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsGetParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageAnalyticsGetParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + "/v1/accounts/usage-analytics" + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsResponse.cs b/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsResponse.cs new file mode 100644 index 00000000..7a568be7 --- /dev/null +++ b/src/Imagekit/Models/Accounts/UsageAnalytics/UsageAnalyticsResponse.cs @@ -0,0 +1,6085 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Imagekit.Core; + +namespace Imagekit.Models.Accounts.UsageAnalytics; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UsageAnalyticsResponse : JsonModel +{ + /// + /// Total bandwidth, in bytes, utilized during the specified date range. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// CDN traffic grouped by browser. + /// + public required Browser Browser + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("browser"); + } + init { this._rawData.Set("browser", value); } + } + + /// + /// CDN cache hit, miss and error counts for the date range. + /// + public required UsageAnalyticsResponseCache Cache + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cache"); + } + init { this._rawData.Set("cache", value); } + } + + /// + /// CDN traffic grouped by country. + /// + public required Country Country + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("country"); + } + init { this._rawData.Set("country", value); } + } + + /// + /// CDN traffic grouped by device and operating system (e.g. `Desktop - Apple + /// Mac`, `Smartphone - Apple iPhone`). + /// + public required Device Device + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("device"); + } + init { this._rawData.Set("device", value); } + } + + /// + /// End date of the computed analytics data. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("endDate"); + } + init { this._rawData.Set("endDate", value); } + } + + /// + /// Request count grouped by origin error reason. This covers failed origin fetches, + /// such as an asset not found at origin or an origin timeout. It is not the + /// HTTP status code returned to the client, see `statusCodes` for that. + /// + public required IReadOnlyList ErrorReasons + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("errorReasons"); + } + init + { + this._rawData.Set>( + "errorReasons", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Raw per-extension operation counts for the date range. These are raw operation + /// counts, not billable extension units. For billable usage, use the `/v1/accounts/usage` endpoint. + /// + public required IReadOnlyList Extensions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("extensions"); + } + init + { + this._rawData.Set>( + "extensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// CDN traffic grouped by response `Content-Type`. + /// + public required Format Format + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("format"); + } + init { this._rawData.Set("format", value); } + } + + /// + /// Date and time when the analytics data was computed. Use this to gauge how + /// fresh the returned data is. The date and time is in ISO8601 format. + /// + public required DateTimeOffset GeneratedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("generatedAt"); + } + init { this._rawData.Set("generatedAt", value); } + } + + /// + /// Total number of requests made during the specified date range. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Start date of the computed analytics data. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("startDate"); + } + init { this._rawData.Set("startDate", value); } + } + + /// + /// Request count grouped by HTTP status code. + /// + public required IReadOnlyList StatusCodes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("statusCodes"); + } + init + { + this._rawData.Set>( + "statusCodes", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top URLs that returned a 404 response. + /// + public required IReadOnlyList Top404Assets + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("top404Assets"); + } + init + { + this._rawData.Set>( + "top404Assets", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top image assets by traffic. + /// + public required TopImages TopImages + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topImages"); + } + init { this._rawData.Set("topImages", value); } + } + + /// + /// Top image transformation strings by traffic. + /// + public required TopImageTransforms TopImageTransforms + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topImageTransforms"); + } + init { this._rawData.Set("topImageTransforms", value); } + } + + /// + /// Top non-image, non-video assets by traffic. + /// + public required TopOtherAssets TopOtherAssets + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topOtherAssets"); + } + init { this._rawData.Set("topOtherAssets", value); } + } + + /// + /// Top HTTP referrers by traffic. + /// + public required TopReferrers TopReferrers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topReferrers"); + } + init { this._rawData.Set("topReferrers", value); } + } + + /// + /// Top user agents by traffic. + /// + public required TopUserAgents TopUserAgents + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topUserAgents"); + } + init { this._rawData.Set("topUserAgents", value); } + } + + /// + /// Top video assets by traffic. + /// + public required TopVideos TopVideos + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topVideos"); + } + init { this._rawData.Set("topVideos", value); } + } + + /// + /// Top video transformation strings by traffic. + /// + public required TopVideoTransforms TopVideoTransforms + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("topVideoTransforms"); + } + init { this._rawData.Set("topVideoTransforms", value); } + } + + /// + /// CDN traffic grouped by configured URL endpoint. Traffic that does not match + /// any named URL endpoint pattern is grouped under `Default`. + /// + public required UsageAnalyticsResponseUrlEndpoints UrlEndpoints + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "urlEndpoints" + ); + } + init { this._rawData.Set("urlEndpoints", value); } + } + + /// + /// Raw observed video transcode output duration, in seconds, grouped by resolution + /// and codec. These are raw seconds, not billable Video Processing Units (VPU). + /// For billable VPU totals, use the `/v1/accounts/usage` endpoint. + /// + public required IReadOnlyList VideoProcessing + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "videoProcessing" + ); + } + init + { + this._rawData.Set>( + "videoProcessing", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + this.Browser.Validate(); + this.Cache.Validate(); + this.Country.Validate(); + this.Device.Validate(); + _ = this.EndDate; + foreach (var item in this.ErrorReasons) + { + item.Validate(); + } + foreach (var item in this.Extensions) + { + item.Validate(); + } + this.Format.Validate(); + _ = this.GeneratedAt; + _ = this.RequestCount; + _ = this.StartDate; + foreach (var item in this.StatusCodes) + { + item.Validate(); + } + foreach (var item in this.Top404Assets) + { + item.Validate(); + } + this.TopImages.Validate(); + this.TopImageTransforms.Validate(); + this.TopOtherAssets.Validate(); + this.TopReferrers.Validate(); + this.TopUserAgents.Validate(); + this.TopVideos.Validate(); + this.TopVideoTransforms.Validate(); + this.UrlEndpoints.Validate(); + foreach (var item in this.VideoProcessing) + { + item.Validate(); + } + } + + public UsageAnalyticsResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsResponse(UsageAnalyticsResponse usageAnalyticsResponse) + : base(usageAnalyticsResponse) { } +#pragma warning restore CS8618 + + public UsageAnalyticsResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageAnalyticsResponseFromRaw : IFromRawJson +{ + /// + public UsageAnalyticsResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageAnalyticsResponse.FromRawUnchecked(rawData); +} + +/// +/// CDN traffic grouped by browser. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Browser : JsonModel +{ + /// + /// Top browsers sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byBandwidth"); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top browsers sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public Browser() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Browser(Browser browser) + : base(browser) { } +#pragma warning restore CS8618 + + public Browser(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Browser(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Browser FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BrowserFromRaw : IFromRawJson +{ + /// + public Browser FromRawUnchecked(IReadOnlyDictionary rawData) => + Browser.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Browser name (e.g. `Chrome`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(ByBandwidth byBandwidth) => + new() + { + BandwidthBytes = byBandwidth.BandwidthBytes, + RequestCount = byBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public ByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ByBandwidth(ByBandwidth byBandwidth) + : base(byBandwidth) { } +#pragma warning restore CS8618 + + public ByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ByBandwidth FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ByBandwidthFromRaw : IFromRawJson +{ + /// + public ByBandwidth FromRawUnchecked(IReadOnlyDictionary rawData) => + ByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BrowserByBandwidthEntry : JsonModel +{ + /// + /// Browser name (e.g. `Chrome`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public BrowserByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BrowserByBandwidthEntry(BrowserByBandwidthEntry browserByBandwidthEntry) + : base(browserByBandwidthEntry) { } +#pragma warning restore CS8618 + + public BrowserByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BrowserByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BrowserByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BrowserByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class BrowserByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public BrowserByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BrowserByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Browser name (e.g. `Chrome`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(ByRequest byRequest) => + new() { BandwidthBytes = byRequest.BandwidthBytes, RequestCount = byRequest.RequestCount }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public ByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ByRequest(ByRequest byRequest) + : base(byRequest) { } +#pragma warning restore CS8618 + + public ByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ByRequest FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ByRequestFromRaw : IFromRawJson +{ + /// + public ByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + ByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class BrowserByRequestsEntry : JsonModel +{ + /// + /// Browser name (e.g. `Chrome`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public BrowserByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BrowserByRequestsEntry(BrowserByRequestsEntry browserByRequestsEntry) + : base(browserByRequestsEntry) { } +#pragma warning restore CS8618 + + public BrowserByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BrowserByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BrowserByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public BrowserByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class BrowserByRequestsEntryFromRaw : IFromRawJson +{ + /// + public BrowserByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BrowserByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// CDN cache hit, miss and error counts for the date range. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UsageAnalyticsResponseCache : JsonModel +{ + /// + /// Number of requests where the CDN encountered a cache error or exceeded capacity + /// while serving the response. + /// + public required double ErrorCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("errorCount"); + } + init { this._rawData.Set("errorCount", value); } + } + + /// + /// Number of requests served from cache, including full hits and revalidated hits. + /// + public required double HitCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("hitCount"); + } + init { this._rawData.Set("hitCount", value); } + } + + /// + /// Number of requests that were not found in cache and had to be fetched from origin. + /// + public required double MissCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("missCount"); + } + init { this._rawData.Set("missCount", value); } + } + + /// + public override void Validate() + { + _ = this.ErrorCount; + _ = this.HitCount; + _ = this.MissCount; + } + + public UsageAnalyticsResponseCache() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsResponseCache(UsageAnalyticsResponseCache usageAnalyticsResponseCache) + : base(usageAnalyticsResponseCache) { } +#pragma warning restore CS8618 + + public UsageAnalyticsResponseCache(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsResponseCache(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsResponseCache FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageAnalyticsResponseCacheFromRaw : IFromRawJson +{ + /// + public UsageAnalyticsResponseCache FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageAnalyticsResponseCache.FromRawUnchecked(rawData); +} + +/// +/// CDN traffic grouped by country. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Country : JsonModel +{ + /// + /// Top requesting countries sorted by total bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top requesting countries sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public Country() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Country(Country country) + : base(country) { } +#pragma warning restore CS8618 + + public Country(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Country(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Country FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CountryFromRaw : IFromRawJson +{ + /// + public Country FromRawUnchecked(IReadOnlyDictionary rawData) => + Country.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CountryByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// ISO country code. + /// + public required string Code + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("code"); + } + init { this._rawData.Set("code", value); } + } + + /// + /// Country name. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(CountryByBandwidth countryByBandwidth) => + new() + { + BandwidthBytes = countryByBandwidth.BandwidthBytes, + RequestCount = countryByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Code; + _ = this.Name; + } + + public CountryByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CountryByBandwidth(CountryByBandwidth countryByBandwidth) + : base(countryByBandwidth) { } +#pragma warning restore CS8618 + + public CountryByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CountryByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CountryByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CountryByBandwidthFromRaw : IFromRawJson +{ + /// + public CountryByBandwidth FromRawUnchecked(IReadOnlyDictionary rawData) => + CountryByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CountryByBandwidthEntry : JsonModel +{ + /// + /// ISO country code. + /// + public required string Code + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("code"); + } + init { this._rawData.Set("code", value); } + } + + /// + /// Country name. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Code; + _ = this.Name; + } + + public CountryByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CountryByBandwidthEntry(CountryByBandwidthEntry countryByBandwidthEntry) + : base(countryByBandwidthEntry) { } +#pragma warning restore CS8618 + + public CountryByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CountryByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CountryByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CountryByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public CountryByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CountryByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CountryByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// ISO country code. + /// + public required string Code + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("code"); + } + init { this._rawData.Set("code", value); } + } + + /// + /// Country name. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(CountryByRequest countryByRequest) => + new() + { + BandwidthBytes = countryByRequest.BandwidthBytes, + RequestCount = countryByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Code; + _ = this.Name; + } + + public CountryByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CountryByRequest(CountryByRequest countryByRequest) + : base(countryByRequest) { } +#pragma warning restore CS8618 + + public CountryByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CountryByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CountryByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CountryByRequestFromRaw : IFromRawJson +{ + /// + public CountryByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + CountryByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class CountryByRequestsEntry : JsonModel +{ + /// + /// ISO country code. + /// + public required string Code + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("code"); + } + init { this._rawData.Set("code", value); } + } + + /// + /// Country name. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Code; + _ = this.Name; + } + + public CountryByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CountryByRequestsEntry(CountryByRequestsEntry countryByRequestsEntry) + : base(countryByRequestsEntry) { } +#pragma warning restore CS8618 + + public CountryByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CountryByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CountryByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CountryByRequestsEntryFromRaw : IFromRawJson +{ + /// + public CountryByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CountryByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// CDN traffic grouped by device and operating system (e.g. `Desktop - Apple Mac`, +/// `Smartphone - Apple iPhone`). +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Device : JsonModel +{ + /// + /// Top device/OS combinations sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byBandwidth"); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top device/OS combinations sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public Device() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Device(Device device) + : base(device) { } +#pragma warning restore CS8618 + + public Device(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Device(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Device FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DeviceFromRaw : IFromRawJson +{ + /// + public Device FromRawUnchecked(IReadOnlyDictionary rawData) => + Device.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DeviceByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Device category combined with operating system or vendor (e.g. `Desktop - + /// Windows PC`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(DeviceByBandwidth deviceByBandwidth) => + new() + { + BandwidthBytes = deviceByBandwidth.BandwidthBytes, + RequestCount = deviceByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public DeviceByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DeviceByBandwidth(DeviceByBandwidth deviceByBandwidth) + : base(deviceByBandwidth) { } +#pragma warning restore CS8618 + + public DeviceByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DeviceByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DeviceByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DeviceByBandwidthFromRaw : IFromRawJson +{ + /// + public DeviceByBandwidth FromRawUnchecked(IReadOnlyDictionary rawData) => + DeviceByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DeviceByBandwidthEntry : JsonModel +{ + /// + /// Device category combined with operating system or vendor (e.g. `Desktop - + /// Windows PC`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public DeviceByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DeviceByBandwidthEntry(DeviceByBandwidthEntry deviceByBandwidthEntry) + : base(deviceByBandwidthEntry) { } +#pragma warning restore CS8618 + + public DeviceByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DeviceByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DeviceByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public DeviceByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class DeviceByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public DeviceByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DeviceByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DeviceByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Device category combined with operating system or vendor (e.g. `Desktop - + /// Windows PC`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(DeviceByRequest deviceByRequest) => + new() + { + BandwidthBytes = deviceByRequest.BandwidthBytes, + RequestCount = deviceByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public DeviceByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DeviceByRequest(DeviceByRequest deviceByRequest) + : base(deviceByRequest) { } +#pragma warning restore CS8618 + + public DeviceByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DeviceByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DeviceByRequest FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DeviceByRequestFromRaw : IFromRawJson +{ + /// + public DeviceByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + DeviceByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DeviceByRequestsEntry : JsonModel +{ + /// + /// Device category combined with operating system or vendor (e.g. `Desktop - + /// Windows PC`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public DeviceByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DeviceByRequestsEntry(DeviceByRequestsEntry deviceByRequestsEntry) + : base(deviceByRequestsEntry) { } +#pragma warning restore CS8618 + + public DeviceByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DeviceByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DeviceByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public DeviceByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class DeviceByRequestsEntryFromRaw : IFromRawJson +{ + /// + public DeviceByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DeviceByRequestsEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ErrorReason : JsonModel +{ + /// + /// Description of the error reason. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Number of requests that failed with this error reason. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + _ = this.RequestCount; + } + + public ErrorReason() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ErrorReason(ErrorReason errorReason) + : base(errorReason) { } +#pragma warning restore CS8618 + + public ErrorReason(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ErrorReason(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ErrorReason FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ErrorReasonFromRaw : IFromRawJson +{ + /// + public ErrorReason FromRawUnchecked(IReadOnlyDictionary rawData) => + ErrorReason.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Extension : JsonModel +{ + /// + /// Extension identifier. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Number of times this extension ran during the date range. + /// + public required double OperationCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("operationCount"); + } + init { this._rawData.Set("operationCount", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + _ = this.OperationCount; + } + + public Extension() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Extension(Extension extension) + : base(extension) { } +#pragma warning restore CS8618 + + public Extension(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Extension(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Extension FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExtensionFromRaw : IFromRawJson +{ + /// + public Extension FromRawUnchecked(IReadOnlyDictionary rawData) => + Extension.FromRawUnchecked(rawData); +} + +/// +/// CDN traffic grouped by response `Content-Type`. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Format : JsonModel +{ + /// + /// Top content types sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byBandwidth"); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top content types sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public Format() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Format(Format format) + : base(format) { } +#pragma warning restore CS8618 + + public Format(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Format(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Format FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FormatFromRaw : IFromRawJson +{ + /// + public Format FromRawUnchecked(IReadOnlyDictionary rawData) => + Format.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FormatByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// MIME type (e.g. `image/webp`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(FormatByBandwidth formatByBandwidth) => + new() + { + BandwidthBytes = formatByBandwidth.BandwidthBytes, + RequestCount = formatByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public FormatByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FormatByBandwidth(FormatByBandwidth formatByBandwidth) + : base(formatByBandwidth) { } +#pragma warning restore CS8618 + + public FormatByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FormatByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FormatByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FormatByBandwidthFromRaw : IFromRawJson +{ + /// + public FormatByBandwidth FromRawUnchecked(IReadOnlyDictionary rawData) => + FormatByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FormatByBandwidthEntry : JsonModel +{ + /// + /// MIME type (e.g. `image/webp`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public FormatByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FormatByBandwidthEntry(FormatByBandwidthEntry formatByBandwidthEntry) + : base(formatByBandwidthEntry) { } +#pragma warning restore CS8618 + + public FormatByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FormatByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FormatByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FormatByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class FormatByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public FormatByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FormatByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FormatByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// MIME type (e.g. `image/webp`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(FormatByRequest formatByRequest) => + new() + { + BandwidthBytes = formatByRequest.BandwidthBytes, + RequestCount = formatByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public FormatByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FormatByRequest(FormatByRequest formatByRequest) + : base(formatByRequest) { } +#pragma warning restore CS8618 + + public FormatByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FormatByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FormatByRequest FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class FormatByRequestFromRaw : IFromRawJson +{ + /// + public FormatByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + FormatByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class FormatByRequestsEntry : JsonModel +{ + /// + /// MIME type (e.g. `image/webp`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public FormatByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FormatByRequestsEntry(FormatByRequestsEntry formatByRequestsEntry) + : base(formatByRequestsEntry) { } +#pragma warning restore CS8618 + + public FormatByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + FormatByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static FormatByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public FormatByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class FormatByRequestsEntryFromRaw : IFromRawJson +{ + /// + public FormatByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => FormatByRequestsEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class StatusCode : JsonModel +{ + /// + /// HTTP status code. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Number of requests that received this status code. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + _ = this.RequestCount; + } + + public StatusCode() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public StatusCode(StatusCode statusCode) + : base(statusCode) { } +#pragma warning restore CS8618 + + public StatusCode(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + StatusCode(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static StatusCode FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class StatusCodeFromRaw : IFromRawJson +{ + /// + public StatusCode FromRawUnchecked(IReadOnlyDictionary rawData) => + StatusCode.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Top404Asset : JsonModel +{ + /// + /// URL that returned a 404 response. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Number of requests to this URL that returned a 404 response. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + _ = this.RequestCount; + } + + public Top404Asset() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Top404Asset(Top404Asset top404Asset) + : base(top404Asset) { } +#pragma warning restore CS8618 + + public Top404Asset(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Top404Asset(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Top404Asset FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class Top404AssetFromRaw : IFromRawJson +{ + /// + public Top404Asset FromRawUnchecked(IReadOnlyDictionary rawData) => + Top404Asset.FromRawUnchecked(rawData); +} + +/// +/// Top image assets by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopImages : JsonModel +{ + /// + /// Top image assets sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top image assets sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopImages() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImages(TopImages topImages) + : base(topImages) { } +#pragma warning restore CS8618 + + public TopImages(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImages(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImages FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImagesFromRaw : IFromRawJson +{ + /// + public TopImages FromRawUnchecked(IReadOnlyDictionary rawData) => + TopImages.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopImagesByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL of the image asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopImagesByBandwidth topImagesByBandwidth + ) => + new() + { + BandwidthBytes = topImagesByBandwidth.BandwidthBytes, + RequestCount = topImagesByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopImagesByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImagesByBandwidth(TopImagesByBandwidth topImagesByBandwidth) + : base(topImagesByBandwidth) { } +#pragma warning restore CS8618 + + public TopImagesByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImagesByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImagesByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImagesByBandwidthFromRaw : IFromRawJson +{ + /// + public TopImagesByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImagesByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopImagesByBandwidthEntry : JsonModel +{ + /// + /// URL of the image asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopImagesByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImagesByBandwidthEntry(TopImagesByBandwidthEntry topImagesByBandwidthEntry) + : base(topImagesByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopImagesByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImagesByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImagesByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopImagesByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopImagesByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopImagesByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImagesByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopImagesByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL of the image asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(TopImagesByRequest topImagesByRequest) => + new() + { + BandwidthBytes = topImagesByRequest.BandwidthBytes, + RequestCount = topImagesByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopImagesByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImagesByRequest(TopImagesByRequest topImagesByRequest) + : base(topImagesByRequest) { } +#pragma warning restore CS8618 + + public TopImagesByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImagesByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImagesByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImagesByRequestFromRaw : IFromRawJson +{ + /// + public TopImagesByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + TopImagesByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopImagesByRequestsEntry : JsonModel +{ + /// + /// URL of the image asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopImagesByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImagesByRequestsEntry(TopImagesByRequestsEntry topImagesByRequestsEntry) + : base(topImagesByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopImagesByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImagesByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImagesByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopImagesByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopImagesByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopImagesByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImagesByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top image transformation strings by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopImageTransforms : JsonModel +{ + /// + /// Top image transformation strings sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top image transformation strings sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byRequests" + ); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopImageTransforms() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImageTransforms(TopImageTransforms topImageTransforms) + : base(topImageTransforms) { } +#pragma warning restore CS8618 + + public TopImageTransforms(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImageTransforms(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImageTransforms FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImageTransformsFromRaw : IFromRawJson +{ + /// + public TopImageTransforms FromRawUnchecked(IReadOnlyDictionary rawData) => + TopImageTransforms.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopImageTransformsByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Image transformation string (e.g. `tr:w-400,h-400`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopImageTransformsByBandwidth topImageTransformsByBandwidth + ) => + new() + { + BandwidthBytes = topImageTransformsByBandwidth.BandwidthBytes, + RequestCount = topImageTransformsByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopImageTransformsByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImageTransformsByBandwidth( + TopImageTransformsByBandwidth topImageTransformsByBandwidth + ) + : base(topImageTransformsByBandwidth) { } +#pragma warning restore CS8618 + + public TopImageTransformsByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImageTransformsByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImageTransformsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImageTransformsByBandwidthFromRaw : IFromRawJson +{ + /// + public TopImageTransformsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImageTransformsByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TopImageTransformsByBandwidthEntry, + TopImageTransformsByBandwidthEntryFromRaw + >) +)] +public sealed record class TopImageTransformsByBandwidthEntry : JsonModel +{ + /// + /// Image transformation string (e.g. `tr:w-400,h-400`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopImageTransformsByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImageTransformsByBandwidthEntry( + TopImageTransformsByBandwidthEntry topImageTransformsByBandwidthEntry + ) + : base(topImageTransformsByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopImageTransformsByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImageTransformsByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImageTransformsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopImageTransformsByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopImageTransformsByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopImageTransformsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImageTransformsByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopImageTransformsByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Image transformation string (e.g. `tr:w-400,h-400`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopImageTransformsByRequest topImageTransformsByRequest + ) => + new() + { + BandwidthBytes = topImageTransformsByRequest.BandwidthBytes, + RequestCount = topImageTransformsByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopImageTransformsByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImageTransformsByRequest(TopImageTransformsByRequest topImageTransformsByRequest) + : base(topImageTransformsByRequest) { } +#pragma warning restore CS8618 + + public TopImageTransformsByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImageTransformsByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImageTransformsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopImageTransformsByRequestFromRaw : IFromRawJson +{ + /// + public TopImageTransformsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImageTransformsByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TopImageTransformsByRequestsEntry, + TopImageTransformsByRequestsEntryFromRaw + >) +)] +public sealed record class TopImageTransformsByRequestsEntry : JsonModel +{ + /// + /// Image transformation string (e.g. `tr:w-400,h-400`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopImageTransformsByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopImageTransformsByRequestsEntry( + TopImageTransformsByRequestsEntry topImageTransformsByRequestsEntry + ) + : base(topImageTransformsByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopImageTransformsByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopImageTransformsByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopImageTransformsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopImageTransformsByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopImageTransformsByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopImageTransformsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopImageTransformsByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top non-image, non-video assets by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopOtherAssets : JsonModel +{ + /// + /// Top non-image, non-video assets sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top non-image, non-video assets sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byRequests" + ); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopOtherAssets() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopOtherAssets(TopOtherAssets topOtherAssets) + : base(topOtherAssets) { } +#pragma warning restore CS8618 + + public TopOtherAssets(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopOtherAssets(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopOtherAssets FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopOtherAssetsFromRaw : IFromRawJson +{ + /// + public TopOtherAssets FromRawUnchecked(IReadOnlyDictionary rawData) => + TopOtherAssets.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopOtherAssetsByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL of the non-image, non-video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopOtherAssetsByBandwidth topOtherAssetsByBandwidth + ) => + new() + { + BandwidthBytes = topOtherAssetsByBandwidth.BandwidthBytes, + RequestCount = topOtherAssetsByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopOtherAssetsByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopOtherAssetsByBandwidth(TopOtherAssetsByBandwidth topOtherAssetsByBandwidth) + : base(topOtherAssetsByBandwidth) { } +#pragma warning restore CS8618 + + public TopOtherAssetsByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopOtherAssetsByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopOtherAssetsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopOtherAssetsByBandwidthFromRaw : IFromRawJson +{ + /// + public TopOtherAssetsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopOtherAssetsByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TopOtherAssetsByBandwidthEntry, + TopOtherAssetsByBandwidthEntryFromRaw + >) +)] +public sealed record class TopOtherAssetsByBandwidthEntry : JsonModel +{ + /// + /// URL of the non-image, non-video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopOtherAssetsByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopOtherAssetsByBandwidthEntry( + TopOtherAssetsByBandwidthEntry topOtherAssetsByBandwidthEntry + ) + : base(topOtherAssetsByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopOtherAssetsByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopOtherAssetsByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopOtherAssetsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopOtherAssetsByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopOtherAssetsByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopOtherAssetsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopOtherAssetsByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopOtherAssetsByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL of the non-image, non-video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopOtherAssetsByRequest topOtherAssetsByRequest + ) => + new() + { + BandwidthBytes = topOtherAssetsByRequest.BandwidthBytes, + RequestCount = topOtherAssetsByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopOtherAssetsByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopOtherAssetsByRequest(TopOtherAssetsByRequest topOtherAssetsByRequest) + : base(topOtherAssetsByRequest) { } +#pragma warning restore CS8618 + + public TopOtherAssetsByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopOtherAssetsByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopOtherAssetsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopOtherAssetsByRequestFromRaw : IFromRawJson +{ + /// + public TopOtherAssetsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopOtherAssetsByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopOtherAssetsByRequestsEntry : JsonModel +{ + /// + /// URL of the non-image, non-video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopOtherAssetsByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopOtherAssetsByRequestsEntry( + TopOtherAssetsByRequestsEntry topOtherAssetsByRequestsEntry + ) + : base(topOtherAssetsByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopOtherAssetsByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopOtherAssetsByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopOtherAssetsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopOtherAssetsByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopOtherAssetsByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopOtherAssetsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopOtherAssetsByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top HTTP referrers by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopReferrers : JsonModel +{ + /// + /// Top HTTP referrers sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top HTTP referrers sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byRequests" + ); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopReferrers() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopReferrers(TopReferrers topReferrers) + : base(topReferrers) { } +#pragma warning restore CS8618 + + public TopReferrers(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopReferrers(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopReferrers FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopReferrersFromRaw : IFromRawJson +{ + /// + public TopReferrers FromRawUnchecked(IReadOnlyDictionary rawData) => + TopReferrers.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopReferrersByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Referrer URL. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopReferrersByBandwidth topReferrersByBandwidth + ) => + new() + { + BandwidthBytes = topReferrersByBandwidth.BandwidthBytes, + RequestCount = topReferrersByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopReferrersByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopReferrersByBandwidth(TopReferrersByBandwidth topReferrersByBandwidth) + : base(topReferrersByBandwidth) { } +#pragma warning restore CS8618 + + public TopReferrersByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopReferrersByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopReferrersByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopReferrersByBandwidthFromRaw : IFromRawJson +{ + /// + public TopReferrersByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopReferrersByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopReferrersByBandwidthEntry : JsonModel +{ + /// + /// Referrer URL. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopReferrersByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopReferrersByBandwidthEntry(TopReferrersByBandwidthEntry topReferrersByBandwidthEntry) + : base(topReferrersByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopReferrersByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopReferrersByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopReferrersByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopReferrersByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopReferrersByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopReferrersByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopReferrersByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopReferrersByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Referrer URL. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopReferrersByRequest topReferrersByRequest + ) => + new() + { + BandwidthBytes = topReferrersByRequest.BandwidthBytes, + RequestCount = topReferrersByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopReferrersByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopReferrersByRequest(TopReferrersByRequest topReferrersByRequest) + : base(topReferrersByRequest) { } +#pragma warning restore CS8618 + + public TopReferrersByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopReferrersByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopReferrersByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopReferrersByRequestFromRaw : IFromRawJson +{ + /// + public TopReferrersByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopReferrersByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopReferrersByRequestsEntry : JsonModel +{ + /// + /// Referrer URL. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopReferrersByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopReferrersByRequestsEntry(TopReferrersByRequestsEntry topReferrersByRequestsEntry) + : base(topReferrersByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopReferrersByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopReferrersByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopReferrersByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopReferrersByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopReferrersByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopReferrersByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopReferrersByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top user agents by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopUserAgents : JsonModel +{ + /// + /// Top user agents sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top user agents sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byRequests" + ); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopUserAgents() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopUserAgents(TopUserAgents topUserAgents) + : base(topUserAgents) { } +#pragma warning restore CS8618 + + public TopUserAgents(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopUserAgents(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopUserAgents FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopUserAgentsFromRaw : IFromRawJson +{ + /// + public TopUserAgents FromRawUnchecked(IReadOnlyDictionary rawData) => + TopUserAgents.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopUserAgentsByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// User agent string. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopUserAgentsByBandwidth topUserAgentsByBandwidth + ) => + new() + { + BandwidthBytes = topUserAgentsByBandwidth.BandwidthBytes, + RequestCount = topUserAgentsByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopUserAgentsByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopUserAgentsByBandwidth(TopUserAgentsByBandwidth topUserAgentsByBandwidth) + : base(topUserAgentsByBandwidth) { } +#pragma warning restore CS8618 + + public TopUserAgentsByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopUserAgentsByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopUserAgentsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopUserAgentsByBandwidthFromRaw : IFromRawJson +{ + /// + public TopUserAgentsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopUserAgentsByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopUserAgentsByBandwidthEntry : JsonModel +{ + /// + /// User agent string. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopUserAgentsByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopUserAgentsByBandwidthEntry( + TopUserAgentsByBandwidthEntry topUserAgentsByBandwidthEntry + ) + : base(topUserAgentsByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopUserAgentsByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopUserAgentsByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopUserAgentsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopUserAgentsByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopUserAgentsByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopUserAgentsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopUserAgentsByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopUserAgentsByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// User agent string. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopUserAgentsByRequest topUserAgentsByRequest + ) => + new() + { + BandwidthBytes = topUserAgentsByRequest.BandwidthBytes, + RequestCount = topUserAgentsByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopUserAgentsByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopUserAgentsByRequest(TopUserAgentsByRequest topUserAgentsByRequest) + : base(topUserAgentsByRequest) { } +#pragma warning restore CS8618 + + public TopUserAgentsByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopUserAgentsByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopUserAgentsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopUserAgentsByRequestFromRaw : IFromRawJson +{ + /// + public TopUserAgentsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopUserAgentsByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopUserAgentsByRequestsEntry : JsonModel +{ + /// + /// User agent string. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopUserAgentsByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopUserAgentsByRequestsEntry(TopUserAgentsByRequestsEntry topUserAgentsByRequestsEntry) + : base(topUserAgentsByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopUserAgentsByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopUserAgentsByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopUserAgentsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopUserAgentsByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopUserAgentsByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopUserAgentsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopUserAgentsByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top video assets by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopVideos : JsonModel +{ + /// + /// Top video assets sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top video assets sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopVideos() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideos(TopVideos topVideos) + : base(topVideos) { } +#pragma warning restore CS8618 + + public TopVideos(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideos(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideos FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideosFromRaw : IFromRawJson +{ + /// + public TopVideos FromRawUnchecked(IReadOnlyDictionary rawData) => + TopVideos.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopVideosByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL of the video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopVideosByBandwidth topVideosByBandwidth + ) => + new() + { + BandwidthBytes = topVideosByBandwidth.BandwidthBytes, + RequestCount = topVideosByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopVideosByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideosByBandwidth(TopVideosByBandwidth topVideosByBandwidth) + : base(topVideosByBandwidth) { } +#pragma warning restore CS8618 + + public TopVideosByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideosByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideosByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideosByBandwidthFromRaw : IFromRawJson +{ + /// + public TopVideosByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideosByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopVideosByBandwidthEntry : JsonModel +{ + /// + /// URL of the video asset. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopVideosByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideosByBandwidthEntry(TopVideosByBandwidthEntry topVideosByBandwidthEntry) + : base(topVideosByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopVideosByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideosByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideosByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopVideosByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopVideosByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopVideosByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideosByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopVideosByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Full URL of the video asset (e.g. `https://ik.imagekit.io/demo/clip.mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry(TopVideosByRequest topVideosByRequest) => + new() + { + BandwidthBytes = topVideosByRequest.BandwidthBytes, + RequestCount = topVideosByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopVideosByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideosByRequest(TopVideosByRequest topVideosByRequest) + : base(topVideosByRequest) { } +#pragma warning restore CS8618 + + public TopVideosByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideosByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideosByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideosByRequestFromRaw : IFromRawJson +{ + /// + public TopVideosByRequest FromRawUnchecked(IReadOnlyDictionary rawData) => + TopVideosByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopVideosByRequestsEntry : JsonModel +{ + /// + /// Full URL of the video asset (e.g. `https://ik.imagekit.io/demo/clip.mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopVideosByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideosByRequestsEntry(TopVideosByRequestsEntry topVideosByRequestsEntry) + : base(topVideosByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopVideosByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideosByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideosByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopVideosByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopVideosByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopVideosByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideosByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// Top video transformation strings by traffic. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TopVideoTransforms : JsonModel +{ + /// + /// Top video transformation strings sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byBandwidth" + ); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top video transformation strings sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "byRequests" + ); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public TopVideoTransforms() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideoTransforms(TopVideoTransforms topVideoTransforms) + : base(topVideoTransforms) { } +#pragma warning restore CS8618 + + public TopVideoTransforms(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideoTransforms(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideoTransforms FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideoTransformsFromRaw : IFromRawJson +{ + /// + public TopVideoTransforms FromRawUnchecked(IReadOnlyDictionary rawData) => + TopVideoTransforms.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopVideoTransformsByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Video transformation string (e.g. `tr:h-720,f-mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopVideoTransformsByBandwidth topVideoTransformsByBandwidth + ) => + new() + { + BandwidthBytes = topVideoTransformsByBandwidth.BandwidthBytes, + RequestCount = topVideoTransformsByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopVideoTransformsByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideoTransformsByBandwidth( + TopVideoTransformsByBandwidth topVideoTransformsByBandwidth + ) + : base(topVideoTransformsByBandwidth) { } +#pragma warning restore CS8618 + + public TopVideoTransformsByBandwidth(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideoTransformsByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideoTransformsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideoTransformsByBandwidthFromRaw : IFromRawJson +{ + /// + public TopVideoTransformsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideoTransformsByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TopVideoTransformsByBandwidthEntry, + TopVideoTransformsByBandwidthEntryFromRaw + >) +)] +public sealed record class TopVideoTransformsByBandwidthEntry : JsonModel +{ + /// + /// Video transformation string (e.g. `tr:h-720,f-mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopVideoTransformsByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideoTransformsByBandwidthEntry( + TopVideoTransformsByBandwidthEntry topVideoTransformsByBandwidthEntry + ) + : base(topVideoTransformsByBandwidthEntry) { } +#pragma warning restore CS8618 + + public TopVideoTransformsByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideoTransformsByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideoTransformsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopVideoTransformsByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopVideoTransformsByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public TopVideoTransformsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideoTransformsByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TopVideoTransformsByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// Video transformation string (e.g. `tr:h-720,f-mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + TopVideoTransformsByRequest topVideoTransformsByRequest + ) => + new() + { + BandwidthBytes = topVideoTransformsByRequest.BandwidthBytes, + RequestCount = topVideoTransformsByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public TopVideoTransformsByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideoTransformsByRequest(TopVideoTransformsByRequest topVideoTransformsByRequest) + : base(topVideoTransformsByRequest) { } +#pragma warning restore CS8618 + + public TopVideoTransformsByRequest(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideoTransformsByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideoTransformsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TopVideoTransformsByRequestFromRaw : IFromRawJson +{ + /// + public TopVideoTransformsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideoTransformsByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + TopVideoTransformsByRequestsEntry, + TopVideoTransformsByRequestsEntryFromRaw + >) +)] +public sealed record class TopVideoTransformsByRequestsEntry : JsonModel +{ + /// + /// Video transformation string (e.g. `tr:h-720,f-mp4`). + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public TopVideoTransformsByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TopVideoTransformsByRequestsEntry( + TopVideoTransformsByRequestsEntry topVideoTransformsByRequestsEntry + ) + : base(topVideoTransformsByRequestsEntry) { } +#pragma warning restore CS8618 + + public TopVideoTransformsByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TopVideoTransformsByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TopVideoTransformsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TopVideoTransformsByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class TopVideoTransformsByRequestsEntryFromRaw : IFromRawJson +{ + /// + public TopVideoTransformsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TopVideoTransformsByRequestsEntry.FromRawUnchecked(rawData); +} + +/// +/// CDN traffic grouped by configured URL endpoint. Traffic that does not match any +/// named URL endpoint pattern is grouped under `Default`. +/// +[JsonConverter( + typeof(JsonModelConverter< + UsageAnalyticsResponseUrlEndpoints, + UsageAnalyticsResponseUrlEndpointsFromRaw + >) +)] +public sealed record class UsageAnalyticsResponseUrlEndpoints : JsonModel +{ + /// + /// Top URL endpoints sorted by bandwidth utilized. + /// + public required IReadOnlyList ByBandwidth + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("byBandwidth"); + } + init + { + this._rawData.Set>( + "byBandwidth", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Top URL endpoints sorted by request count. + /// + public required IReadOnlyList ByRequests + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("byRequests"); + } + init + { + this._rawData.Set>( + "byRequests", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.ByBandwidth) + { + item.Validate(); + } + foreach (var item in this.ByRequests) + { + item.Validate(); + } + } + + public UsageAnalyticsResponseUrlEndpoints() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsResponseUrlEndpoints( + UsageAnalyticsResponseUrlEndpoints usageAnalyticsResponseUrlEndpoints + ) + : base(usageAnalyticsResponseUrlEndpoints) { } +#pragma warning restore CS8618 + + public UsageAnalyticsResponseUrlEndpoints(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsResponseUrlEndpoints(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsResponseUrlEndpoints FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageAnalyticsResponseUrlEndpointsFromRaw : IFromRawJson +{ + /// + public UsageAnalyticsResponseUrlEndpoints FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageAnalyticsResponseUrlEndpoints.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UsageAnalyticsResponseUrlEndpointsByBandwidth, + UsageAnalyticsResponseUrlEndpointsByBandwidthFromRaw + >) +)] +public sealed record class UsageAnalyticsResponseUrlEndpointsByBandwidth : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL endpoint name, or `Default` for traffic that does not match a named endpoint. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + UsageAnalyticsResponseUrlEndpointsByBandwidth usageAnalyticsResponseUrlEndpointsByBandwidth + ) => + new() + { + BandwidthBytes = usageAnalyticsResponseUrlEndpointsByBandwidth.BandwidthBytes, + RequestCount = usageAnalyticsResponseUrlEndpointsByBandwidth.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public UsageAnalyticsResponseUrlEndpointsByBandwidth() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsResponseUrlEndpointsByBandwidth( + UsageAnalyticsResponseUrlEndpointsByBandwidth usageAnalyticsResponseUrlEndpointsByBandwidth + ) + : base(usageAnalyticsResponseUrlEndpointsByBandwidth) { } +#pragma warning restore CS8618 + + public UsageAnalyticsResponseUrlEndpointsByBandwidth( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsResponseUrlEndpointsByBandwidth(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsResponseUrlEndpointsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageAnalyticsResponseUrlEndpointsByBandwidthFromRaw + : IFromRawJson +{ + /// + public UsageAnalyticsResponseUrlEndpointsByBandwidth FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageAnalyticsResponseUrlEndpointsByBandwidth.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UrlEndpointsByBandwidthEntry : JsonModel +{ + /// + /// URL endpoint name, or `Default` for traffic that does not match a named endpoint. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public UrlEndpointsByBandwidthEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointsByBandwidthEntry(UrlEndpointsByBandwidthEntry urlEndpointsByBandwidthEntry) + : base(urlEndpointsByBandwidthEntry) { } +#pragma warning restore CS8618 + + public UrlEndpointsByBandwidthEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointsByBandwidthEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UrlEndpointsByBandwidthEntry(string name) + : this() + { + this.Name = name; + } +} + +class UrlEndpointsByBandwidthEntryFromRaw : IFromRawJson +{ + /// + public UrlEndpointsByBandwidthEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UrlEndpointsByBandwidthEntry.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + UsageAnalyticsResponseUrlEndpointsByRequest, + UsageAnalyticsResponseUrlEndpointsByRequestFromRaw + >) +)] +public sealed record class UsageAnalyticsResponseUrlEndpointsByRequest : JsonModel +{ + /// + /// Total bandwidth used in bytes. + /// + public required double BandwidthBytes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("bandwidthBytes"); + } + init { this._rawData.Set("bandwidthBytes", value); } + } + + /// + /// Number of requests. + /// + public required double RequestCount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("requestCount"); + } + init { this._rawData.Set("requestCount", value); } + } + + /// + /// URL endpoint name, or `Default` for traffic that does not match a named endpoint. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + public static implicit operator RequestBandwidthEntry( + UsageAnalyticsResponseUrlEndpointsByRequest usageAnalyticsResponseUrlEndpointsByRequest + ) => + new() + { + BandwidthBytes = usageAnalyticsResponseUrlEndpointsByRequest.BandwidthBytes, + RequestCount = usageAnalyticsResponseUrlEndpointsByRequest.RequestCount, + }; + + /// + public override void Validate() + { + _ = this.BandwidthBytes; + _ = this.RequestCount; + _ = this.Name; + } + + public UsageAnalyticsResponseUrlEndpointsByRequest() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageAnalyticsResponseUrlEndpointsByRequest( + UsageAnalyticsResponseUrlEndpointsByRequest usageAnalyticsResponseUrlEndpointsByRequest + ) + : base(usageAnalyticsResponseUrlEndpointsByRequest) { } +#pragma warning restore CS8618 + + public UsageAnalyticsResponseUrlEndpointsByRequest( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageAnalyticsResponseUrlEndpointsByRequest(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageAnalyticsResponseUrlEndpointsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageAnalyticsResponseUrlEndpointsByRequestFromRaw + : IFromRawJson +{ + /// + public UsageAnalyticsResponseUrlEndpointsByRequest FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageAnalyticsResponseUrlEndpointsByRequest.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UrlEndpointsByRequestsEntry : JsonModel +{ + /// + /// URL endpoint name, or `Default` for traffic that does not match a named endpoint. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.Name; + } + + public UrlEndpointsByRequestsEntry() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UrlEndpointsByRequestsEntry(UrlEndpointsByRequestsEntry urlEndpointsByRequestsEntry) + : base(urlEndpointsByRequestsEntry) { } +#pragma warning restore CS8618 + + public UrlEndpointsByRequestsEntry(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UrlEndpointsByRequestsEntry(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UrlEndpointsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public UrlEndpointsByRequestsEntry(string name) + : this() + { + this.Name = name; + } +} + +class UrlEndpointsByRequestsEntryFromRaw : IFromRawJson +{ + /// + public UrlEndpointsByRequestsEntry FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UrlEndpointsByRequestsEntry.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class VideoProcessing : JsonModel +{ + /// + /// Video codec used for the output (e.g. `h264`, `av1`). + /// + public required string Codec + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("codec"); + } + init { this._rawData.Set("codec", value); } + } + + /// + /// Total output duration, in seconds, for this resolution and codec combination. + /// + public required double DurationSeconds + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("durationSeconds"); + } + init { this._rawData.Set("durationSeconds", value); } + } + + /// + /// Output resolution tier (e.g. `SD`, `HD`, `4K`). + /// + public required string Resolution + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("resolution"); + } + init { this._rawData.Set("resolution", value); } + } + + /// + public override void Validate() + { + _ = this.Codec; + _ = this.DurationSeconds; + _ = this.Resolution; + } + + public VideoProcessing() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public VideoProcessing(VideoProcessing videoProcessing) + : base(videoProcessing) { } +#pragma warning restore CS8618 + + public VideoProcessing(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + VideoProcessing(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static VideoProcessing FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class VideoProcessingFromRaw : IFromRawJson +{ + /// + public VideoProcessing FromRawUnchecked(IReadOnlyDictionary rawData) => + VideoProcessing.FromRawUnchecked(rawData); +} diff --git a/src/Imagekit/Services/AccountService.cs b/src/Imagekit/Services/AccountService.cs index cc3702ac..a532e814 100644 --- a/src/Imagekit/Services/AccountService.cs +++ b/src/Imagekit/Services/AccountService.cs @@ -29,6 +29,7 @@ public AccountService(IImageKitClient client) _withRawResponse = new(() => new AccountServiceWithRawResponse(client.WithRawResponse)); _usage = new(() => new UsageService(client)); + _usageAnalytics = new(() => new UsageAnalyticsService(client)); _origins = new(() => new OriginService(client)); _urlEndpoints = new(() => new UrlEndpointService(client)); } @@ -39,6 +40,12 @@ public IUsageService Usage get { return _usage.Value; } } + readonly Lazy _usageAnalytics; + public IUsageAnalyticsService UsageAnalytics + { + get { return _usageAnalytics.Value; } + } + readonly Lazy _origins; public IOriginService Origins { @@ -68,6 +75,7 @@ public AccountServiceWithRawResponse(IImageKitClientWithRawResponse client) _client = client; _usage = new(() => new UsageServiceWithRawResponse(client)); + _usageAnalytics = new(() => new UsageAnalyticsServiceWithRawResponse(client)); _origins = new(() => new OriginServiceWithRawResponse(client)); _urlEndpoints = new(() => new UrlEndpointServiceWithRawResponse(client)); } @@ -78,6 +86,12 @@ public IUsageServiceWithRawResponse Usage get { return _usage.Value; } } + readonly Lazy _usageAnalytics; + public IUsageAnalyticsServiceWithRawResponse UsageAnalytics + { + get { return _usageAnalytics.Value; } + } + readonly Lazy _origins; public IOriginServiceWithRawResponse Origins { diff --git a/src/Imagekit/Services/Accounts/IUsageAnalyticsService.cs b/src/Imagekit/Services/Accounts/IUsageAnalyticsService.cs new file mode 100644 index 00000000..3fb0f7b4 --- /dev/null +++ b/src/Imagekit/Services/Accounts/IUsageAnalyticsService.cs @@ -0,0 +1,70 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Accounts.UsageAnalytics; + +namespace Imagekit.Services.Accounts; + +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public interface IUsageAnalyticsService +{ + /// + /// Returns a view of this service that provides access to raw HTTP responses + /// for each method. + /// + IUsageAnalyticsServiceWithRawResponse WithRawResponse { get; } + + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageAnalyticsService WithOptions(Func modifier); + + /// + /// **Note:** This API is currently in beta. + /// + /// Get the account analytics data between two dates. The response covers the + /// period from the start date to the end date, both dates inclusive. Both dates are + /// interpreted as UTC calendar days. + /// + /// The returned data is scoped to the requesting account only. Unlike + /// `/v1/accounts/usage`, an agency account's analytics are not aggregated across + /// its child accounts. + /// + /// The response is cached for 5 minutes per account and date range. Use + /// `generatedAt` to check how fresh the returned data is. + /// + Task Get( + UsageAnalyticsGetParams parameters, + CancellationToken cancellationToken = default + ); +} + +/// +/// A view of that provides access to raw +/// HTTP responses for each method. +/// +public interface IUsageAnalyticsServiceWithRawResponse +{ + /// + /// Returns a view of this service with the given option modifications applied. + /// + /// The original service is not modified. + /// + IUsageAnalyticsServiceWithRawResponse WithOptions(Func modifier); + + /// + /// Returns a raw HTTP response for get /v1/accounts/usage-analytics, but is otherwise the + /// same as . + /// + Task> Get( + UsageAnalyticsGetParams parameters, + CancellationToken cancellationToken = default + ); +} diff --git a/src/Imagekit/Services/Accounts/IUsageService.cs b/src/Imagekit/Services/Accounts/IUsageService.cs index 8cdd7ea1..5da11b72 100644 --- a/src/Imagekit/Services/Accounts/IUsageService.cs +++ b/src/Imagekit/Services/Accounts/IUsageService.cs @@ -31,6 +31,12 @@ public interface IUsageService /// includes data from the start date while excluding data from the end date. In /// other words, the data covers the period starting from the specified start date /// up to, but not including, the end date. + /// + /// For an agency account, the returned usage is aggregated across the agency + /// and all of its child accounts that are billed to it. + /// + /// The response is cached for 6 hours per account, date range and requested + /// metrics. /// Task Get( UsageGetParams parameters, diff --git a/src/Imagekit/Services/Accounts/UsageAnalyticsService.cs b/src/Imagekit/Services/Accounts/UsageAnalyticsService.cs new file mode 100644 index 00000000..0ceb1c21 --- /dev/null +++ b/src/Imagekit/Services/Accounts/UsageAnalyticsService.cs @@ -0,0 +1,96 @@ +using System; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Imagekit.Core; +using Imagekit.Models.Accounts.UsageAnalytics; + +namespace Imagekit.Services.Accounts; + +/// +public sealed class UsageAnalyticsService : IUsageAnalyticsService +{ + readonly Lazy _withRawResponse; + + /// + public IUsageAnalyticsServiceWithRawResponse WithRawResponse + { + get { return _withRawResponse.Value; } + } + + readonly IImageKitClient _client; + + /// + public IUsageAnalyticsService WithOptions(Func modifier) + { + return new UsageAnalyticsService(this._client.WithOptions(modifier)); + } + + public UsageAnalyticsService(IImageKitClient client) + { + _client = client; + + _withRawResponse = new(() => + new UsageAnalyticsServiceWithRawResponse(client.WithRawResponse) + ); + } + + /// + public async Task Get( + UsageAnalyticsGetParams parameters, + CancellationToken cancellationToken = default + ) + { + using var response = await this + .WithRawResponse.Get(parameters, cancellationToken) + .ConfigureAwait(false); + return await response.Deserialize(cancellationToken).ConfigureAwait(false); + } +} + +/// +public sealed class UsageAnalyticsServiceWithRawResponse : IUsageAnalyticsServiceWithRawResponse +{ + readonly IImageKitClientWithRawResponse _client; + + /// + public IUsageAnalyticsServiceWithRawResponse WithOptions( + Func modifier + ) + { + return new UsageAnalyticsServiceWithRawResponse(this._client.WithOptions(modifier)); + } + + public UsageAnalyticsServiceWithRawResponse(IImageKitClientWithRawResponse client) + { + _client = client; + } + + /// + public async Task> Get( + UsageAnalyticsGetParams parameters, + CancellationToken cancellationToken = default + ) + { + HttpRequest request = new() + { + Method = HttpMethod.Get, + Params = parameters, + }; + var response = await this._client.Execute(request, cancellationToken).ConfigureAwait(false); + return new( + response, + async (token) => + { + var usageAnalyticsResponse = await response + .Deserialize(token) + .ConfigureAwait(false); + if (this._client.ResponseValidation) + { + usageAnalyticsResponse.Validate(); + } + return usageAnalyticsResponse; + } + ); + } +} diff --git a/src/Imagekit/Services/IAccountService.cs b/src/Imagekit/Services/IAccountService.cs index 9eaf50b2..4e69536c 100644 --- a/src/Imagekit/Services/IAccountService.cs +++ b/src/Imagekit/Services/IAccountService.cs @@ -26,6 +26,8 @@ public interface IAccountService IUsageService Usage { get; } + IUsageAnalyticsService UsageAnalytics { get; } + IOriginService Origins { get; } IUrlEndpointService UrlEndpoints { get; } @@ -46,6 +48,8 @@ public interface IAccountServiceWithRawResponse IUsageServiceWithRawResponse Usage { get; } + IUsageAnalyticsServiceWithRawResponse UsageAnalytics { get; } + IOriginServiceWithRawResponse Origins { get; } IUrlEndpointServiceWithRawResponse UrlEndpoints { get; }