From 80a89e0ff5b5c8962aed1b5632bc9958c46af455 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 24 Jan 2025 04:30:31 +0000 Subject: [PATCH] CodeGen from PR 32249 in Azure/azure-rest-api-specs Merge 8cfb1b5e04651bf1696da08a1f1716a3754187f2 into 443a57ead6db77c28a6f0d16858c7f44f1374337 --- .../Azure.Developer.LoadTesting.sln | 56 + .../Azure.Developer.LoadTesting/CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../Azure.Developer.LoadTesting/README.md | 107 + .../src/Azure.Developer.LoadTesting.csproj | 19 + .../AzureDeveloperLoadTestingClientOptions.cs | 52 + ...loperLoadTestingClientBuilderExtensions.cs | 52 + .../DeveloperLoadTestingModelFactory.cs | 772 +++++ .../Docs/LoadTestAdministrationClient.xml | 923 ++++++ .../src/Generated/Docs/LoadTestRunClient.xml | 1101 +++++++ .../src/Generated/Internal/Argument.cs | 129 + .../Internal/ChangeTrackingDictionary.cs | 167 ++ .../Generated/Internal/ChangeTrackingList.cs | 153 + .../Internal/ModelSerializationExtensions.cs | 398 +++ .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 + .../Generated/LoadTestAdministrationClient.cs | 2035 +++++++++++++ .../src/Generated/LoadTestRunClient.cs | 2619 +++++++++++++++++ .../src/Generated/Models/AggregationType.cs | 84 + .../Models/AppComponent.Serialization.cs | 213 ++ .../src/Generated/Models/AppComponent.cs | 102 + .../ArtifactsContainerInfo.Serialization.cs | 164 ++ .../Models/ArtifactsContainerInfo.cs | 69 + .../Models/AutoStopCriteria.Serialization.cs | 179 ++ .../src/Generated/Models/AutoStopCriteria.cs | 73 + .../CertificateMetadata.Serialization.cs | 171 ++ .../Generated/Models/CertificateMetadata.cs | 73 + .../src/Generated/Models/CertificateType.cs | 48 + .../src/Generated/Models/CreateByTypes.cs | 51 + .../Models/DimensionFilter.Serialization.cs | 170 ++ .../src/Generated/Models/DimensionFilter.cs | 70 + .../Models/DimensionValue.Serialization.cs | 156 + .../src/Generated/Models/DimensionValue.cs | 69 + .../Models/ErrorDetails.Serialization.cs | 145 + .../src/Generated/Models/ErrorDetails.cs | 65 + .../src/Generated/Models/FileStatus.cs | 60 + .../src/Generated/Models/FileType.cs | 63 + ...tionResourceConfiguration.Serialization.cs | 150 + ...ionFlexConsumptionResourceConfiguration.cs | 78 + ...getResourceConfigurations.Serialization.cs | 152 + ...ConsumptionTargetResourceConfigurations.cs | 35 + .../LoadTestConfiguration.Serialization.cs | 225 ++ .../Generated/Models/LoadTestConfiguration.cs | 98 + .../Generated/Models/ManagedIdentityType.cs | 51 + .../MetricAvailability.Serialization.cs | 149 + .../Generated/Models/MetricAvailability.cs | 71 + .../Models/MetricDefinition.Serialization.cs | 281 ++ .../src/Generated/Models/MetricDefinition.cs | 102 + ...etricDefinitionCollection.Serialization.cs | 152 + .../Models/MetricDefinitionCollection.cs | 76 + .../Models/MetricNamespace.Serialization.cs | 156 + .../src/Generated/Models/MetricNamespace.cs | 69 + ...MetricNamespaceCollection.Serialization.cs | 152 + .../Models/MetricNamespaceCollection.cs | 76 + .../MetricRequestPayload.Serialization.cs | 159 + .../Generated/Models/MetricRequestPayload.cs | 76 + .../src/Generated/Models/MetricUnit.cs | 69 + .../Models/MetricValue.Serialization.cs | 164 ++ .../src/Generated/Models/MetricValue.cs | 69 + .../Models/NameAndDesc.Serialization.cs | 156 + .../src/Generated/Models/NameAndDesc.cs | 69 + .../OptionalLoadTestConfig.Serialization.cs | 227 ++ .../Models/OptionalLoadTestConfig.cs | 85 + .../src/Generated/Models/PFAction.cs | 51 + .../src/Generated/Models/PFAgFunc.cs | 90 + .../src/Generated/Models/PFMetrics.cs | 60 + .../src/Generated/Models/PFResult.cs | 54 + .../src/Generated/Models/PFTestResult.cs | 54 + .../Models/PassFailCriteria.Serialization.cs | 186 ++ .../src/Generated/Models/PassFailCriteria.cs | 71 + .../Models/PassFailMetric.Serialization.cs | 255 ++ .../src/Generated/Models/PassFailMetric.cs | 109 + .../PassFailServerMetric.Serialization.cs | 237 ++ .../Generated/Models/PassFailServerMetric.cs | 121 + .../Models/RecommendationCategory.cs | 51 + .../RegionalConfiguration.Serialization.cs | 150 + .../Generated/Models/RegionalConfiguration.cs | 93 + .../src/Generated/Models/RequestDataLevel.cs | 51 + .../src/Generated/Models/ResourceKind.cs | 48 + .../Models/ResourceMetric.Serialization.cs | 216 ++ .../src/Generated/Models/ResourceMetric.cs | 119 + .../Generated/Models/Secret.Serialization.cs | 160 + .../src/Generated/Models/Secret.cs | 69 + .../src/Generated/Models/SecretType.cs | 51 + .../src/Generated/Models/Status.cs | 93 + ...getResourceConfigurations.Serialization.cs | 133 + .../Models/TargetResourceConfigurations.cs | 69 + .../Generated/Models/Test.Serialization.cs | 511 ++++ .../src/Generated/Models/Test.cs | 172 ++ .../Models/TestAppComponents.Serialization.cs | 223 ++ .../src/Generated/Models/TestAppComponents.cs | 107 + .../Models/TestFileInfo.Serialization.cs | 220 ++ .../src/Generated/Models/TestFileInfo.cs | 95 + .../TestInputArtifacts.Serialization.cs | 241 ++ .../Generated/Models/TestInputArtifacts.cs | 86 + .../src/Generated/Models/TestKind.cs | 54 + .../Models/TestProfile.Serialization.cs | 267 ++ .../src/Generated/Models/TestProfile.cs | 109 + .../Models/TestProfileRun.Serialization.cs | 410 +++ .../src/Generated/Models/TestProfileRun.cs | 146 + ...tProfileRunRecommendation.Serialization.cs | 167 ++ .../Models/TestProfileRunRecommendation.cs | 77 + .../Generated/Models/TestProfileRunStatus.cs | 66 + .../Generated/Models/TestRun.Serialization.cs | 685 +++++ .../src/Generated/Models/TestRun.cs | 226 ++ .../TestRunAppComponents.Serialization.cs | 223 ++ .../Generated/Models/TestRunAppComponents.cs | 107 + .../Models/TestRunArtifacts.Serialization.cs | 164 ++ .../src/Generated/Models/TestRunArtifacts.cs | 69 + .../Models/TestRunDetail.Serialization.cs | 169 ++ .../src/Generated/Models/TestRunDetail.cs | 88 + .../Models/TestRunFileInfo.Serialization.cs | 220 ++ .../src/Generated/Models/TestRunFileInfo.cs | 95 + .../TestRunInputArtifacts.Serialization.cs | 241 ++ .../Generated/Models/TestRunInputArtifacts.cs | 86 + .../TestRunOutputArtifacts.Serialization.cs | 194 ++ .../Models/TestRunOutputArtifacts.cs | 77 + ...TestRunServerMetricConfig.Serialization.cs | 230 ++ .../Models/TestRunServerMetricConfig.cs | 94 + .../Models/TestRunStatistics.Serialization.cs | 451 +++ .../src/Generated/Models/TestRunStatistics.cs | 141 + .../TestServerMetricConfig.Serialization.cs | 223 ++ .../Models/TestServerMetricConfig.cs | 107 + .../src/Generated/Models/TimeGrain.cs | 60 + .../Models/TimeSeriesElement.Serialization.cs | 184 ++ .../src/Generated/Models/TimeSeriesElement.cs | 71 + ...getResourceConfigurations.Serialization.cs | 126 + .../UnknownTargetResourceConfigurations.cs | 28 + .../src/Properties/AssemblyInfo.cs | 11 + .../Azure.Developer.LoadTesting.Tests.csproj | 20 + .../Samples_LoadTestAdministrationClient.cs | 939 ++++++ .../Samples/Samples_LoadTestRunClient.cs | 1129 +++++++ .../tsp-location.yaml | 4 + sdk/loadtesting/ci.yml | 35 + .../src/autorest.md | 2 +- 135 files changed, 25918 insertions(+), 1 deletion(-) create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/README.md create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestAdministrationClient.xml create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestRunClient.xml create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AggregationType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreateByTypes.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileStatus.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ManagedIdentityType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricUnit.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAction.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAgFunc.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFMetrics.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFResult.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFTestResult.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RecommendationCategory.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RequestDataLevel.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceKind.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/SecretType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Status.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestKind.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunStatus.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeGrain.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/tests/Azure.Developer.LoadTesting.Tests.csproj create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestAdministrationClient.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestRunClient.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml create mode 100644 sdk/loadtesting/ci.yml diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln b/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln new file mode 100644 index 0000000000000..fb32820aaea67 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/Azure.Developer.LoadTesting.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Developer.LoadTesting", "src\Azure.Developer.LoadTesting.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Developer.LoadTesting.Tests", "tests\Azure.Developer.LoadTesting.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md b/sdk/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md new file mode 100644 index 0000000000000..8b33f0fedccc1 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props b/sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props new file mode 100644 index 0000000000000..63bd836ad44b7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/README.md b/sdk/loadtesting/Azure.Developer.LoadTesting/README.md new file mode 100644 index 0000000000000..09c7f0c5f2cd9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/README.md @@ -0,0 +1,107 @@ +# Azure.Developer.LoadTesting client library for .NET + +Azure.Developer.LoadTesting is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/loadtesting/Azure.Developer.LoadTesting/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.Developer.LoadTesting --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/loadtesting/Azure.Developer.LoadTesting/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/loadtesting/Azure.Developer.LoadTesting/README.png) \ No newline at end of file diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj new file mode 100644 index 0000000000000..e46421196dcf3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Azure.Developer.LoadTesting.csproj @@ -0,0 +1,19 @@ + + + This is the Azure.Developer.LoadTesting client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.Developer.LoadTesting for Azure Data Plane + 1.0.0-beta.1 + Azure.Developer.LoadTesting + $(RequiredTargetFrameworks) + true + + + + + + + + + + + diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs new file mode 100644 index 0000000000000..182a9afccf680 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/AzureDeveloperLoadTestingClientOptions.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + /// Client options for Azure.Developer.LoadTesting library clients. + public partial class AzureDeveloperLoadTestingClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_12_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2022-11-01". + V2022_11_01 = 1, + /// Service version "2023-04-01-preview". + V2023_04_01_Preview = 2, + /// Service version "2024-03-01-preview". + V2024_03_01_Preview = 3, + /// Service version "2024-05-01-preview". + V2024_05_01_Preview = 4, + /// Service version "2024-07-01-preview". + V2024_07_01_Preview = 5, + /// Service version "2024-12-01-preview". + V2024_12_01_Preview = 6, + } + + internal string Version { get; } + + /// Initializes new instance of AzureDeveloperLoadTestingClientOptions. + public AzureDeveloperLoadTestingClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2022_11_01 => "2022-11-01", + ServiceVersion.V2023_04_01_Preview => "2023-04-01-preview", + ServiceVersion.V2024_03_01_Preview => "2024-03-01-preview", + ServiceVersion.V2024_05_01_Preview => "2024-05-01-preview", + ServiceVersion.V2024_07_01_Preview => "2024-07-01-preview", + ServiceVersion.V2024_12_01_Preview => "2024-12-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs new file mode 100644 index 0000000000000..6d76257f95b60 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingClientBuilderExtensions.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Extensions; +using Azure.Developer.LoadTesting; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add , to client builder. + public static partial class DeveloperLoadTestingClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The to use. + public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new LoadTestAdministrationClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The to use. + public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new LoadTestRunClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddLoadTestAdministrationClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddLoadTestRunClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs new file mode 100644 index 0000000000000..cc5331cd7ccb8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs @@ -0,0 +1,772 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Model factory for models. + public static partial class DeveloperLoadTestingModelFactory + { + /// Initializes a new instance of . + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// The load test configuration. + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + /// The input artifacts for the test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The test description. + /// Display name of a test. + /// Subnet ID on which the load test instances should run. + /// Kind of test. + /// Inject load test engines without deploying public IP for outbound access. + /// Type of the managed identity referencing the Key vault. + /// Resource Id of the managed identity referencing the Key vault. + /// Type of the managed identity referencing the metrics. + /// Resource Id of the managed identity referencing the metrics. + /// Type of the managed identity built in load test engines. + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static Test Test(PassFailCriteria passFailCriteria = null, AutoStopCriteria autoStopCriteria = null, IDictionary secrets = null, CertificateMetadata certificate = null, IDictionary environmentVariables = null, LoadTestConfiguration loadTestConfiguration = null, string baselineTestRunId = null, TestInputArtifacts inputArtifacts = null, string testId = null, string description = null, string displayName = null, string subnetId = null, TestKind? kind = null, bool? publicIPDisabled = null, string keyvaultReferenceIdentityType = null, string keyvaultReferenceIdentityId = null, ManagedIdentityType? metricsReferenceIdentityType = null, string metricsReferenceIdentityId = null, ManagedIdentityType? engineBuiltInIdentityType = null, IEnumerable engineBuiltInIdentityIds = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + secrets ??= new Dictionary(); + environmentVariables ??= new Dictionary(); + engineBuiltInIdentityIds ??= new List(); + + return new Test( + passFailCriteria, + autoStopCriteria, + secrets, + certificate, + environmentVariables, + loadTestConfiguration, + baselineTestRunId, + inputArtifacts, + testId, + description, + displayName, + subnetId, + kind, + publicIPDisabled, + keyvaultReferenceIdentityType, + keyvaultReferenceIdentityId, + metricsReferenceIdentityType, + metricsReferenceIdentityId, + engineBuiltInIdentityType, + engineBuiltInIdentityIds?.ToList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The client metric on which the criteria should be applied. + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + /// The comparison operator. Supported types ‘>’, ‘<’. + /// Request name for which the Pass fail criteria has to be applied. + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the client metric for the test run. + /// Outcome of the test run. + /// A new instance for mocking. + public static PassFailMetric PassFailMetric(PFMetrics? clientMetric = null, PFAgFunc? aggregate = null, string condition = null, string requestName = null, double? value = null, PFAction? action = null, double? actualValue = null, PFResult? result = null) + { + return new PassFailMetric( + clientMetric, + aggregate, + condition, + requestName, + value, + action, + actualValue, + result, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the server metric. + /// Outcome of the test run. + /// A new instance for mocking. + public static PassFailServerMetric PassFailServerMetric(string resourceId = null, string metricNamespace = null, string metricName = null, string aggregation = null, string condition = null, double value = default, PFAction? action = null, double? actualValue = null, PFResult? result = null) + { + return new PassFailServerMetric( + resourceId, + metricNamespace, + metricName, + aggregation, + condition, + value, + action, + actualValue, + result, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// File info. + /// File info. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// A new instance for mocking. + public static TestInputArtifacts TestInputArtifacts(TestFileInfo configFileInfo = null, TestFileInfo testScriptFileInfo = null, TestFileInfo userPropFileInfo = null, TestFileInfo inputArtifactsZipFileInfo = null, TestFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// A new instance for mocking. + public static TestFileInfo TestFileInfo(string fileName = null, Uri url = null, FileType? fileType = null, DateTimeOffset? expireDateTime = null, FileStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestAppComponents TestAppComponents(IDictionary components = null, string testId = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + components ??= new Dictionary(); + + return new TestAppComponents( + components, + testId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// Azure resource display name. + /// Resource group name of the Azure resource. + /// Subscription Id of the Azure resource. + /// Kind of Azure resource type. + /// A new instance for mocking. + public static AppComponent AppComponent(string resourceId = null, string resourceName = null, string resourceType = null, string displayName = null, string resourceGroup = null, string subscriptionId = null, string kind = null) + { + return new AppComponent( + resourceId, + resourceName, + resourceType, + displayName, + resourceGroup, + subscriptionId, + kind, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Test identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestServerMetricConfig TestServerMetricConfig(string testId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestServerMetricConfig( + testId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique name for metric. + /// Azure resource id. + /// Metric name space. + /// Metric description. + /// The invariant value of metric name. + /// Metric aggregation. + /// Metric unit. + /// Azure resource type. + /// A new instance for mocking. + public static ResourceMetric ResourceMetric(string id = null, string resourceId = null, string metricNamespace = null, string displayDescription = null, string name = null, string aggregation = null, string unit = null, string resourceType = null) + { + return new ResourceMetric( + id, + resourceId, + metricNamespace, + displayDescription, + name, + aggregation, + unit, + resourceType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name of the test profile. + /// Description for the test profile. + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + /// + /// Configurations of the target resource on which testing would be done. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestProfile TestProfile(string testProfileId = null, string displayName = null, string description = null, string testId = null, string targetResourceId = null, TargetResourceConfigurations targetResourceConfigurations = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + return new TestProfile( + testProfileId, + displayName, + description, + testId, + targetResourceId, + targetResourceConfigurations, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// Error details if there is any failure in load test run. + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// The load test configuration. + /// Collection of test run artifacts. + /// Test result for pass/Fail criteria used during the test run. + /// Number of virtual users, for which test has been run. + /// Display name of a testRun. + /// Associated test Id. + /// The test run description. + /// The test run status. + /// The test run start DateTime(RFC 3339 literal format). + /// The test run end DateTime(RFC 3339 literal format). + /// Test run initiated time. + /// Portal url. + /// Test run duration in milliseconds. + /// Virtual user hours consumed by the test run. + /// Subnet ID on which the load test instances should run. + /// Type of test. + /// Request data collection level for test run. + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + /// Inject load test engines without deploying public IP for outbound access. + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestRun TestRun(string testRunId = null, PassFailCriteria passFailCriteria = null, AutoStopCriteria autoStopCriteria = null, IDictionary secrets = null, CertificateMetadata certificate = null, IDictionary environmentVariables = null, IEnumerable errorDetails = null, IReadOnlyDictionary testRunStatistics = null, IReadOnlyDictionary regionalStatistics = null, LoadTestConfiguration loadTestConfiguration = null, TestRunArtifacts testArtifacts = null, PFTestResult? testResult = null, int? virtualUsers = null, string displayName = null, string testId = null, string description = null, Status? status = null, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, DateTimeOffset? executedDateTime = null, string portalUrl = null, long? duration = null, double? virtualUserHours = null, string subnetId = null, TestKind? kind = null, RequestDataLevel? requestDataLevel = null, bool? debugLogsEnabled = null, bool? publicIPDisabled = null, CreateByTypes? createdByType = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + secrets ??= new Dictionary(); + environmentVariables ??= new Dictionary(); + errorDetails ??= new List(); + testRunStatistics ??= new Dictionary(); + regionalStatistics ??= new Dictionary(); + + return new TestRun( + testRunId, + passFailCriteria, + autoStopCriteria, + secrets, + certificate, + environmentVariables, + errorDetails?.ToList(), + testRunStatistics, + regionalStatistics, + loadTestConfiguration, + testArtifacts, + testResult, + virtualUsers, + displayName, + testId, + description, + status, + startDateTime, + endDateTime, + executedDateTime, + portalUrl, + duration, + virtualUserHours, + subnetId, + kind, + requestDataLevel, + debugLogsEnabled, + publicIPDisabled, + createdByType, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Error details in case test run was not successfully run. + /// A new instance for mocking. + public static ErrorDetails ErrorDetails(string message = null) + { + return new ErrorDetails(message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Transaction name. + /// Sampler count. + /// Error count. + /// Error percentage. + /// Mean response time. + /// Median response time. + /// Max response time. + /// Minimum response time. + /// 90 percentile response time. + /// 95 percentile response time. + /// 99 percentile response time. + /// 75 percentile response time. + /// 96 percentile response time. + /// 97 percentile response time. + /// 98 percentile response time. + /// 99.9 percentile response time. + /// 99.99 percentile response time. + /// Throughput. + /// Received network bytes. + /// Send network bytes. + /// A new instance for mocking. + public static TestRunStatistics TestRunStatistics(string transaction = null, double? sampleCount = null, double? errorCount = null, double? errorPct = null, double? meanResTime = null, double? medianResTime = null, double? maxResTime = null, double? minResTime = null, double? pct1ResTime = null, double? pct2ResTime = null, double? pct3ResTime = null, double? pct75ResTime = null, double? pct96ResTime = null, double? pct97ResTime = null, double? pct98ResTime = null, double? pct999ResTime = null, double? pct9999ResTime = null, double? throughput = null, double? receivedKBytesPerSec = null, double? sentKBytesPerSec = null) + { + return new TestRunStatistics( + transaction, + sampleCount, + errorCount, + errorPct, + meanResTime, + medianResTime, + maxResTime, + minResTime, + pct1ResTime, + pct2ResTime, + pct3ResTime, + pct75ResTime, + pct96ResTime, + pct97ResTime, + pct98ResTime, + pct999ResTime, + pct9999ResTime, + throughput, + receivedKBytesPerSec, + sentKBytesPerSec, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The input artifacts for the test run. + /// The output artifacts for the test run. + /// A new instance for mocking. + public static TestRunArtifacts TestRunArtifacts(TestRunInputArtifacts inputArtifacts = null, TestRunOutputArtifacts outputArtifacts = null) + { + return new TestRunArtifacts(inputArtifacts, outputArtifacts, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// File info. + /// File info. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// A new instance for mocking. + public static TestRunInputArtifacts TestRunInputArtifacts(TestRunFileInfo configFileInfo = null, TestRunFileInfo testScriptFileInfo = null, TestRunFileInfo userPropFileInfo = null, TestRunFileInfo inputArtifactsZipFileInfo = null, TestRunFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestRunInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// A new instance for mocking. + public static TestRunFileInfo TestRunFileInfo(string fileName = null, Uri url = null, FileType? fileType = null, DateTimeOffset? expireDateTime = null, FileStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestRunFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// The container for test run artifacts. + /// The report file for the test run. + /// A new instance for mocking. + public static TestRunOutputArtifacts TestRunOutputArtifacts(TestRunFileInfo resultFileInfo = null, TestRunFileInfo logsFileInfo = null, ArtifactsContainerInfo artifactsContainerInfo = null, TestRunFileInfo reportFileInfo = null) + { + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + /// Expiry time of the container (RFC 3339 literal format). + /// A new instance for mocking. + public static ArtifactsContainerInfo ArtifactsContainerInfo(Uri url = null, DateTimeOffset? expireDateTime = null) + { + return new ArtifactsContainerInfo(url, expireDateTime, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test run identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestRunAppComponents TestRunAppComponents(IDictionary components = null, string testRunId = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + components ??= new Dictionary(); + + return new TestRunAppComponents( + components, + testRunId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Test run identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestRunServerMetricConfig TestRunServerMetricConfig(string testRunId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestRunServerMetricConfig( + testRunId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// the values for the metric definitions. + /// A new instance for mocking. + public static MetricDefinitionCollection MetricDefinitionCollection(IEnumerable value = null) + { + value ??= new List(); + + return new MetricDefinitionCollection(value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of dimensions. + /// The metric description. + /// The metric name. + /// The namespace the metric belongs to. + /// The primary aggregation type value defining how to use the values for display. + /// The collection of what all aggregation types are supported. + /// The unit of the metric. + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + /// A new instance for mocking. + public static MetricDefinition MetricDefinition(IEnumerable dimensions = null, string description = null, string name = null, string @namespace = null, AggregationType? primaryAggregationType = null, IEnumerable supportedAggregationTypes = null, MetricUnit? unit = null, IEnumerable metricAvailabilities = null) + { + dimensions ??= new List(); + supportedAggregationTypes ??= new List(); + metricAvailabilities ??= new List(); + + return new MetricDefinition( + dimensions?.ToList(), + description, + name, + @namespace, + primaryAggregationType, + supportedAggregationTypes?.ToList(), + unit, + metricAvailabilities?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The description. + /// The name. + /// A new instance for mocking. + public static NameAndDesc NameAndDesc(string description = null, string name = null) + { + return new NameAndDesc(description, name, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + /// A new instance for mocking. + public static MetricAvailability MetricAvailability(TimeGrain? timeGrain = null) + { + return new MetricAvailability(timeGrain, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The values for the metric namespaces. + /// A new instance for mocking. + public static MetricNamespaceCollection MetricNamespaceCollection(IEnumerable value = null) + { + value ??= new List(); + + return new MetricNamespaceCollection(value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The namespace description. + /// The metric namespace name. + /// A new instance for mocking. + public static MetricNamespace MetricNamespace(string description = null, string name = null) + { + return new MetricNamespace(description, name, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of data points representing the metric values. + /// The dimension values. + /// A new instance for mocking. + public static TimeSeriesElement TimeSeriesElement(IEnumerable data = null, IEnumerable dimensionValues = null) + { + data ??= new List(); + dimensionValues ??= new List(); + + return new TimeSeriesElement(data?.ToList(), dimensionValues?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The timestamp for the metric value in RFC 3339 format. + /// The metric value. + /// A new instance for mocking. + public static MetricValue MetricValue(DateTimeOffset? timestamp = null, double? value = null) + { + return new MetricValue(timestamp, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name of the dimension. + /// The value of the dimension. + /// A new instance for mocking. + public static DimensionValue DimensionValue(string name = null, string value = null) + { + return new DimensionValue(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name for the test profile run. + /// The test profile run description. + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + /// Target resource ID on which the test profile run is created. + /// + /// Configurations of the target resource on which the test profile ran. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The test profile run status. + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + /// The test profile run start DateTime(RFC 3339 literal format). + /// The test profile run end DateTime(RFC 3339 literal format). + /// Test profile run duration in seconds. + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + /// Recommendations provided based on a successful test profile run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// A new instance for mocking. + public static TestProfileRun TestProfileRun(string testProfileRunId = null, string displayName = null, string description = null, string testProfileId = null, string targetResourceId = null, TargetResourceConfigurations targetResourceConfigurations = null, TestProfileRunStatus? status = null, IEnumerable errorDetails = null, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, long? durationInSeconds = null, IReadOnlyDictionary testRunDetails = null, IEnumerable recommendations = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + errorDetails ??= new List(); + testRunDetails ??= new Dictionary(); + recommendations ??= new List(); + + return new TestProfileRun( + testProfileRunId, + displayName, + description, + testProfileId, + targetResourceId, + targetResourceConfigurations, + status, + errorDetails?.ToList(), + startDateTime, + endDateTime, + durationInSeconds, + testRunDetails, + recommendations?.ToList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// A new instance for mocking. + public static TestRunDetail TestRunDetail(Status status = default, string configurationId = null, IReadOnlyDictionary properties = null) + { + properties ??= new Dictionary(); + + return new TestRunDetail(status, configurationId, properties, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Category of the recommendation. + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + /// A new instance for mocking. + public static TestProfileRunRecommendation TestProfileRunRecommendation(RecommendationCategory category = default, IEnumerable configurations = null) + { + configurations ??= new List(); + + return new TestProfileRunRecommendation(category, configurations?.ToList(), serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestAdministrationClient.xml b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestAdministrationClient.xml new file mode 100644 index 0000000000000..51a64da3667f5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestAdministrationClient.xml @@ -0,0 +1,923 @@ + + + + + +This sample shows how to call CreateOrUpdateTestAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + description = "sample description", + displayName = "Performance_LoadTest", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + subnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0", + keyvaultReferenceIdentityType = "UserAssigned", + keyvaultReferenceIdentityId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename", + metricsReferenceIdentityType = "UserAssigned", + metricsReferenceIdentityId = "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename", + engineBuiltInIdentityType = "UserAssigned", + engineBuiltInIdentityIds = new object[] + { + "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename" + }, +}); +Response response = await client.CreateOrUpdateTestAsync("12345678-1234-1234-1234-123456789012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTest and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + description = "sample description", + displayName = "Performance_LoadTest", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + subnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0", + keyvaultReferenceIdentityType = "UserAssigned", + keyvaultReferenceIdentityId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename", + metricsReferenceIdentityType = "UserAssigned", + metricsReferenceIdentityId = "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename", + engineBuiltInIdentityType = "UserAssigned", + engineBuiltInIdentityIds = new object[] + { + "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename" + }, +}); +Response response = client.CreateOrUpdateTest("12345678-1234-1234-1234-123456789012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAppComponentsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, +}); +Response response = await client.CreateOrUpdateAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAppComponents and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, +}); +Response response = client.CreateOrUpdateAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateServerMetricsConfigAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, +}); +Response response = await client.CreateOrUpdateServerMetricsConfigAsync("edc6e529-d009-4b99-b763-ca492e3a2823", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateServerMetricsConfig and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, +}); +Response response = client.CreateOrUpdateServerMetricsConfig("edc6e529-d009-4b99-b763-ca492e3a2823", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetAppComponentsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); +]]> + + + +This sample shows how to call GetAppComponents. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); +]]> + + + +This sample shows how to call GetAppComponentsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetAppComponents and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetServerMetricsConfigAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetServerMetricsConfig. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetServerMetricsConfigAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetServerMetricsConfig and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); +Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetTestAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestAsync("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetTest. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTest("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetTestAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestAsync("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testId").ToString()); +]]> + + + +This sample shows how to call GetTest and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTest("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testId").ToString()); +]]> + + + +This sample shows how to call GetTestFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx"); +]]> + + + +This sample shows how to call GetTestFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx"); +]]> + + + +This sample shows how to call GetTestFileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call GetTestFile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call UploadTestFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.UploadTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", BinaryData.FromObjectAsJson("application/octet-stream content")); +]]> + + + +This sample shows how to call UploadTestFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.UploadTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", BinaryData.FromObjectAsJson("application/octet-stream content")); +]]> + + + +This sample shows how to call UploadTestFileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create("application/octet-stream content"); +Response response = await client.UploadTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call UploadTestFile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create("application/octet-stream content"); +Response response = client.UploadTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call DeleteTestFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.DeleteTestFileAsync("12345678-1234-1234-1234-123456789012", "app.jmx"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTestFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.DeleteTestFile("12345678-1234-1234-1234-123456789012", "app.jmx"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTestAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.DeleteTestAsync("12345678-1234-1234-1234-123456789012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTest. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.DeleteTest("12345678-1234-1234-1234-123456789012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call CreateOrUpdateTestProfileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + description = "sample description", + displayName = "Performance_TestProfile", + testId = "12346-abcd-6789", + targetResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Web/sites/myfunctionapp", + targetResourceConfigurations = new + { + kind = "FunctionsFlexConsumption", + configurations = new + { + config1 = new + { + instanceMemoryMB = 2048L, + httpConcurrency = 16L, + }, + config2 = new + { + instanceMemoryMB = 4096L, + httpConcurrency = 16L, + }, + }, + }, +}); +Response response = await client.CreateOrUpdateTestProfileAsync("12345678-1234-1234-1234-123456789012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTestProfile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + description = "sample description", + displayName = "Performance_TestProfile", + testId = "12346-abcd-6789", + targetResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Web/sites/myfunctionapp", + targetResourceConfigurations = new + { + kind = "FunctionsFlexConsumption", + configurations = new + { + config1 = new + { + instanceMemoryMB = 2048L, + httpConcurrency = 16L, + }, + config2 = new + { + instanceMemoryMB = 4096L, + httpConcurrency = 16L, + }, + }, + }, +}); +Response response = client.CreateOrUpdateTestProfile("12345678-1234-1234-1234-123456789012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileId").ToString()); +]]> + + + +This sample shows how to call DeleteTestProfileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.DeleteTestProfileAsync("12345678-1234-1234-1234-123456789012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTestProfile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.DeleteTestProfile("12345678-1234-1234-1234-123456789012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetTestProfileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestProfileAsync("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetTestProfile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTestProfile("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetTestProfileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = await client.GetTestProfileAsync("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileId").ToString()); +]]> + + + +This sample shows how to call GetTestProfile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +Response response = client.GetTestProfile("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileId").ToString()); +]]> + + + +This sample shows how to call GetTestFilesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (TestFileInfo item in client.GetTestFilesAsync("12345678-1234-1234-1234-123456789012")) +{ +} +]]> + + + +This sample shows how to call GetTestFiles. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (TestFileInfo item in client.GetTestFiles("12345678-1234-1234-1234-123456789012")) +{ +} +]]> + + + +This sample shows how to call GetTestFilesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTestFilesAsync("12345678-1234-1234-1234-123456789012", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); +} +]]> + + + +This sample shows how to call GetTestFiles and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (BinaryData item in client.GetTestFiles("12345678-1234-1234-1234-123456789012", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); +} +]]> + + + +This sample shows how to call GetTestsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (Test item in client.GetTestsAsync()) +{ +} +]]> + + + +This sample shows how to call GetTests. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (Test item in client.GetTests()) +{ +} +]]> + + + +This sample shows how to call GetTestsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTestsAsync(null, "Performance_LoadTest", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); +} +]]> + + + +This sample shows how to call GetTests and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (BinaryData item in client.GetTests(null, "Performance_LoadTest", null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); +} +]]> + + + +This sample shows how to call GetTestProfilesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (TestProfile item in client.GetTestProfilesAsync()) +{ +} +]]> + + + +This sample shows how to call GetTestProfiles. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (TestProfile item in client.GetTestProfiles()) +{ +} +]]> + + + +This sample shows how to call GetTestProfilesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTestProfilesAsync(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, "12346-abcd-6789", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); +} +]]> + + + +This sample shows how to call GetTestProfiles and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + +foreach (BinaryData item in client.GetTestProfiles(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, "12346-abcd-6789", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestRunClient.xml b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestRunClient.xml new file mode 100644 index 0000000000000..400f23e76b4d0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestRunClient.xml @@ -0,0 +1,1101 @@ + + + + + +This sample shows how to call CreateOrUpdateTestRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "Performance_LoadTest_Run1", + testId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + debugLogsEnabled = true, + requestDataLevel = "NONE", +}); +Response response = await client.CreateOrUpdateTestRunAsync("12316678-1234-1234-1234-122451189012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTestRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "Performance_LoadTest_Run1", + testId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + debugLogsEnabled = true, + requestDataLevel = "NONE", +}); +Response response = client.CreateOrUpdateTestRun("12316678-1234-1234-1234-122451189012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAppComponentsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, +}); +Response response = await client.CreateOrUpdateAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAppComponents and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, +}); +Response response = client.CreateOrUpdateAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateServerMetricsConfigAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, +}); +Response response = await client.CreateOrUpdateServerMetricsConfigAsync("edc6e529-d009-4b99-b763-ca492e3a2823", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateServerMetricsConfig and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, +}); +Response response = client.CreateOrUpdateServerMetricsConfig("edc6e529-d009-4b99-b763-ca492e3a2823", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call DeleteTestRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.DeleteTestRunAsync("12316678-1234-1234-1234-122451189012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTestRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.DeleteTestRun("12316678-1234-1234-1234-122451189012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetAppComponentsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); +]]> + + + +This sample shows how to call GetAppComponents. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); +]]> + + + +This sample shows how to call GetAppComponentsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetAppComponents and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); +Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); +]]> + + + +This sample shows how to call GetServerMetricsConfigAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetServerMetricsConfig. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012"); +]]> + + + +This sample shows how to call GetServerMetricsConfigAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetServerMetricsConfig and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetTestRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestRunAsync("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetTestRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestRun("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetTestRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestRunAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call GetTestRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestRun("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call GetTestRunFileAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestRunFileAsync("12316678-1234-1234-1234-122451189012", "sample.jmx"); +]]> + + + +This sample shows how to call GetTestRunFile. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestRunFile("12316678-1234-1234-1234-122451189012", "sample.jmx"); +]]> + + + +This sample shows how to call GetTestRunFileAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestRunFileAsync("12316678-1234-1234-1234-122451189012", "sample.jmx", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call GetTestRunFile and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestRunFile("12316678-1234-1234-1234-122451189012", "sample.jmx", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("fileName").ToString()); +]]> + + + +This sample shows how to call GetMetricDefinitionsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetMetricDefinitionsAsync("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics"); +]]> + + + +This sample shows how to call GetMetricDefinitions. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetMetricDefinitions("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics"); +]]> + + + +This sample shows how to call GetMetricDefinitionsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetMetricDefinitionsAsync("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].ToString()); +]]> + + + +This sample shows how to call GetMetricDefinitions and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetMetricDefinitions("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].ToString()); +]]> + + + +This sample shows how to call GetMetricNamespacesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetMetricNamespacesAsync("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetMetricNamespaces. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetMetricNamespaces("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetMetricNamespacesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetMetricNamespacesAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].ToString()); +]]> + + + +This sample shows how to call GetMetricNamespaces and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetMetricNamespaces("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].ToString()); +]]> + + + +This sample shows how to call StopTestRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.StopTestRunAsync("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call StopTestRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.StopTestRun("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call StopTestRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.StopTestRunAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call StopTestRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.StopTestRun("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testRunId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTestProfileRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "Performance_TestProfile_Run1", + testProfileId = "12345678-1234-1234-1234-123456789012", + description = "sample description", +}); +Response response = await client.CreateOrUpdateTestProfileRunAsync("12316678-1234-1234-1234-122451189012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateTestProfileRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + displayName = "Performance_TestProfile_Run1", + testProfileId = "12345678-1234-1234-1234-123456789012", + description = "sample description", +}); +Response response = client.CreateOrUpdateTestProfileRun("12316678-1234-1234-1234-122451189012", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call DeleteTestProfileRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.DeleteTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DeleteTestProfileRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.DeleteTestProfileRun("12316678-1234-1234-1234-122451189012"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetTestProfileRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); +]]> +This sample shows how to call GetTestProfileRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetTestProfileRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012"); +]]> +This sample shows how to call GetTestProfileRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call GetTestProfileRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> +This sample shows how to call GetTestProfileRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call GetTestProfileRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> +This sample shows how to call GetTestProfileRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call StopTestProfileRunAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.StopTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call StopTestProfileRun. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.StopTestProfileRun("12316678-1234-1234-1234-122451189012"); +]]> + + + +This sample shows how to call StopTestProfileRunAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = await client.StopTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call StopTestProfileRun and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +Response response = client.StopTestProfileRun("12316678-1234-1234-1234-122451189012", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +]]> + + + +This sample shows how to call GetMetricDimensionValuesAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (string item in client.GetMetricDimensionValuesAsync("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) +{ +} +]]> + + + +This sample shows how to call GetMetricDimensionValues. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (string item in client.GetMetricDimensionValues("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) +{ +} +]]> + + + +This sample shows how to call GetMetricDimensionValuesAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (BinaryData item in client.GetMetricDimensionValuesAsync("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", "PT1H", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); +} +]]> + + + +This sample shows how to call GetMetricDimensionValues and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (BinaryData item in client.GetMetricDimensionValues("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", "PT1H", null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); +} +]]> + + + +This sample shows how to call GetMetricsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (TimeSeriesElement item in client.GetMetricsAsync("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) +{ +} +]]> + + + +This sample shows how to call GetMetrics. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (TimeSeriesElement item in client.GetMetrics("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) +{ +} +]]> + + + +This sample shows how to call GetMetricsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + filters = new object[] + { + new + { + name = "SamplerName", + values = new object[] + { + "HTTP Request" + }, + } + }, +}); +await foreach (BinaryData item in client.GetMetricsAsync("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", content)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); +} +]]> + + + +This sample shows how to call GetMetrics and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +using RequestContent content = RequestContent.Create(new +{ + filters = new object[] + { + new + { + name = "SamplerName", + values = new object[] + { + "HTTP Request" + }, + } + }, +}); +foreach (BinaryData item in client.GetMetrics("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", content)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); +} +]]> + + + +This sample shows how to call GetTestRunsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (TestRun item in client.GetTestRunsAsync()) +{ +} +]]> + + + +This sample shows how to call GetTestRuns. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (TestRun item in client.GetTestRuns()) +{ +} +]]> + + + +This sample shows how to call GetTestRunsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTestRunsAsync(null, "Performance_LoadTest_Run1", "12345678-1234-1234-1234-123456789012", DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), "DONE,EXECUTING", null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); +} +]]> + + + +This sample shows how to call GetTestRuns and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (BinaryData item in client.GetTestRuns(null, "Performance_LoadTest_Run1", "12345678-1234-1234-1234-123456789012", DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), "DONE,EXECUTING", null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); +} +]]> + + + +This sample shows how to call GetTestProfileRunsAsync. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (TestProfileRun item in client.GetTestProfileRunsAsync()) +{ +} +]]> + + + +This sample shows how to call GetTestProfileRuns. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (TestProfileRun item in client.GetTestProfileRuns()) +{ +} +]]> + + + +This sample shows how to call GetTestProfileRunsAsync and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +await foreach (BinaryData item in client.GetTestProfileRunsAsync(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +} +]]> + + + +This sample shows how to call GetTestProfileRuns and parse the result. +"); +TokenCredential credential = new DefaultAzureCredential(); +LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + +foreach (BinaryData item in client.GetTestProfileRuns(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs new file mode 100644 index 0000000000000..946929b236ffa --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 0000000000000..9a5316eba10d5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 0000000000000..5de8334393558 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 0000000000000..c65bc0eab62df --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs new file mode 100644 index 0000000000000..248e10182762c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.Developer.LoadTesting +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 0000000000000..5130928c6e0b0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.Developer.LoadTesting +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs new file mode 100644 index 0000000000000..b9dd7a43e1f67 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestAdministrationClient.cs @@ -0,0 +1,2035 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Developer.LoadTesting.Models; + +namespace Azure.Developer.LoadTesting +{ + // Data plane generated client. + /// The LoadTestAdministration service client. + public partial class LoadTestAdministrationClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of LoadTestAdministrationClient for mocking. + protected LoadTestAdministrationClient() + { + } + + /// Initializes a new instance of LoadTestAdministrationClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureDeveloperLoadTestingClientOptions()) + { + } + + /// Initializes a new instance of LoadTestAdministrationClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public LoadTestAdministrationClient(Uri endpoint, TokenCredential credential, AzureDeveloperLoadTestingClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureDeveloperLoadTestingClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// + /// [Protocol Method] Create a new test or update an existing test by providing the test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateTestAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test or update an existing test by providing the test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateTest(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTest"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAppComponentsAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateAppComponents(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateServerMetricsConfigAsync(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateServerMetricsConfig(string testId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get associated app component (collection of azure resources) for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetAppComponentsAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAppComponentsAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(TestAppComponents.FromResponse(response), response); + } + + /// Get associated app component (collection of azure resources) for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetAppComponents(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAppComponents(testId, context); + return Response.FromValue(TestAppComponents.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAppComponentsAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAppComponents(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List server metrics configuration for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetServerMetricsConfigAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetServerMetricsConfigAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(TestServerMetricConfig.FromResponse(response), response); + } + + /// List server metrics configuration for the given test. + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetServerMetricsConfig(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetServerMetricsConfig(testId, context); + return Response.FromValue(TestServerMetricConfig.FromResponse(response), response); + } + + /// + /// [Protocol Method] List server metrics configuration for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetServerMetricsConfigAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List server metrics configuration for the given test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetServerMetricsConfig(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get load test details by test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTestAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestAsync(testId, context).ConfigureAwait(false); + return Response.FromValue(Test.FromResponse(response), response); + } + + /// Get load test details by test Id. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTest(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTest(testId, context); + return Response.FromValue(Test.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get load test details by test Id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get load test details by test Id + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTest(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTest"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get all the files that are associated with a test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTestFileAsync(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestFileAsync(testId, fileName, context).ConfigureAwait(false); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// Get all the files that are associated with a test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTestFile(string testId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestFile(testId, fileName, context); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get all the files that are associated with a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestFileAsync(string testId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get all the files that are associated with a test. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTestFile(string testId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestFileRequest(testId, fileName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The file content as application/octet-stream. + /// File type. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> UploadTestFileAsync(string testId, string fileName, BinaryData body, FileType? fileType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadTestFileAsync(testId, fileName, content, fileType?.ToString(), context).ConfigureAwait(false); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The file content as application/octet-stream. + /// File type. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response UploadTestFile(string testId, string fileName, BinaryData body, FileType? fileType = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UploadTestFile(testId, fileName, content, fileType?.ToString(), context); + return Response.FromValue(TestFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The content to send as the body of the request. + /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS" | "ZIPPED_ARTIFACTS" | "URL_TEST_CONFIG" | "TEST_SCRIPT". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task UploadTestFileAsync(string testId, string fileName, RequestContent content, string fileType = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Upload input file for a given test Id. File size can't be more than 50 MB. + /// Existing file with same name for the given test will be overwritten. File + /// should be provided in the request body as application/octet-stream. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Unique name for test file with file extension like : App.jmx. + /// The content to send as the body of the request. + /// File type. Allowed values: "JMX_FILE" | "USER_PROPERTIES" | "ADDITIONAL_ARTIFACTS" | "ZIPPED_ARTIFACTS" | "URL_TEST_CONFIG" | "TEST_SCRIPT". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response UploadTestFile(string testId, string fileName, RequestContent content, string fileType = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.UploadTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadTestFileRequest(testId, fileName, content, fileType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete file by the file name for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTestFileAsync(string testId, string fileName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete file by the file name for a test + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTestFile(string testId, string fileName, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestFile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestFileRequest(testId, fileName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete a test by its test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTestAsync(string testId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRequest(testId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete a test by its test Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTest(string testId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTest"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRequest(testId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test profile or update an existing test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateTestProfileAsync(string testProfileId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create a new test profile or update an existing test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateTestProfile(string testProfileId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.CreateOrUpdateTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRequest(testProfileId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete a test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTestProfileAsync(string testProfileId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete a test profile. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTestProfile(string testProfileId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.DeleteTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRequest(testProfileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get load test profile details. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get load test profile details by test profile Id. + /// + public virtual async Task> GetTestProfileAsync(string testProfileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestProfileAsync(testProfileId, context).ConfigureAwait(false); + return Response.FromValue(TestProfile.FromResponse(response), response); + } + + /// Get load test profile details. + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get load test profile details by test profile Id. + /// + public virtual Response GetTestProfile(string testProfileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestProfile(testProfileId, context); + return Response.FromValue(TestProfile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get load test profile details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestProfileAsync(string testProfileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get load test profile details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTestProfile(string testProfileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileId, nameof(testProfileId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestAdministrationClient.GetTestProfile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRequest(testProfileId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get all test files. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetTestFilesAsync(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestFileInfo.DeserializeTestFileInfo(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// Get all test files. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetTestFiles(string testId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestFileInfo.DeserializeTestFileInfo(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get all test files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTestFilesAsync(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Get all test files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTestFiles(string testId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testId, nameof(testId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestFilesRequest(testId, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestFilesNextPageRequest(nextLink, testId, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestFiles", "value", "nextLink", context); + } + + /// + /// Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetTestsAsync(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Test.DeserializeTest(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The cancellation token to use. + /// + public virtual Pageable GetTests(string orderby = null, string search = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Test.DeserializeTest(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTestsAsync(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all load tests by the fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: + /// lastModifiedDateTime asc. Supported fields - lastModifiedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - displayName, + /// createdBy. For example, to search for a test, with display name is Login Test, + /// the search parameter can be Login. + /// + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter tests. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTests(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestsRequest(orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestsNextPageRequest(nextLink, orderby, search, lastModifiedStartTime, lastModifiedEndTime, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTests", "value", "nextLink", maxpagesize, context); + } + + /// List test profiles. + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The cancellation token to use. + /// Get all test profiles for the given filters. + /// + public virtual AsyncPageable GetTestProfilesAsync(int? maxpagesize = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, IEnumerable testProfileIds = null, string testIds = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestProfile.DeserializeTestProfile(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// List test profiles. + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The cancellation token to use. + /// Get all test profiles for the given filters. + /// + public virtual Pageable GetTestProfiles(int? maxpagesize = null, DateTimeOffset? lastModifiedStartTime = null, DateTimeOffset? lastModifiedEndTime = null, IEnumerable testProfileIds = null, string testIds = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestProfile.DeserializeTestProfile(e), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profiles. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTestProfilesAsync(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, string testIds, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profiles. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Start DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// End DateTime(RFC 3339 literal format) of the last updated time range to filter test profiles. + /// Comma separated list of IDs of the test profiles to filter. + /// Comma separated list IDs of the tests which should be associated with the test profiles to fetch. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTestProfiles(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, string testIds, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfilesRequest(pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfilesNextPageRequest(nextLink, pageSizeHint, lastModifiedStartTime, lastModifiedEndTime, testProfileIds, testIds, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestAdministrationClient.GetTestProfiles", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateCreateOrUpdateTestRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFileRequest(string testId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFilesRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestsRequest(string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (search != null) + { + uri.AppendQuery("search", search, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateUploadTestFileRequest(string testId, string fileName, RequestContent content, string fileType, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier201); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (fileType != null) + { + uri.AppendQuery("fileType", fileType, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/octet-stream"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestFileRequest(string testId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteTestRequest(string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/tests/", false); + uri.AppendPath(testId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRequest(string testProfileId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRequest(string testProfileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRequest(string testProfileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles/", false); + uri.AppendPath(testProfileId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfilesRequest(int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, string testIds, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profiles", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (lastModifiedStartTime != null) + { + uri.AppendQuery("lastModifiedStartTime", lastModifiedStartTime.Value, "O", true); + } + if (lastModifiedEndTime != null) + { + uri.AppendQuery("lastModifiedEndTime", lastModifiedEndTime.Value, "O", true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", true); + } + if (testIds != null) + { + uri.AppendQuery("testIds", testIds, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestFilesNextPageRequest(string nextLink, string testId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestsNextPageRequest(string nextLink, string orderby, string search, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfilesNextPageRequest(string nextLink, int? maxpagesize, DateTimeOffset? lastModifiedStartTime, DateTimeOffset? lastModifiedEndTime, IEnumerable testProfileIds, string testIds, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier201; + private static ResponseClassifier ResponseClassifier201 => _responseClassifier201 ??= new StatusCodeClassifier(stackalloc ushort[] { 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs new file mode 100644 index 0000000000000..29a6a5474668d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/LoadTestRunClient.cs @@ -0,0 +1,2619 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Developer.LoadTesting.Models; + +namespace Azure.Developer.LoadTesting +{ + // Data plane generated client. + /// The LoadTestRun service client. + public partial class LoadTestRunClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://cnt-prod.loadtesting.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of LoadTestRunClient for mocking. + protected LoadTestRunClient() + { + } + + /// Initializes a new instance of LoadTestRunClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public LoadTestRunClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new AzureDeveloperLoadTestingClientOptions()) + { + } + + /// Initializes a new instance of LoadTestRunClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public LoadTestRunClient(Uri endpoint, TokenCredential credential, AzureDeveloperLoadTestingClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AzureDeveloperLoadTestingClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// + /// [Protocol Method] Create and start a new test run with the given test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// + /// Existing test run identifier that should be rerun, if this is provided, the + /// test will run with the JMX file, configuration and app components from the + /// existing test run. You can override the configuration values for new test run + /// in the request body. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateTestRunAsync(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test run with the given test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// + /// Existing test run identifier that should be rerun, if this is provided, the + /// test will run with the JMX file, configuration and app components from the + /// existing test run. You can override the configuration values for new test run + /// in the request body. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateTestRun(string testRunId, RequestContent content, string oldTestRunId = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestRunRequest(testRunId, content, oldTestRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAppComponentsAsync(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Add an app component to a test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateAppComponents(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateAppComponentsRequest(testRunId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test run + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateServerMetricsConfigAsync(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Configure server metrics for a test run + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// + /// Unique Id for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateServerMetricsConfig(string testRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateServerMetricsConfigRequest(testRunId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete an existing load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTestRunAsync(string testRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete an existing load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTestRun(string testRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetAppComponentsAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAppComponentsAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRunAppComponents.FromResponse(response), response); + } + + /// + /// Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetAppComponents(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAppComponents(testRunId, context); + return Response.FromValue(TestRunAppComponents.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAppComponentsAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated app component (collection of azure resources) for the given test + /// run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAppComponents(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetAppComponents"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAppComponentsRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get associated server metrics configuration for the given test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetServerMetricsConfigAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetServerMetricsConfigAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRunServerMetricConfig.FromResponse(response), response); + } + + /// Get associated server metrics configuration for the given test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetServerMetricsConfig(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetServerMetricsConfig(testRunId, context); + return Response.FromValue(TestRunServerMetricConfig.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get associated server metrics configuration for the given test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetServerMetricsConfigAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get associated server metrics configuration for the given test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetServerMetricsConfig(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetServerMetricsConfig"); + scope.Start(); + try + { + using HttpMessage message = CreateGetServerMetricsConfigRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test run details by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestRunAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRun.FromResponse(response), response); + } + + /// Get test run details by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTestRun(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestRun(testRunId, context); + return Response.FromValue(TestRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test run details by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestRunAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test run details by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTestRun(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test run file by file name. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetTestRunFileAsync(string testRunId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestRunFileAsync(testRunId, fileName, context).ConfigureAwait(false); + return Response.FromValue(TestRunFileInfo.FromResponse(response), response); + } + + /// Get test run file by file name. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetTestRunFile(string testRunId, string fileName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestRunFile(testRunId, fileName, context); + return Response.FromValue(TestRunFileInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test run file by file name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestRunFileAsync(string testRunId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test run file by file name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Name of the file. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTestRunFile(string testRunId, string fileName, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(fileName, nameof(fileName)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestRunFile"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestRunFileRequest(testRunId, fileName, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the metric definitions for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetMetricDefinitionsAsync(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMetricDefinitionsAsync(testRunId, metricNamespace, context).ConfigureAwait(false); + return Response.FromValue(MetricDefinitionCollection.FromResponse(response), response); + } + + /// List the metric definitions for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetMetricDefinitions(string testRunId, string metricNamespace, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMetricDefinitions(testRunId, metricNamespace, context); + return Response.FromValue(MetricDefinitionCollection.FromResponse(response), response); + } + + /// + /// [Protocol Method] List the metric definitions for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetMetricDefinitionsAsync(string testRunId, string metricNamespace, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List the metric definitions for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric namespace to query metric definitions for. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetMetricDefinitions(string testRunId, string metricNamespace, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricDefinitions"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricDefinitionsRequest(testRunId, metricNamespace, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the metric namespaces for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetMetricNamespacesAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetMetricNamespacesAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(MetricNamespaceCollection.FromResponse(response), response); + } + + /// List the metric namespaces for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetMetricNamespaces(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetMetricNamespaces(testRunId, context); + return Response.FromValue(MetricNamespaceCollection.FromResponse(response), response); + } + + /// + /// [Protocol Method] List the metric namespaces for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetMetricNamespacesAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] List the metric namespaces for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetMetricNamespaces(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetMetricNamespaces"); + scope.Start(); + try + { + using HttpMessage message = CreateGetMetricNamespacesRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stop test run by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> StopTestRunAsync(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StopTestRunAsync(testRunId, context).ConfigureAwait(false); + return Response.FromValue(TestRun.FromResponse(response), response); + } + + /// Stop test run by test run Id. + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response StopTestRun(string testRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StopTestRun(testRunId, context); + return Response.FromValue(TestRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Stop test run by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task StopTestRunAsync(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Stop test run by test run Id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response StopTestRun(string testRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestRunRequest(testRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateTestProfileRunAsync(string testProfileRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Create and start a new test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdateTestProfileRun(string testProfileRunId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.CreateOrUpdateTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateTestProfileRunRequest(testProfileRunId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete an existing load test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteTestProfileRunAsync(string testProfileRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Delete an existing load test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response DeleteTestProfileRun(string testProfileRunId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.DeleteTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Get test profile run details. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get test profile run details by test profile run Id. + /// + public virtual async Task> GetTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetTestProfileRunAsync(testProfileRunId, context).ConfigureAwait(false); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// Get test profile run details. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Get test profile run details by test profile run Id. + /// + public virtual Response GetTestProfileRun(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetTestProfileRun(testProfileRunId, context); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Get test profile run details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetTestProfileRunAsync(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Get test profile run details. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetTestProfileRun(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.GetTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateGetTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Stop test profile run. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Stop test profile run for the given test profile run Id. + /// + public virtual async Task> StopTestProfileRunAsync(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await StopTestProfileRunAsync(testProfileRunId, context).ConfigureAwait(false); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// Stop test profile run. + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Stop test profile run for the given test profile run Id. + /// + public virtual Response StopTestProfileRun(string testProfileRunId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = StopTestProfileRun(testProfileRunId, context); + return Response.FromValue(TestProfileRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Stop test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task StopTestProfileRunAsync(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Stop test profile run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response StopTestProfileRun(string testProfileRunId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testProfileRunId, nameof(testProfileRunId)); + + using var scope = ClientDiagnostics.CreateScope("LoadTestRunClient.StopTestProfileRun"); + scope.Start(); + try + { + using HttpMessage message = CreateStopTestProfileRunRequest(testProfileRunId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// List the dimension values for the given metric dimension name. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => e.GetString(), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// List the dimension values for the given metric dimension name. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => e.GetString(), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the dimension values for the given metric dimension name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetMetricDimensionValuesAsync(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the dimension values for the given metric dimension name. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Dimension name. + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetMetricDimensionValues(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricDimensionValuesRequest(testRunId, name, metricname, metricNamespace, timespan, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricDimensionValuesNextPageRequest(nextLink, testRunId, name, metricname, metricNamespace, timespan, interval, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetricDimensionValues", "value", "nextLink", context); + } + + /// List the metric values for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// Metric dimension filter. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, MetricRequestPayload body = null, string aggregation = null, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContent content = body..ToRequestContent(); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TimeSeriesElement.DeserializeTimeSeriesElement(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// List the metric values for a load test run. + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// Metric dimension filter. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. + /// The cancellation token to use. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, MetricRequestPayload body = null, string aggregation = null, TimeGrain? interval = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + RequestContent content = body..ToRequestContent(); + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval?.ToString(), context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TimeSeriesElement.DeserializeTimeSeriesElement(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the metric values for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The content to send as the body of the request. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetMetricsAsync(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = null, string interval = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// + /// [Protocol Method] List the metric values for a load test run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Unique name for the load test run, must contain only lower-case alphabetic, + /// numeric, underscore or hyphen characters. + /// + /// Metric name. + /// Metric namespace to query metric definitions for. + /// The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'. + /// The content to send as the body of the request. + /// The aggregation. + /// The interval (i.e. timegrain) of the query. Allowed values: "PT5S" | "PT10S" | "PT1M" | "PT5M" | "PT1H". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetMetrics(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation = null, string interval = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(testRunId, nameof(testRunId)); + Argument.AssertNotNull(metricname, nameof(metricname)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(timespan, nameof(timespan)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetMetricsRequest(testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetMetricsNextPageRequest(nextLink, testRunId, metricname, metricNamespace, timespan, content, aggregation, interval, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetMetrics", "value", "nextLink", context); + } + + /// Get all test runs for the given filters. + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetTestRunsAsync(string orderby = null, string search = null, string testId = null, DateTimeOffset? executionFrom = null, DateTimeOffset? executionTo = null, string status = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestRun.DeserializeTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// Get all test runs for the given filters. + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// The cancellation token to use. + /// + public virtual Pageable GetTestRuns(string orderby = null, string search = null, string testId = null, DateTimeOffset? executionFrom = null, DateTimeOffset? executionTo = null, string status = null, int? maxpagesize = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestRun.DeserializeTestRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all test runs for the given filters. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTestRunsAsync(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] Get all test runs for the given filters. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// + /// Sort on the supported fields in (field asc/desc) format. eg: executedDateTime + /// asc. Supported fields - executedDateTime + /// + /// + /// Prefix based, case sensitive search on searchable fields - description, + /// executedUser. For example, to search for a test run, with description 500 VUs, + /// the search parameter can be 500. + /// + /// Unique name of an existing load test. + /// Start DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// End DateTime(RFC 3339 literal format) of test-run execution time filter range. + /// Comma separated list of test run status. + /// Number of results in response. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTestRuns(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestRunsRequest(orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestRunsNextPageRequest(nextLink, orderby, search, testId, executionFrom, executionTo, status, pageSizeHint, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestRuns", "value", "nextLink", maxpagesize, context); + } + + /// List test profile runs. + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The cancellation token to use. + /// Get all test profile runs for the given filters. + /// + public virtual AsyncPageable GetTestProfileRunsAsync(int? maxpagesize = null, DateTimeOffset? minStartDateTime = null, DateTimeOffset? maxStartDateTime = null, DateTimeOffset? minEndDateTime = null, DateTimeOffset? maxEndDateTime = null, DateTimeOffset? createdDateStartTime = null, DateTimeOffset? createdDateEndTime = null, IEnumerable testProfileRunIds = null, IEnumerable testProfileIds = null, IEnumerable statuses = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => TestProfileRun.DeserializeTestProfileRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// List test profile runs. + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The cancellation token to use. + /// Get all test profile runs for the given filters. + /// + public virtual Pageable GetTestProfileRuns(int? maxpagesize = null, DateTimeOffset? minStartDateTime = null, DateTimeOffset? maxStartDateTime = null, DateTimeOffset? minEndDateTime = null, DateTimeOffset? maxEndDateTime = null, DateTimeOffset? createdDateStartTime = null, DateTimeOffset? createdDateEndTime = null, IEnumerable testProfileRunIds = null, IEnumerable testProfileIds = null, IEnumerable statuses = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => TestProfileRun.DeserializeTestProfileRun(e), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profile runs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetTestProfileRunsAsync(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + /// + /// [Protocol Method] List test profile runs. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Maximum number of results to include in a single response. + /// Minimum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum Start DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Minimum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Maximum End DateTime(RFC 3339 literal format) of the test profile runs to filter on. + /// Start DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// End DateTime(RFC 3339 literal format) of the created time range to filter test profile runs. + /// Comma separated list of IDs of the test profile runs to filter. + /// Comma separated IDs of the test profiles which should be associated with the test profile runs to fetch. + /// Comma separated list of Statuses of the test profile runs to filter. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetTestProfileRuns(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetTestProfileRunsRequest(pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetTestProfileRunsNextPageRequest(nextLink, pageSizeHint, minStartDateTime, maxStartDateTime, minEndDateTime, maxEndDateTime, createdDateStartTime, createdDateEndTime, testProfileRunIds, testProfileIds, statuses, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "LoadTestRunClient.GetTestProfileRuns", "value", "nextLink", maxpagesize, context); + } + + internal HttpMessage CreateCreateOrUpdateTestRunRequest(string testRunId, RequestContent content, string oldTestRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (oldTestRunId != null) + { + uri.AppendQuery("oldTestRunId", oldTestRunId, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateAppComponentsRequest(string testRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateOrUpdateServerMetricsConfigRequest(string testRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAppComponentsRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/app-components", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetServerMetricsConfigRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/server-metrics-config", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunFileRequest(string testRunId, string fileName, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDimensionValuesRequest(string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-dimensions/", false); + uri.AppendPath(name, true); + uri.AppendPath("/values", false); + uri.AppendQuery("metricname", metricname, true); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDefinitionsRequest(string testRunId, string metricNamespace, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-definitions", false); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricNamespacesRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metric-namespaces", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricsRequest(string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath("/metrics", false); + uri.AppendQuery("metricname", metricname, true); + uri.AppendQuery("metricNamespace", metricNamespace, true); + uri.AppendQuery("timespan", timespan, true); + uri.AppendQuery("api-version", _apiVersion, true); + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetTestRunsRequest(string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (search != null) + { + uri.AppendQuery("search", search, true); + } + if (testId != null) + { + uri.AppendQuery("testId", testId, true); + } + if (executionFrom != null) + { + uri.AppendQuery("executionFrom", executionFrom.Value, "O", true); + } + if (executionTo != null) + { + uri.AppendQuery("executionTo", executionTo.Value, "O", true); + } + if (status != null) + { + uri.AppendQuery("status", status, true); + } + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestRunRequest(string testRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-runs/", false); + uri.AppendPath(testRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateTestProfileRunRequest(string testProfileRunId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunsRequest(int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (minStartDateTime != null) + { + uri.AppendQuery("minStartDateTime", minStartDateTime.Value, "O", true); + } + if (maxStartDateTime != null) + { + uri.AppendQuery("maxStartDateTime", maxStartDateTime.Value, "O", true); + } + if (minEndDateTime != null) + { + uri.AppendQuery("minEndDateTime", minEndDateTime.Value, "O", true); + } + if (maxEndDateTime != null) + { + uri.AppendQuery("maxEndDateTime", maxEndDateTime.Value, "O", true); + } + if (createdDateStartTime != null) + { + uri.AppendQuery("createdDateStartTime", createdDateStartTime.Value, "O", true); + } + if (createdDateEndTime != null) + { + uri.AppendQuery("createdDateEndTime", createdDateEndTime.Value, "O", true); + } + if (testProfileRunIds != null && !(testProfileRunIds is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileRunIds", testProfileRunIds, ",", true); + } + if (testProfileIds != null && !(testProfileIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("testProfileIds", testProfileIds, ",", true); + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + uri.AppendQueryDelimited("statuses", statuses, ",", true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateStopTestProfileRunRequest(string testProfileRunId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendPath("/test-profile-runs/", false); + uri.AppendPath(testProfileRunId, true); + uri.AppendPath(":stop", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricDimensionValuesNextPageRequest(string nextLink, string testRunId, string name, string metricname, string metricNamespace, string timespan, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetMetricsNextPageRequest(string nextLink, string testRunId, string metricname, string metricNamespace, string timespan, RequestContent content, string aggregation, string interval, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestRunsNextPageRequest(string nextLink, string orderby, string search, string testId, DateTimeOffset? executionFrom, DateTimeOffset? executionTo, string status, int? maxpagesize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetTestProfileRunsNextPageRequest(string nextLink, int? maxpagesize, DateTimeOffset? minStartDateTime, DateTimeOffset? maxStartDateTime, DateTimeOffset? minEndDateTime, DateTimeOffset? maxEndDateTime, DateTimeOffset? createdDateStartTime, DateTimeOffset? createdDateEndTime, IEnumerable testProfileRunIds, IEnumerable testProfileIds, IEnumerable statuses, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.AppendRaw("https://", false); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AggregationType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AggregationType.cs new file mode 100644 index 0000000000000..7f516a1a4c3d2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AggregationType.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Aggregation type. + public readonly partial struct AggregationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AggregationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AverageValue = "Average"; + private const string CountValue = "Count"; + private const string NoneValue = "None"; + private const string TotalValue = "Total"; + private const string Percentile75Value = "Percentile75"; + private const string Percentile90Value = "Percentile90"; + private const string Percentile95Value = "Percentile95"; + private const string Percentile96Value = "Percentile96"; + private const string Percentile97Value = "Percentile97"; + private const string Percentile98Value = "Percentile98"; + private const string Percentile99Value = "Percentile99"; + private const string Percentile999Value = "Percentile999"; + private const string Percentile9999Value = "Percentile9999"; + + /// Average value. + public static AggregationType Average { get; } = new AggregationType(AverageValue); + /// Total count. + public static AggregationType Count { get; } = new AggregationType(CountValue); + /// Aggregation will be average in this case. + public static AggregationType None { get; } = new AggregationType(NoneValue); + /// Total sum. + public static AggregationType Total { get; } = new AggregationType(TotalValue); + /// 75th percentile. + public static AggregationType Percentile75 { get; } = new AggregationType(Percentile75Value); + /// 90th percentile. + public static AggregationType Percentile90 { get; } = new AggregationType(Percentile90Value); + /// 95th percentile. + public static AggregationType Percentile95 { get; } = new AggregationType(Percentile95Value); + /// 96th percentile. + public static AggregationType Percentile96 { get; } = new AggregationType(Percentile96Value); + /// 97th percentile. + public static AggregationType Percentile97 { get; } = new AggregationType(Percentile97Value); + /// 98th percentile. + public static AggregationType Percentile98 { get; } = new AggregationType(Percentile98Value); + /// 99th percentile. + public static AggregationType Percentile99 { get; } = new AggregationType(Percentile99Value); + /// 99.9th percentile. + public static AggregationType Percentile999 { get; } = new AggregationType(Percentile999Value); + /// 99.99th percentile. + public static AggregationType Percentile9999 { get; } = new AggregationType(Percentile9999Value); + /// Determines if two values are the same. + public static bool operator ==(AggregationType left, AggregationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AggregationType left, AggregationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AggregationType(string value) => new AggregationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AggregationType other && Equals(other); + /// + public bool Equals(AggregationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.Serialization.cs new file mode 100644 index 0000000000000..2d9984e7315b7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.Serialization.cs @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class AppComponent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AppComponent)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + writer.WritePropertyName("resourceName"u8); + writer.WriteStringValue(ResourceName); + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(ResourceGroup)) + { + writer.WritePropertyName("resourceGroup"u8); + writer.WriteStringValue(ResourceGroup); + } + if (options.Format != "W" && Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AppComponent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AppComponent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAppComponent(document.RootElement, options); + } + + internal static AppComponent DeserializeAppComponent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceId = default; + string resourceName = default; + string resourceType = default; + string displayName = default; + string resourceGroup = default; + string subscriptionId = default; + string kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceName"u8)) + { + resourceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceGroup"u8)) + { + resourceGroup = property.Value.GetString(); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AppComponent( + resourceId, + resourceName, + resourceType, + displayName, + resourceGroup, + subscriptionId, + kind, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AppComponent)} does not support writing '{options.Format}' format."); + } + } + + AppComponent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAppComponent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AppComponent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AppComponent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAppComponent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.cs new file mode 100644 index 0000000000000..084093404e076 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AppComponent.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// An Azure resource object (Refer azure generic resource model :https://learn.microsoft.com/en-us/rest/api/resources/resources/get-by-id#genericresource). + public partial class AppComponent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// or is null. + public AppComponent(string resourceName, string resourceType) + { + Argument.AssertNotNull(resourceName, nameof(resourceName)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + ResourceName = resourceName; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + /// Azure resource name, required while creating the app component. + /// Azure resource type, required while creating the app component. + /// Azure resource display name. + /// Resource group name of the Azure resource. + /// Subscription Id of the Azure resource. + /// Kind of Azure resource type. + /// Keeps track of any properties unknown to the library. + internal AppComponent(string resourceId, string resourceName, string resourceType, string displayName, string resourceGroup, string subscriptionId, string kind, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + ResourceName = resourceName; + ResourceType = resourceType; + DisplayName = displayName; + ResourceGroup = resourceGroup; + SubscriptionId = subscriptionId; + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AppComponent() + { + } + + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + public string ResourceId { get; } + /// Azure resource name, required while creating the app component. + public string ResourceName { get; set; } + /// Azure resource type, required while creating the app component. + public string ResourceType { get; set; } + /// Azure resource display name. + public string DisplayName { get; set; } + /// Resource group name of the Azure resource. + public string ResourceGroup { get; } + /// Subscription Id of the Azure resource. + public string SubscriptionId { get; } + /// Kind of Azure resource type. + public string Kind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.Serialization.cs new file mode 100644 index 0000000000000..078a1ab8e2e1b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class ArtifactsContainerInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ArtifactsContainerInfo)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (Optional.IsDefined(ExpireDateTime)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpireDateTime.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ArtifactsContainerInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ArtifactsContainerInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeArtifactsContainerInfo(document.RootElement, options); + } + + internal static ArtifactsContainerInfo DeserializeArtifactsContainerInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri url = default; + DateTimeOffset? expireDateTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ArtifactsContainerInfo(url, expireDateTime, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ArtifactsContainerInfo)} does not support writing '{options.Format}' format."); + } + } + + ArtifactsContainerInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeArtifactsContainerInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ArtifactsContainerInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ArtifactsContainerInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeArtifactsContainerInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.cs new file mode 100644 index 0000000000000..08bb3d75f1235 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Artifacts container info. + public partial class ArtifactsContainerInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ArtifactsContainerInfo() + { + } + + /// Initializes a new instance of . + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + /// Expiry time of the container (RFC 3339 literal format). + /// Keeps track of any properties unknown to the library. + internal ArtifactsContainerInfo(Uri url, DateTimeOffset? expireDateTime, IDictionary serializedAdditionalRawData) + { + Url = url; + ExpireDateTime = expireDateTime; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + public Uri Url { get; } + /// Expiry time of the container (RFC 3339 literal format). + public DateTimeOffset? ExpireDateTime { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.Serialization.cs new file mode 100644 index 0000000000000..32bea3f44bb65 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.Serialization.cs @@ -0,0 +1,179 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class AutoStopCriteria : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AutoStopCriteria)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AutoStopDisabled)) + { + writer.WritePropertyName("autoStopDisabled"u8); + writer.WriteBooleanValue(AutoStopDisabled.Value); + } + if (Optional.IsDefined(ErrorRate)) + { + writer.WritePropertyName("errorRate"u8); + writer.WriteNumberValue(ErrorRate.Value); + } + if (Optional.IsDefined(ErrorRateTimeWindowInSeconds)) + { + writer.WritePropertyName("errorRateTimeWindowInSeconds"u8); + writer.WriteNumberValue(ErrorRateTimeWindowInSeconds.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AutoStopCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AutoStopCriteria)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAutoStopCriteria(document.RootElement, options); + } + + internal static AutoStopCriteria DeserializeAutoStopCriteria(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? autoStopDisabled = default; + float? errorRate = default; + int? errorRateTimeWindowInSeconds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("autoStopDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("errorRate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorRate = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("errorRateTimeWindowInSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorRateTimeWindowInSeconds = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AutoStopCriteria(autoStopDisabled, errorRate, errorRateTimeWindowInSeconds, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AutoStopCriteria)} does not support writing '{options.Format}' format."); + } + } + + AutoStopCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAutoStopCriteria(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AutoStopCriteria)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AutoStopCriteria FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAutoStopCriteria(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.cs new file mode 100644 index 0000000000000..f723968e7021e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/AutoStopCriteria.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public partial class AutoStopCriteria + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public AutoStopCriteria() + { + } + + /// Initializes a new instance of . + /// Whether auto-stop should be disabled. The default value is false. + /// Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0. + /// Time window during which the error percentage should be evaluated in seconds. + /// Keeps track of any properties unknown to the library. + internal AutoStopCriteria(bool? autoStopDisabled, float? errorRate, int? errorRateTimeWindowInSeconds, IDictionary serializedAdditionalRawData) + { + AutoStopDisabled = autoStopDisabled; + ErrorRate = errorRate; + ErrorRateTimeWindowInSeconds = errorRateTimeWindowInSeconds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Whether auto-stop should be disabled. The default value is false. + public bool? AutoStopDisabled { get; set; } + /// Threshold percentage of errors on which test run should be automatically stopped. Allowed values are in range of 0.0-100.0. + public float? ErrorRate { get; set; } + /// Time window during which the error percentage should be evaluated in seconds. + public int? ErrorRateTimeWindowInSeconds { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.Serialization.cs new file mode 100644 index 0000000000000..bb723d35c9771 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class CertificateMetadata : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertificateMetadata)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CertificateMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CertificateMetadata)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCertificateMetadata(document.RootElement, options); + } + + internal static CertificateMetadata DeserializeCertificateMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + CertificateType? type = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new CertificateType(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CertificateMetadata(value, type, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CertificateMetadata)} does not support writing '{options.Format}' format."); + } + } + + CertificateMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCertificateMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CertificateMetadata)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CertificateMetadata FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCertificateMetadata(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.cs new file mode 100644 index 0000000000000..e521080d6f097 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateMetadata.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Certificates metadata. + public partial class CertificateMetadata + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CertificateMetadata() + { + } + + /// Initializes a new instance of . + /// The value of the certificate for respective type. + /// Type of certificate. + /// Name of the certificate. + /// Keeps track of any properties unknown to the library. + internal CertificateMetadata(string value, CertificateType? type, string name, IDictionary serializedAdditionalRawData) + { + Value = value; + Type = type; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the certificate for respective type. + public string Value { get; set; } + /// Type of certificate. + public CertificateType? Type { get; set; } + /// Name of the certificate. + public string Name { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateType.cs new file mode 100644 index 0000000000000..83e2491fcccc0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CertificateType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Types of certificates supported. + public readonly partial struct CertificateType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CertificateType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AKVCERTURIValue = "AKV_CERT_URI"; + + /// If the certificate is stored in an Azure Key Vault. + public static CertificateType AKVCERTURI { get; } = new CertificateType(AKVCERTURIValue); + /// Determines if two values are the same. + public static bool operator ==(CertificateType left, CertificateType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CertificateType left, CertificateType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CertificateType(string value) => new CertificateType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CertificateType other && Equals(other); + /// + public bool Equals(CertificateType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreateByTypes.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreateByTypes.cs new file mode 100644 index 0000000000000..37893e506b835 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreateByTypes.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + public readonly partial struct CreateByTypes : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CreateByTypes(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "User"; + private const string ScheduledTriggerValue = "ScheduledTrigger"; + + /// Entity was created by a user. + public static CreateByTypes User { get; } = new CreateByTypes(UserValue); + /// Entity was created by a scheduled trigger. + public static CreateByTypes ScheduledTrigger { get; } = new CreateByTypes(ScheduledTriggerValue); + /// Determines if two values are the same. + public static bool operator ==(CreateByTypes left, CreateByTypes right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CreateByTypes left, CreateByTypes right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CreateByTypes(string value) => new CreateByTypes(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CreateByTypes other && Equals(other); + /// + public bool Equals(CreateByTypes other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.Serialization.cs new file mode 100644 index 0000000000000..1c8f8b2cc5453 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class DimensionFilter : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionFilter)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsCollectionDefined(Values)) + { + writer.WritePropertyName("values"u8); + writer.WriteStartArray(); + foreach (var item in Values) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DimensionFilter IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionFilter)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDimensionFilter(document.RootElement, options); + } + + internal static DimensionFilter DeserializeDimensionFilter(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IList values = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + values = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DimensionFilter(name, values ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DimensionFilter)} does not support writing '{options.Format}' format."); + } + } + + DimensionFilter IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDimensionFilter(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DimensionFilter)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DimensionFilter FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDimensionFilter(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.cs new file mode 100644 index 0000000000000..4948de1807792 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionFilter.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Dimension name and values to filter. + public partial class DimensionFilter + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public DimensionFilter() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The dimension name. + /// The dimension values. Maximum values can be 20. + /// Keeps track of any properties unknown to the library. + internal DimensionFilter(string name, IList values, IDictionary serializedAdditionalRawData) + { + Name = name; + Values = values; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The dimension name. + public string Name { get; set; } + /// The dimension values. Maximum values can be 20. + public IList Values { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.Serialization.cs new file mode 100644 index 0000000000000..12ccd08067fb8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class DimensionValue : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionValue)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DimensionValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DimensionValue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDimensionValue(document.RootElement, options); + } + + internal static DimensionValue DeserializeDimensionValue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DimensionValue(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DimensionValue)} does not support writing '{options.Format}' format."); + } + } + + DimensionValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDimensionValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DimensionValue)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DimensionValue FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDimensionValue(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.cs new file mode 100644 index 0000000000000..b69587bcf34f0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/DimensionValue.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Represents a metric dimension value. + public partial class DimensionValue + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal DimensionValue() + { + } + + /// Initializes a new instance of . + /// The name of the dimension. + /// The value of the dimension. + /// Keeps track of any properties unknown to the library. + internal DimensionValue(string name, string value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the dimension. + public string Name { get; } + /// The value of the dimension. + public string Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.Serialization.cs new file mode 100644 index 0000000000000..6e32c3118b597 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class ErrorDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ErrorDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ErrorDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ErrorDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorDetails(document.RootElement, options); + } + + internal static ErrorDetails DeserializeErrorDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorDetails(message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ErrorDetails)} does not support writing '{options.Format}' format."); + } + } + + ErrorDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeErrorDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ErrorDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeErrorDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.cs new file mode 100644 index 0000000000000..0cb62e2207443 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ErrorDetails.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Error details if there is any failure in load test run. + public partial class ErrorDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ErrorDetails() + { + } + + /// Initializes a new instance of . + /// Error details in case test run was not successfully run. + /// Keeps track of any properties unknown to the library. + internal ErrorDetails(string message, IDictionary serializedAdditionalRawData) + { + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Error details in case test run was not successfully run. + public string Message { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileStatus.cs new file mode 100644 index 0000000000000..5216f9a94d759 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileStatus.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// File status. + public readonly partial struct FileStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NOTVALIDATEDValue = "NOT_VALIDATED"; + private const string VALIDATIONSUCCESSValue = "VALIDATION_SUCCESS"; + private const string VALIDATIONFAILUREValue = "VALIDATION_FAILURE"; + private const string VALIDATIONINITIATEDValue = "VALIDATION_INITIATED"; + private const string VALIDATIONNOTREQUIREDValue = "VALIDATION_NOT_REQUIRED"; + + /// File is not validated. + public static FileStatus NOTVALIDATED { get; } = new FileStatus(NOTVALIDATEDValue); + /// File is validated. + public static FileStatus VALIDATIONSUCCESS { get; } = new FileStatus(VALIDATIONSUCCESSValue); + /// File validation is failed. + public static FileStatus VALIDATIONFAILURE { get; } = new FileStatus(VALIDATIONFAILUREValue); + /// File validation is in progress. + public static FileStatus VALIDATIONINITIATED { get; } = new FileStatus(VALIDATIONINITIATEDValue); + /// Validation is not required. + public static FileStatus VALIDATIONNOTREQUIRED { get; } = new FileStatus(VALIDATIONNOTREQUIREDValue); + /// Determines if two values are the same. + public static bool operator ==(FileStatus left, FileStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileStatus left, FileStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileStatus(string value) => new FileStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileStatus other && Equals(other); + /// + public bool Equals(FileStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileType.cs new file mode 100644 index 0000000000000..71a00061bc159 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileType.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Types of file supported. + public readonly partial struct FileType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JMXFILEValue = "JMX_FILE"; + private const string USERPROPERTIESValue = "USER_PROPERTIES"; + private const string ADDITIONALARTIFACTSValue = "ADDITIONAL_ARTIFACTS"; + private const string ZIPPEDARTIFACTSValue = "ZIPPED_ARTIFACTS"; + private const string URLTESTCONFIGValue = "URL_TEST_CONFIG"; + private const string TESTSCRIPTValue = "TEST_SCRIPT"; + + /// If the file is a JMX script. + public static FileType JMXFILE { get; } = new FileType(JMXFILEValue); + /// If the file is a user properties file. + public static FileType USERPROPERTIES { get; } = new FileType(USERPROPERTIESValue); + /// If the file is not among any of the other supported file types. + public static FileType ADDITIONALARTIFACTS { get; } = new FileType(ADDITIONALARTIFACTSValue); + /// If the file is a compressed archive containing a collection of various artifacts or resources. + public static FileType ZIPPEDARTIFACTS { get; } = new FileType(ZIPPEDARTIFACTSValue); + /// If the file is a JSON config file to define the requests for a URL test. + public static FileType URLTESTCONFIG { get; } = new FileType(URLTESTCONFIGValue); + /// If the file is a test script. + public static FileType TESTSCRIPT { get; } = new FileType(TESTSCRIPTValue); + /// Determines if two values are the same. + public static bool operator ==(FileType left, FileType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileType left, FileType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileType(string value) => new FileType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileType other && Equals(other); + /// + public bool Equals(FileType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.Serialization.cs new file mode 100644 index 0000000000000..31eaa6c447ec3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class FunctionFlexConsumptionResourceConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionFlexConsumptionResourceConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("instanceMemoryMB"u8); + writer.WriteNumberValue(InstanceMemoryMB); + writer.WritePropertyName("httpConcurrency"u8); + writer.WriteNumberValue(HttpConcurrency); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FunctionFlexConsumptionResourceConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionFlexConsumptionResourceConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement, options); + } + + internal static FunctionFlexConsumptionResourceConfiguration DeserializeFunctionFlexConsumptionResourceConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long instanceMemoryMB = default; + long httpConcurrency = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("instanceMemoryMB"u8)) + { + instanceMemoryMB = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("httpConcurrency"u8)) + { + httpConcurrency = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionFlexConsumptionResourceConfiguration(instanceMemoryMB, httpConcurrency, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionResourceConfiguration)} does not support writing '{options.Format}' format."); + } + } + + FunctionFlexConsumptionResourceConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionResourceConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FunctionFlexConsumptionResourceConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFunctionFlexConsumptionResourceConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.cs new file mode 100644 index 0000000000000..e425ed4546cd5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Resource configuration instance for a Flex Consumption based Azure Function App. + public partial class FunctionFlexConsumptionResourceConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Memory size of the instance. Supported values are 2048, 4096. + /// HTTP Concurrency for the function app. + public FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB, long httpConcurrency) + { + InstanceMemoryMB = instanceMemoryMB; + HttpConcurrency = httpConcurrency; + } + + /// Initializes a new instance of . + /// Memory size of the instance. Supported values are 2048, 4096. + /// HTTP Concurrency for the function app. + /// Keeps track of any properties unknown to the library. + internal FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB, long httpConcurrency, IDictionary serializedAdditionalRawData) + { + InstanceMemoryMB = instanceMemoryMB; + HttpConcurrency = httpConcurrency; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FunctionFlexConsumptionResourceConfiguration() + { + } + + /// Memory size of the instance. Supported values are 2048, 4096. + public long InstanceMemoryMB { get; set; } + /// HTTP Concurrency for the function app. + public long HttpConcurrency { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs new file mode 100644 index 0000000000000..294f6b517ebb9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class FunctionFlexConsumptionTargetResourceConfigurations : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionFlexConsumptionTargetResourceConfigurations)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsCollectionDefined(Configurations)) + { + writer.WritePropertyName("configurations"u8); + writer.WriteStartObject(); + foreach (var item in Configurations) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + } + + FunctionFlexConsumptionTargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionFlexConsumptionTargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement, options); + } + + internal static FunctionFlexConsumptionTargetResourceConfigurations DeserializeFunctionFlexConsumptionTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary configurations = default; + ResourceKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, FunctionFlexConsumptionResourceConfiguration.DeserializeFunctionFlexConsumptionResourceConfiguration(property0.Value, options)); + } + configurations = dictionary; + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new ResourceKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionFlexConsumptionTargetResourceConfigurations(kind, serializedAdditionalRawData, configurations ?? new ChangeTrackingDictionary()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionTargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + FunctionFlexConsumptionTargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionFlexConsumptionTargetResourceConfigurations)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new FunctionFlexConsumptionTargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFunctionFlexConsumptionTargetResourceConfigurations(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.cs new file mode 100644 index 0000000000000..cfa5c90ce964e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionTargetResourceConfigurations.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Configurations for a Function App using Flex Consumption Plan. + public partial class FunctionFlexConsumptionTargetResourceConfigurations : TargetResourceConfigurations + { + /// Initializes a new instance of . + public FunctionFlexConsumptionTargetResourceConfigurations() + { + Kind = ResourceKind.FunctionsFlexConsumption; + Configurations = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + /// A map of configurations for a Function app using Flex Consumption Plan. + internal FunctionFlexConsumptionTargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData, IDictionary configurations) : base(kind, serializedAdditionalRawData) + { + Configurations = configurations; + } + + /// A map of configurations for a Function app using Flex Consumption Plan. + public IDictionary Configurations { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.Serialization.cs new file mode 100644 index 0000000000000..fe6c1e2a83111 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class LoadTestConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LoadTestConfiguration)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EngineInstances)) + { + writer.WritePropertyName("engineInstances"u8); + writer.WriteNumberValue(EngineInstances.Value); + } + if (Optional.IsDefined(SplitAllCSVs)) + { + writer.WritePropertyName("splitAllCSVs"u8); + writer.WriteBooleanValue(SplitAllCSVs.Value); + } + if (Optional.IsDefined(QuickStartTest)) + { + writer.WritePropertyName("quickStartTest"u8); + writer.WriteBooleanValue(QuickStartTest.Value); + } + if (Optional.IsDefined(OptionalLoadTestConfig)) + { + writer.WritePropertyName("optionalLoadTestConfig"u8); + writer.WriteObjectValue(OptionalLoadTestConfig, options); + } + if (Optional.IsCollectionDefined(RegionalLoadTestConfig)) + { + writer.WritePropertyName("regionalLoadTestConfig"u8); + writer.WriteStartArray(); + foreach (var item in RegionalLoadTestConfig) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LoadTestConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LoadTestConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTestConfiguration(document.RootElement, options); + } + + internal static LoadTestConfiguration DeserializeLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? engineInstances = default; + bool? splitAllCSVs = default; + bool? quickStartTest = default; + OptionalLoadTestConfig optionalLoadTestConfig = default; + IList regionalLoadTestConfig = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("engineInstances"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + engineInstances = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("splitAllCSVs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + splitAllCSVs = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("quickStartTest"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quickStartTest = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("optionalLoadTestConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + optionalLoadTestConfig = OptionalLoadTestConfig.DeserializeOptionalLoadTestConfig(property.Value, options); + continue; + } + if (property.NameEquals("regionalLoadTestConfig"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RegionalConfiguration.DeserializeRegionalConfiguration(item, options)); + } + regionalLoadTestConfig = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LoadTestConfiguration( + engineInstances, + splitAllCSVs, + quickStartTest, + optionalLoadTestConfig, + regionalLoadTestConfig ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(LoadTestConfiguration)} does not support writing '{options.Format}' format."); + } + } + + LoadTestConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLoadTestConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTestConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static LoadTestConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeLoadTestConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.cs new file mode 100644 index 0000000000000..2e6262c421f92 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestConfiguration.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Configurations for the load test. + public partial class LoadTestConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public LoadTestConfiguration() + { + RegionalLoadTestConfig = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. + /// + /// If false, Azure Load Testing copies and processes your input files unmodified + /// across all test engine instances. If true, Azure Load Testing splits the CSV + /// input data evenly across all engine instances. If you provide multiple CSV + /// files, each file will be split evenly. + /// + /// + /// If true, optionalLoadTestConfig is required and JMX script for the load test is + /// not required to upload. + /// + /// Configuration for quick load test. + /// Region distribution configuration for the load test. + /// Keeps track of any properties unknown to the library. + internal LoadTestConfiguration(int? engineInstances, bool? splitAllCSVs, bool? quickStartTest, OptionalLoadTestConfig optionalLoadTestConfig, IList regionalLoadTestConfig, IDictionary serializedAdditionalRawData) + { + EngineInstances = engineInstances; + SplitAllCSVs = splitAllCSVs; + QuickStartTest = quickStartTest; + OptionalLoadTestConfig = optionalLoadTestConfig; + RegionalLoadTestConfig = regionalLoadTestConfig; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The number of engine instances to execute load test. Supported values are in range of 1-400. Required for creating a new test. + public int? EngineInstances { get; set; } + /// + /// If false, Azure Load Testing copies and processes your input files unmodified + /// across all test engine instances. If true, Azure Load Testing splits the CSV + /// input data evenly across all engine instances. If you provide multiple CSV + /// files, each file will be split evenly. + /// + public bool? SplitAllCSVs { get; set; } + /// + /// If true, optionalLoadTestConfig is required and JMX script for the load test is + /// not required to upload. + /// + public bool? QuickStartTest { get; set; } + /// Configuration for quick load test. + public OptionalLoadTestConfig OptionalLoadTestConfig { get; set; } + /// Region distribution configuration for the load test. + public IList RegionalLoadTestConfig { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ManagedIdentityType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ManagedIdentityType.cs new file mode 100644 index 0000000000000..07a8bd6c6dce1 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ManagedIdentityType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Managed identity type. + public readonly partial struct ManagedIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ManagedIdentityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SystemAssignedValue = "SystemAssigned"; + private const string UserAssignedValue = "UserAssigned"; + + /// System-assigned managed identity. + public static ManagedIdentityType SystemAssigned { get; } = new ManagedIdentityType(SystemAssignedValue); + /// User-assigned managed identity. + public static ManagedIdentityType UserAssigned { get; } = new ManagedIdentityType(UserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(ManagedIdentityType left, ManagedIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ManagedIdentityType left, ManagedIdentityType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ManagedIdentityType(string value) => new ManagedIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ManagedIdentityType other && Equals(other); + /// + public bool Equals(ManagedIdentityType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.Serialization.cs new file mode 100644 index 0000000000000..96b16ce06ae1c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricAvailability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricAvailability)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(TimeGrain)) + { + writer.WritePropertyName("timeGrain"u8); + writer.WriteStringValue(TimeGrain.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricAvailability IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricAvailability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricAvailability(document.RootElement, options); + } + + internal static MetricAvailability DeserializeMetricAvailability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TimeGrain? timeGrain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeGrain"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeGrain = new TimeGrain(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricAvailability(timeGrain, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricAvailability)} does not support writing '{options.Format}' format."); + } + } + + MetricAvailability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricAvailability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricAvailability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricAvailability FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricAvailability(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.cs new file mode 100644 index 0000000000000..ec1d9a12c5f8b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricAvailability.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Metric availability specifies the time grain (aggregation interval or frequency). + public partial class MetricAvailability + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MetricAvailability() + { + } + + /// Initializes a new instance of . + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + /// Keeps track of any properties unknown to the library. + internal MetricAvailability(TimeGrain? timeGrain, IDictionary serializedAdditionalRawData) + { + TimeGrain = timeGrain; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The time grain specifies the aggregation interval for the metric. Expressed as + /// a duration 'PT1M', 'PT1H', etc. + /// + public TimeGrain? TimeGrain { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.Serialization.cs new file mode 100644 index 0000000000000..8979cabffb72d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.Serialization.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricDefinition)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Dimensions)) + { + writer.WritePropertyName("dimensions"u8); + writer.WriteStartArray(); + foreach (var item in Dimensions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Namespace)) + { + writer.WritePropertyName("namespace"u8); + writer.WriteStringValue(Namespace); + } + if (Optional.IsDefined(PrimaryAggregationType)) + { + writer.WritePropertyName("primaryAggregationType"u8); + writer.WriteStringValue(PrimaryAggregationType.Value.ToString()); + } + if (Optional.IsCollectionDefined(SupportedAggregationTypes)) + { + writer.WritePropertyName("supportedAggregationTypes"u8); + writer.WriteStartArray(); + foreach (var item in SupportedAggregationTypes) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit.Value.ToString()); + } + if (Optional.IsCollectionDefined(MetricAvailabilities)) + { + writer.WritePropertyName("metricAvailabilities"u8); + writer.WriteStartArray(); + foreach (var item in MetricAvailabilities) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricDefinition(document.RootElement, options); + } + + internal static MetricDefinition DeserializeMetricDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList dimensions = default; + string description = default; + string name = default; + string @namespace = default; + AggregationType? primaryAggregationType = default; + IReadOnlyList supportedAggregationTypes = default; + MetricUnit? unit = default; + IReadOnlyList metricAvailabilities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dimensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameAndDesc.DeserializeNameAndDesc(item, options)); + } + dimensions = array; + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("namespace"u8)) + { + @namespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("primaryAggregationType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + primaryAggregationType = new AggregationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("supportedAggregationTypes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + supportedAggregationTypes = array; + continue; + } + if (property.NameEquals("unit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + unit = new MetricUnit(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricAvailabilities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricAvailability.DeserializeMetricAvailability(item, options)); + } + metricAvailabilities = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricDefinition( + dimensions ?? new ChangeTrackingList(), + description, + name, + @namespace, + primaryAggregationType, + supportedAggregationTypes ?? new ChangeTrackingList(), + unit, + metricAvailabilities ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricDefinition)} does not support writing '{options.Format}' format."); + } + } + + MetricDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricDefinition(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.cs new file mode 100644 index 0000000000000..c1e7026dea940 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinition.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Metric definition. + public partial class MetricDefinition + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MetricDefinition() + { + Dimensions = new ChangeTrackingList(); + SupportedAggregationTypes = new ChangeTrackingList(); + MetricAvailabilities = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of dimensions. + /// The metric description. + /// The metric name. + /// The namespace the metric belongs to. + /// The primary aggregation type value defining how to use the values for display. + /// The collection of what all aggregation types are supported. + /// The unit of the metric. + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + /// Keeps track of any properties unknown to the library. + internal MetricDefinition(IReadOnlyList dimensions, string description, string name, string @namespace, AggregationType? primaryAggregationType, IReadOnlyList supportedAggregationTypes, MetricUnit? unit, IReadOnlyList metricAvailabilities, IDictionary serializedAdditionalRawData) + { + Dimensions = dimensions; + Description = description; + Name = name; + Namespace = @namespace; + PrimaryAggregationType = primaryAggregationType; + SupportedAggregationTypes = supportedAggregationTypes; + Unit = unit; + MetricAvailabilities = metricAvailabilities; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of dimensions. + public IReadOnlyList Dimensions { get; } + /// The metric description. + public string Description { get; } + /// The metric name. + public string Name { get; } + /// The namespace the metric belongs to. + public string Namespace { get; } + /// The primary aggregation type value defining how to use the values for display. + public AggregationType? PrimaryAggregationType { get; } + /// The collection of what all aggregation types are supported. + public IReadOnlyList SupportedAggregationTypes { get; } + /// The unit of the metric. + public MetricUnit? Unit { get; } + /// + /// Metric availability specifies the time grain (aggregation interval or + /// frequency). + /// + public IReadOnlyList MetricAvailabilities { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.Serialization.cs new file mode 100644 index 0000000000000..82ff55f86575b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricDefinitionCollection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricDefinitionCollection)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricDefinitionCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricDefinitionCollection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricDefinitionCollection(document.RootElement, options); + } + + internal static MetricDefinitionCollection DeserializeMetricDefinitionCollection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricDefinition.DeserializeMetricDefinition(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricDefinitionCollection(value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricDefinitionCollection)} does not support writing '{options.Format}' format."); + } + } + + MetricDefinitionCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricDefinitionCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricDefinitionCollection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricDefinitionCollection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricDefinitionCollection(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.cs new file mode 100644 index 0000000000000..055e966bec2f3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricDefinitionCollection.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Represents collection of metric definitions. + public partial class MetricDefinitionCollection + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// the values for the metric definitions. + /// is null. + internal MetricDefinitionCollection(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// the values for the metric definitions. + /// Keeps track of any properties unknown to the library. + internal MetricDefinitionCollection(IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetricDefinitionCollection() + { + } + + /// the values for the metric definitions. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.Serialization.cs new file mode 100644 index 0000000000000..72fd5bf2207ef --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricNamespace : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricNamespace)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricNamespace IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricNamespace)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricNamespace(document.RootElement, options); + } + + internal static MetricNamespace DeserializeMetricNamespace(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricNamespace(description, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricNamespace)} does not support writing '{options.Format}' format."); + } + } + + MetricNamespace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricNamespace(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricNamespace)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricNamespace FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricNamespace(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.cs new file mode 100644 index 0000000000000..69ae3aeb2859b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespace.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Metric namespace class specifies the metadata for a metric namespace. + public partial class MetricNamespace + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MetricNamespace() + { + } + + /// Initializes a new instance of . + /// The namespace description. + /// The metric namespace name. + /// Keeps track of any properties unknown to the library. + internal MetricNamespace(string description, string name, IDictionary serializedAdditionalRawData) + { + Description = description; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The namespace description. + public string Description { get; } + /// The metric namespace name. + public string Name { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.Serialization.cs new file mode 100644 index 0000000000000..adcb578975cc2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricNamespaceCollection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricNamespaceCollection)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricNamespaceCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricNamespaceCollection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricNamespaceCollection(document.RootElement, options); + } + + internal static MetricNamespaceCollection DeserializeMetricNamespaceCollection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricNamespace.DeserializeMetricNamespace(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricNamespaceCollection(value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricNamespaceCollection)} does not support writing '{options.Format}' format."); + } + } + + MetricNamespaceCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricNamespaceCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricNamespaceCollection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricNamespaceCollection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricNamespaceCollection(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.cs new file mode 100644 index 0000000000000..3d9e93c3256a8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricNamespaceCollection.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Represents collection of metric namespaces. + public partial class MetricNamespaceCollection + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The values for the metric namespaces. + /// is null. + internal MetricNamespaceCollection(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The values for the metric namespaces. + /// Keeps track of any properties unknown to the library. + internal MetricNamespaceCollection(IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetricNamespaceCollection() + { + } + + /// The values for the metric namespaces. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.Serialization.cs new file mode 100644 index 0000000000000..4483d01f4bc63 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricRequestPayload : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricRequestPayload)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Filters)) + { + writer.WritePropertyName("filters"u8); + writer.WriteStartArray(); + foreach (var item in Filters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricRequestPayload IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricRequestPayload)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricRequestPayload(document.RootElement, options); + } + + internal static MetricRequestPayload DeserializeMetricRequestPayload(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList filters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DimensionFilter.DeserializeDimensionFilter(item, options)); + } + filters = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricRequestPayload(filters ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricRequestPayload)} does not support writing '{options.Format}' format."); + } + } + + MetricRequestPayload IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricRequestPayload(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricRequestPayload)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricRequestPayload FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricRequestPayload(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.cs new file mode 100644 index 0000000000000..9cc4e05064291 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricRequestPayload.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Filters to fetch the set of metric. + public partial class MetricRequestPayload + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public MetricRequestPayload() + { + Filters = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Get metrics for specific dimension values. Example: Metric contains dimension + /// like SamplerName, Error. To retrieve all the time series data where SamplerName + /// is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be + /// {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} + /// + /// Keeps track of any properties unknown to the library. + internal MetricRequestPayload(IList filters, IDictionary serializedAdditionalRawData) + { + Filters = filters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Get metrics for specific dimension values. Example: Metric contains dimension + /// like SamplerName, Error. To retrieve all the time series data where SamplerName + /// is equals to HTTPRequest1 or HTTPRequest2, the DimensionFilter value will be + /// {"SamplerName", ["HTTPRequest1", "HTTPRequest2"} + /// + public IList Filters { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricUnit.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricUnit.cs new file mode 100644 index 0000000000000..cbbb0d8d3b485 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricUnit.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Metric unit. + public readonly partial struct MetricUnit : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MetricUnit(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NotSpecifiedValue = "NotSpecified"; + private const string PercentValue = "Percent"; + private const string CountValue = "Count"; + private const string SecondsValue = "Seconds"; + private const string MillisecondsValue = "Milliseconds"; + private const string BytesValue = "Bytes"; + private const string BytesPerSecondValue = "BytesPerSecond"; + private const string CountPerSecondValue = "CountPerSecond"; + + /// No unit specified. + public static MetricUnit NotSpecified { get; } = new MetricUnit(NotSpecifiedValue); + /// Percentage. + public static MetricUnit Percent { get; } = new MetricUnit(PercentValue); + /// Value count. + public static MetricUnit Count { get; } = new MetricUnit(CountValue); + /// Seconds. + public static MetricUnit Seconds { get; } = new MetricUnit(SecondsValue); + /// Milliseconds. + public static MetricUnit Milliseconds { get; } = new MetricUnit(MillisecondsValue); + /// Bytes. + public static MetricUnit Bytes { get; } = new MetricUnit(BytesValue); + /// Bytes per second. + public static MetricUnit BytesPerSecond { get; } = new MetricUnit(BytesPerSecondValue); + /// Count per second. + public static MetricUnit CountPerSecond { get; } = new MetricUnit(CountPerSecondValue); + /// Determines if two values are the same. + public static bool operator ==(MetricUnit left, MetricUnit right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MetricUnit left, MetricUnit right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MetricUnit(string value) => new MetricUnit(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MetricUnit other && Equals(other); + /// + public bool Equals(MetricUnit other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.Serialization.cs new file mode 100644 index 0000000000000..3976c364085c6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class MetricValue : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricValue)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Timestamp)) + { + writer.WritePropertyName("timestamp"u8); + writer.WriteStringValue(Timestamp.Value, "O"); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MetricValue IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MetricValue)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMetricValue(document.RootElement, options); + } + + internal static MetricValue DeserializeMetricValue(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? timestamp = default; + double? value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MetricValue(timestamp, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MetricValue)} does not support writing '{options.Format}' format."); + } + } + + MetricValue IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMetricValue(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MetricValue)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MetricValue FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMetricValue(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.cs new file mode 100644 index 0000000000000..6efff07efdc36 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/MetricValue.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Represents a metric value. + public partial class MetricValue + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MetricValue() + { + } + + /// Initializes a new instance of . + /// The timestamp for the metric value in RFC 3339 format. + /// The metric value. + /// Keeps track of any properties unknown to the library. + internal MetricValue(DateTimeOffset? timestamp, double? value, IDictionary serializedAdditionalRawData) + { + Timestamp = timestamp; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The timestamp for the metric value in RFC 3339 format. + public DateTimeOffset? Timestamp { get; } + /// The metric value. + public double? Value { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.Serialization.cs new file mode 100644 index 0000000000000..7c579ceaad7e1 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class NameAndDesc : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameAndDesc)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameAndDesc IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameAndDesc)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameAndDesc(document.RootElement, options); + } + + internal static NameAndDesc DeserializeNameAndDesc(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameAndDesc(description, name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameAndDesc)} does not support writing '{options.Format}' format."); + } + } + + NameAndDesc IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeNameAndDesc(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameAndDesc)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static NameAndDesc FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeNameAndDesc(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.cs new file mode 100644 index 0000000000000..f4391f85c0097 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDesc.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The name and description. + public partial class NameAndDesc + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal NameAndDesc() + { + } + + /// Initializes a new instance of . + /// The description. + /// The name. + /// Keeps track of any properties unknown to the library. + internal NameAndDesc(string description, string name, IDictionary serializedAdditionalRawData) + { + Description = description; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The description. + public string Description { get; } + /// The name. + public string Name { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.Serialization.cs new file mode 100644 index 0000000000000..6b4f898607c5b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.Serialization.cs @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class OptionalLoadTestConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OptionalLoadTestConfig)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EndpointUrl)) + { + writer.WritePropertyName("endpointUrl"u8); + writer.WriteStringValue(EndpointUrl); + } + if (Optional.IsDefined(RequestsPerSecond)) + { + writer.WritePropertyName("requestsPerSecond"u8); + writer.WriteNumberValue(RequestsPerSecond.Value); + } + if (Optional.IsDefined(MaxResponseTimeInMs)) + { + writer.WritePropertyName("maxResponseTimeInMs"u8); + writer.WriteNumberValue(MaxResponseTimeInMs.Value); + } + if (Optional.IsDefined(VirtualUsers)) + { + writer.WritePropertyName("virtualUsers"u8); + writer.WriteNumberValue(VirtualUsers.Value); + } + if (Optional.IsDefined(RampUpTime)) + { + writer.WritePropertyName("rampUpTime"u8); + writer.WriteNumberValue(RampUpTime.Value); + } + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Duration.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OptionalLoadTestConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OptionalLoadTestConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOptionalLoadTestConfig(document.RootElement, options); + } + + internal static OptionalLoadTestConfig DeserializeOptionalLoadTestConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string endpointUrl = default; + int? requestsPerSecond = default; + int? maxResponseTimeInMs = default; + int? virtualUsers = default; + int? rampUpTime = default; + int? duration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointUrl"u8)) + { + endpointUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestsPerSecond"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestsPerSecond = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxResponseTimeInMs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxResponseTimeInMs = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("virtualUsers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUsers = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("rampUpTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rampUpTime = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OptionalLoadTestConfig( + endpointUrl, + requestsPerSecond, + maxResponseTimeInMs, + virtualUsers, + rampUpTime, + duration, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OptionalLoadTestConfig)} does not support writing '{options.Format}' format."); + } + } + + OptionalLoadTestConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOptionalLoadTestConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OptionalLoadTestConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static OptionalLoadTestConfig FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeOptionalLoadTestConfig(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.cs new file mode 100644 index 0000000000000..1e635dbfaeb9a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfig.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Configuration for quick load test. + public partial class OptionalLoadTestConfig + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public OptionalLoadTestConfig() + { + } + + /// Initializes a new instance of . + /// Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login. + /// Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. + /// Maximum response time in milliseconds of the API/endpoint. + /// No of concurrent virtual users. + /// Ramp up time in seconds. + /// Test run duration in seconds. + /// Keeps track of any properties unknown to the library. + internal OptionalLoadTestConfig(string endpointUrl, int? requestsPerSecond, int? maxResponseTimeInMs, int? virtualUsers, int? rampUpTime, int? duration, IDictionary serializedAdditionalRawData) + { + EndpointUrl = endpointUrl; + RequestsPerSecond = requestsPerSecond; + MaxResponseTimeInMs = maxResponseTimeInMs; + VirtualUsers = virtualUsers; + RampUpTime = rampUpTime; + Duration = duration; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Test URL. Provide the complete HTTP URL. For example, https://contoso-app.azurewebsites.net/login. + public string EndpointUrl { get; set; } + /// Target throughput (requests per second). This may not be necessarily achieved. The actual throughput will be lower if the application is not capable of handling it. + public int? RequestsPerSecond { get; set; } + /// Maximum response time in milliseconds of the API/endpoint. + public int? MaxResponseTimeInMs { get; set; } + /// No of concurrent virtual users. + public int? VirtualUsers { get; set; } + /// Ramp up time in seconds. + public int? RampUpTime { get; set; } + /// Test run duration in seconds. + public int? Duration { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAction.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAction.cs new file mode 100644 index 0000000000000..667290be6672e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAction.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Action to take on failure of pass/fail criteria. + public readonly partial struct PFAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PFAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContinueValue = "continue"; + private const string StopValue = "stop"; + + /// Test will continue to run even if pass fail metric criteria metric gets failed. + public static PFAction Continue { get; } = new PFAction(ContinueValue); + /// Test run will stop if pass fail criteria metric is not passed. + public static PFAction Stop { get; } = new PFAction(StopValue); + /// Determines if two values are the same. + public static bool operator ==(PFAction left, PFAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PFAction left, PFAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PFAction(string value) => new PFAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PFAction other && Equals(other); + /// + public bool Equals(PFAction other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAgFunc.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAgFunc.cs new file mode 100644 index 0000000000000..9758e8b4a2b64 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFAgFunc.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Aggregation functions for pass/fail criteria. + public readonly partial struct PFAgFunc : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PFAgFunc(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CountValue = "count"; + private const string PercentageValue = "percentage"; + private const string AvgValue = "avg"; + private const string P50Value = "p50"; + private const string P75Value = "p75"; + private const string P90Value = "p90"; + private const string P95Value = "p95"; + private const string P96Value = "p96"; + private const string P97Value = "p97"; + private const string P98Value = "p98"; + private const string P99Value = "p99"; + private const string P999Value = "p99.9"; + private const string P9999Value = "p99.99"; + private const string MinValue = "min"; + private const string MaxValue = "max"; + + /// Criteria applies for count value. + public static PFAgFunc Count { get; } = new PFAgFunc(CountValue); + /// Criteria applies for given percentage value. + public static PFAgFunc Percentage { get; } = new PFAgFunc(PercentageValue); + /// Criteria applies for avg value. + public static PFAgFunc Avg { get; } = new PFAgFunc(AvgValue); + /// Criteria applies for 50th percentile value. + public static PFAgFunc P50 { get; } = new PFAgFunc(P50Value); + /// Criteria applies for 75th percentile value. + public static PFAgFunc P75 { get; } = new PFAgFunc(P75Value); + /// Criteria applies for 90th percentile value. + public static PFAgFunc P90 { get; } = new PFAgFunc(P90Value); + /// Criteria applies for 95th percentile value. + public static PFAgFunc P95 { get; } = new PFAgFunc(P95Value); + /// Criteria applies for 96th percentile value. + public static PFAgFunc P96 { get; } = new PFAgFunc(P96Value); + /// Criteria applies for 97th percentile value. + public static PFAgFunc P97 { get; } = new PFAgFunc(P97Value); + /// Criteria applies for 98th percentile value. + public static PFAgFunc P98 { get; } = new PFAgFunc(P98Value); + /// Criteria applies for 99th percentile value. + public static PFAgFunc P99 { get; } = new PFAgFunc(P99Value); + /// Criteria applies for 99.9th percentile value. + public static PFAgFunc P999 { get; } = new PFAgFunc(P999Value); + /// Criteria applies for 99.99th percentile value. + public static PFAgFunc P9999 { get; } = new PFAgFunc(P9999Value); + /// Criteria applies for minimum value. + public static PFAgFunc Min { get; } = new PFAgFunc(MinValue); + /// Criteria applies for maximum value. + public static PFAgFunc Max { get; } = new PFAgFunc(MaxValue); + /// Determines if two values are the same. + public static bool operator ==(PFAgFunc left, PFAgFunc right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PFAgFunc left, PFAgFunc right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PFAgFunc(string value) => new PFAgFunc(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PFAgFunc other && Equals(other); + /// + public bool Equals(PFAgFunc other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFMetrics.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFMetrics.cs new file mode 100644 index 0000000000000..63350c935c485 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFMetrics.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Metrics for pass/fail criteria. + public readonly partial struct PFMetrics : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PFMetrics(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ResponseTimeMsValue = "response_time_ms"; + private const string LatencyValue = "latency"; + private const string ErrorValue = "error"; + private const string RequestsValue = "requests"; + private const string RequestsPerSecValue = "requests_per_sec"; + + /// Pass fail criteria for response time metric in milliseconds. + public static PFMetrics ResponseTimeMs { get; } = new PFMetrics(ResponseTimeMsValue); + /// Pass fail criteria for latency metric in milliseconds. + public static PFMetrics Latency { get; } = new PFMetrics(LatencyValue); + /// Pass fail criteria for error metric. + public static PFMetrics Error { get; } = new PFMetrics(ErrorValue); + /// Pass fail criteria for total requests. + public static PFMetrics Requests { get; } = new PFMetrics(RequestsValue); + /// Pass fail criteria for request per second. + public static PFMetrics RequestsPerSec { get; } = new PFMetrics(RequestsPerSecValue); + /// Determines if two values are the same. + public static bool operator ==(PFMetrics left, PFMetrics right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PFMetrics left, PFMetrics right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PFMetrics(string value) => new PFMetrics(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PFMetrics other && Equals(other); + /// + public bool Equals(PFMetrics other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFResult.cs new file mode 100644 index 0000000000000..0aab85536f1a8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFResult.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Pass/fail criteria result. + public readonly partial struct PFResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PFResult(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PassedValue = "passed"; + private const string UndeterminedValue = "undetermined"; + private const string FailedValue = "failed"; + + /// Given pass fail criteria metric has passed. + public static PFResult Passed { get; } = new PFResult(PassedValue); + /// Given pass fail criteria metric couldn't determine. + public static PFResult Undetermined { get; } = new PFResult(UndeterminedValue); + /// Given pass fail criteria metric has failed. + public static PFResult Failed { get; } = new PFResult(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(PFResult left, PFResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PFResult left, PFResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PFResult(string value) => new PFResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PFResult other && Equals(other); + /// + public bool Equals(PFResult other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFTestResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFTestResult.cs new file mode 100644 index 0000000000000..45630f7357fbb --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PFTestResult.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test result based on pass/fail criteria. + public readonly partial struct PFTestResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PFTestResult(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PASSEDValue = "PASSED"; + private const string NOTAPPLICABLEValue = "NOT_APPLICABLE"; + private const string FAILEDValue = "FAILED"; + + /// Pass/fail criteria has passed. + public static PFTestResult PASSED { get; } = new PFTestResult(PASSEDValue); + /// Pass/fail criteria is not applicable. + public static PFTestResult NOTAPPLICABLE { get; } = new PFTestResult(NOTAPPLICABLEValue); + /// Pass/fail criteria has failed. + public static PFTestResult FAILED { get; } = new PFTestResult(FAILEDValue); + /// Determines if two values are the same. + public static bool operator ==(PFTestResult left, PFTestResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PFTestResult left, PFTestResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PFTestResult(string value) => new PFTestResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PFTestResult other && Equals(other); + /// + public bool Equals(PFTestResult other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.Serialization.cs new file mode 100644 index 0000000000000..8e8a2324d8970 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.Serialization.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class PassFailCriteria : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailCriteria)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(PassFailMetrics)) + { + writer.WritePropertyName("passFailMetrics"u8); + writer.WriteStartObject(); + foreach (var item in PassFailMetrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(PassFailServerMetrics)) + { + writer.WritePropertyName("passFailServerMetrics"u8); + writer.WriteStartObject(); + foreach (var item in PassFailServerMetrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailCriteria IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailCriteria)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailCriteria(document.RootElement, options); + } + + internal static PassFailCriteria DeserializePassFailCriteria(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary passFailMetrics = default; + IDictionary passFailServerMetrics = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("passFailMetrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, PassFailMetric.DeserializePassFailMetric(property0.Value, options)); + } + passFailMetrics = dictionary; + continue; + } + if (property.NameEquals("passFailServerMetrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, PassFailServerMetric.DeserializePassFailServerMetric(property0.Value, options)); + } + passFailServerMetrics = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailCriteria(passFailMetrics ?? new ChangeTrackingDictionary(), passFailServerMetrics ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PassFailCriteria)} does not support writing '{options.Format}' format."); + } + } + + PassFailCriteria IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePassFailCriteria(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailCriteria)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PassFailCriteria FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePassFailCriteria(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.cs new file mode 100644 index 0000000000000..ea8a042edf9e9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailCriteria.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Pass fail criteria for a test. + public partial class PassFailCriteria + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PassFailCriteria() + { + PassFailMetrics = new ChangeTrackingDictionary(); + PassFailServerMetrics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Map of id and pass fail metrics { id : pass fail metrics }. + /// Map of id and pass fail server metrics { id : pass fail metrics }. + /// Keeps track of any properties unknown to the library. + internal PassFailCriteria(IDictionary passFailMetrics, IDictionary passFailServerMetrics, IDictionary serializedAdditionalRawData) + { + PassFailMetrics = passFailMetrics; + PassFailServerMetrics = passFailServerMetrics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Map of id and pass fail metrics { id : pass fail metrics }. + public IDictionary PassFailMetrics { get; } + /// Map of id and pass fail server metrics { id : pass fail metrics }. + public IDictionary PassFailServerMetrics { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.Serialization.cs new file mode 100644 index 0000000000000..3662a0ff511e8 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.Serialization.cs @@ -0,0 +1,255 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class PassFailMetric : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailMetric)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ClientMetric)) + { + writer.WritePropertyName("clientMetric"u8); + writer.WriteStringValue(ClientMetric.Value.ToString()); + } + if (Optional.IsDefined(Aggregate)) + { + writer.WritePropertyName("aggregate"u8); + writer.WriteStringValue(Aggregate.Value.ToString()); + } + if (Optional.IsDefined(Condition)) + { + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + } + if (Optional.IsDefined(RequestName)) + { + writer.WritePropertyName("requestName"u8); + writer.WriteStringValue(RequestName); + } + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteStringValue(Action.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ActualValue)) + { + writer.WritePropertyName("actualValue"u8); + writer.WriteNumberValue(ActualValue.Value); + } + if (options.Format != "W" && Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailMetric(document.RootElement, options); + } + + internal static PassFailMetric DeserializePassFailMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PFMetrics? clientMetric = default; + PFAgFunc? aggregate = default; + string condition = default; + string requestName = default; + double? value = default; + PFAction? action = default; + double? actualValue = default; + PFResult? result = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clientMetric"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + clientMetric = new PFMetrics(property.Value.GetString()); + continue; + } + if (property.NameEquals("aggregate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + aggregate = new PFAgFunc(property.Value.GetString()); + continue; + } + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestName"u8)) + { + requestName = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = new PFAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("actualValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actualValue = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("result"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + result = new PFResult(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailMetric( + clientMetric, + aggregate, + condition, + requestName, + value, + action, + actualValue, + result, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PassFailMetric)} does not support writing '{options.Format}' format."); + } + } + + PassFailMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePassFailMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailMetric)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PassFailMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePassFailMetric(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.cs new file mode 100644 index 0000000000000..5b59f97d53307 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailMetric.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Pass fail metric. + public partial class PassFailMetric + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public PassFailMetric() + { + } + + /// Initializes a new instance of . + /// The client metric on which the criteria should be applied. + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + /// The comparison operator. Supported types ‘>’, ‘<’. + /// Request name for which the Pass fail criteria has to be applied. + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the client metric for the test run. + /// Outcome of the test run. + /// Keeps track of any properties unknown to the library. + internal PassFailMetric(PFMetrics? clientMetric, PFAgFunc? aggregate, string condition, string requestName, double? value, PFAction? action, double? actualValue, PFResult? result, IDictionary serializedAdditionalRawData) + { + ClientMetric = clientMetric; + Aggregate = aggregate; + Condition = condition; + RequestName = requestName; + Value = value; + Action = action; + ActualValue = actualValue; + Result = result; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The client metric on which the criteria should be applied. + public PFMetrics? ClientMetric { get; set; } + /// + /// The aggregation function to be applied on the client metric. Allowed functions + /// - ‘percentage’ - for error metric , ‘avg’, percentiles like ‘p50’, ‘p90’, & so on, ‘min’, + /// ‘max’ - for response_time_ms and latency metric, ‘avg’ - for requests_per_sec, + /// ‘count’ - for requests + /// + public PFAgFunc? Aggregate { get; set; } + /// The comparison operator. Supported types ‘>’, ‘<’. + public string Condition { get; set; } + /// Request name for which the Pass fail criteria has to be applied. + public string RequestName { get; set; } + /// + /// The value to compare with the client metric. Allowed values - ‘error : [0.0 , + /// 100.0] unit- % ’, response_time_ms and latency : any integer value unit- ms. + /// + public double? Value { get; set; } + /// Action taken after the threshold is met. Default is ‘continue’. + public PFAction? Action { get; set; } + /// The actual value of the client metric for the test run. + public double? ActualValue { get; } + /// Outcome of the test run. + public PFResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.Serialization.cs new file mode 100644 index 0000000000000..7f0250e7f69e7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.Serialization.cs @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class PassFailServerMetric : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailServerMetric)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("metricNamespace"u8); + writer.WriteStringValue(MetricNamespace); + writer.WritePropertyName("metricName"u8); + writer.WriteStringValue(MetricName); + writer.WritePropertyName("aggregation"u8); + writer.WriteStringValue(Aggregation); + writer.WritePropertyName("condition"u8); + writer.WriteStringValue(Condition); + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value); + if (Optional.IsDefined(Action)) + { + writer.WritePropertyName("action"u8); + writer.WriteStringValue(Action.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ActualValue)) + { + writer.WritePropertyName("actualValue"u8); + writer.WriteNumberValue(ActualValue.Value); + } + if (options.Format != "W" && Optional.IsDefined(Result)) + { + writer.WritePropertyName("result"u8); + writer.WriteStringValue(Result.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PassFailServerMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PassFailServerMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePassFailServerMetric(document.RootElement, options); + } + + internal static PassFailServerMetric DeserializePassFailServerMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string resourceId = default; + string metricNamespace = default; + string metricName = default; + string aggregation = default; + string condition = default; + double value = default; + PFAction? action = default; + double? actualValue = default; + PFResult? result = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace"u8)) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricName"u8)) + { + metricName = property.Value.GetString(); + continue; + } + if (property.NameEquals("aggregation"u8)) + { + aggregation = property.Value.GetString(); + continue; + } + if (property.NameEquals("condition"u8)) + { + condition = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("action"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + action = new PFAction(property.Value.GetString()); + continue; + } + if (property.NameEquals("actualValue"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actualValue = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("result"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + result = new PFResult(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PassFailServerMetric( + resourceId, + metricNamespace, + metricName, + aggregation, + condition, + value, + action, + actualValue, + result, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(PassFailServerMetric)} does not support writing '{options.Format}' format."); + } + } + + PassFailServerMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePassFailServerMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PassFailServerMetric)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static PassFailServerMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializePassFailServerMetric(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.cs new file mode 100644 index 0000000000000..7be784cb09824 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.cs @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Pass fail server metric. + public partial class PassFailServerMetric + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// , , , or is null. + public PassFailServerMetric(string resourceId, string metricNamespace, string metricName, string aggregation, string condition, double value) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(metricName, nameof(metricName)); + Argument.AssertNotNull(aggregation, nameof(aggregation)); + Argument.AssertNotNull(condition, nameof(condition)); + + ResourceId = resourceId; + MetricNamespace = metricNamespace; + MetricName = metricName; + Aggregation = aggregation; + Condition = condition; + Value = value; + } + + /// Initializes a new instance of . + /// The resource id of the resource emitting the metric. + /// The server metric namespace. + /// The server metric name. + /// Aggregation Type. + /// The comparison operator. Supported types ‘>’, ‘<’. + /// The value to compare with the server metric. + /// Action taken after the threshold is met. Default is ‘continue’. + /// The actual value of the server metric. + /// Outcome of the test run. + /// Keeps track of any properties unknown to the library. + internal PassFailServerMetric(string resourceId, string metricNamespace, string metricName, string aggregation, string condition, double value, PFAction? action, double? actualValue, PFResult? result, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + MetricNamespace = metricNamespace; + MetricName = metricName; + Aggregation = aggregation; + Condition = condition; + Value = value; + Action = action; + ActualValue = actualValue; + Result = result; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal PassFailServerMetric() + { + } + + /// The resource id of the resource emitting the metric. + public string ResourceId { get; set; } + /// The server metric namespace. + public string MetricNamespace { get; set; } + /// The server metric name. + public string MetricName { get; set; } + /// Aggregation Type. + public string Aggregation { get; set; } + /// The comparison operator. Supported types ‘>’, ‘<’. + public string Condition { get; set; } + /// The value to compare with the server metric. + public double Value { get; set; } + /// Action taken after the threshold is met. Default is ‘continue’. + public PFAction? Action { get; set; } + /// The actual value of the server metric. + public double? ActualValue { get; } + /// Outcome of the test run. + public PFResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RecommendationCategory.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RecommendationCategory.cs new file mode 100644 index 0000000000000..bdf73908d836d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RecommendationCategory.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Category of Recommendation. + public readonly partial struct RecommendationCategory : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RecommendationCategory(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThroughputOptimizedValue = "ThroughputOptimized"; + private const string CostOptimizedValue = "CostOptimized"; + + /// The recommendation for this category optimizes the throughput/RPS (Requests per Second) of the app. + public static RecommendationCategory ThroughputOptimized { get; } = new RecommendationCategory(ThroughputOptimizedValue); + /// The recommendation for this category optimizes the cost of the app. + public static RecommendationCategory CostOptimized { get; } = new RecommendationCategory(CostOptimizedValue); + /// Determines if two values are the same. + public static bool operator ==(RecommendationCategory left, RecommendationCategory right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RecommendationCategory left, RecommendationCategory right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RecommendationCategory(string value) => new RecommendationCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RecommendationCategory other && Equals(other); + /// + public bool Equals(RecommendationCategory other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.Serialization.cs new file mode 100644 index 0000000000000..a524a07ab0c4e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class RegionalConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RegionalConfiguration)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("engineInstances"u8); + writer.WriteNumberValue(EngineInstances); + writer.WritePropertyName("region"u8); + writer.WriteStringValue(Region); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RegionalConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RegionalConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRegionalConfiguration(document.RootElement, options); + } + + internal static RegionalConfiguration DeserializeRegionalConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int engineInstances = default; + string region = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("engineInstances"u8)) + { + engineInstances = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("region"u8)) + { + region = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RegionalConfiguration(engineInstances, region, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RegionalConfiguration)} does not support writing '{options.Format}' format."); + } + } + + RegionalConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRegionalConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RegionalConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RegionalConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRegionalConfiguration(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.cs new file mode 100644 index 0000000000000..5c75ab33f8500 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Region distribution configuration for the load test. + public partial class RegionalConfiguration + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// is null. + public RegionalConfiguration(int engineInstances, string region) + { + Argument.AssertNotNull(region, nameof(region)); + + EngineInstances = engineInstances; + Region = region; + } + + /// Initializes a new instance of . + /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// Keeps track of any properties unknown to the library. + internal RegionalConfiguration(int engineInstances, string region, IDictionary serializedAdditionalRawData) + { + EngineInstances = engineInstances; + Region = region; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RegionalConfiguration() + { + } + + /// The number of engine instances to execute load test in specified region. Supported values are in range of 1-400. + public int EngineInstances { get; set; } + /// + /// Azure region name. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + public string Region { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RequestDataLevel.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RequestDataLevel.cs new file mode 100644 index 0000000000000..8cdec590de130 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RequestDataLevel.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Request data collection level for test run. + public readonly partial struct RequestDataLevel : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RequestDataLevel(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NONEValue = "NONE"; + private const string ERRORSValue = "ERRORS"; + + /// No request data will be collected. + public static RequestDataLevel NONE { get; } = new RequestDataLevel(NONEValue); + /// Request data will be collected in case of failed requests. + public static RequestDataLevel ERRORS { get; } = new RequestDataLevel(ERRORSValue); + /// Determines if two values are the same. + public static bool operator ==(RequestDataLevel left, RequestDataLevel right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RequestDataLevel left, RequestDataLevel right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RequestDataLevel(string value) => new RequestDataLevel(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RequestDataLevel other && Equals(other); + /// + public bool Equals(RequestDataLevel other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceKind.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceKind.cs new file mode 100644 index 0000000000000..6f76a9a94bde0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceKind.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Kind of the resource on which test profile is created. + internal readonly partial struct ResourceKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FunctionsFlexConsumptionValue = "FunctionsFlexConsumption"; + + /// Resource is a Azure FunctionApp on Flex Consumption Plan. + public static ResourceKind FunctionsFlexConsumption { get; } = new ResourceKind(FunctionsFlexConsumptionValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceKind left, ResourceKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceKind left, ResourceKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ResourceKind(string value) => new ResourceKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceKind other && Equals(other); + /// + public bool Equals(ResourceKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.Serialization.cs new file mode 100644 index 0000000000000..d57f7075d59ae --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class ResourceMetric : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceMetric)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("metricNamespace"u8); + writer.WriteStringValue(MetricNamespace); + if (Optional.IsDefined(DisplayDescription)) + { + writer.WritePropertyName("displayDescription"u8); + writer.WriteStringValue(DisplayDescription); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("aggregation"u8); + writer.WriteStringValue(Aggregation); + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit); + } + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ResourceMetric IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceMetric)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceMetric(document.RootElement, options); + } + + internal static ResourceMetric DeserializeResourceMetric(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string resourceId = default; + string metricNamespace = default; + string displayDescription = default; + string name = default; + string aggregation = default; + string unit = default; + string resourceType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricNamespace"u8)) + { + metricNamespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayDescription"u8)) + { + displayDescription = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("aggregation"u8)) + { + aggregation = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceMetric( + id, + resourceId, + metricNamespace, + displayDescription, + name, + aggregation, + unit, + resourceType, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ResourceMetric)} does not support writing '{options.Format}' format."); + } + } + + ResourceMetric IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceMetric(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceMetric)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ResourceMetric FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeResourceMetric(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.cs new file mode 100644 index 0000000000000..389fb59c9c489 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.cs @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// + /// Associated metric definition for particular metrics of the azure resource ( + /// Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition). + /// + public partial class ResourceMetric + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Azure resource id. + /// Metric name space. + /// The invariant value of metric name. + /// Metric aggregation. + /// Azure resource type. + /// , , , or is null. + public ResourceMetric(string resourceId, string metricNamespace, string name, string aggregation, string resourceType) + { + Argument.AssertNotNull(resourceId, nameof(resourceId)); + Argument.AssertNotNull(metricNamespace, nameof(metricNamespace)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(aggregation, nameof(aggregation)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + ResourceId = resourceId; + MetricNamespace = metricNamespace; + Name = name; + Aggregation = aggregation; + ResourceType = resourceType; + } + + /// Initializes a new instance of . + /// Unique name for metric. + /// Azure resource id. + /// Metric name space. + /// Metric description. + /// The invariant value of metric name. + /// Metric aggregation. + /// Metric unit. + /// Azure resource type. + /// Keeps track of any properties unknown to the library. + internal ResourceMetric(string id, string resourceId, string metricNamespace, string displayDescription, string name, string aggregation, string unit, string resourceType, IDictionary serializedAdditionalRawData) + { + Id = id; + ResourceId = resourceId; + MetricNamespace = metricNamespace; + DisplayDescription = displayDescription; + Name = name; + Aggregation = aggregation; + Unit = unit; + ResourceType = resourceType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceMetric() + { + } + + /// Unique name for metric. + public string Id { get; } + /// Azure resource id. + public string ResourceId { get; set; } + /// Metric name space. + public string MetricNamespace { get; set; } + /// Metric description. + public string DisplayDescription { get; set; } + /// The invariant value of metric name. + public string Name { get; set; } + /// Metric aggregation. + public string Aggregation { get; set; } + /// Metric unit. + public string Unit { get; set; } + /// Azure resource type. + public string ResourceType { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.Serialization.cs new file mode 100644 index 0000000000000..a31b18e640f72 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class Secret : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Secret)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Secret IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Secret)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSecret(document.RootElement, options); + } + + internal static Secret DeserializeSecret(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + SecretType? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new SecretType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Secret(value, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Secret)} does not support writing '{options.Format}' format."); + } + } + + Secret IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSecret(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Secret)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Secret FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeSecret(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.cs new file mode 100644 index 0000000000000..3eb818ce5cc7e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Secret.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Secret. + public partial class Secret + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Secret() + { + } + + /// Initializes a new instance of . + /// The value of the secret for the respective type. + /// Type of secret. + /// Keeps track of any properties unknown to the library. + internal Secret(string value, SecretType? type, IDictionary serializedAdditionalRawData) + { + Value = value; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the secret for the respective type. + public string Value { get; set; } + /// Type of secret. + public SecretType? Type { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/SecretType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/SecretType.cs new file mode 100644 index 0000000000000..3a97c395ba42f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/SecretType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Types of secrets supported. + public readonly partial struct SecretType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SecretType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AKVSECRETURIValue = "AKV_SECRET_URI"; + private const string SECRETVALUEValue = "SECRET_VALUE"; + + /// If the secret is stored in an Azure Key Vault. + public static SecretType AKVSECRETURI { get; } = new SecretType(AKVSECRETURIValue); + /// If the secret value provided as plain text. + public static SecretType SECRETVALUE { get; } = new SecretType(SECRETVALUEValue); + /// Determines if two values are the same. + public static bool operator ==(SecretType left, SecretType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SecretType left, SecretType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SecretType(string value) => new SecretType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SecretType other && Equals(other); + /// + public bool Equals(SecretType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Status.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Status.cs new file mode 100644 index 0000000000000..51af3e7cb4d50 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Status.cs @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test run status. + public readonly partial struct Status : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Status(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ACCEPTEDValue = "ACCEPTED"; + private const string NOTSTARTEDValue = "NOTSTARTED"; + private const string PROVISIONINGValue = "PROVISIONING"; + private const string PROVISIONEDValue = "PROVISIONED"; + private const string CONFIGURINGValue = "CONFIGURING"; + private const string CONFIGUREDValue = "CONFIGURED"; + private const string EXECUTINGValue = "EXECUTING"; + private const string EXECUTEDValue = "EXECUTED"; + private const string DEPROVISIONINGValue = "DEPROVISIONING"; + private const string DEPROVISIONEDValue = "DEPROVISIONED"; + private const string DONEValue = "DONE"; + private const string CANCELLINGValue = "CANCELLING"; + private const string CANCELLEDValue = "CANCELLED"; + private const string FAILEDValue = "FAILED"; + private const string VALIDATIONSUCCESSValue = "VALIDATION_SUCCESS"; + private const string VALIDATIONFAILUREValue = "VALIDATION_FAILURE"; + + /// Test run request is accepted. + public static Status ACCEPTED { get; } = new Status(ACCEPTEDValue); + /// Test run is not yet started. + public static Status NOTSTARTED { get; } = new Status(NOTSTARTEDValue); + /// Test run is provisioning. + public static Status PROVISIONING { get; } = new Status(PROVISIONINGValue); + /// Test run is provisioned. + public static Status PROVISIONED { get; } = new Status(PROVISIONEDValue); + /// Test run is getting configured. + public static Status CONFIGURING { get; } = new Status(CONFIGURINGValue); + /// Test run configuration is done. + public static Status CONFIGURED { get; } = new Status(CONFIGUREDValue); + /// Test run has started executing. + public static Status EXECUTING { get; } = new Status(EXECUTINGValue); + /// Test run execution is completed. + public static Status EXECUTED { get; } = new Status(EXECUTEDValue); + /// Test run is getting deprovisioned. + public static Status DEPROVISIONING { get; } = new Status(DEPROVISIONINGValue); + /// Test run is deprovisioned. + public static Status DEPROVISIONED { get; } = new Status(DEPROVISIONEDValue); + /// Test run is completed. + public static Status DONE { get; } = new Status(DONEValue); + /// Test run is being cancelled. + public static Status CANCELLING { get; } = new Status(CANCELLINGValue); + /// Test run request is cancelled. + public static Status CANCELLED { get; } = new Status(CANCELLEDValue); + /// Test run request is failed. + public static Status FAILED { get; } = new Status(FAILEDValue); + /// Test run JMX file is validated. + public static Status VALIDATIONSUCCESS { get; } = new Status(VALIDATIONSUCCESSValue); + /// Test run JMX file validation is failed. + public static Status VALIDATIONFAILURE { get; } = new Status(VALIDATIONFAILUREValue); + /// Determines if two values are the same. + public static bool operator ==(Status left, Status right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Status left, Status right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator Status(string value) => new Status(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Status other && Equals(other); + /// + public bool Equals(Status other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.Serialization.cs new file mode 100644 index 0000000000000..83a43884c4efb --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + [PersistableModelProxy(typeof(UnknownTargetResourceConfigurations))] + public partial class TargetResourceConfigurations : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + + internal static TargetResourceConfigurations DeserializeTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "FunctionsFlexConsumption": return FunctionFlexConsumptionTargetResourceConfigurations.DeserializeFunctionFlexConsumptionTargetResourceConfigurations(element, options); + } + } + return UnknownTargetResourceConfigurations.DeserializeUnknownTargetResourceConfigurations(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTargetResourceConfigurations(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.cs new file mode 100644 index 0000000000000..688ae88d6ec83 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// + /// Configurations of a target resource. This varies with the kind of resource. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public abstract partial class TargetResourceConfigurations + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected TargetResourceConfigurations() + { + } + + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + internal TargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData) + { + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Kind of the resource for which the configurations apply. + internal ResourceKind Kind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.Serialization.cs new file mode 100644 index 0000000000000..fcf76470b9fd3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.Serialization.cs @@ -0,0 +1,511 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class Test : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Test)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(PassFailCriteria)) + { + writer.WritePropertyName("passFailCriteria"u8); + writer.WriteObjectValue(PassFailCriteria, options); + } + if (Optional.IsDefined(AutoStopCriteria)) + { + writer.WritePropertyName("autoStopCriteria"u8); + writer.WriteObjectValue(AutoStopCriteria, options); + } + if (Optional.IsCollectionDefined(Secrets)) + { + writer.WritePropertyName("secrets"u8); + writer.WriteStartObject(); + foreach (var item in Secrets) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Certificate)) + { + writer.WritePropertyName("certificate"u8); + writer.WriteObjectValue(Certificate, options); + } + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environmentVariables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(LoadTestConfiguration)) + { + writer.WritePropertyName("loadTestConfiguration"u8); + writer.WriteObjectValue(LoadTestConfiguration, options); + } + if (Optional.IsDefined(BaselineTestRunId)) + { + writer.WritePropertyName("baselineTestRunId"u8); + writer.WriteStringValue(BaselineTestRunId); + } + if (options.Format != "W" && Optional.IsDefined(InputArtifacts)) + { + writer.WritePropertyName("inputArtifacts"u8); + writer.WriteObjectValue(InputArtifacts, options); + } + if (options.Format != "W") + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(SubnetId)) + { + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + } + if (Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (Optional.IsDefined(PublicIPDisabled)) + { + writer.WritePropertyName("publicIPDisabled"u8); + writer.WriteBooleanValue(PublicIPDisabled.Value); + } + if (Optional.IsDefined(KeyvaultReferenceIdentityType)) + { + writer.WritePropertyName("keyvaultReferenceIdentityType"u8); + writer.WriteStringValue(KeyvaultReferenceIdentityType); + } + if (Optional.IsDefined(KeyvaultReferenceIdentityId)) + { + writer.WritePropertyName("keyvaultReferenceIdentityId"u8); + writer.WriteStringValue(KeyvaultReferenceIdentityId); + } + if (Optional.IsDefined(MetricsReferenceIdentityType)) + { + writer.WritePropertyName("metricsReferenceIdentityType"u8); + writer.WriteStringValue(MetricsReferenceIdentityType.Value.ToString()); + } + if (Optional.IsDefined(MetricsReferenceIdentityId)) + { + writer.WritePropertyName("metricsReferenceIdentityId"u8); + writer.WriteStringValue(MetricsReferenceIdentityId); + } + if (Optional.IsDefined(EngineBuiltInIdentityType)) + { + writer.WritePropertyName("engineBuiltInIdentityType"u8); + writer.WriteStringValue(EngineBuiltInIdentityType.Value.ToString()); + } + if (Optional.IsCollectionDefined(EngineBuiltInIdentityIds)) + { + writer.WritePropertyName("engineBuiltInIdentityIds"u8); + writer.WriteStartArray(); + foreach (var item in EngineBuiltInIdentityIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Test IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Test)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTest(document.RootElement, options); + } + + internal static Test DeserializeTest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PassFailCriteria passFailCriteria = default; + AutoStopCriteria autoStopCriteria = default; + IDictionary secrets = default; + CertificateMetadata certificate = default; + IDictionary environmentVariables = default; + LoadTestConfiguration loadTestConfiguration = default; + string baselineTestRunId = default; + TestInputArtifacts inputArtifacts = default; + string testId = default; + string description = default; + string displayName = default; + string subnetId = default; + TestKind? kind = default; + bool? publicIPDisabled = default; + string keyvaultReferenceIdentityType = default; + string keyvaultReferenceIdentityId = default; + ManagedIdentityType? metricsReferenceIdentityType = default; + string metricsReferenceIdentityId = default; + ManagedIdentityType? engineBuiltInIdentityType = default; + IList engineBuiltInIdentityIds = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("passFailCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + continue; + } + if (property.NameEquals("autoStopCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + continue; + } + if (property.NameEquals("secrets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, Secret.DeserializeSecret(property0.Value, options)); + } + secrets = dictionary; + continue; + } + if (property.NameEquals("certificate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + certificate = CertificateMetadata.DeserializeCertificateMetadata(property.Value, options); + continue; + } + if (property.NameEquals("environmentVariables"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + environmentVariables = dictionary; + continue; + } + if (property.NameEquals("loadTestConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("baselineTestRunId"u8)) + { + baselineTestRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("inputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifacts = TestInputArtifacts.DeserializeTestInputArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("subnetId"u8)) + { + subnetId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new TestKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("publicIPDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("keyvaultReferenceIdentityType"u8)) + { + keyvaultReferenceIdentityType = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyvaultReferenceIdentityId"u8)) + { + keyvaultReferenceIdentityId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metricsReferenceIdentityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + metricsReferenceIdentityType = new ManagedIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("metricsReferenceIdentityId"u8)) + { + metricsReferenceIdentityId = property.Value.GetString(); + continue; + } + if (property.NameEquals("engineBuiltInIdentityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + engineBuiltInIdentityType = new ManagedIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("engineBuiltInIdentityIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + engineBuiltInIdentityIds = array; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Test( + passFailCriteria, + autoStopCriteria, + secrets ?? new ChangeTrackingDictionary(), + certificate, + environmentVariables ?? new ChangeTrackingDictionary(), + loadTestConfiguration, + baselineTestRunId, + inputArtifacts, + testId, + description, + displayName, + subnetId, + kind, + publicIPDisabled, + keyvaultReferenceIdentityType, + keyvaultReferenceIdentityId, + metricsReferenceIdentityType, + metricsReferenceIdentityId, + engineBuiltInIdentityType, + engineBuiltInIdentityIds ?? new ChangeTrackingList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Test)} does not support writing '{options.Format}' format."); + } + } + + Test IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Test)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Test FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.cs new file mode 100644 index 0000000000000..c16ea755b9fa6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Test.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Load test model. + public partial class Test + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Test() + { + Secrets = new ChangeTrackingDictionary(); + EnvironmentVariables = new ChangeTrackingDictionary(); + EngineBuiltInIdentityIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// The load test configuration. + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + /// The input artifacts for the test. + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// The test description. + /// Display name of a test. + /// Subnet ID on which the load test instances should run. + /// Kind of test. + /// Inject load test engines without deploying public IP for outbound access. + /// Type of the managed identity referencing the Key vault. + /// Resource Id of the managed identity referencing the Key vault. + /// Type of the managed identity referencing the metrics. + /// Resource Id of the managed identity referencing the metrics. + /// Type of the managed identity built in load test engines. + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal Test(PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCriteria, IDictionary secrets, CertificateMetadata certificate, IDictionary environmentVariables, LoadTestConfiguration loadTestConfiguration, string baselineTestRunId, TestInputArtifacts inputArtifacts, string testId, string description, string displayName, string subnetId, TestKind? kind, bool? publicIPDisabled, string keyvaultReferenceIdentityType, string keyvaultReferenceIdentityId, ManagedIdentityType? metricsReferenceIdentityType, string metricsReferenceIdentityId, ManagedIdentityType? engineBuiltInIdentityType, IList engineBuiltInIdentityIds, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + PassFailCriteria = passFailCriteria; + AutoStopCriteria = autoStopCriteria; + Secrets = secrets; + Certificate = certificate; + EnvironmentVariables = environmentVariables; + LoadTestConfiguration = loadTestConfiguration; + BaselineTestRunId = baselineTestRunId; + InputArtifacts = inputArtifacts; + TestId = testId; + Description = description; + DisplayName = displayName; + SubnetId = subnetId; + Kind = kind; + PublicIPDisabled = publicIPDisabled; + KeyvaultReferenceIdentityType = keyvaultReferenceIdentityType; + KeyvaultReferenceIdentityId = keyvaultReferenceIdentityId; + MetricsReferenceIdentityType = metricsReferenceIdentityType; + MetricsReferenceIdentityId = metricsReferenceIdentityId; + EngineBuiltInIdentityType = engineBuiltInIdentityType; + EngineBuiltInIdentityIds = engineBuiltInIdentityIds; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Pass fail criteria for a test. + public PassFailCriteria PassFailCriteria { get; set; } + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public AutoStopCriteria AutoStopCriteria { get; set; } + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + public IDictionary Secrets { get; } + /// Certificates metadata. + public CertificateMetadata Certificate { get; set; } + /// Environment variables which are defined as a set of <name,value> pairs. + public IDictionary EnvironmentVariables { get; } + /// The load test configuration. + public LoadTestConfiguration LoadTestConfiguration { get; set; } + /// Id of the test run to be marked as baseline to view trends of client-side metrics from recent test runs. + public string BaselineTestRunId { get; set; } + /// The input artifacts for the test. + public TestInputArtifacts InputArtifacts { get; } + /// Unique test identifier for the load test, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestId { get; } + /// The test description. + public string Description { get; set; } + /// Display name of a test. + public string DisplayName { get; set; } + /// Subnet ID on which the load test instances should run. + public string SubnetId { get; set; } + /// Kind of test. + public TestKind? Kind { get; set; } + /// Inject load test engines without deploying public IP for outbound access. + public bool? PublicIPDisabled { get; set; } + /// Type of the managed identity referencing the Key vault. + public string KeyvaultReferenceIdentityType { get; set; } + /// Resource Id of the managed identity referencing the Key vault. + public string KeyvaultReferenceIdentityId { get; set; } + /// Type of the managed identity referencing the metrics. + public ManagedIdentityType? MetricsReferenceIdentityType { get; set; } + /// Resource Id of the managed identity referencing the metrics. + public string MetricsReferenceIdentityId { get; set; } + /// Type of the managed identity built in load test engines. + public ManagedIdentityType? EngineBuiltInIdentityType { get; set; } + /// Resource Ids of the managed identity built in to load test engines. Required if engineBuiltInIdentityType is UserAssigned. + public IList EngineBuiltInIdentityIds { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.Serialization.cs new file mode 100644 index 0000000000000..1aa72aae2f077 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestAppComponents : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestAppComponents)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("components"u8); + writer.WriteStartObject(); + foreach (var item in Components) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestAppComponents)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestAppComponents(document.RootElement, options); + } + + internal static TestAppComponents DeserializeTestAppComponents(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary components = default; + string testId = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("components"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, AppComponent.DeserializeAppComponent(property0.Value, options)); + } + components = dictionary; + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestAppComponents( + components, + testId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestAppComponents)} does not support writing '{options.Format}' format."); + } + } + + TestAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestAppComponents(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestAppComponents)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestAppComponents FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestAppComponents(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.cs new file mode 100644 index 0000000000000..08f2bf5175f9f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestAppComponents.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test app components. + public partial class TestAppComponents + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// is null. + public TestAppComponents(IDictionary components) + { + Argument.AssertNotNull(components, nameof(components)); + + Components = components; + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestAppComponents(IDictionary components, string testId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + Components = components; + TestId = testId; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestAppComponents() + { + } + + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + public IDictionary Components { get; } + /// Test identifier. + public string TestId { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.Serialization.cs new file mode 100644 index 0000000000000..5d29a2992995b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.Serialization.cs @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestFileInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestFileInfo)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + if (options.Format != "W" && Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpireDateTime)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpireDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ValidationStatus)) + { + writer.WritePropertyName("validationStatus"u8); + writer.WriteStringValue(ValidationStatus.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ValidationFailureDetails)) + { + writer.WritePropertyName("validationFailureDetails"u8); + writer.WriteStringValue(ValidationFailureDetails); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestFileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestFileInfo(document.RootElement, options); + } + + internal static TestFileInfo DeserializeTestFileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + Uri url = default; + FileType? fileType = default; + DateTimeOffset? expireDateTime = default; + FileStatus? validationStatus = default; + string validationFailureDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("fileType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileType = new FileType(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("validationStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + validationStatus = new FileStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("validationFailureDetails"u8)) + { + validationFailureDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestFileInfo)} does not support writing '{options.Format}' format."); + } + } + + TestFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestFileInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestFileInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestFileInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.cs new file mode 100644 index 0000000000000..7473a17037bd4 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestFileInfo.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test file info. + public partial class TestFileInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name of the file. + /// is null. + internal TestFileInfo(string fileName) + { + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileName = fileName; + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// Keeps track of any properties unknown to the library. + internal TestFileInfo(string fileName, Uri url, FileType? fileType, DateTimeOffset? expireDateTime, FileStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Url = url; + FileType = fileType; + ExpireDateTime = expireDateTime; + ValidationStatus = validationStatus; + ValidationFailureDetails = validationFailureDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestFileInfo() + { + } + + /// Name of the file. + public string FileName { get; } + /// File URL. + public Uri Url { get; } + /// File type. + public FileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpireDateTime { get; } + /// Validation status of the file. + public FileStatus? ValidationStatus { get; } + /// Validation failure error details. + public string ValidationFailureDetails { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.Serialization.cs new file mode 100644 index 0000000000000..6a8f7b485d53d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.Serialization.cs @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestInputArtifacts : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestInputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ConfigFileInfo)) + { + writer.WritePropertyName("configFileInfo"u8); + writer.WriteObjectValue(ConfigFileInfo, options); + } + if (Optional.IsDefined(TestScriptFileInfo)) + { + writer.WritePropertyName("testScriptFileInfo"u8); + writer.WriteObjectValue(TestScriptFileInfo, options); + } + if (Optional.IsDefined(UserPropFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropFileInfo, options); + } + if (Optional.IsDefined(InputArtifactsZipFileInfo)) + { + writer.WritePropertyName("inputArtifactsZipFileInfo"u8); + writer.WriteObjectValue(InputArtifactsZipFileInfo, options); + } + if (Optional.IsDefined(UrlTestConfigFileInfo)) + { + writer.WritePropertyName("urlTestConfigFileInfo"u8); + writer.WriteObjectValue(UrlTestConfigFileInfo, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalFileInfo)) + { + writer.WritePropertyName("additionalFileInfo"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalFileInfo) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestInputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestInputArtifacts(document.RootElement, options); + } + + internal static TestInputArtifacts DeserializeTestInputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestFileInfo configFileInfo = default; + TestFileInfo testScriptFileInfo = default; + TestFileInfo userPropFileInfo = default; + TestFileInfo inputArtifactsZipFileInfo = default; + TestFileInfo urlTestConfigFileInfo = default; + IReadOnlyList additionalFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("testScriptFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testScriptFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("userPropFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userPropFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifactsZipFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("urlTestConfigFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + urlTestConfigFileInfo = TestFileInfo.DeserializeTestFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("additionalFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestFileInfo.DeserializeTestFileInfo(item, options)); + } + additionalFileInfo = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestInputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestInputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestInputArtifacts)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestInputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestInputArtifacts(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.cs new file mode 100644 index 0000000000000..02998121eeb56 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestInputArtifacts.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The input artifacts for the test. + public partial class TestInputArtifacts + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TestInputArtifacts() + { + AdditionalFileInfo = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// File info. + /// File info. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// Keeps track of any properties unknown to the library. + internal TestInputArtifacts(TestFileInfo configFileInfo, TestFileInfo testScriptFileInfo, TestFileInfo userPropFileInfo, TestFileInfo inputArtifactsZipFileInfo, TestFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropFileInfo = userPropFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// File info. + public TestFileInfo ConfigFileInfo { get; } + /// File info. + public TestFileInfo TestScriptFileInfo { get; } + /// File info. + public TestFileInfo UserPropFileInfo { get; } + /// File info. + public TestFileInfo InputArtifactsZipFileInfo { get; } + /// The config json file for url based test. + public TestFileInfo UrlTestConfigFileInfo { get; } + /// Additional supported files for the test run. + public IReadOnlyList AdditionalFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestKind.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestKind.cs new file mode 100644 index 0000000000000..9ac517a5aff10 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestKind.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test kind. + public readonly partial struct TestKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string URLValue = "URL"; + private const string JMXValue = "JMX"; + private const string LocustValue = "Locust"; + + /// URL Test. + public static TestKind URL { get; } = new TestKind(URLValue); + /// JMX Test. + public static TestKind JMX { get; } = new TestKind(JMXValue); + /// Locust Test. + public static TestKind Locust { get; } = new TestKind(LocustValue); + /// Determines if two values are the same. + public static bool operator ==(TestKind left, TestKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestKind left, TestKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TestKind(string value) => new TestKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestKind other && Equals(other); + /// + public bool Equals(TestKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.Serialization.cs new file mode 100644 index 0000000000000..abfb91e8a896b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.Serialization.cs @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfile)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testProfileId"u8); + writer.WriteStringValue(TestProfileId); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(TargetResourceId)) + { + writer.WritePropertyName("targetResourceId"u8); + writer.WriteStringValue(TargetResourceId); + } + if (Optional.IsDefined(TargetResourceConfigurations)) + { + writer.WritePropertyName("targetResourceConfigurations"u8); + writer.WriteObjectValue(TargetResourceConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfile(document.RootElement, options); + } + + internal static TestProfile DeserializeTestProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testProfileId = default; + string displayName = default; + string description = default; + string testId = default; + string targetResourceId = default; + TargetResourceConfigurations targetResourceConfigurations = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testProfileId"u8)) + { + testProfileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceId"u8)) + { + targetResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfile( + testProfileId, + displayName, + description, + testId, + targetResourceId, + targetResourceConfigurations, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestProfile)} does not support writing '{options.Format}' format."); + } + } + + TestProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestProfile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestProfile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.cs new file mode 100644 index 0000000000000..38c5d1f23c6d7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The Test Profile Model. A Test Profile resource enables you to set up a test profile which contains various configurations for a supported resource type and a load test to execute on that resource. + public partial class TestProfile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestProfile() + { + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name of the test profile. + /// Description for the test profile. + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + /// + /// Configurations of the target resource on which testing would be done. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestProfile(string testProfileId, string displayName, string description, string testId, string targetResourceId, TargetResourceConfigurations targetResourceConfigurations, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestProfileId = testProfileId; + DisplayName = displayName; + Description = description; + TestId = testId; + TargetResourceId = targetResourceId; + TargetResourceConfigurations = targetResourceConfigurations; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier for the test profile, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestProfileId { get; } + /// Display name of the test profile. + public string DisplayName { get; set; } + /// Description for the test profile. + public string Description { get; set; } + /// Associated test ID for the test profile. This property is required for creating a Test Profile and it's not allowed to be updated. + public string TestId { get; set; } + /// Target resource ID on which the test profile is created. This property is required for creating a Test Profile and it's not allowed to be updated. + public string TargetResourceId { get; set; } + /// + /// Configurations of the target resource on which testing would be done. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public TargetResourceConfigurations TargetResourceConfigurations { get; set; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.Serialization.cs new file mode 100644 index 0000000000000..4efd2dc5b90db --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.Serialization.cs @@ -0,0 +1,410 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestProfileRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfileRun)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testProfileRunId"u8); + writer.WriteStringValue(TestProfileRunId); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(TestProfileId)) + { + writer.WritePropertyName("testProfileId"u8); + writer.WriteStringValue(TestProfileId); + } + if (options.Format != "W" && Optional.IsDefined(TargetResourceId)) + { + writer.WritePropertyName("targetResourceId"u8); + writer.WriteStringValue(TargetResourceId); + } + if (options.Format != "W" && Optional.IsDefined(TargetResourceConfigurations)) + { + writer.WritePropertyName("targetResourceConfigurations"u8); + writer.WriteObjectValue(TargetResourceConfigurations, options); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ErrorDetails)) + { + writer.WritePropertyName("errorDetails"u8); + writer.WriteStartArray(); + foreach (var item in ErrorDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(DurationInSeconds)) + { + writer.WritePropertyName("durationInSeconds"u8); + writer.WriteNumberValue(DurationInSeconds.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TestRunDetails)) + { + writer.WritePropertyName("testRunDetails"u8); + writer.WriteStartObject(); + foreach (var item in TestRunDetails) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Recommendations)) + { + writer.WritePropertyName("recommendations"u8); + writer.WriteStartArray(); + foreach (var item in Recommendations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestProfileRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfileRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfileRun(document.RootElement, options); + } + + internal static TestProfileRun DeserializeTestProfileRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testProfileRunId = default; + string displayName = default; + string description = default; + string testProfileId = default; + string targetResourceId = default; + TargetResourceConfigurations targetResourceConfigurations = default; + TestProfileRunStatus? status = default; + IReadOnlyList errorDetails = default; + DateTimeOffset? startDateTime = default; + DateTimeOffset? endDateTime = default; + long? durationInSeconds = default; + IReadOnlyDictionary testRunDetails = default; + IReadOnlyList recommendations = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testProfileRunId"u8)) + { + testProfileRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("testProfileId"u8)) + { + testProfileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceId"u8)) + { + targetResourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("targetResourceConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceConfigurations = TargetResourceConfigurations.DeserializeTargetResourceConfigurations(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new TestProfileRunStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.ErrorDetails.DeserializeErrorDetails(item, options)); + } + errorDetails = array; + continue; + } + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("durationInSeconds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + durationInSeconds = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("testRunDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, TestRunDetail.DeserializeTestRunDetail(property0.Value, options)); + } + testRunDetails = dictionary; + continue; + } + if (property.NameEquals("recommendations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestProfileRunRecommendation.DeserializeTestProfileRunRecommendation(item, options)); + } + recommendations = array; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfileRun( + testProfileRunId, + displayName, + description, + testProfileId, + targetResourceId, + targetResourceConfigurations, + status, + errorDetails ?? new ChangeTrackingList(), + startDateTime, + endDateTime, + durationInSeconds, + testRunDetails ?? new ChangeTrackingDictionary(), + recommendations ?? new ChangeTrackingList(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestProfileRun)} does not support writing '{options.Format}' format."); + } + } + + TestProfileRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestProfileRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfileRun)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestProfileRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestProfileRun(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.cs new file mode 100644 index 0000000000000..020765e25cd71 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The Test Profile Run Model. Test Profile Run resource enables you to instantiate an already created test profile and run load tests to get recommendations on the optimal configuration for the target resource. + public partial class TestProfileRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestProfileRun() + { + ErrorDetails = new ChangeTrackingList(); + TestRunDetails = new ChangeTrackingDictionary(); + Recommendations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Display name for the test profile run. + /// The test profile run description. + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + /// Target resource ID on which the test profile run is created. + /// + /// Configurations of the target resource on which the test profile ran. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + /// The test profile run status. + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + /// The test profile run start DateTime(RFC 3339 literal format). + /// The test profile run end DateTime(RFC 3339 literal format). + /// Test profile run duration in seconds. + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + /// Recommendations provided based on a successful test profile run. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestProfileRun(string testProfileRunId, string displayName, string description, string testProfileId, string targetResourceId, TargetResourceConfigurations targetResourceConfigurations, TestProfileRunStatus? status, IReadOnlyList errorDetails, DateTimeOffset? startDateTime, DateTimeOffset? endDateTime, long? durationInSeconds, IReadOnlyDictionary testRunDetails, IReadOnlyList recommendations, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestProfileRunId = testProfileRunId; + DisplayName = displayName; + Description = description; + TestProfileId = testProfileId; + TargetResourceId = targetResourceId; + TargetResourceConfigurations = targetResourceConfigurations; + Status = status; + ErrorDetails = errorDetails; + StartDateTime = startDateTime; + EndDateTime = endDateTime; + DurationInSeconds = durationInSeconds; + TestRunDetails = testRunDetails; + Recommendations = recommendations; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier for the test profile run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestProfileRunId { get; } + /// Display name for the test profile run. + public string DisplayName { get; set; } + /// The test profile run description. + public string Description { get; set; } + /// Associated test profile ID for the test profile run. This is required to create a test profile run and can't be updated. + public string TestProfileId { get; set; } + /// Target resource ID on which the test profile run is created. + public string TargetResourceId { get; } + /// + /// Configurations of the target resource on which the test profile ran. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include . + /// + public TargetResourceConfigurations TargetResourceConfigurations { get; } + /// The test profile run status. + public TestProfileRunStatus? Status { get; } + /// Error details if there is any failure in test profile run. These errors are specific to the Test Profile Run. + public IReadOnlyList ErrorDetails { get; } + /// The test profile run start DateTime(RFC 3339 literal format). + public DateTimeOffset? StartDateTime { get; } + /// The test profile run end DateTime(RFC 3339 literal format). + public DateTimeOffset? EndDateTime { get; } + /// Test profile run duration in seconds. + public long? DurationInSeconds { get; } + /// + /// Details of the test runs ran as part of the test profile run. + /// Key is the testRunId of the corresponding testRun. + /// + public IReadOnlyDictionary TestRunDetails { get; } + /// Recommendations provided based on a successful test profile run. + public IReadOnlyList Recommendations { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.Serialization.cs new file mode 100644 index 0000000000000..7fa4c4cd76051 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestProfileRunRecommendation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("category"u8); + writer.WriteStringValue(Category.ToString()); + if (Optional.IsCollectionDefined(Configurations)) + { + writer.WritePropertyName("configurations"u8); + writer.WriteStartArray(); + foreach (var item in Configurations) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestProfileRunRecommendation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestProfileRunRecommendation(document.RootElement, options); + } + + internal static TestProfileRunRecommendation DeserializeTestProfileRunRecommendation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RecommendationCategory category = default; + IReadOnlyList configurations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("category"u8)) + { + category = new RecommendationCategory(property.Value.GetString()); + continue; + } + if (property.NameEquals("configurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + configurations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestProfileRunRecommendation(category, configurations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} does not support writing '{options.Format}' format."); + } + } + + TestProfileRunRecommendation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestProfileRunRecommendation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestProfileRunRecommendation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestProfileRunRecommendation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestProfileRunRecommendation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.cs new file mode 100644 index 0000000000000..90f549283cd14 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunRecommendation.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// A recommendation object that provides a list of configuration that optimizes its category. + public partial class TestProfileRunRecommendation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Category of the recommendation. + internal TestProfileRunRecommendation(RecommendationCategory category) + { + Category = category; + Configurations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Category of the recommendation. + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + /// Keeps track of any properties unknown to the library. + internal TestProfileRunRecommendation(RecommendationCategory category, IReadOnlyList configurations, IDictionary serializedAdditionalRawData) + { + Category = category; + Configurations = configurations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestProfileRunRecommendation() + { + } + + /// Category of the recommendation. + public RecommendationCategory Category { get; } + /// List of configurations IDs for which the recommendation is applicable. These are a subset of the provided target resource configurations. + public IReadOnlyList Configurations { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunStatus.cs new file mode 100644 index 0000000000000..f98dc22655154 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRunStatus.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test profile run status. + public readonly partial struct TestProfileRunStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestProfileRunStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ACCEPTEDValue = "ACCEPTED"; + private const string NOTSTARTEDValue = "NOTSTARTED"; + private const string EXECUTINGValue = "EXECUTING"; + private const string DONEValue = "DONE"; + private const string CANCELLINGValue = "CANCELLING"; + private const string CANCELLEDValue = "CANCELLED"; + private const string FAILEDValue = "FAILED"; + + /// Test profile run request is accepted. + public static TestProfileRunStatus ACCEPTED { get; } = new TestProfileRunStatus(ACCEPTEDValue); + /// Test profile run is not yet started. + public static TestProfileRunStatus NOTSTARTED { get; } = new TestProfileRunStatus(NOTSTARTEDValue); + /// Test profile run has started executing. + public static TestProfileRunStatus EXECUTING { get; } = new TestProfileRunStatus(EXECUTINGValue); + /// Test profile run has completed successfully. + public static TestProfileRunStatus DONE { get; } = new TestProfileRunStatus(DONEValue); + /// Test profile run is being cancelled. + public static TestProfileRunStatus CANCELLING { get; } = new TestProfileRunStatus(CANCELLINGValue); + /// Test profile run is cancelled. + public static TestProfileRunStatus CANCELLED { get; } = new TestProfileRunStatus(CANCELLEDValue); + /// Test profile run has failed. + public static TestProfileRunStatus FAILED { get; } = new TestProfileRunStatus(FAILEDValue); + /// Determines if two values are the same. + public static bool operator ==(TestProfileRunStatus left, TestProfileRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestProfileRunStatus left, TestProfileRunStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TestProfileRunStatus(string value) => new TestProfileRunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestProfileRunStatus other && Equals(other); + /// + public bool Equals(TestProfileRunStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.Serialization.cs new file mode 100644 index 0000000000000..4929953a468bc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.Serialization.cs @@ -0,0 +1,685 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRun : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRun)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (Optional.IsDefined(PassFailCriteria)) + { + writer.WritePropertyName("passFailCriteria"u8); + writer.WriteObjectValue(PassFailCriteria, options); + } + if (Optional.IsDefined(AutoStopCriteria)) + { + writer.WritePropertyName("autoStopCriteria"u8); + writer.WriteObjectValue(AutoStopCriteria, options); + } + if (Optional.IsCollectionDefined(Secrets)) + { + writer.WritePropertyName("secrets"u8); + writer.WriteStartObject(); + foreach (var item in Secrets) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Certificate)) + { + writer.WritePropertyName("certificate"u8); + writer.WriteObjectValue(Certificate, options); + } + if (Optional.IsCollectionDefined(EnvironmentVariables)) + { + writer.WritePropertyName("environmentVariables"u8); + writer.WriteStartObject(); + foreach (var item in EnvironmentVariables) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ErrorDetails)) + { + writer.WritePropertyName("errorDetails"u8); + writer.WriteStartArray(); + foreach (var item in ErrorDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TestRunStatistics)) + { + writer.WritePropertyName("testRunStatistics"u8); + writer.WriteStartObject(); + foreach (var item in TestRunStatistics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RegionalStatistics)) + { + writer.WritePropertyName("regionalStatistics"u8); + writer.WriteStartObject(); + foreach (var item in RegionalStatistics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(LoadTestConfiguration)) + { + writer.WritePropertyName("loadTestConfiguration"u8); + writer.WriteObjectValue(LoadTestConfiguration, options); + } + if (options.Format != "W" && Optional.IsDefined(TestArtifacts)) + { + writer.WritePropertyName("testArtifacts"u8); + writer.WriteObjectValue(TestArtifacts, options); + } + if (options.Format != "W" && Optional.IsDefined(TestResult)) + { + writer.WritePropertyName("testResult"u8); + writer.WriteStringValue(TestResult.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(VirtualUsers)) + { + writer.WritePropertyName("virtualUsers"u8); + writer.WriteNumberValue(VirtualUsers.Value); + } + if (Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExecutedDateTime)) + { + writer.WritePropertyName("executedDateTime"u8); + writer.WriteStringValue(ExecutedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(PortalUrl)) + { + writer.WritePropertyName("portalUrl"u8); + writer.WriteStringValue(PortalUrl); + } + if (options.Format != "W" && Optional.IsDefined(Duration)) + { + writer.WritePropertyName("duration"u8); + writer.WriteNumberValue(Duration.Value); + } + if (options.Format != "W" && Optional.IsDefined(VirtualUserHours)) + { + writer.WritePropertyName("virtualUserHours"u8); + writer.WriteNumberValue(VirtualUserHours.Value); + } + if (options.Format != "W" && Optional.IsDefined(SubnetId)) + { + writer.WritePropertyName("subnetId"u8); + writer.WriteStringValue(SubnetId); + } + if (options.Format != "W" && Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (Optional.IsDefined(RequestDataLevel)) + { + writer.WritePropertyName("requestDataLevel"u8); + writer.WriteStringValue(RequestDataLevel.Value.ToString()); + } + if (Optional.IsDefined(DebugLogsEnabled)) + { + writer.WritePropertyName("debugLogsEnabled"u8); + writer.WriteBooleanValue(DebugLogsEnabled.Value); + } + if (options.Format != "W" && Optional.IsDefined(PublicIPDisabled)) + { + writer.WritePropertyName("publicIPDisabled"u8); + writer.WriteBooleanValue(PublicIPDisabled.Value); + } + if (Optional.IsDefined(CreatedByType)) + { + writer.WritePropertyName("createdByType"u8); + writer.WriteStringValue(CreatedByType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRun IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRun)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRun(document.RootElement, options); + } + + internal static TestRun DeserializeTestRun(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testRunId = default; + PassFailCriteria passFailCriteria = default; + AutoStopCriteria autoStopCriteria = default; + IDictionary secrets = default; + CertificateMetadata certificate = default; + IDictionary environmentVariables = default; + IReadOnlyList errorDetails = default; + IReadOnlyDictionary testRunStatistics = default; + IReadOnlyDictionary regionalStatistics = default; + LoadTestConfiguration loadTestConfiguration = default; + TestRunArtifacts testArtifacts = default; + PFTestResult? testResult = default; + int? virtualUsers = default; + string displayName = default; + string testId = default; + string description = default; + Status? status = default; + DateTimeOffset? startDateTime = default; + DateTimeOffset? endDateTime = default; + DateTimeOffset? executedDateTime = default; + string portalUrl = default; + long? duration = default; + double? virtualUserHours = default; + string subnetId = default; + TestKind? kind = default; + RequestDataLevel? requestDataLevel = default; + bool? debugLogsEnabled = default; + bool? publicIPDisabled = default; + CreateByTypes? createdByType = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("passFailCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + passFailCriteria = PassFailCriteria.DeserializePassFailCriteria(property.Value, options); + continue; + } + if (property.NameEquals("autoStopCriteria"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoStopCriteria = AutoStopCriteria.DeserializeAutoStopCriteria(property.Value, options); + continue; + } + if (property.NameEquals("secrets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, Secret.DeserializeSecret(property0.Value, options)); + } + secrets = dictionary; + continue; + } + if (property.NameEquals("certificate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + certificate = CertificateMetadata.DeserializeCertificateMetadata(property.Value, options); + continue; + } + if (property.NameEquals("environmentVariables"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + environmentVariables = dictionary; + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.ErrorDetails.DeserializeErrorDetails(item, options)); + } + errorDetails = array; + continue; + } + if (property.NameEquals("testRunStatistics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, Models.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + } + testRunStatistics = dictionary; + continue; + } + if (property.NameEquals("regionalStatistics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, Models.TestRunStatistics.DeserializeTestRunStatistics(property0.Value, options)); + } + regionalStatistics = dictionary; + continue; + } + if (property.NameEquals("loadTestConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + loadTestConfiguration = LoadTestConfiguration.DeserializeLoadTestConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("testArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testArtifacts = TestRunArtifacts.DeserializeTestRunArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("testResult"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testResult = new PFTestResult(property.Value.GetString()); + continue; + } + if (property.NameEquals("virtualUsers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUsers = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new Status(property.Value.GetString()); + continue; + } + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("executedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + executedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("portalUrl"u8)) + { + portalUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("duration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + duration = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("virtualUserHours"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + virtualUserHours = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("subnetId"u8)) + { + subnetId = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new TestKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("requestDataLevel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requestDataLevel = new RequestDataLevel(property.Value.GetString()); + continue; + } + if (property.NameEquals("debugLogsEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + debugLogsEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("publicIPDisabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPDisabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("createdByType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdByType = new CreateByTypes(property.Value.GetString()); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRun( + testRunId, + passFailCriteria, + autoStopCriteria, + secrets ?? new ChangeTrackingDictionary(), + certificate, + environmentVariables ?? new ChangeTrackingDictionary(), + errorDetails ?? new ChangeTrackingList(), + testRunStatistics ?? new ChangeTrackingDictionary(), + regionalStatistics ?? new ChangeTrackingDictionary(), + loadTestConfiguration, + testArtifacts, + testResult, + virtualUsers, + displayName, + testId, + description, + status, + startDateTime, + endDateTime, + executedDateTime, + portalUrl, + duration, + virtualUserHours, + subnetId, + kind, + requestDataLevel, + debugLogsEnabled, + publicIPDisabled, + createdByType, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRun)} does not support writing '{options.Format}' format."); + } + } + + TestRun IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRun(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRun)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRun FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRun(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.cs new file mode 100644 index 0000000000000..fcad81f941403 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.cs @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Load test run model. + public partial class TestRun + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestRun() + { + Secrets = new ChangeTrackingDictionary(); + EnvironmentVariables = new ChangeTrackingDictionary(); + ErrorDetails = new ChangeTrackingList(); + TestRunStatistics = new ChangeTrackingDictionary(); + RegionalStatistics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + /// Pass fail criteria for a test. + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + /// Certificates metadata. + /// Environment variables which are defined as a set of <name,value> pairs. + /// Error details if there is any failure in load test run. + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + /// The load test configuration. + /// Collection of test run artifacts. + /// Test result for pass/Fail criteria used during the test run. + /// Number of virtual users, for which test has been run. + /// Display name of a testRun. + /// Associated test Id. + /// The test run description. + /// The test run status. + /// The test run start DateTime(RFC 3339 literal format). + /// The test run end DateTime(RFC 3339 literal format). + /// Test run initiated time. + /// Portal url. + /// Test run duration in milliseconds. + /// Virtual user hours consumed by the test run. + /// Subnet ID on which the load test instances should run. + /// Type of test. + /// Request data collection level for test run. + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + /// Inject load test engines without deploying public IP for outbound access. + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestRun(string testRunId, PassFailCriteria passFailCriteria, AutoStopCriteria autoStopCriteria, IDictionary secrets, CertificateMetadata certificate, IDictionary environmentVariables, IReadOnlyList errorDetails, IReadOnlyDictionary testRunStatistics, IReadOnlyDictionary regionalStatistics, LoadTestConfiguration loadTestConfiguration, TestRunArtifacts testArtifacts, PFTestResult? testResult, int? virtualUsers, string displayName, string testId, string description, Status? status, DateTimeOffset? startDateTime, DateTimeOffset? endDateTime, DateTimeOffset? executedDateTime, string portalUrl, long? duration, double? virtualUserHours, string subnetId, TestKind? kind, RequestDataLevel? requestDataLevel, bool? debugLogsEnabled, bool? publicIPDisabled, CreateByTypes? createdByType, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestRunId = testRunId; + PassFailCriteria = passFailCriteria; + AutoStopCriteria = autoStopCriteria; + Secrets = secrets; + Certificate = certificate; + EnvironmentVariables = environmentVariables; + ErrorDetails = errorDetails; + TestRunStatistics = testRunStatistics; + RegionalStatistics = regionalStatistics; + LoadTestConfiguration = loadTestConfiguration; + TestArtifacts = testArtifacts; + TestResult = testResult; + VirtualUsers = virtualUsers; + DisplayName = displayName; + TestId = testId; + Description = description; + Status = status; + StartDateTime = startDateTime; + EndDateTime = endDateTime; + ExecutedDateTime = executedDateTime; + PortalUrl = portalUrl; + Duration = duration; + VirtualUserHours = virtualUserHours; + SubnetId = subnetId; + Kind = kind; + RequestDataLevel = requestDataLevel; + DebugLogsEnabled = debugLogsEnabled; + PublicIPDisabled = publicIPDisabled; + CreatedByType = createdByType; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique test run identifier for the load test run, must contain only lower-case alphabetic, numeric, underscore or hyphen characters. + public string TestRunId { get; } + /// Pass fail criteria for a test. + public PassFailCriteria PassFailCriteria { get; set; } + /// Auto stop criteria for a test. This will automatically stop a load test if the error percentage is high for a certain time window. + public AutoStopCriteria AutoStopCriteria { get; set; } + /// + /// Secrets can be stored in an Azure Key Vault or any other secret store. If the + /// secret is stored in an Azure Key Vault, the value should be the secret + /// identifier and the type should be AKV_SECRET_URI. If the secret is stored + /// elsewhere, the secret value should be provided directly and the type should be + /// SECRET_VALUE. + /// + public IDictionary Secrets { get; } + /// Certificates metadata. + public CertificateMetadata Certificate { get; set; } + /// Environment variables which are defined as a set of <name,value> pairs. + public IDictionary EnvironmentVariables { get; } + /// Error details if there is any failure in load test run. + public IReadOnlyList ErrorDetails { get; } + /// + /// Test run statistics. Key is the sampler name and value is the set of statistics for performance metrics like response time, throughput, etc. from the load test run. + /// The sampler name is the same as the name mentioned in the test script. + /// Sampler name "Total" represents the aggregated statistics of all the samplers. + /// + public IReadOnlyDictionary TestRunStatistics { get; } + /// + /// Regional statistics. Key is the Azure region name and value is the test run statistics. + /// The region name should of format accepted by ARM, and should be a region supported by Azure Load Testing. For example, East US should be passed as "eastus". + /// The region name must match one of the strings in the "Name" column returned from running the "az account list-locations -o table" Azure CLI command. + /// + public IReadOnlyDictionary RegionalStatistics { get; } + /// The load test configuration. + public LoadTestConfiguration LoadTestConfiguration { get; set; } + /// Collection of test run artifacts. + public TestRunArtifacts TestArtifacts { get; } + /// Test result for pass/Fail criteria used during the test run. + public PFTestResult? TestResult { get; } + /// Number of virtual users, for which test has been run. + public int? VirtualUsers { get; } + /// Display name of a testRun. + public string DisplayName { get; set; } + /// Associated test Id. + public string TestId { get; set; } + /// The test run description. + public string Description { get; set; } + /// The test run status. + public Status? Status { get; } + /// The test run start DateTime(RFC 3339 literal format). + public DateTimeOffset? StartDateTime { get; } + /// The test run end DateTime(RFC 3339 literal format). + public DateTimeOffset? EndDateTime { get; } + /// Test run initiated time. + public DateTimeOffset? ExecutedDateTime { get; } + /// Portal url. + public string PortalUrl { get; } + /// Test run duration in milliseconds. + public long? Duration { get; } + /// Virtual user hours consumed by the test run. + public double? VirtualUserHours { get; } + /// Subnet ID on which the load test instances should run. + public string SubnetId { get; } + /// Type of test. + public TestKind? Kind { get; } + /// Request data collection level for test run. + public RequestDataLevel? RequestDataLevel { get; set; } + /// Enable or disable debug level logging. True if debug logs are enabled for the test run. False otherwise. + public bool? DebugLogsEnabled { get; set; } + /// Inject load test engines without deploying public IP for outbound access. + public bool? PublicIPDisabled { get; } + /// The type of the entity that created the test run. (E.x. User, ScheduleTrigger, etc). + public CreateByTypes? CreatedByType { get; set; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.Serialization.cs new file mode 100644 index 0000000000000..409754c0c1319 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunAppComponents : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunAppComponents)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("components"u8); + writer.WriteStartObject(); + foreach (var item in Components) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(TestRunId)) + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunAppComponents IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunAppComponents)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunAppComponents(document.RootElement, options); + } + + internal static TestRunAppComponents DeserializeTestRunAppComponents(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary components = default; + string testRunId = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("components"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, AppComponent.DeserializeAppComponent(property0.Value, options)); + } + components = dictionary; + continue; + } + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunAppComponents( + components, + testRunId, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunAppComponents)} does not support writing '{options.Format}' format."); + } + } + + TestRunAppComponents IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunAppComponents(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunAppComponents)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunAppComponents FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunAppComponents(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.cs new file mode 100644 index 0000000000000..e36c08dae5f71 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunAppComponents.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test run app component. + public partial class TestRunAppComponents + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// is null. + public TestRunAppComponents(IDictionary components) + { + Argument.AssertNotNull(components, nameof(components)); + + Components = components; + } + + /// Initializes a new instance of . + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + /// Test run identifier. + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestRunAppComponents(IDictionary components, string testRunId, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + Components = components; + TestRunId = testRunId; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunAppComponents() + { + } + + /// + /// Azure resource collection { resource id (fully qualified resource Id e.g + /// subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}) + /// : resource object } + /// + public IDictionary Components { get; } + /// Test run identifier. + public string TestRunId { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.Serialization.cs new file mode 100644 index 0000000000000..0d645f65d7f07 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunArtifacts : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunArtifacts)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(InputArtifacts)) + { + writer.WritePropertyName("inputArtifacts"u8); + writer.WriteObjectValue(InputArtifacts, options); + } + if (Optional.IsDefined(OutputArtifacts)) + { + writer.WritePropertyName("outputArtifacts"u8); + writer.WriteObjectValue(OutputArtifacts, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunArtifacts(document.RootElement, options); + } + + internal static TestRunArtifacts DeserializeTestRunArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunInputArtifacts inputArtifacts = default; + TestRunOutputArtifacts outputArtifacts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("inputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifacts = TestRunInputArtifacts.DeserializeTestRunInputArtifacts(property.Value, options); + continue; + } + if (property.NameEquals("outputArtifacts"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + outputArtifacts = TestRunOutputArtifacts.DeserializeTestRunOutputArtifacts(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunArtifacts(inputArtifacts, outputArtifacts, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunArtifacts)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunArtifacts(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.cs new file mode 100644 index 0000000000000..7578b5ed6a056 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunArtifacts.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Collection of test run artifacts. + public partial class TestRunArtifacts + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TestRunArtifacts() + { + } + + /// Initializes a new instance of . + /// The input artifacts for the test run. + /// The output artifacts for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunArtifacts(TestRunInputArtifacts inputArtifacts, TestRunOutputArtifacts outputArtifacts, IDictionary serializedAdditionalRawData) + { + InputArtifacts = inputArtifacts; + OutputArtifacts = outputArtifacts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The input artifacts for the test run. + public TestRunInputArtifacts InputArtifacts { get; } + /// The output artifacts for the test run. + public TestRunOutputArtifacts OutputArtifacts { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.Serialization.cs new file mode 100644 index 0000000000000..eb1b223697af0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.Serialization.cs @@ -0,0 +1,169 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunDetail : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunDetail)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("configurationId"u8); + writer.WriteStringValue(ConfigurationId); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunDetail(document.RootElement, options); + } + + internal static TestRunDetail DeserializeTestRunDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Status status = default; + string configurationId = default; + IReadOnlyDictionary properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("status"u8)) + { + status = new Status(property.Value.GetString()); + continue; + } + if (property.NameEquals("configurationId"u8)) + { + configurationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + properties = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunDetail(status, configurationId, properties, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunDetail)} does not support writing '{options.Format}' format."); + } + } + + TestRunDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunDetail FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunDetail(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.cs new file mode 100644 index 0000000000000..d39ce04c438e7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunDetail.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Details of a particular test run for a test profile run. + public partial class TestRunDetail + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// or is null. + internal TestRunDetail(Status status, string configurationId, IReadOnlyDictionary properties) + { + Argument.AssertNotNull(configurationId, nameof(configurationId)); + Argument.AssertNotNull(properties, nameof(properties)); + + Status = status; + ConfigurationId = configurationId; + Properties = properties; + } + + /// Initializes a new instance of . + /// Status of the test run. + /// ID of the configuration on which the test ran. + /// Key value pair of extra properties associated with the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunDetail(Status status, string configurationId, IReadOnlyDictionary properties, IDictionary serializedAdditionalRawData) + { + Status = status; + ConfigurationId = configurationId; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunDetail() + { + } + + /// Status of the test run. + public Status Status { get; } + /// ID of the configuration on which the test ran. + public string ConfigurationId { get; } + /// Key value pair of extra properties associated with the test run. + public IReadOnlyDictionary Properties { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.Serialization.cs new file mode 100644 index 0000000000000..07ec51be4563d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.Serialization.cs @@ -0,0 +1,220 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunFileInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunFileInfo)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("fileName"u8); + writer.WriteStringValue(FileName); + if (options.Format != "W" && Optional.IsDefined(Url)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpireDateTime)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpireDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ValidationStatus)) + { + writer.WritePropertyName("validationStatus"u8); + writer.WriteStringValue(ValidationStatus.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ValidationFailureDetails)) + { + writer.WritePropertyName("validationFailureDetails"u8); + writer.WriteStringValue(ValidationFailureDetails); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunFileInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunFileInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunFileInfo(document.RootElement, options); + } + + internal static TestRunFileInfo DeserializeTestRunFileInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileName = default; + Uri url = default; + FileType? fileType = default; + DateTimeOffset? expireDateTime = default; + FileStatus? validationStatus = default; + string validationFailureDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("fileName"u8)) + { + fileName = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("fileType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileType = new FileType(property.Value.GetString()); + continue; + } + if (property.NameEquals("expireDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expireDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("validationStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + validationStatus = new FileStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("validationFailureDetails"u8)) + { + validationFailureDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunFileInfo( + fileName, + url, + fileType, + expireDateTime, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunFileInfo)} does not support writing '{options.Format}' format."); + } + } + + TestRunFileInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunFileInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunFileInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunFileInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunFileInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.cs new file mode 100644 index 0000000000000..07c2f393b5fef --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunFileInfo.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test run file info. + public partial class TestRunFileInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name of the file. + /// is null. + internal TestRunFileInfo(string fileName) + { + Argument.AssertNotNull(fileName, nameof(fileName)); + + FileName = fileName; + } + + /// Initializes a new instance of . + /// Name of the file. + /// File URL. + /// File type. + /// Expiry time of the file (RFC 3339 literal format). + /// Validation status of the file. + /// Validation failure error details. + /// Keeps track of any properties unknown to the library. + internal TestRunFileInfo(string fileName, Uri url, FileType? fileType, DateTimeOffset? expireDateTime, FileStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Url = url; + FileType = fileType; + ExpireDateTime = expireDateTime; + ValidationStatus = validationStatus; + ValidationFailureDetails = validationFailureDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestRunFileInfo() + { + } + + /// Name of the file. + public string FileName { get; } + /// File URL. + public Uri Url { get; } + /// File type. + public FileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpireDateTime { get; } + /// Validation status of the file. + public FileStatus? ValidationStatus { get; } + /// Validation failure error details. + public string ValidationFailureDetails { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.Serialization.cs new file mode 100644 index 0000000000000..be2ca41a58c2a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.Serialization.cs @@ -0,0 +1,241 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunInputArtifacts : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ConfigFileInfo)) + { + writer.WritePropertyName("configFileInfo"u8); + writer.WriteObjectValue(ConfigFileInfo, options); + } + if (Optional.IsDefined(TestScriptFileInfo)) + { + writer.WritePropertyName("testScriptFileInfo"u8); + writer.WriteObjectValue(TestScriptFileInfo, options); + } + if (Optional.IsDefined(UserPropFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropFileInfo, options); + } + if (Optional.IsDefined(InputArtifactsZipFileInfo)) + { + writer.WritePropertyName("inputArtifactsZipFileInfo"u8); + writer.WriteObjectValue(InputArtifactsZipFileInfo, options); + } + if (Optional.IsDefined(UrlTestConfigFileInfo)) + { + writer.WritePropertyName("urlTestConfigFileInfo"u8); + writer.WriteObjectValue(UrlTestConfigFileInfo, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(AdditionalFileInfo)) + { + writer.WritePropertyName("additionalFileInfo"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalFileInfo) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunInputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunInputArtifacts(document.RootElement, options); + } + + internal static TestRunInputArtifacts DeserializeTestRunInputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunFileInfo configFileInfo = default; + TestRunFileInfo testScriptFileInfo = default; + TestRunFileInfo userPropFileInfo = default; + TestRunFileInfo inputArtifactsZipFileInfo = default; + TestRunFileInfo urlTestConfigFileInfo = default; + IReadOnlyList additionalFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("testScriptFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + testScriptFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("userPropFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userPropFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("inputArtifactsZipFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + inputArtifactsZipFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("urlTestConfigFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + urlTestConfigFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("additionalFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TestRunFileInfo.DeserializeTestRunFileInfo(item, options)); + } + additionalFileInfo = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropFileInfo, + inputArtifactsZipFileInfo, + urlTestConfigFileInfo, + additionalFileInfo ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunInputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunInputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunInputArtifacts)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunInputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunInputArtifacts(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.cs new file mode 100644 index 0000000000000..4aec90e888df3 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunInputArtifacts.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The input artifacts for the test run. + public partial class TestRunInputArtifacts + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TestRunInputArtifacts() + { + AdditionalFileInfo = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// File info. + /// File info. + /// The config json file for url based test. + /// Additional supported files for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunInputArtifacts(TestRunFileInfo configFileInfo, TestRunFileInfo testScriptFileInfo, TestRunFileInfo userPropFileInfo, TestRunFileInfo inputArtifactsZipFileInfo, TestRunFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropFileInfo = userPropFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// File info. + public TestRunFileInfo ConfigFileInfo { get; } + /// File info. + public TestRunFileInfo TestScriptFileInfo { get; } + /// File info. + public TestRunFileInfo UserPropFileInfo { get; } + /// File info. + public TestRunFileInfo InputArtifactsZipFileInfo { get; } + /// The config json file for url based test. + public TestRunFileInfo UrlTestConfigFileInfo { get; } + /// Additional supported files for the test run. + public IReadOnlyList AdditionalFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.Serialization.cs new file mode 100644 index 0000000000000..6fba796609118 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.Serialization.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunOutputArtifacts : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunOutputArtifacts)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ResultFileInfo)) + { + writer.WritePropertyName("resultFileInfo"u8); + writer.WriteObjectValue(ResultFileInfo, options); + } + if (Optional.IsDefined(LogsFileInfo)) + { + writer.WritePropertyName("logsFileInfo"u8); + writer.WriteObjectValue(LogsFileInfo, options); + } + if (Optional.IsDefined(ArtifactsContainerInfo)) + { + writer.WritePropertyName("artifactsContainerInfo"u8); + writer.WriteObjectValue(ArtifactsContainerInfo, options); + } + if (Optional.IsDefined(ReportFileInfo)) + { + writer.WritePropertyName("reportFileInfo"u8); + writer.WriteObjectValue(ReportFileInfo, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunOutputArtifacts IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunOutputArtifacts)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunOutputArtifacts(document.RootElement, options); + } + + internal static TestRunOutputArtifacts DeserializeTestRunOutputArtifacts(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TestRunFileInfo resultFileInfo = default; + TestRunFileInfo logsFileInfo = default; + ArtifactsContainerInfo artifactsContainerInfo = default; + TestRunFileInfo reportFileInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resultFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resultFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("logsFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + logsFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (property.NameEquals("artifactsContainerInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + artifactsContainerInfo = ArtifactsContainerInfo.DeserializeArtifactsContainerInfo(property.Value, options); + continue; + } + if (property.NameEquals("reportFileInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + reportFileInfo = TestRunFileInfo.DeserializeTestRunFileInfo(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunOutputArtifacts(resultFileInfo, logsFileInfo, artifactsContainerInfo, reportFileInfo, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunOutputArtifacts)} does not support writing '{options.Format}' format."); + } + } + + TestRunOutputArtifacts IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunOutputArtifacts(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunOutputArtifacts)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunOutputArtifacts FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunOutputArtifacts(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.cs new file mode 100644 index 0000000000000..5d405ee0d8e2b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunOutputArtifacts.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The output artifacts for the test run. + public partial class TestRunOutputArtifacts + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TestRunOutputArtifacts() + { + } + + /// Initializes a new instance of . + /// File info. + /// File info. + /// The container for test run artifacts. + /// The report file for the test run. + /// Keeps track of any properties unknown to the library. + internal TestRunOutputArtifacts(TestRunFileInfo resultFileInfo, TestRunFileInfo logsFileInfo, ArtifactsContainerInfo artifactsContainerInfo, TestRunFileInfo reportFileInfo, IDictionary serializedAdditionalRawData) + { + ResultFileInfo = resultFileInfo; + LogsFileInfo = logsFileInfo; + ArtifactsContainerInfo = artifactsContainerInfo; + ReportFileInfo = reportFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// File info. + public TestRunFileInfo ResultFileInfo { get; } + /// File info. + public TestRunFileInfo LogsFileInfo { get; } + /// The container for test run artifacts. + public ArtifactsContainerInfo ArtifactsContainerInfo { get; } + /// The report file for the test run. + public TestRunFileInfo ReportFileInfo { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.Serialization.cs new file mode 100644 index 0000000000000..95e46fa142952 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.Serialization.cs @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunServerMetricConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunServerMetricConfig)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TestRunId)) + { + writer.WritePropertyName("testRunId"u8); + writer.WriteStringValue(TestRunId); + } + if (Optional.IsCollectionDefined(Metrics)) + { + writer.WritePropertyName("metrics"u8); + writer.WriteStartObject(); + foreach (var item in Metrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunServerMetricConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunServerMetricConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunServerMetricConfig(document.RootElement, options); + } + + internal static TestRunServerMetricConfig DeserializeTestRunServerMetricConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testRunId = default; + IDictionary metrics = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testRunId"u8)) + { + testRunId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + } + metrics = dictionary; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunServerMetricConfig( + testRunId, + metrics ?? new ChangeTrackingDictionary(), + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunServerMetricConfig)} does not support writing '{options.Format}' format."); + } + } + + TestRunServerMetricConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunServerMetricConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunServerMetricConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunServerMetricConfig FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunServerMetricConfig(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.cs new file mode 100644 index 0000000000000..ada85b9fd1723 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricConfig.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test run server metrics configuration. + public partial class TestRunServerMetricConfig + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public TestRunServerMetricConfig() + { + Metrics = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Test run identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestRunServerMetricConfig(string testRunId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestRunId = testRunId; + Metrics = metrics; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Test run identifier. + public string TestRunId { get; } + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + public IDictionary Metrics { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.Serialization.cs new file mode 100644 index 0000000000000..5d26d568164ab --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.Serialization.cs @@ -0,0 +1,451 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestRunStatistics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunStatistics)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Transaction)) + { + writer.WritePropertyName("transaction"u8); + writer.WriteStringValue(Transaction); + } + if (options.Format != "W" && Optional.IsDefined(SampleCount)) + { + writer.WritePropertyName("sampleCount"u8); + writer.WriteNumberValue(SampleCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ErrorCount)) + { + writer.WritePropertyName("errorCount"u8); + writer.WriteNumberValue(ErrorCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(ErrorPct)) + { + writer.WritePropertyName("errorPct"u8); + writer.WriteNumberValue(ErrorPct.Value); + } + if (options.Format != "W" && Optional.IsDefined(MeanResTime)) + { + writer.WritePropertyName("meanResTime"u8); + writer.WriteNumberValue(MeanResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MedianResTime)) + { + writer.WritePropertyName("medianResTime"u8); + writer.WriteNumberValue(MedianResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MaxResTime)) + { + writer.WritePropertyName("maxResTime"u8); + writer.WriteNumberValue(MaxResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MinResTime)) + { + writer.WritePropertyName("minResTime"u8); + writer.WriteNumberValue(MinResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct1ResTime)) + { + writer.WritePropertyName("pct1ResTime"u8); + writer.WriteNumberValue(Pct1ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct2ResTime)) + { + writer.WritePropertyName("pct2ResTime"u8); + writer.WriteNumberValue(Pct2ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct3ResTime)) + { + writer.WritePropertyName("pct3ResTime"u8); + writer.WriteNumberValue(Pct3ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct75ResTime)) + { + writer.WritePropertyName("pct75ResTime"u8); + writer.WriteNumberValue(Pct75ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct96ResTime)) + { + writer.WritePropertyName("pct96ResTime"u8); + writer.WriteNumberValue(Pct96ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct97ResTime)) + { + writer.WritePropertyName("pct97ResTime"u8); + writer.WriteNumberValue(Pct97ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct98ResTime)) + { + writer.WritePropertyName("pct98ResTime"u8); + writer.WriteNumberValue(Pct98ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct999ResTime)) + { + writer.WritePropertyName("pct999ResTime"u8); + writer.WriteNumberValue(Pct999ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Pct9999ResTime)) + { + writer.WritePropertyName("pct9999ResTime"u8); + writer.WriteNumberValue(Pct9999ResTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Throughput)) + { + writer.WritePropertyName("throughput"u8); + writer.WriteNumberValue(Throughput.Value); + } + if (options.Format != "W" && Optional.IsDefined(ReceivedKBytesPerSec)) + { + writer.WritePropertyName("receivedKBytesPerSec"u8); + writer.WriteNumberValue(ReceivedKBytesPerSec.Value); + } + if (options.Format != "W" && Optional.IsDefined(SentKBytesPerSec)) + { + writer.WritePropertyName("sentKBytesPerSec"u8); + writer.WriteNumberValue(SentKBytesPerSec.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunStatistics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestRunStatistics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunStatistics(document.RootElement, options); + } + + internal static TestRunStatistics DeserializeTestRunStatistics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string transaction = default; + double? sampleCount = default; + double? errorCount = default; + double? errorPct = default; + double? meanResTime = default; + double? medianResTime = default; + double? maxResTime = default; + double? minResTime = default; + double? pct1ResTime = default; + double? pct2ResTime = default; + double? pct3ResTime = default; + double? pct75ResTime = default; + double? pct96ResTime = default; + double? pct97ResTime = default; + double? pct98ResTime = default; + double? pct999ResTime = default; + double? pct9999ResTime = default; + double? throughput = default; + double? receivedKBytesPerSec = default; + double? sentKBytesPerSec = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("transaction"u8)) + { + transaction = property.Value.GetString(); + continue; + } + if (property.NameEquals("sampleCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sampleCount = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("errorCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorCount = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("errorPct"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errorPct = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("meanResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + meanResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("medianResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + medianResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("maxResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("minResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct1ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct1ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct2ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct2ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct3ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct3ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct75ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct75ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct96ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct96ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct97ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct97ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct98ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct98ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct999ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct999ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("pct9999ResTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pct9999ResTime = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("throughput"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + throughput = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("receivedKBytesPerSec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + receivedKBytesPerSec = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("sentKBytesPerSec"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sentKBytesPerSec = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestRunStatistics( + transaction, + sampleCount, + errorCount, + errorPct, + meanResTime, + medianResTime, + maxResTime, + minResTime, + pct1ResTime, + pct2ResTime, + pct3ResTime, + pct75ResTime, + pct96ResTime, + pct97ResTime, + pct98ResTime, + pct999ResTime, + pct9999ResTime, + throughput, + receivedKBytesPerSec, + sentKBytesPerSec, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestRunStatistics)} does not support writing '{options.Format}' format."); + } + } + + TestRunStatistics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestRunStatistics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunStatistics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestRunStatistics FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestRunStatistics(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.cs new file mode 100644 index 0000000000000..74478351d9c2a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatistics.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test run statistics. + public partial class TestRunStatistics + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TestRunStatistics() + { + } + + /// Initializes a new instance of . + /// Transaction name. + /// Sampler count. + /// Error count. + /// Error percentage. + /// Mean response time. + /// Median response time. + /// Max response time. + /// Minimum response time. + /// 90 percentile response time. + /// 95 percentile response time. + /// 99 percentile response time. + /// 75 percentile response time. + /// 96 percentile response time. + /// 97 percentile response time. + /// 98 percentile response time. + /// 99.9 percentile response time. + /// 99.99 percentile response time. + /// Throughput. + /// Received network bytes. + /// Send network bytes. + /// Keeps track of any properties unknown to the library. + internal TestRunStatistics(string transaction, double? sampleCount, double? errorCount, double? errorPct, double? meanResTime, double? medianResTime, double? maxResTime, double? minResTime, double? pct1ResTime, double? pct2ResTime, double? pct3ResTime, double? pct75ResTime, double? pct96ResTime, double? pct97ResTime, double? pct98ResTime, double? pct999ResTime, double? pct9999ResTime, double? throughput, double? receivedKBytesPerSec, double? sentKBytesPerSec, IDictionary serializedAdditionalRawData) + { + Transaction = transaction; + SampleCount = sampleCount; + ErrorCount = errorCount; + ErrorPct = errorPct; + MeanResTime = meanResTime; + MedianResTime = medianResTime; + MaxResTime = maxResTime; + MinResTime = minResTime; + Pct1ResTime = pct1ResTime; + Pct2ResTime = pct2ResTime; + Pct3ResTime = pct3ResTime; + Pct75ResTime = pct75ResTime; + Pct96ResTime = pct96ResTime; + Pct97ResTime = pct97ResTime; + Pct98ResTime = pct98ResTime; + Pct999ResTime = pct999ResTime; + Pct9999ResTime = pct9999ResTime; + Throughput = throughput; + ReceivedKBytesPerSec = receivedKBytesPerSec; + SentKBytesPerSec = sentKBytesPerSec; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Transaction name. + public string Transaction { get; } + /// Sampler count. + public double? SampleCount { get; } + /// Error count. + public double? ErrorCount { get; } + /// Error percentage. + public double? ErrorPct { get; } + /// Mean response time. + public double? MeanResTime { get; } + /// Median response time. + public double? MedianResTime { get; } + /// Max response time. + public double? MaxResTime { get; } + /// Minimum response time. + public double? MinResTime { get; } + /// 90 percentile response time. + public double? Pct1ResTime { get; } + /// 95 percentile response time. + public double? Pct2ResTime { get; } + /// 99 percentile response time. + public double? Pct3ResTime { get; } + /// 75 percentile response time. + public double? Pct75ResTime { get; } + /// 96 percentile response time. + public double? Pct96ResTime { get; } + /// 97 percentile response time. + public double? Pct97ResTime { get; } + /// 98 percentile response time. + public double? Pct98ResTime { get; } + /// 99.9 percentile response time. + public double? Pct999ResTime { get; } + /// 99.99 percentile response time. + public double? Pct9999ResTime { get; } + /// Throughput. + public double? Throughput { get; } + /// Received network bytes. + public double? ReceivedKBytesPerSec { get; } + /// Send network bytes. + public double? SentKBytesPerSec { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.Serialization.cs new file mode 100644 index 0000000000000..38bc7f1682530 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TestServerMetricConfig : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestServerMetricConfig)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TestId)) + { + writer.WritePropertyName("testId"u8); + writer.WriteStringValue(TestId); + } + writer.WritePropertyName("metrics"u8); + writer.WriteStartObject(); + foreach (var item in Metrics) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedDateTime)) + { + writer.WritePropertyName("lastModifiedDateTime"u8); + writer.WriteStringValue(LastModifiedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(LastModifiedBy)) + { + writer.WritePropertyName("lastModifiedBy"u8); + writer.WriteStringValue(LastModifiedBy); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestServerMetricConfig IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TestServerMetricConfig)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestServerMetricConfig(document.RootElement, options); + } + + internal static TestServerMetricConfig DeserializeTestServerMetricConfig(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string testId = default; + IDictionary metrics = default; + DateTimeOffset? createdDateTime = default; + string createdBy = default; + DateTimeOffset? lastModifiedDateTime = default; + string lastModifiedBy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("testId"u8)) + { + testId = property.Value.GetString(); + continue; + } + if (property.NameEquals("metrics"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, ResourceMetric.DeserializeResourceMetric(property0.Value, options)); + } + metrics = dictionary; + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("lastModifiedBy"u8)) + { + lastModifiedBy = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TestServerMetricConfig( + testId, + metrics, + createdDateTime, + createdBy, + lastModifiedDateTime, + lastModifiedBy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TestServerMetricConfig)} does not support writing '{options.Format}' format."); + } + } + + TestServerMetricConfig IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTestServerMetricConfig(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestServerMetricConfig)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TestServerMetricConfig FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTestServerMetricConfig(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.cs new file mode 100644 index 0000000000000..361b77bd6d0b7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricConfig.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Test server metrics configuration. + public partial class TestServerMetricConfig + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// is null. + public TestServerMetricConfig(IDictionary metrics) + { + Argument.AssertNotNull(metrics, nameof(metrics)); + + Metrics = metrics; + } + + /// Initializes a new instance of . + /// Test identifier. + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + /// The creation datetime(RFC 3339 literal format). + /// The user that created. + /// The last Modified datetime(RFC 3339 literal format). + /// The user that last modified. + /// Keeps track of any properties unknown to the library. + internal TestServerMetricConfig(string testId, IDictionary metrics, DateTimeOffset? createdDateTime, string createdBy, DateTimeOffset? lastModifiedDateTime, string lastModifiedBy, IDictionary serializedAdditionalRawData) + { + TestId = testId; + Metrics = metrics; + CreatedDateTime = createdDateTime; + CreatedBy = createdBy; + LastModifiedDateTime = lastModifiedDateTime; + LastModifiedBy = lastModifiedBy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TestServerMetricConfig() + { + } + + /// Test identifier. + public string TestId { get; } + /// + /// Azure resource metrics collection {metric id : metrics object} (Refer : + /// https://learn.microsoft.com/en-us/rest/api/monitor/metric-definitions/list#metricdefinition + /// for metric id). + /// + public IDictionary Metrics { get; } + /// The creation datetime(RFC 3339 literal format). + public DateTimeOffset? CreatedDateTime { get; } + /// The user that created. + public string CreatedBy { get; } + /// The last Modified datetime(RFC 3339 literal format). + public DateTimeOffset? LastModifiedDateTime { get; } + /// The user that last modified. + public string LastModifiedBy { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeGrain.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeGrain.cs new file mode 100644 index 0000000000000..4e1905de93060 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeGrain.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Time Grain. + public readonly partial struct TimeGrain : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TimeGrain(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PT5SValue = "PT5S"; + private const string PT10SValue = "PT10S"; + private const string PT1MValue = "PT1M"; + private const string PT5MValue = "PT5M"; + private const string PT1HValue = "PT1H"; + + /// 5 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain PT5S { get; } = new TimeGrain(PT5SValue); + /// 10 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain PT10S { get; } = new TimeGrain(PT10SValue); + /// 1 minute. + public static TimeGrain PT1M { get; } = new TimeGrain(PT1MValue); + /// 5 minutes, available only if test run duration is greater than 1 minute. + public static TimeGrain PT5M { get; } = new TimeGrain(PT5MValue); + /// 1 hour, available only if test run duration is greater than 1 minute. + public static TimeGrain PT1H { get; } = new TimeGrain(PT1HValue); + /// Determines if two values are the same. + public static bool operator ==(TimeGrain left, TimeGrain right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TimeGrain left, TimeGrain right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TimeGrain(string value) => new TimeGrain(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TimeGrain other && Equals(other); + /// + public bool Equals(TimeGrain other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.Serialization.cs new file mode 100644 index 0000000000000..593e92d0bf38b --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.Serialization.cs @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + public partial class TimeSeriesElement : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimeSeriesElement)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DimensionValues)) + { + writer.WritePropertyName("dimensionValues"u8); + writer.WriteStartArray(); + foreach (var item in DimensionValues) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TimeSeriesElement IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TimeSeriesElement)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTimeSeriesElement(document.RootElement, options); + } + + internal static TimeSeriesElement DeserializeTimeSeriesElement(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList data = default; + IReadOnlyList dimensionValues = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricValue.DeserializeMetricValue(item, options)); + } + data = array; + continue; + } + if (property.NameEquals("dimensionValues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DimensionValue.DeserializeDimensionValue(item, options)); + } + dimensionValues = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TimeSeriesElement(data ?? new ChangeTrackingList(), dimensionValues ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TimeSeriesElement)} does not support writing '{options.Format}' format."); + } + } + + TimeSeriesElement IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTimeSeriesElement(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TimeSeriesElement)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TimeSeriesElement FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTimeSeriesElement(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.cs new file mode 100644 index 0000000000000..f7aa8099f958a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TimeSeriesElement.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// The time series returned when a data query is performed. + public partial class TimeSeriesElement + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal TimeSeriesElement() + { + Data = new ChangeTrackingList(); + DimensionValues = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// An array of data points representing the metric values. + /// The dimension values. + /// Keeps track of any properties unknown to the library. + internal TimeSeriesElement(IReadOnlyList data, IReadOnlyList dimensionValues, IDictionary serializedAdditionalRawData) + { + Data = data; + DimensionValues = dimensionValues; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// An array of data points representing the metric values. + public IReadOnlyList Data { get; } + /// The dimension values. + public IReadOnlyList DimensionValues { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.Serialization.cs new file mode 100644 index 0000000000000..1dbe573feea81 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Developer.LoadTesting.Models +{ + internal partial class UnknownTargetResourceConfigurations : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + TargetResourceConfigurations IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + + internal static UnknownTargetResourceConfigurations DeserializeUnknownTargetResourceConfigurations(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new ResourceKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownTargetResourceConfigurations(kind, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support writing '{options.Format}' format."); + } + } + + TargetResourceConfigurations IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTargetResourceConfigurations(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetResourceConfigurations)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownTargetResourceConfigurations FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownTargetResourceConfigurations(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.cs new file mode 100644 index 0000000000000..90008a4d42059 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/UnknownTargetResourceConfigurations.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.Developer.LoadTesting.Models +{ + /// Unknown version of TargetResourceConfigurations. + internal partial class UnknownTargetResourceConfigurations : TargetResourceConfigurations + { + /// Initializes a new instance of . + /// Kind of the resource for which the configurations apply. + /// Keeps track of any properties unknown to the library. + internal UnknownTargetResourceConfigurations(ResourceKind kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownTargetResourceConfigurations() + { + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000000..7a74481114125 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.Developer.LoadTesting.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Azure.Developer.LoadTesting.Tests.csproj b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Azure.Developer.LoadTesting.Tests.csproj new file mode 100644 index 0000000000000..ed860a4c070a2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Azure.Developer.LoadTesting.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestAdministrationClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestAdministrationClient.cs new file mode 100644 index 0000000000000..84e016f98153f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestAdministrationClient.cs @@ -0,0 +1,939 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Developer.LoadTesting.Models; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Developer.LoadTesting.Samples +{ + public partial class Samples_LoadTestAdministrationClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_CreateOrUpdateTest_CreateOrUpdateALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + description = "sample description", + displayName = "Performance_LoadTest", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + subnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0", + keyvaultReferenceIdentityType = "UserAssigned", + keyvaultReferenceIdentityId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename", + metricsReferenceIdentityType = "UserAssigned", + metricsReferenceIdentityId = "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename", + engineBuiltInIdentityType = "UserAssigned", + engineBuiltInIdentityIds = new object[] + { +"/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename" + }, + }); + Response response = client.CreateOrUpdateTest("12345678-1234-1234-1234-123456789012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_CreateOrUpdateTest_CreateOrUpdateALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + description = "sample description", + displayName = "Performance_LoadTest", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + subnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Network/virtualNetworks/samplenetworkresource/subnets/AAAAA0A0A0", + keyvaultReferenceIdentityType = "UserAssigned", + keyvaultReferenceIdentityId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/sampleprovider/sampleresourcetype/sampleresourcename", + metricsReferenceIdentityType = "UserAssigned", + metricsReferenceIdentityId = "/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename", + engineBuiltInIdentityType = "UserAssigned", + engineBuiltInIdentityIds = new object[] + { +"/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/samplerg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/sampleresourcename" + }, + }); + Response response = await client.CreateOrUpdateTestAsync("12345678-1234-1234-1234-123456789012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_CreateOrUpdateAppComponents_AddOrUpdateAppComponentsToALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, + }); + Response response = client.CreateOrUpdateAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_CreateOrUpdateAppComponents_AddOrUpdateAppComponentsToALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, + }); + Response response = await client.CreateOrUpdateAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_CreateOrUpdateServerMetricsConfig_AddOrUpdateServerMetricsConfigurationForALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, + }); + Response response = client.CreateOrUpdateServerMetricsConfig("edc6e529-d009-4b99-b763-ca492e3a2823", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_CreateOrUpdateServerMetricsConfig_AddOrUpdateServerMetricsConfigurationForALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, + }); + Response response = await client.CreateOrUpdateServerMetricsConfigAsync("edc6e529-d009-4b99-b763-ca492e3a2823", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTest_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTest_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("metricNamespace").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("name").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("aggregation").ToString()); + Console.WriteLine(result.GetProperty("metrics").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTest_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTest_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_GetTest_GetALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTest("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_GetTest_GetALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestAsync("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_GetTest_GetALoadTest_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTest("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_GetTest_GetALoadTest_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestAsync("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestFileInfo_GetTestFile_GetAFileFromALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestFileInfo_GetTestFile_GetAFileFromALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestFileInfo_GetTestFile_GetAFileFromALoadTest_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestFileInfo_GetTestFile_GetAFileFromALoadTest_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_UploadTestFile_UploadInputFileForAGivenTestName() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create("application/octet-stream content"); + Response response = client.UploadTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_UploadTestFile_UploadInputFileForAGivenTestName_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create("application/octet-stream content"); + Response response = await client.UploadTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_AdministrationOperations_UploadTestFile_UploadInputFileForAGivenTestName_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.UploadTestFile("12345678-1234-1234-1234-123456789012", "sample.jmx", BinaryData.FromObjectAsJson("application/octet-stream content")); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_AdministrationOperations_UploadTestFile_UploadInputFileForAGivenTestName_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.UploadTestFileAsync("12345678-1234-1234-1234-123456789012", "sample.jmx", BinaryData.FromObjectAsJson("application/octet-stream content")); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestFileInfo_DeleteTestFile_DeleteAFileFromALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.DeleteTestFile("12345678-1234-1234-1234-123456789012", "app.jmx"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestFileInfo_DeleteTestFile_DeleteAFileFromALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.DeleteTestFileAsync("12345678-1234-1234-1234-123456789012", "app.jmx"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_DeleteTest_DeleteALoadTest() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.DeleteTest("12345678-1234-1234-1234-123456789012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_DeleteTest_DeleteALoadTest_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.DeleteTestAsync("12345678-1234-1234-1234-123456789012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_CreateOrUpdateTestProfile_CreateOrUpdateATestProfile() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + description = "sample description", + displayName = "Performance_TestProfile", + testId = "12346-abcd-6789", + targetResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Web/sites/myfunctionapp", + targetResourceConfigurations = new + { + kind = "FunctionsFlexConsumption", + configurations = new + { + config1 = new + { + instanceMemoryMB = 2048L, + httpConcurrency = 16L, + }, + config2 = new + { + instanceMemoryMB = 4096L, + httpConcurrency = 16L, + }, + }, + }, + }); + Response response = client.CreateOrUpdateTestProfile("12345678-1234-1234-1234-123456789012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_CreateOrUpdateTestProfile_CreateOrUpdateATestProfile_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + description = "sample description", + displayName = "Performance_TestProfile", + testId = "12346-abcd-6789", + targetResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/Microsoft.Web/sites/myfunctionapp", + targetResourceConfigurations = new + { + kind = "FunctionsFlexConsumption", + configurations = new + { + config1 = new + { + instanceMemoryMB = 2048L, + httpConcurrency = 16L, + }, + config2 = new + { + instanceMemoryMB = 4096L, + httpConcurrency = 16L, + }, + }, + }, + }); + Response response = await client.CreateOrUpdateTestProfileAsync("12345678-1234-1234-1234-123456789012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_DeleteTestProfile_DeleteATestProfile() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.DeleteTestProfile("12345678-1234-1234-1234-123456789012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_DeleteTestProfile_DeleteATestProfile_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.DeleteTestProfileAsync("12345678-1234-1234-1234-123456789012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_GetTestProfile_GetATestProfile() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTestProfile("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_GetTestProfile_GetATestProfile_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestProfileAsync("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_GetTestProfile_GetATestProfile_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = client.GetTestProfile("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_GetTestProfile_GetATestProfile_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + Response response = await client.GetTestProfileAsync("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestFileInfo_GetTestFiles_GetAllTestFiles() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (BinaryData item in client.GetTestFiles("12345678-1234-1234-1234-123456789012", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestFileInfo_GetTestFiles_GetAllTestFiles_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTestFilesAsync("12345678-1234-1234-1234-123456789012", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestFileInfo_GetTestFiles_GetAllTestFiles_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (TestFileInfo item in client.GetTestFiles("12345678-1234-1234-1234-123456789012")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestFileInfo_GetTestFiles_GetAllTestFiles_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (TestFileInfo item in client.GetTestFilesAsync("12345678-1234-1234-1234-123456789012")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_GetTests_GetAllLoadTests() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (BinaryData item in client.GetTests(null, "Performance_LoadTest", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_GetTests_GetAllLoadTests_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTestsAsync(null, "Performance_LoadTest", null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Test_GetTests_GetAllLoadTests_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (Test item in client.GetTests()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Test_GetTests_GetAllLoadTests_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (Test item in client.GetTestsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_GetTestProfiles_GetAllTestProfilesForTheSpecifiedFilters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (BinaryData item in client.GetTestProfiles(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, "12346-abcd-6789", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_GetTestProfiles_GetAllTestProfilesForTheSpecifiedFilters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTestProfilesAsync(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, "12346-abcd-6789", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfile_GetTestProfiles_GetAllTestProfilesForTheSpecifiedFilters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + foreach (TestProfile item in client.GetTestProfiles()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfile_GetTestProfiles_GetAllTestProfilesForTheSpecifiedFilters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestAdministrationClient client = new LoadTestAdministrationClient(endpoint, credential); + + await foreach (TestProfile item in client.GetTestProfilesAsync()) + { + } + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestRunClient.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestRunClient.cs new file mode 100644 index 0000000000000..81d832c913718 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestRunClient.cs @@ -0,0 +1,1129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Developer.LoadTesting.Models; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.Developer.LoadTesting.Samples +{ + public partial class Samples_LoadTestRunClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_CreateOrUpdateTestRun_CreateUpdateAndStartALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + displayName = "Performance_LoadTest_Run1", + testId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + debugLogsEnabled = true, + requestDataLevel = "NONE", + }); + Response response = client.CreateOrUpdateTestRun("12316678-1234-1234-1234-122451189012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_CreateOrUpdateTestRun_CreateUpdateAndStartALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + displayName = "Performance_LoadTest_Run1", + testId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + loadTestConfiguration = new + { + engineInstances = 6, + splitAllCSVs = true, + }, + passFailCriteria = new + { + passFailMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + clientMetric = "response_time_ms", + aggregate = "percentage", + condition = ">", + value = 20, + action = "continue", + } + }, + passFailServerMetrics = new Dictionary + { + ["fefd759d-7fe8-4f83-8b6d-aeebe0f491fe"] = new + { + resourceId = "/subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM", + metricNamespace = "Microsoft.Compute/virtualMachines", + metricName = "Percentage CPU", + aggregation = "Average", + condition = ">", + value = 20, + action = "continue", + } + }, + }, + autoStopCriteria = new + { + autoStopDisabled = true, + errorRate = 70F, + errorRateTimeWindowInSeconds = 60, + }, + secrets = new + { + secret1 = new + { + value = "https://samplevault.vault.azure.net/secrets/samplesecret/f113f91fd4c44a368049849c164db827", + type = "AKV_SECRET_URI", + }, + }, + environmentVariables = new + { + envvar1 = "sampletext", + }, + debugLogsEnabled = true, + requestDataLevel = "NONE", + }); + Response response = await client.CreateOrUpdateTestRunAsync("12316678-1234-1234-1234-122451189012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_CreateOrUpdateAppComponents_AddOrUpdateAppComponentsToALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, + }); + Response response = client.CreateOrUpdateAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_CreateOrUpdateAppComponents_AddOrUpdateAppComponentsToALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + components = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource"] = new + { + resourceType = "microsoft.insights/components", + resourceName = "appcomponentresource", + displayName = "Performance_LoadTest_Insights", + kind = "web", + } + }, + }); + Response response = await client.CreateOrUpdateAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_CreateOrUpdateServerMetricsConfig_AddOrUpdateServerMetricsConfigurationForALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, + }); + Response response = client.CreateOrUpdateServerMetricsConfig("edc6e529-d009-4b99-b763-ca492e3a2823", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_CreateOrUpdateServerMetricsConfig_AddOrUpdateServerMetricsConfigurationForALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + metrics = new Dictionary + { + ["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource/providers/microsoft.insights/metricdefinitions/requests/duration"] = new + { + resourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplerg/providers/microsoft.insights/components/appcomponentresource", + metricNamespace = "microsoft.insights/components", + displayDescription = "sample description", + name = "requests/duration", + aggregation = "Average", + resourceType = "microsoft.insights/components", + } + }, + }); + Response response = await client.CreateOrUpdateServerMetricsConfigAsync("edc6e529-d009-4b99-b763-ca492e3a2823", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_DeleteTestRun_DeleteALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.DeleteTestRun("12316678-1234-1234-1234-122451189012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_DeleteTestRun_DeleteALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.DeleteTestRunAsync("12316678-1234-1234-1234-122451189012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceId").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceName").ToString()); + Console.WriteLine(result.GetProperty("components").GetProperty("").GetProperty("resourceType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetAppComponents("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetAppComponents_GetAssociatedAppComponentForTheGivenTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetAppComponentsAsync("ee843bd9-a6d4-4364-a45c-427a03c39fa7"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetServerMetricsConfig("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetServerMetricsConfig_ListServerMetricsConfigurationForTheGivenTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetServerMetricsConfigAsync("12345678-1234-1234-1234-123456789012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_GetTestRun_GetALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestRun("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_GetTestRun_GetALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestRunAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_GetTestRun_GetALoadTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestRun("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_GetTestRun_GetALoadTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestRunAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunFileInfo_GetTestRunFile_GetAFileAssociatedToALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestRunFile("12316678-1234-1234-1234-122451189012", "sample.jmx", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunFileInfo_GetTestRunFile_GetAFileAssociatedToALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestRunFileAsync("12316678-1234-1234-1234-122451189012", "sample.jmx", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("fileName").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunFileInfo_GetTestRunFile_GetAFileAssociatedToALoadTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestRunFile("12316678-1234-1234-1234-122451189012", "sample.jmx"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunFileInfo_GetTestRunFile_GetAFileAssociatedToALoadTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestRunFileAsync("12316678-1234-1234-1234-122451189012", "sample.jmx"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricDefinitions_ListTheMetricDefinitionsForALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetMetricDefinitions("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricDefinitions_ListTheMetricDefinitionsForALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetMetricDefinitionsAsync("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricDefinitions_ListTheMetricDefinitionsForALoadTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetMetricDefinitions("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricDefinitions_ListTheMetricDefinitionsForALoadTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetMetricDefinitionsAsync("12316678-1234-1234-1234-122451189012", "LoadTestRunMetrics"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricNamespaces_ListTheMetricNamespacesForALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetMetricNamespaces("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricNamespaces_ListTheMetricNamespacesForALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetMetricNamespacesAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricNamespaces_ListTheMetricNamespacesForALoadTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetMetricNamespaces("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricNamespaces_ListTheMetricNamespacesForALoadTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetMetricNamespacesAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_StopTestRun_StopTestRunByName() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.StopTestRun("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_StopTestRun_StopTestRunByName_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.StopTestRunAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_StopTestRun_StopTestRunByName_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.StopTestRun("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_StopTestRun_StopTestRunByName_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.StopTestRunAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_CreateOrUpdateTestProfileRun_CreateUpdateAndStartATestProfileRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + displayName = "Performance_TestProfile_Run1", + testProfileId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + }); + Response response = client.CreateOrUpdateTestProfileRun("12316678-1234-1234-1234-122451189012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_CreateOrUpdateTestProfileRun_CreateUpdateAndStartATestProfileRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + displayName = "Performance_TestProfile_Run1", + testProfileId = "12345678-1234-1234-1234-123456789012", + description = "sample description", + }); + Response response = await client.CreateOrUpdateTestProfileRunAsync("12316678-1234-1234-1234-122451189012", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_DeleteTestProfileRun_DeletesATestProfileRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.DeleteTestProfileRun("12316678-1234-1234-1234-122451189012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_DeleteTestProfileRun_DeletesATestProfileRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.DeleteTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunAfterTheRunHasExecuted() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunAfterTheRunHasExecuted_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunAfterTheRunHasExecuted_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunAfterTheRunHasExecuted_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunWhileTheRunIsExecuting() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunWhileTheRunIsExecuting_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunWhileTheRunIsExecuting_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.GetTestProfileRun("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRun_GetATestProfileRunWhileTheRunIsExecuting_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.GetTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_StopTestProfileRun_StopATestProfileRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.StopTestProfileRun("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_StopTestProfileRun_StopATestProfileRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.StopTestProfileRunAsync("12316678-1234-1234-1234-122451189012", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_StopTestProfileRun_StopATestProfileRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = client.StopTestProfileRun("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_StopTestProfileRun_StopATestProfileRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + Response response = await client.StopTestProfileRunAsync("12316678-1234-1234-1234-122451189012"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricDimensionValues_ListTheDimensionValuesForTheGivenMetricDimensionName() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (BinaryData item in client.GetMetricDimensionValues("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", "PT1H", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricDimensionValues_ListTheDimensionValuesForTheGivenMetricDimensionName_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (BinaryData item in client.GetMetricDimensionValuesAsync("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", "PT1H", null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetricDimensionValues_ListTheDimensionValuesForTheGivenMetricDimensionName_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (string item in client.GetMetricDimensionValues("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetricDimensionValues_ListTheDimensionValuesForTheGivenMetricDimensionName_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (string item in client.GetMetricDimensionValuesAsync("12316678-1234-1234-1234-122451189012", "SamplerName", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetrics_ListTheMetricValuesForALoadTestRun() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + filters = new object[] + { +new +{ +name = "SamplerName", +values = new object[] +{ +"HTTP Request" +}, +} + }, + }); + foreach (BinaryData item in client.GetMetrics("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", content)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetrics_ListTheMetricValuesForALoadTestRun_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + using RequestContent content = RequestContent.Create(new + { + filters = new object[] + { +new +{ +name = "SamplerName", +values = new object[] +{ +"HTTP Request" +}, +} + }, + }); + await foreach (BinaryData item in client.GetMetricsAsync("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z", content)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRunOperations_GetMetrics_ListTheMetricValuesForALoadTestRun_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (TimeSeriesElement item in client.GetMetrics("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRunOperations_GetMetrics_ListTheMetricValuesForALoadTestRun_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (TimeSeriesElement item in client.GetMetricsAsync("12316678-1234-1234-1234-122451189012", "ActiveThreads", "LoadTestRunMetrics", "2022-09-24T19:00:40Z/2022-09-25T19:28:40Z")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_GetTestRuns_ListTestRuns() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (BinaryData item in client.GetTestRuns(null, "Performance_LoadTest_Run1", "12345678-1234-1234-1234-123456789012", DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), "DONE,EXECUTING", null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_GetTestRuns_ListTestRuns_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTestRunsAsync(null, "Performance_LoadTest_Run1", "12345678-1234-1234-1234-123456789012", DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), DateTimeOffset.Parse("2021-12-05T16:43:48.805Z"), "DONE,EXECUTING", null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testRunId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestRun_GetTestRuns_ListTestRuns_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (TestRun item in client.GetTestRuns()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestRun_GetTestRuns_ListTestRuns_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (TestRun item in client.GetTestRunsAsync()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRuns_GetAllTestProfileRunsForTheSpecifiedFilters() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (BinaryData item in client.GetTestProfileRuns(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRuns_GetAllTestProfileRunsForTheSpecifiedFilters_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (BinaryData item in client.GetTestProfileRunsAsync(null, DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:00:46.072Z"), DateTimeOffset.Parse("2024-05-01T16:50:46.072Z"), null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("testProfileRunId").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_TestProfileRun_GetTestProfileRuns_GetAllTestProfileRunsForTheSpecifiedFilters_Convenience() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + foreach (TestProfileRun item in client.GetTestProfileRuns()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_TestProfileRun_GetTestProfileRuns_GetAllTestProfileRunsForTheSpecifiedFilters_Convenience_Async() + { + Uri endpoint = new Uri(""); + TokenCredential credential = new DefaultAzureCredential(); + LoadTestRunClient client = new LoadTestRunClient(endpoint, credential); + + await foreach (TestProfileRun item in client.GetTestProfileRunsAsync()) + { + } + } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml new file mode 100644 index 0000000000000..5b9320eef6a35 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService +commit: 48c055d35a51f736a2b7985fcfde92dc2bd4e0b1 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/loadtesting/ci.yml b/sdk/loadtesting/ci.yml new file mode 100644 index 0000000000000..5046481ec78c0 --- /dev/null +++ b/sdk/loadtesting/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/loadtesting + - sdk/loadtesting/ci.yml + - sdk/loadtesting/Azure.Developer.LoadTesting + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/loadtesting + - sdk/loadtesting/ci.yml + - sdk/loadtesting/Azure.Developer.LoadTesting + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: loadtesting + ArtifactName: packages + Artifacts: + - name: Azure.Developer.LoadTesting + safeName: AzureDeveloperLoadTesting diff --git a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/autorest.md b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/autorest.md index 186369cb15118..11daab9035913 100644 --- a/sdk/loadtestservice/Azure.Developer.LoadTesting/src/autorest.md +++ b/sdk/loadtestservice/Azure.Developer.LoadTesting/src/autorest.md @@ -6,7 +6,7 @@ Run `dotnet build /t:GenerateCode` to generate code. > see https://aka.ms/autorest ``` yaml -input-file: https://github.com/Azure/azure-rest-api-specs/blob/3e27c70e7c02c07b458bc0e94716c3d82d3fdd19/specification/loadtestservice/data-plane/Microsoft.LoadTestService/stable/2022-11-01/loadtestservice.json +input-file: https://github.com/Azure/azure-rest-api-specs/blob/48c055d35a51f736a2b7985fcfde92dc2bd4e0b1/specification/loadtestservice/data-plane/Microsoft.LoadTestService/stable/2022-11-01/loadtestservice.json namespace: Azure.Developer.LoadTesting security: AADToken security-scopes: https://cnt-prod.loadtesting.azure.com/.default