From a291093fe26f5ba003f4613400b25a32e07da816 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 20 Mar 2025 09:49:04 +0000 Subject: [PATCH] CodeGen from PR 33347 in Azure/azure-rest-api-specs Merge d669207447fc2024a0acfa9498783164d05325f9 into 8101a5323ca718856b5d462446107fdeabf28c6d --- .../tsp-location.yaml | 3 +- .../DeidentificationCustomizationOptions.cs | 4 +- ...DeidentificationJobCustomizationOptions.cs | 4 +- .../tsp-location.yaml | 5 +- .../tsp-location.yaml | 7 +- .../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 | 773 ++ .../Docs/LoadTestAdministrationClient.xml | 923 ++ .../src/Generated/Docs/LoadTestRunClient.xml | 1091 +++ .../src/Generated/Internal/Argument.cs | 129 + .../Internal/ChangeTrackingDictionary.cs | 167 + .../Generated/Internal/ChangeTrackingList.cs | 153 + .../Internal/ModelSerializationExtensions.cs | 399 + .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 + .../Generated/LoadTestAdministrationClient.cs | 2035 +++++ .../src/Generated/LoadTestRunClient.cs | 2619 ++++++ .../src/Generated/Models/Aggregation.cs | 84 + .../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/CreatedByType.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/FileType.cs | 63 + .../Generated/Models/FileValidationStatus.cs | 60 + ...tionResourceConfiguration.Serialization.cs | 157 + ...ionFlexConsumptionResourceConfiguration.cs | 76 + ...getResourceConfigurations.Serialization.cs | 152 + ...ConsumptionTargetResourceConfigurations.cs | 35 + .../LoadTestConfiguration.Serialization.cs | 225 + .../Generated/Models/LoadTestConfiguration.cs | 98 + .../LoadTestingAppComponent.Serialization.cs | 213 + .../Models/LoadTestingAppComponent.cs | 103 + .../Models/LoadTestingManagedIdentityType.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 + .../NameAndDescription.Serialization.cs | 156 + .../Generated/Models/NameAndDescription.cs | 69 + ...onalLoadTestConfiguration.Serialization.cs | 231 + .../Models/OptionalLoadTestConfiguration.cs | 85 + .../src/Generated/Models/PFMetrics.cs | 60 + .../src/Generated/Models/PassFailAction.cs | 51 + .../Models/PassFailAggregationFunction.cs | 90 + .../Models/PassFailCriteria.Serialization.cs | 186 + .../src/Generated/Models/PassFailCriteria.cs | 71 + .../Models/PassFailMetric.Serialization.cs | 255 + .../src/Generated/Models/PassFailMetric.cs | 109 + .../src/Generated/Models/PassFailResult.cs | 54 + .../PassFailServerMetric.Serialization.cs | 237 + .../Generated/Models/PassFailServerMetric.cs | 122 + .../Generated/Models/PassFailTestResult.cs | 54 + .../Models/RecommendationCategory.cs | 51 + .../RegionalConfiguration.Serialization.cs | 150 + .../Generated/Models/RegionalConfiguration.cs | 91 + .../src/Generated/Models/RequestDataLevel.cs | 51 + .../src/Generated/Models/ResourceKind.cs | 48 + .../Models/ResourceMetric.Serialization.cs | 216 + .../src/Generated/Models/ResourceMetric.cs | 120 + .../src/Generated/Models/SecretType.cs | 51 + ...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 | 271 + .../src/Generated/Models/TestProfile.cs | 110 + .../Models/TestProfileRun.Serialization.cs | 414 + .../src/Generated/Models/TestProfileRun.cs | 147 + ...tProfileRunRecommendation.Serialization.cs | 167 + .../Models/TestProfileRunRecommendation.cs | 77 + .../Generated/Models/TestProfileRunStatus.cs | 66 + .../Generated/Models/TestRun.Serialization.cs | 689 ++ .../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 + ...erverMetricsConfiguration.Serialization.cs | 230 + .../TestRunServerMetricsConfiguration.cs | 94 + .../Models/TestRunStatistics.Serialization.cs | 451 + .../src/Generated/Models/TestRunStatistics.cs | 141 + .../src/Generated/Models/TestRunStatus.cs | 93 + .../Models/TestSecret.Serialization.cs | 160 + .../src/Generated/Models/TestSecret.cs | 69 + ...erverMetricsConfiguration.Serialization.cs | 223 + .../Models/TestServerMetricsConfiguration.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 | 1119 +++ .../tsp-location.yaml | 4 + sdk/loadtesting/ci.yml | 35 + .../Azure.AI.ChatProtocol.sln | 56 + .../Azure.AI.ChatProtocol/CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../Azure.AI.ChatProtocol/README.md | 107 + .../src/Azure.AI.ChatProtocol.csproj | 20 + .../AIChatProtocolClientBuilderExtensions.cs | 46 + .../Generated/AIChatProtocolModelFactory.cs | 59 + .../src/Generated/Chat.cs | 381 + .../src/Generated/ChatChoice.Serialization.cs | 231 + .../src/Generated/ChatChoice.cs | 178 + .../Generated/ChatCompletion.Serialization.cs | 152 + .../src/Generated/ChatCompletion.cs | 76 + .../ChatCompletionChunk.Serialization.cs | 152 + .../src/Generated/ChatCompletionChunk.cs | 76 + .../Generated/ChatMessage.Serialization.cs | 147 + .../src/Generated/ChatMessage.cs | 121 + .../ChatMessageDelta.Serialization.cs | 150 + .../src/Generated/ChatMessageDelta.cs | 114 + .../src/Generated/ChatProtocolClient.cs | 95 + .../Generated/ChatProtocolClientOptions.cs | 37 + .../src/Generated/ChatRole.cs | 54 + .../Generated/ChoiceDelta.Serialization.cs | 238 + .../src/Generated/ChoiceDelta.cs | 176 + .../Generated/CreateRequest.Serialization.cs | 227 + .../src/Generated/CreateRequest.cs | 172 + .../CreateStreamingRequest.Serialization.cs | 227 + .../src/Generated/CreateStreamingRequest.cs | 172 + .../src/Generated/Docs/Chat.xml | 93 + .../src/Generated/FinishReason.cs | 51 + .../src/Generated/Internal/Argument.cs | 129 + .../Internal/ChangeTrackingDictionary.cs | 167 + .../Generated/Internal/ChangeTrackingList.cs | 153 + .../Internal/ModelSerializationExtensions.cs | 399 + .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 + .../src/Generated/MessageKind.cs | 48 + .../TextChatMessage.Serialization.cs | 150 + .../src/Generated/TextChatMessage.cs | 52 + .../TextChatMessageDelta.Serialization.cs | 157 + .../src/Generated/TextChatMessageDelta.cs | 41 + .../UnknownChatMessage.Serialization.cs | 142 + .../src/Generated/UnknownChatMessage.cs | 35 + .../UnknownChatMessageDelta.Serialization.cs | 146 + .../src/Generated/UnknownChatMessageDelta.cs | 35 + .../src/Properties/AssemblyInfo.cs | 11 + .../tests/Azure.AI.ChatProtocol.Tests.csproj | 20 + .../tests/Generated/Samples/Samples_Chat.cs | 107 + .../Azure.AI.ChatProtocol/tsp-location.yaml | 4 + sdk/machinelearning/ci.yml | 35 + .../Configuration.json | 12 + .../tsp-location.yaml | 5 +- .../tspCodeModel.json | 7668 +++++++++++++++++ sdk/storage/ci.yml | 4 + 192 files changed, 39184 insertions(+), 13 deletions(-) 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/Aggregation.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/CreatedByType.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/FileType.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileValidationStatus.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/LoadTestingAppComponent.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingManagedIdentityType.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/NameAndDescription.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDescription.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.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/PassFailAction.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailAggregationFunction.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/PassFailResult.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/PassFailTestResult.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/SecretType.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/TestRunServerMetricsConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricsConfiguration.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/TestRunStatus.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.Serialization.cs create mode 100644 sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.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 create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/Azure.AI.ChatProtocol.sln create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/CHANGELOG.md create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/Directory.Build.props create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/README.md create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Azure.AI.ChatProtocol.csproj create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolClientBuilderExtensions.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolModelFactory.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Chat.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClient.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClientOptions.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatRole.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Docs/Chat.xml create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/FinishReason.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Argument.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Optional.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/MessageKind.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.Serialization.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/src/Properties/AssemblyInfo.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/tests/Azure.AI.ChatProtocol.Tests.csproj create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/tests/Generated/Samples/Samples_Chat.cs create mode 100644 sdk/machinelearning/Azure.AI.ChatProtocol/tsp-location.yaml create mode 100644 sdk/machinelearning/ci.yml create mode 100644 sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/Configuration.json create mode 100644 sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tspCodeModel.json diff --git a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml index 622b565ea84a..a25a1a610a32 100644 --- a/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml +++ b/sdk/databasewatcher/Azure.ResourceManager.DatabaseWatcher/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/databasewatcher/DatabaseWatcher.Management -commit: 0e8e3ecd19f7e804b70c6ec2ff5bc406666bff6f +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationCustomizationOptions.cs b/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationCustomizationOptions.cs index b54a3e2b4225..06a018acf8bb 100644 --- a/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationCustomizationOptions.cs +++ b/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationCustomizationOptions.cs @@ -53,7 +53,7 @@ public DeidentificationCustomizationOptions() /// Initializes a new instance of . /// /// Format of the redacted output. Only valid when Operation is Redact. - /// Please refer to https://learn.microsoft.com/en-us/azure/healthcare-apis/deidentification/redaction-format for more details. + /// Please refer to https://learn.microsoft.com/azure/healthcare-apis/deidentification/redaction-format for more details. /// /// Locale in which the output surrogates are written. /// Keeps track of any properties unknown to the library. @@ -66,7 +66,7 @@ internal DeidentificationCustomizationOptions(string redactionFormat, string sur /// /// Format of the redacted output. Only valid when Operation is Redact. - /// Please refer to https://learn.microsoft.com/en-us/azure/healthcare-apis/deidentification/redaction-format for more details. + /// Please refer to https://learn.microsoft.com/azure/healthcare-apis/deidentification/redaction-format for more details. /// public string RedactionFormat { get; set; } /// Locale in which the output surrogates are written. diff --git a/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationJobCustomizationOptions.cs b/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationJobCustomizationOptions.cs index 37f3fb7909bf..5abcb2ab0cb1 100644 --- a/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationJobCustomizationOptions.cs +++ b/sdk/healthdataaiservices/Azure.Health.Deidentification/src/Generated/DeidentificationJobCustomizationOptions.cs @@ -53,7 +53,7 @@ public DeidentificationJobCustomizationOptions() /// Initializes a new instance of . /// /// Format of the redacted output. Only valid when Operation is Redact. - /// Please refer to https://learn.microsoft.com/en-us/azure/healthcare-apis/deidentification/redaction-format for more details. + /// Please refer to https://learn.microsoft.com/azure/healthcare-apis/deidentification/redaction-format for more details. /// /// Locale in which the output surrogates are written. /// Keeps track of any properties unknown to the library. @@ -66,7 +66,7 @@ internal DeidentificationJobCustomizationOptions(string redactionFormat, string /// /// Format of the redacted output. Only valid when Operation is Redact. - /// Please refer to https://learn.microsoft.com/en-us/azure/healthcare-apis/deidentification/redaction-format for more details. + /// Please refer to https://learn.microsoft.com/azure/healthcare-apis/deidentification/redaction-format for more details. /// public string RedactionFormat { get; set; } /// Locale in which the output surrogates are written. diff --git a/sdk/healthdataaiservices/Azure.Health.Deidentification/tsp-location.yaml b/sdk/healthdataaiservices/Azure.Health.Deidentification/tsp-location.yaml index 5feffc1106d3..8324a482d6d2 100644 --- a/sdk/healthdataaiservices/Azure.Health.Deidentification/tsp-location.yaml +++ b/sdk/healthdataaiservices/Azure.Health.Deidentification/tsp-location.yaml @@ -1,5 +1,4 @@ directory: specification/healthdataaiservices/HealthDataAIServices.DeidServices +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f repo: Azure/azure-rest-api-specs -commit: 45baf6e76beba3c271f839c8e3c2d2fffa209ab8 -additionalDirectories: [] - +additionalDirectories: diff --git a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/tsp-location.yaml b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/tsp-location.yaml index a1387410c13f..e73ce826bb11 100644 --- a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/tsp-location.yaml +++ b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/tsp-location.yaml @@ -1,3 +1,4 @@ -directory: specification/informatica/Informatica.DataManagement -commit: 00a6d4f6cdfe2e3ffd069d0771ee0a52143a13c0 -repo: Azure/azure-rest-api-specs \ No newline at end of file +directory: specification/informatica/Informatica.DataManagement.Management +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f +repo: Azure/azure-rest-api-specs +additionalDirectories: 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 000000000000..fb32820aaea6 --- /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 000000000000..8b33f0fedccc --- /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 000000000000..63bd836ad44b --- /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 000000000000..09c7f0c5f2cd --- /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 000000000000..e46421196dcf --- /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 000000000000..182a9afccf68 --- /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 000000000000..6d76257f95b6 --- /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 000000000000..04a9a9d5718e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/DeveloperLoadTestingModelFactory.cs @@ -0,0 +1,773 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +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, LoadTestingManagedIdentityType? metricsReferenceIdentityType = null, string metricsReferenceIdentityId = null, LoadTestingManagedIdentityType? 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, PassFailAggregationFunction? aggregate = null, string condition = null, string requestName = null, double? value = null, PassFailAction? action = null, double? actualValue = null, PassFailResult? 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(ResourceIdentifier resourceId = null, string metricNamespace = null, string metricName = null, string aggregation = null, string condition = null, double value = default, PassFailAction? action = null, double? actualValue = null, PassFailResult? result = null) + { + return new PassFailServerMetric( + resourceId, + metricNamespace, + metricName, + aggregation, + condition, + value, + action, + actualValue, + result, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file with all input artifacts. + /// 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 userPropertyFileInfo = null, TestFileInfo inputArtifactsZipFileInfo = null, TestFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropertyFileInfo, + 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 uri = null, FileType? fileType = null, DateTimeOffset? expiresOn = null, FileValidationStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestFileInfo( + fileName, + uri, + fileType, + expiresOn, + 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 LoadTestingAppComponent LoadTestingAppComponent(ResourceIdentifier resourceId = null, string resourceName = null, string resourceType = null, string displayName = null, string resourceGroup = null, string subscriptionId = null, string kind = null) + { + return new LoadTestingAppComponent( + 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 TestServerMetricsConfiguration TestServerMetricsConfiguration(string testId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestServerMetricsConfiguration( + 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, ResourceIdentifier 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, ResourceIdentifier 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, PassFailTestResult? testResult = null, int? virtualUsers = null, string displayName = null, string testId = null, string description = null, TestRunStatus? status = null, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, DateTimeOffset? executedDateTime = null, Uri portalUri = null, long? duration = null, double? virtualUserHours = null, string subnetId = null, TestKind? kind = null, RequestDataLevel? requestDataLevel = null, bool? debugLogsEnabled = null, bool? publicIpDisabled = null, CreatedByType? 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, + portalUri, + 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? errorPercentage = null, double? meanResponseTime = null, double? medianResponseTime = null, double? maxResponseTime = null, double? minResponseTime = null, double? percentile90ResponseTime = null, double? percentile95ResponseTime = null, double? percentile99ResponseTime = null, double? percentile75ResponseTime = null, double? percentile96ResponseTime = null, double? percentile97ResponseTime = null, double? percentile98ResponseTime = null, double? percentile999ResponseTime = null, double? percentile9999ResponseTime = null, double? throughput = null, double? receivedKBytesPerSec = null, double? sentKBytesPerSec = null) + { + return new TestRunStatistics( + transaction, + sampleCount, + errorCount, + errorPercentage, + meanResponseTime, + medianResponseTime, + maxResponseTime, + minResponseTime, + percentile90ResponseTime, + percentile95ResponseTime, + percentile99ResponseTime, + percentile75ResponseTime, + percentile96ResponseTime, + percentile97ResponseTime, + percentile98ResponseTime, + percentile999ResponseTime, + percentile9999ResponseTime, + 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 . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file for all input artifacts. + /// 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 userPropertyFileInfo = null, TestRunFileInfo inputArtifactsZipFileInfo = null, TestRunFileInfo urlTestConfigFileInfo = null, IEnumerable additionalFileInfo = null) + { + additionalFileInfo ??= new List(); + + return new TestRunInputArtifacts( + configFileInfo, + testScriptFileInfo, + userPropertyFileInfo, + 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 uri = null, FileType? fileType = null, DateTimeOffset? expiresOn = null, FileValidationStatus? validationStatus = null, string validationFailureDetails = null) + { + return new TestRunFileInfo( + fileName, + uri, + fileType, + expiresOn, + validationStatus, + validationFailureDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The test run results file. + /// The test run report with metrics. + /// 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 uri = null, DateTimeOffset? expiresOn = null) + { + return new ArtifactsContainerInfo(uri, expiresOn, 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 TestRunServerMetricsConfiguration TestRunServerMetricsConfiguration(string testRunId = null, IDictionary metrics = null, DateTimeOffset? createdDateTime = null, string createdBy = null, DateTimeOffset? lastModifiedDateTime = null, string lastModifiedBy = null) + { + metrics ??= new Dictionary(); + + return new TestRunServerMetricsConfiguration( + 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, Aggregation? 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 NameAndDescription NameAndDescription(string description = null, string name = null) + { + return new NameAndDescription(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, ResourceIdentifier 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(TestRunStatus 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 000000000000..7d003cbcffda --- /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, null, 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, null, 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 000000000000..73af105c47a9 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Docs/LoadTestRunClient.xml @@ -0,0 +1,1091 @@ + + + + + +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", + 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", + 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 000000000000..946929b236ff --- /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 000000000000..9a5316eba10d --- /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 000000000000..5de833439355 --- /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 000000000000..f72f1fe51168 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// 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 JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + 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 000000000000..248e10182762 --- /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 000000000000..5130928c6e0b --- /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 000000000000..a9f75c11a80b --- /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(TestServerMetricsConfiguration.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(TestServerMetricsConfiguration.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, IEnumerable 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, IEnumerable 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, IEnumerable 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, IEnumerable 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, IEnumerable 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 && !(testIds is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + uri.AppendQueryDelimited("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, IEnumerable 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 000000000000..505cfa91ce0b --- /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(TestRunServerMetricsConfiguration.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(TestRunServerMetricsConfiguration.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/Aggregation.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Aggregation.cs new file mode 100644 index 000000000000..1e08b134890f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/Aggregation.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 Aggregation : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Aggregation(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 Aggregation Average { get; } = new Aggregation(AverageValue); + /// Total count. + public static Aggregation Count { get; } = new Aggregation(CountValue); + /// Aggregation will be average in this case. + public static Aggregation None { get; } = new Aggregation(NoneValue); + /// Total sum. + public static Aggregation Total { get; } = new Aggregation(TotalValue); + /// 75th percentile. + public static Aggregation Percentile75 { get; } = new Aggregation(Percentile75Value); + /// 90th percentile. + public static Aggregation Percentile90 { get; } = new Aggregation(Percentile90Value); + /// 95th percentile. + public static Aggregation Percentile95 { get; } = new Aggregation(Percentile95Value); + /// 96th percentile. + public static Aggregation Percentile96 { get; } = new Aggregation(Percentile96Value); + /// 97th percentile. + public static Aggregation Percentile97 { get; } = new Aggregation(Percentile97Value); + /// 98th percentile. + public static Aggregation Percentile98 { get; } = new Aggregation(Percentile98Value); + /// 99th percentile. + public static Aggregation Percentile99 { get; } = new Aggregation(Percentile99Value); + /// 99.9th percentile. + public static Aggregation Percentile999 { get; } = new Aggregation(Percentile999Value); + /// 99.99th percentile. + public static Aggregation Percentile9999 { get; } = new Aggregation(Percentile9999Value); + /// Determines if two values are the same. + public static bool operator ==(Aggregation left, Aggregation right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Aggregation left, Aggregation right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator Aggregation(string value) => new Aggregation(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Aggregation other && Equals(other); + /// + public bool Equals(Aggregation 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/ArtifactsContainerInfo.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ArtifactsContainerInfo.Serialization.cs new file mode 100644 index 000000000000..f2bd51e735b7 --- /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(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..f9f96c218e8d --- /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 uri, DateTimeOffset? expiresOn, IDictionary serializedAdditionalRawData) + { + Uri = uri; + ExpiresOn = expiresOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// This is a SAS URI to an Azure Storage Container that contains the test run artifacts. + public Uri Uri { get; } + /// Expiry time of the container (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { 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 000000000000..e10d38f761e9 --- /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(ErrorRateTimeWindow)) + { + writer.WritePropertyName("errorRateTimeWindowInSeconds"u8); + writer.WriteNumberValue(Convert.ToInt32(ErrorRateTimeWindow.Value.ToString("%s"))); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + TimeSpan? 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 = TimeSpan.FromSeconds(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..2b585bd6e9d2 --- /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, TimeSpan? errorRateTimeWindow, IDictionary serializedAdditionalRawData) + { + AutoStopDisabled = autoStopDisabled; + ErrorRate = errorRate; + ErrorRateTimeWindow = errorRateTimeWindow; + _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 TimeSpan? ErrorRateTimeWindow { 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 000000000000..c57fbf75f2ef --- /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(CertificateKind)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(CertificateKind.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..c526e0b10973 --- /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? certificateKind, string name, IDictionary serializedAdditionalRawData) + { + Value = value; + CertificateKind = certificateKind; + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the certificate for respective type. + public string Value { get; set; } + /// Type of certificate. + public CertificateType? CertificateKind { 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 000000000000..b988b5f46974 --- /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 KeyVaultCertificateUriValue = "AKV_CERT_URI"; + + /// If the certificate is stored in an Azure Key Vault. + public static CertificateType KeyVaultCertificateUri { get; } = new CertificateType(KeyVaultCertificateUriValue); + /// 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/CreatedByType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreatedByType.cs new file mode 100644 index 000000000000..5dfcd8cd9c41 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/CreatedByType.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 CreatedByType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CreatedByType(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 CreatedByType User { get; } = new CreatedByType(UserValue); + /// Entity was created by a scheduled trigger. + public static CreatedByType ScheduledTrigger { get; } = new CreatedByType(ScheduledTriggerValue); + /// Determines if two values are the same. + public static bool operator ==(CreatedByType left, CreatedByType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CreatedByType left, CreatedByType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CreatedByType(string value) => new CreatedByType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CreatedByType other && Equals(other); + /// + public bool Equals(CreatedByType 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 000000000000..77c0ba4c5e4c --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..4948de180779 --- /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 000000000000..08037c612ea5 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..b69587bcf34f --- /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 000000000000..3a503c2cbabf --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..0cb62e220744 --- /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/FileType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileType.cs new file mode 100644 index 000000000000..5c3fc570914e --- /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/FileValidationStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileValidationStatus.cs new file mode 100644 index 000000000000..1506aea5de9a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FileValidationStatus.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 FileValidationStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileValidationStatus(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 FileValidationStatus NotValidated { get; } = new FileValidationStatus(NotValidatedValue); + /// File is validated. + public static FileValidationStatus ValidationSuccess { get; } = new FileValidationStatus(ValidationSuccessValue); + /// File validation is failed. + public static FileValidationStatus ValidationFailure { get; } = new FileValidationStatus(ValidationFailureValue); + /// File validation is in progress. + public static FileValidationStatus ValidationInitiated { get; } = new FileValidationStatus(ValidationInitiatedValue); + /// Validation is not required. + public static FileValidationStatus ValidationNotRequired { get; } = new FileValidationStatus(ValidationNotRequiredValue); + /// Determines if two values are the same. + public static bool operator ==(FileValidationStatus left, FileValidationStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileValidationStatus left, FileValidationStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FileValidationStatus(string value) => new FileValidationStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileValidationStatus other && Equals(other); + /// + public bool Equals(FileValidationStatus 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 000000000000..86f482da0cd7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.Serialization.cs @@ -0,0 +1,157 @@ +// 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); + if (Optional.IsDefined(HttpConcurrency)) + { + writer.WritePropertyName("httpConcurrency"u8); + writer.WriteNumberValue(HttpConcurrency.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..a8510e8f6f8e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/FunctionFlexConsumptionResourceConfiguration.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 +{ + /// 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. + public FunctionFlexConsumptionResourceConfiguration(long instanceMemoryMB) + { + InstanceMemoryMB = instanceMemoryMB; + } + + /// 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 000000000000..ee6b1de2a41d --- /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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..cfa5c90ce964 --- /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 000000000000..51abf8b4d0c7 --- /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(OptionalLoadTestConfiguration)) + { + writer.WritePropertyName("optionalLoadTestConfig"u8); + writer.WriteObjectValue(OptionalLoadTestConfiguration, options); + } + if (Optional.IsCollectionDefined(RegionalLoadTestConfiguration)) + { + writer.WritePropertyName("regionalLoadTestConfig"u8); + writer.WriteStartArray(); + foreach (var item in RegionalLoadTestConfiguration) + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + OptionalLoadTestConfiguration 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 = OptionalLoadTestConfiguration.DeserializeOptionalLoadTestConfiguration(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..ed98de48c83c --- /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() + { + RegionalLoadTestConfiguration = 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, OptionalLoadTestConfiguration optionalLoadTestConfiguration, IList regionalLoadTestConfiguration, IDictionary serializedAdditionalRawData) + { + EngineInstances = engineInstances; + SplitAllCsvs = splitAllCsvs; + QuickStartTest = quickStartTest; + OptionalLoadTestConfiguration = optionalLoadTestConfiguration; + RegionalLoadTestConfiguration = regionalLoadTestConfiguration; + _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 OptionalLoadTestConfiguration OptionalLoadTestConfiguration { get; set; } + /// Region distribution configuration for the load test. + public IList RegionalLoadTestConfiguration { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.Serialization.cs new file mode 100644 index 000000000000..5f4960a06a34 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.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 LoadTestingAppComponent : 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(LoadTestingAppComponent)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LoadTestingAppComponent 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(LoadTestingAppComponent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLoadTestingAppComponent(document.RootElement, options); + } + + internal static LoadTestingAppComponent DeserializeLoadTestingAppComponent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier 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 = new ResourceIdentifier(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 LoadTestingAppComponent( + 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(LoadTestingAppComponent)} does not support writing '{options.Format}' format."); + } + } + + LoadTestingAppComponent 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestingAppComponent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LoadTestingAppComponent)} 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 LoadTestingAppComponent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLoadTestingAppComponent(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/LoadTestingAppComponent.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.cs new file mode 100644 index 000000000000..499d4485d0e0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingAppComponent.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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 LoadTestingAppComponent + { + /// + /// 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 LoadTestingAppComponent(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 LoadTestingAppComponent(ResourceIdentifier 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 LoadTestingAppComponent() + { + } + + /// fully qualified resource Id e.g subscriptions/{subId}/resourceGroups/{rg}/providers/Microsoft.LoadTestService/loadtests/{resName}. + public ResourceIdentifier 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/LoadTestingManagedIdentityType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingManagedIdentityType.cs new file mode 100644 index 000000000000..44f752641439 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/LoadTestingManagedIdentityType.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 LoadTestingManagedIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LoadTestingManagedIdentityType(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 LoadTestingManagedIdentityType SystemAssigned { get; } = new LoadTestingManagedIdentityType(SystemAssignedValue); + /// User-assigned managed identity. + public static LoadTestingManagedIdentityType UserAssigned { get; } = new LoadTestingManagedIdentityType(UserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LoadTestingManagedIdentityType left, LoadTestingManagedIdentityType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LoadTestingManagedIdentityType(string value) => new LoadTestingManagedIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LoadTestingManagedIdentityType other && Equals(other); + /// + public bool Equals(LoadTestingManagedIdentityType 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 000000000000..3dd51f4ce04b --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..ec1d9a12c5f8 --- /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 000000000000..81de640249a2 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + Aggregation? 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(NameAndDescription.DeserializeNameAndDescription(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 Aggregation(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..d81f999e8a54 --- /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, Aggregation? 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 Aggregation? 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 000000000000..26cd2f369365 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..055e966bec2f --- /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 000000000000..c1c36c2de9fb --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..69ae3aeb2859 --- /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 000000000000..147ad41126e7 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..3d9e93c3256a --- /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 000000000000..c9909304ec23 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..9cc4e0506429 --- /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 000000000000..cbbb0d8d3b48 --- /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 000000000000..27c921c13caf --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..6efff07efdc3 --- /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/NameAndDescription.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDescription.Serialization.cs new file mode 100644 index 000000000000..2b0d623f4dd6 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDescription.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 NameAndDescription : 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(NameAndDescription)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameAndDescription 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(NameAndDescription)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameAndDescription(document.RootElement, options); + } + + internal static NameAndDescription DeserializeNameAndDescription(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 NameAndDescription(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(NameAndDescription)} does not support writing '{options.Format}' format."); + } + } + + NameAndDescription 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameAndDescription(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameAndDescription)} 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 NameAndDescription FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameAndDescription(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/NameAndDescription.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDescription.cs new file mode 100644 index 000000000000..5d4b2e66bce5 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/NameAndDescription.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 NameAndDescription + { + /// + /// 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 NameAndDescription() + { + } + + /// Initializes a new instance of . + /// The description. + /// The name. + /// Keeps track of any properties unknown to the library. + internal NameAndDescription(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/OptionalLoadTestConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.Serialization.cs new file mode 100644 index 000000000000..ffb059758800 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.Serialization.cs @@ -0,0 +1,231 @@ +// 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 OptionalLoadTestConfiguration : 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(OptionalLoadTestConfiguration)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(EndpointUri)) + { + writer.WritePropertyName("endpointUrl"u8); + writer.WriteStringValue(EndpointUri.AbsoluteUri); + } + 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(Convert.ToInt32(Duration.Value.ToString("%s"))); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + OptionalLoadTestConfiguration 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(OptionalLoadTestConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOptionalLoadTestConfiguration(document.RootElement, options); + } + + internal static OptionalLoadTestConfiguration DeserializeOptionalLoadTestConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Uri endpointUrl = default; + int? requestsPerSecond = default; + int? maxResponseTimeInMs = default; + int? virtualUsers = default; + int? rampUpTime = default; + TimeSpan? duration = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("endpointUrl"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endpointUrl = new Uri(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 = TimeSpan.FromSeconds(property.Value.GetInt32()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OptionalLoadTestConfiguration( + 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(OptionalLoadTestConfiguration)} does not support writing '{options.Format}' format."); + } + } + + OptionalLoadTestConfiguration 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOptionalLoadTestConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OptionalLoadTestConfiguration)} 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 OptionalLoadTestConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOptionalLoadTestConfiguration(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/OptionalLoadTestConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.cs new file mode 100644 index 000000000000..d781d9ce193f --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/OptionalLoadTestConfiguration.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 OptionalLoadTestConfiguration + { + /// + /// 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 OptionalLoadTestConfiguration() + { + } + + /// 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 OptionalLoadTestConfiguration(Uri endpointUri, int? requestsPerSecond, int? maxResponseTimeInMs, int? virtualUsers, int? rampUpTime, TimeSpan? duration, IDictionary serializedAdditionalRawData) + { + EndpointUri = endpointUri; + 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 Uri EndpointUri { 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 TimeSpan? Duration { get; set; } + } +} 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 000000000000..21a4b2e5540d --- /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 ResponseTimeInMillisecondsValue = "response_time_ms"; + private const string LatencyValue = "latency"; + private const string ErrorValue = "error"; + private const string RequestsValue = "requests"; + private const string RequestsPerSecondValue = "requests_per_sec"; + + /// Pass fail criteria for response time metric in milliseconds. + public static PFMetrics ResponseTimeInMilliseconds { get; } = new PFMetrics(ResponseTimeInMillisecondsValue); + /// 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 RequestsPerSecond { get; } = new PFMetrics(RequestsPerSecondValue); + /// 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/PassFailAction.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailAction.cs new file mode 100644 index 000000000000..3e11b4c3d327 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailAction.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 PassFailAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailAction(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 PassFailAction Continue { get; } = new PassFailAction(ContinueValue); + /// Test run will stop if pass fail criteria metric is not passed. + public static PassFailAction Stop { get; } = new PassFailAction(StopValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailAction left, PassFailAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailAction left, PassFailAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailAction(string value) => new PassFailAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailAction other && Equals(other); + /// + public bool Equals(PassFailAction 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/PassFailAggregationFunction.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailAggregationFunction.cs new file mode 100644 index 000000000000..5c4f084e0a5a --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailAggregationFunction.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 PassFailAggregationFunction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailAggregationFunction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CountValue = "count"; + private const string PercentageValue = "percentage"; + private const string AverageValue = "avg"; + private const string Percentile50Value = "p50"; + private const string Percentile75Value = "p75"; + private const string Percentile90Value = "p90"; + private const string Percentile95Value = "p95"; + private const string Percentile96Value = "p96"; + private const string Percentile97Value = "p97"; + private const string Percentile98Value = "p98"; + private const string Percentile99Value = "p99"; + private const string Percentile999Value = "p99.9"; + private const string Percentile9999Value = "p99.99"; + private const string MinimumValue = "min"; + private const string MaximumValue = "max"; + + /// Criteria applies for count value. + public static PassFailAggregationFunction Count { get; } = new PassFailAggregationFunction(CountValue); + /// Criteria applies for given percentage value. + public static PassFailAggregationFunction Percentage { get; } = new PassFailAggregationFunction(PercentageValue); + /// Criteria applies for avg value. + public static PassFailAggregationFunction Average { get; } = new PassFailAggregationFunction(AverageValue); + /// Criteria applies for 50th percentile value. + public static PassFailAggregationFunction Percentile50 { get; } = new PassFailAggregationFunction(Percentile50Value); + /// Criteria applies for 75th percentile value. + public static PassFailAggregationFunction Percentile75 { get; } = new PassFailAggregationFunction(Percentile75Value); + /// Criteria applies for 90th percentile value. + public static PassFailAggregationFunction Percentile90 { get; } = new PassFailAggregationFunction(Percentile90Value); + /// Criteria applies for 95th percentile value. + public static PassFailAggregationFunction Percentile95 { get; } = new PassFailAggregationFunction(Percentile95Value); + /// Criteria applies for 96th percentile value. + public static PassFailAggregationFunction Percentile96 { get; } = new PassFailAggregationFunction(Percentile96Value); + /// Criteria applies for 97th percentile value. + public static PassFailAggregationFunction Percentile97 { get; } = new PassFailAggregationFunction(Percentile97Value); + /// Criteria applies for 98th percentile value. + public static PassFailAggregationFunction Percentile98 { get; } = new PassFailAggregationFunction(Percentile98Value); + /// Criteria applies for 99th percentile value. + public static PassFailAggregationFunction Percentile99 { get; } = new PassFailAggregationFunction(Percentile99Value); + /// Criteria applies for 99.9th percentile value. + public static PassFailAggregationFunction Percentile999 { get; } = new PassFailAggregationFunction(Percentile999Value); + /// Criteria applies for 99.99th percentile value. + public static PassFailAggregationFunction Percentile9999 { get; } = new PassFailAggregationFunction(Percentile9999Value); + /// Criteria applies for minimum value. + public static PassFailAggregationFunction Minimum { get; } = new PassFailAggregationFunction(MinimumValue); + /// Criteria applies for maximum value. + public static PassFailAggregationFunction Maximum { get; } = new PassFailAggregationFunction(MaximumValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailAggregationFunction left, PassFailAggregationFunction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailAggregationFunction left, PassFailAggregationFunction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailAggregationFunction(string value) => new PassFailAggregationFunction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailAggregationFunction other && Equals(other); + /// + public bool Equals(PassFailAggregationFunction 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 000000000000..979cb5056742 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..ea8a042edf9e --- /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 000000000000..b979fb3ab5e8 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + PassFailAggregationFunction? aggregate = default; + string condition = default; + string requestName = default; + double? value = default; + PassFailAction? action = default; + double? actualValue = default; + PassFailResult? 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 PassFailAggregationFunction(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 PassFailAction(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 PassFailResult(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..d295bebd002a --- /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, PassFailAggregationFunction? aggregate, string condition, string requestName, double? value, PassFailAction? action, double? actualValue, PassFailResult? 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 PassFailAggregationFunction? 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 PassFailAction? Action { get; set; } + /// The actual value of the client metric for the test run. + public double? ActualValue { get; } + /// Outcome of the test run. + public PassFailResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailResult.cs new file mode 100644 index 000000000000..9900c6666a32 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailResult.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 PassFailResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailResult(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 PassFailResult Passed { get; } = new PassFailResult(PassedValue); + /// Given pass fail criteria metric couldn't determine. + public static PassFailResult Undetermined { get; } = new PassFailResult(UndeterminedValue); + /// Given pass fail criteria metric has failed. + public static PassFailResult Failed { get; } = new PassFailResult(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailResult left, PassFailResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailResult left, PassFailResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailResult(string value) => new PassFailResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailResult other && Equals(other); + /// + public bool Equals(PassFailResult 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/PassFailServerMetric.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.Serialization.cs new file mode 100644 index 000000000000..3284bbde2142 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + } + ResourceIdentifier resourceId = default; + string metricNamespace = default; + string metricName = default; + string aggregation = default; + string condition = default; + double value = default; + PassFailAction? action = default; + double? actualValue = default; + PassFailResult? result = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(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 PassFailAction(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 PassFailResult(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..6b919f195456 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailServerMetric.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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(ResourceIdentifier 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(ResourceIdentifier resourceId, string metricNamespace, string metricName, string aggregation, string condition, double value, PassFailAction? action, double? actualValue, PassFailResult? 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 ResourceIdentifier 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 PassFailAction? Action { get; set; } + /// The actual value of the server metric. + public double? ActualValue { get; } + /// Outcome of the test run. + public PassFailResult? Result { get; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailTestResult.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailTestResult.cs new file mode 100644 index 000000000000..009fbcf28ea7 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/PassFailTestResult.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 PassFailTestResult : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PassFailTestResult(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 PassFailTestResult PASSED { get; } = new PassFailTestResult(PASSEDValue); + /// Pass/fail criteria is not applicable. + public static PassFailTestResult NOTAPPLICABLE { get; } = new PassFailTestResult(NOTAPPLICABLEValue); + /// Pass/fail criteria has failed. + public static PassFailTestResult FAILED { get; } = new PassFailTestResult(FAILEDValue); + /// Determines if two values are the same. + public static bool operator ==(PassFailTestResult left, PassFailTestResult right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PassFailTestResult left, PassFailTestResult right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PassFailTestResult(string value) => new PassFailTestResult(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PassFailTestResult other && Equals(other); + /// + public bool Equals(PassFailTestResult 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/RecommendationCategory.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RecommendationCategory.cs new file mode 100644 index 000000000000..bdf73908d836 --- /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 000000000000..7a254b0f9f6d --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + AzureLocation 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 = new AzureLocation(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..61eaccae1d3d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/RegionalConfiguration.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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. + /// + public RegionalConfiguration(int engineInstances, AzureLocation 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, AzureLocation 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 AzureLocation 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 000000000000..8cdec590de13 --- /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 000000000000..6f76a9a94bde --- /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 000000000000..c3ad69a085b9 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + ResourceIdentifier 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 = new ResourceIdentifier(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..80c3c1102a9e --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/ResourceMetric.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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(ResourceIdentifier 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, ResourceIdentifier 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 ResourceIdentifier 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/SecretType.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/SecretType.cs new file mode 100644 index 000000000000..1904d5f77c05 --- /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 KeyVaultSecretUriValue = "AKV_SECRET_URI"; + private const string SecretValueValue = "SECRET_VALUE"; + + /// If the secret is stored in an Azure Key Vault. + public static SecretType KeyVaultSecretUri { get; } = new SecretType(KeyVaultSecretUriValue); + /// 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/TargetResourceConfigurations.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TargetResourceConfigurations.Serialization.cs new file mode 100644 index 000000000000..73f95e8c671a --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..688ae88d6ec8 --- /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 000000000000..7d47b71ebbb7 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + LoadTestingManagedIdentityType? metricsReferenceIdentityType = default; + string metricsReferenceIdentityId = default; + LoadTestingManagedIdentityType? 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, TestSecret.DeserializeTestSecret(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 LoadTestingManagedIdentityType(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 LoadTestingManagedIdentityType(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..dbeddf88176a --- /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, LoadTestingManagedIdentityType? metricsReferenceIdentityType, string metricsReferenceIdentityId, LoadTestingManagedIdentityType? 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 LoadTestingManagedIdentityType? 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 LoadTestingManagedIdentityType? 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 000000000000..e610e3b98859 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..cf2ac6781766 --- /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 000000000000..b4b7a733d909 --- /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(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + FileValidationStatus? 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 FileValidationStatus(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..37eebd309c3e --- /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 uri, FileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Uri = uri; + FileType = fileType; + ExpiresOn = expiresOn; + 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 Uri { get; } + /// File type. + public FileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { get; } + /// Validation status of the file. + public FileValidationStatus? 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 000000000000..72c0892a8e6e --- /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(UserPropertyFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropertyFileInfo, 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..74a96b0f4bb6 --- /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 . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file with all input artifacts. + /// 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 userPropertyFileInfo, TestFileInfo inputArtifactsZipFileInfo, TestFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropertyFileInfo = userPropertyFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The load test YAML file that contains the the test configuration. + public TestFileInfo ConfigFileInfo { get; } + /// The test script file for the test run. + public TestFileInfo TestScriptFileInfo { get; } + /// The user properties file. + public TestFileInfo UserPropertyFileInfo { get; } + /// The zip file with all input artifacts. + 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 000000000000..b424add8f012 --- /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 000000000000..9a6fe5ddd1ae --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.Serialization.cs @@ -0,0 +1,271 @@ +// 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + ResourceIdentifier 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)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceId = new ResourceIdentifier(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..ea6d2a9ffd6c --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfile.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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, ResourceIdentifier 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 ResourceIdentifier 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 000000000000..6ce98b99cd95 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.Serialization.cs @@ -0,0 +1,414 @@ +// 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + ResourceIdentifier 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)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetResourceId = new ResourceIdentifier(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..da186562b4fc --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestProfileRun.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +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, ResourceIdentifier 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 ResourceIdentifier 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 000000000000..d82e5c3d42f3 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..90f549283cd1 --- /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 000000000000..a7415faffd4a --- /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 000000000000..82a488d162a2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRun.Serialization.cs @@ -0,0 +1,689 @@ +// 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 (options.Format != "W" && 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(PortalUri)) + { + writer.WritePropertyName("portalUrl"u8); + writer.WriteStringValue(PortalUri.AbsoluteUri); + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + PassFailTestResult? testResult = default; + int? virtualUsers = default; + string displayName = default; + string testId = default; + string description = default; + TestRunStatus? status = default; + DateTimeOffset? startDateTime = default; + DateTimeOffset? endDateTime = default; + DateTimeOffset? executedDateTime = default; + Uri portalUrl = default; + long? duration = default; + double? virtualUserHours = default; + string subnetId = default; + TestKind? kind = default; + RequestDataLevel? requestDataLevel = default; + bool? debugLogsEnabled = default; + bool? publicIPDisabled = default; + CreatedByType? 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, TestSecret.DeserializeTestSecret(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 PassFailTestResult(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 TestRunStatus(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)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + portalUrl = new Uri(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 CreatedByType(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..f6a7b3ba35ae --- /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, PassFailTestResult? testResult, int? virtualUsers, string displayName, string testId, string description, TestRunStatus? status, DateTimeOffset? startDateTime, DateTimeOffset? endDateTime, DateTimeOffset? executedDateTime, Uri portalUri, long? duration, double? virtualUserHours, string subnetId, TestKind? kind, RequestDataLevel? requestDataLevel, bool? debugLogsEnabled, bool? publicIpDisabled, CreatedByType? 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; + PortalUri = portalUri; + 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; } + /// Collection of test run artifacts. + public TestRunArtifacts TestArtifacts { get; } + /// Test result for pass/Fail criteria used during the test run. + public PassFailTestResult? 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 TestRunStatus? 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 Uri PortalUri { 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 CreatedByType? 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 000000000000..b9f2aff85fa8 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, LoadTestingAppComponent.DeserializeLoadTestingAppComponent(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..c73d8ee7bcc7 --- /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 000000000000..9760bc967516 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..7578b5ed6a05 --- /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 000000000000..1f9fbc9ee9ad --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + } + TestRunStatus 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 TestRunStatus(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..72add4205b04 --- /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(TestRunStatus 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(TestRunStatus 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 TestRunStatus 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 000000000000..e3d2aac87460 --- /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(Uri)) + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri.AbsoluteUri); + } + if (options.Format != "W" && Optional.IsDefined(FileType)) + { + writer.WritePropertyName("fileType"u8); + writer.WriteStringValue(FileType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ExpiresOn)) + { + writer.WritePropertyName("expireDateTime"u8); + writer.WriteStringValue(ExpiresOn.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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; + FileValidationStatus? 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 FileValidationStatus(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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..31421912e713 --- /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 uri, FileType? fileType, DateTimeOffset? expiresOn, FileValidationStatus? validationStatus, string validationFailureDetails, IDictionary serializedAdditionalRawData) + { + FileName = fileName; + Uri = uri; + FileType = fileType; + ExpiresOn = expiresOn; + 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 Uri { get; } + /// File type. + public FileType? FileType { get; } + /// Expiry time of the file (RFC 3339 literal format). + public DateTimeOffset? ExpiresOn { get; } + /// Validation status of the file. + public FileValidationStatus? 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 000000000000..15964d6ea1c8 --- /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(UserPropertyFileInfo)) + { + writer.WritePropertyName("userPropFileInfo"u8); + writer.WriteObjectValue(UserPropertyFileInfo, 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..c5004ea574f3 --- /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 . + /// The load test YAML file that contains the the test configuration. + /// The test script file for the test run. + /// The user properties file. + /// The zip file for all input artifacts. + /// 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 userPropertyFileInfo, TestRunFileInfo inputArtifactsZipFileInfo, TestRunFileInfo urlTestConfigFileInfo, IReadOnlyList additionalFileInfo, IDictionary serializedAdditionalRawData) + { + ConfigFileInfo = configFileInfo; + TestScriptFileInfo = testScriptFileInfo; + UserPropertyFileInfo = userPropertyFileInfo; + InputArtifactsZipFileInfo = inputArtifactsZipFileInfo; + UrlTestConfigFileInfo = urlTestConfigFileInfo; + AdditionalFileInfo = additionalFileInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The load test YAML file that contains the the test configuration. + public TestRunFileInfo ConfigFileInfo { get; } + /// The test script file for the test run. + public TestRunFileInfo TestScriptFileInfo { get; } + /// The user properties file. + public TestRunFileInfo UserPropertyFileInfo { get; } + /// The zip file for all input artifacts. + 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 000000000000..5fb8f375fe49 --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..a5365275e626 --- /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 . + /// The test run results file. + /// The test run report with metrics. + /// 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; + } + + /// The test run results file. + public TestRunFileInfo ResultFileInfo { get; } + /// The test run report with metrics. + 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/TestRunServerMetricsConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricsConfiguration.Serialization.cs new file mode 100644 index 000000000000..7feb1621ea93 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricsConfiguration.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 TestRunServerMetricsConfiguration : 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(TestRunServerMetricsConfiguration)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestRunServerMetricsConfiguration 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(TestRunServerMetricsConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestRunServerMetricsConfiguration(document.RootElement, options); + } + + internal static TestRunServerMetricsConfiguration DeserializeTestRunServerMetricsConfiguration(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 TestRunServerMetricsConfiguration( + 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(TestRunServerMetricsConfiguration)} does not support writing '{options.Format}' format."); + } + } + + TestRunServerMetricsConfiguration 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunServerMetricsConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestRunServerMetricsConfiguration)} 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 TestRunServerMetricsConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestRunServerMetricsConfiguration(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/TestRunServerMetricsConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricsConfiguration.cs new file mode 100644 index 000000000000..d135fc359c0d --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunServerMetricsConfiguration.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 TestRunServerMetricsConfiguration + { + /// + /// 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 TestRunServerMetricsConfiguration() + { + 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 TestRunServerMetricsConfiguration(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 000000000000..13767f6806dc --- /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(ErrorPercentage)) + { + writer.WritePropertyName("errorPct"u8); + writer.WriteNumberValue(ErrorPercentage.Value); + } + if (options.Format != "W" && Optional.IsDefined(MeanResponseTime)) + { + writer.WritePropertyName("meanResTime"u8); + writer.WriteNumberValue(MeanResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MedianResponseTime)) + { + writer.WritePropertyName("medianResTime"u8); + writer.WriteNumberValue(MedianResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MaxResponseTime)) + { + writer.WritePropertyName("maxResTime"u8); + writer.WriteNumberValue(MaxResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(MinResponseTime)) + { + writer.WritePropertyName("minResTime"u8); + writer.WriteNumberValue(MinResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile90ResponseTime)) + { + writer.WritePropertyName("pct1ResTime"u8); + writer.WriteNumberValue(Percentile90ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile95ResponseTime)) + { + writer.WritePropertyName("pct2ResTime"u8); + writer.WriteNumberValue(Percentile95ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile99ResponseTime)) + { + writer.WritePropertyName("pct3ResTime"u8); + writer.WriteNumberValue(Percentile99ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile75ResponseTime)) + { + writer.WritePropertyName("pct75ResTime"u8); + writer.WriteNumberValue(Percentile75ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile96ResponseTime)) + { + writer.WritePropertyName("pct96ResTime"u8); + writer.WriteNumberValue(Percentile96ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile97ResponseTime)) + { + writer.WritePropertyName("pct97ResTime"u8); + writer.WriteNumberValue(Percentile97ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile98ResponseTime)) + { + writer.WritePropertyName("pct98ResTime"u8); + writer.WriteNumberValue(Percentile98ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile999ResponseTime)) + { + writer.WritePropertyName("pct999ResTime"u8); + writer.WriteNumberValue(Percentile999ResponseTime.Value); + } + if (options.Format != "W" && Optional.IsDefined(Percentile9999ResponseTime)) + { + writer.WritePropertyName("pct9999ResTime"u8); + writer.WriteNumberValue(Percentile9999ResponseTime.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..44c9e886782f --- /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? errorPercentage, double? meanResponseTime, double? medianResponseTime, double? maxResponseTime, double? minResponseTime, double? percentile90ResponseTime, double? percentile95ResponseTime, double? percentile99ResponseTime, double? percentile75ResponseTime, double? percentile96ResponseTime, double? percentile97ResponseTime, double? percentile98ResponseTime, double? percentile999ResponseTime, double? percentile9999ResponseTime, double? throughput, double? receivedKBytesPerSec, double? sentKBytesPerSec, IDictionary serializedAdditionalRawData) + { + Transaction = transaction; + SampleCount = sampleCount; + ErrorCount = errorCount; + ErrorPercentage = errorPercentage; + MeanResponseTime = meanResponseTime; + MedianResponseTime = medianResponseTime; + MaxResponseTime = maxResponseTime; + MinResponseTime = minResponseTime; + Percentile90ResponseTime = percentile90ResponseTime; + Percentile95ResponseTime = percentile95ResponseTime; + Percentile99ResponseTime = percentile99ResponseTime; + Percentile75ResponseTime = percentile75ResponseTime; + Percentile96ResponseTime = percentile96ResponseTime; + Percentile97ResponseTime = percentile97ResponseTime; + Percentile98ResponseTime = percentile98ResponseTime; + Percentile999ResponseTime = percentile999ResponseTime; + Percentile9999ResponseTime = percentile9999ResponseTime; + 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? ErrorPercentage { get; } + /// Mean response time. + public double? MeanResponseTime { get; } + /// Median response time. + public double? MedianResponseTime { get; } + /// Max response time. + public double? MaxResponseTime { get; } + /// Minimum response time. + public double? MinResponseTime { get; } + /// 90 percentile response time. + public double? Percentile90ResponseTime { get; } + /// 95 percentile response time. + public double? Percentile95ResponseTime { get; } + /// 99 percentile response time. + public double? Percentile99ResponseTime { get; } + /// 75 percentile response time. + public double? Percentile75ResponseTime { get; } + /// 96 percentile response time. + public double? Percentile96ResponseTime { get; } + /// 97 percentile response time. + public double? Percentile97ResponseTime { get; } + /// 98 percentile response time. + public double? Percentile98ResponseTime { get; } + /// 99.9 percentile response time. + public double? Percentile999ResponseTime { get; } + /// 99.99 percentile response time. + public double? Percentile9999ResponseTime { 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/TestRunStatus.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatus.cs new file mode 100644 index 000000000000..9dd421ee5970 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestRunStatus.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 TestRunStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TestRunStatus(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 TestRunStatus Accepted { get; } = new TestRunStatus(AcceptedValue); + /// Test run is not yet started. + public static TestRunStatus NotStarted { get; } = new TestRunStatus(NotStartedValue); + /// Test run is provisioning. + public static TestRunStatus Provisioning { get; } = new TestRunStatus(ProvisioningValue); + /// Test run is provisioned. + public static TestRunStatus Provisioned { get; } = new TestRunStatus(ProvisionedValue); + /// Test run is getting configured. + public static TestRunStatus Configuring { get; } = new TestRunStatus(ConfiguringValue); + /// Test run configuration is done. + public static TestRunStatus Configured { get; } = new TestRunStatus(ConfiguredValue); + /// Test run has started executing. + public static TestRunStatus Executing { get; } = new TestRunStatus(ExecutingValue); + /// Test run execution is completed. + public static TestRunStatus Executed { get; } = new TestRunStatus(ExecutedValue); + /// Test run is getting deprovisioned. + public static TestRunStatus Deprovisioning { get; } = new TestRunStatus(DeprovisioningValue); + /// Test run is deprovisioned. + public static TestRunStatus Deprovisioned { get; } = new TestRunStatus(DeprovisionedValue); + /// Test run is completed. + public static TestRunStatus Done { get; } = new TestRunStatus(DoneValue); + /// Test run is being cancelled. + public static TestRunStatus Cancelling { get; } = new TestRunStatus(CancellingValue); + /// Test run request is cancelled. + public static TestRunStatus Cancelled { get; } = new TestRunStatus(CancelledValue); + /// Test run request is failed. + public static TestRunStatus Failed { get; } = new TestRunStatus(FailedValue); + /// Test run JMX file is validated. + public static TestRunStatus ValidationSuccess { get; } = new TestRunStatus(ValidationSuccessValue); + /// Test run JMX file validation is failed. + public static TestRunStatus ValidationFailure { get; } = new TestRunStatus(ValidationFailureValue); + /// Determines if two values are the same. + public static bool operator ==(TestRunStatus left, TestRunStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TestRunStatus left, TestRunStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TestRunStatus(string value) => new TestRunStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TestRunStatus other && Equals(other); + /// + public bool Equals(TestRunStatus 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/TestSecret.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.Serialization.cs new file mode 100644 index 000000000000..f5023d2c8bd0 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.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 TestSecret : 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(TestSecret)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsDefined(SecretKind)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(SecretKind.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestSecret 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(TestSecret)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestSecret(document.RootElement, options); + } + + internal static TestSecret DeserializeTestSecret(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 TestSecret(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(TestSecret)} does not support writing '{options.Format}' format."); + } + } + + TestSecret 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestSecret(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestSecret)} 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 TestSecret FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestSecret(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/TestSecret.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.cs new file mode 100644 index 000000000000..7d5ead0d5ffa --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestSecret.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 TestSecret + { + /// + /// 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 TestSecret() + { + } + + /// 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 TestSecret(string value, SecretType? secretKind, IDictionary serializedAdditionalRawData) + { + Value = value; + SecretKind = secretKind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The value of the secret for the respective type. + public string Value { get; set; } + /// Type of secret. + public SecretType? SecretKind { get; set; } + } +} diff --git a/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.Serialization.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.Serialization.cs new file mode 100644 index 000000000000..feb306b3bfe2 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.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 TestServerMetricsConfiguration : 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(TestServerMetricsConfiguration)} 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TestServerMetricsConfiguration 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(TestServerMetricsConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTestServerMetricsConfiguration(document.RootElement, options); + } + + internal static TestServerMetricsConfiguration DeserializeTestServerMetricsConfiguration(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 TestServerMetricsConfiguration( + 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(TestServerMetricsConfiguration)} does not support writing '{options.Format}' format."); + } + } + + TestServerMetricsConfiguration 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestServerMetricsConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TestServerMetricsConfiguration)} 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 TestServerMetricsConfiguration FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTestServerMetricsConfiguration(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/TestServerMetricsConfiguration.cs b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.cs new file mode 100644 index 000000000000..c1185f418186 --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/src/Generated/Models/TestServerMetricsConfiguration.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 TestServerMetricsConfiguration + { + /// + /// 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 TestServerMetricsConfiguration(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 TestServerMetricsConfiguration(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 TestServerMetricsConfiguration() + { + } + + /// 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 000000000000..ae362b9b3750 --- /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 FiveSecondsValue = "PT5S"; + private const string TenSecondsValue = "PT10S"; + private const string OneMinuteValue = "PT1M"; + private const string FiveMinutesValue = "PT5M"; + private const string OneHourValue = "PT1H"; + + /// 5 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain FiveSeconds { get; } = new TimeGrain(FiveSecondsValue); + /// 10 seconds, available only if test run duration is less than 10 minutes. + public static TimeGrain TenSeconds { get; } = new TimeGrain(TenSecondsValue); + /// 1 minute. + public static TimeGrain OneMinute { get; } = new TimeGrain(OneMinuteValue); + /// 5 minutes, available only if test run duration is greater than 1 minute. + public static TimeGrain FiveMinutes { get; } = new TimeGrain(FiveMinutesValue); + /// 1 hour, available only if test run duration is greater than 1 minute. + public static TimeGrain OneHour { get; } = new TimeGrain(OneHourValue); + /// 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 000000000000..2e54aadd590f --- /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, ModelSerializationExtensions.JsonDocumentOptions)) + { + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..f7aa8099f958 --- /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 000000000000..c86a862c906f --- /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, ModelSerializationExtensions.JsonDocumentOptions); + 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, ModelSerializationExtensions.JsonDocumentOptions); + 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 000000000000..90008a4d4205 --- /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 000000000000..7a7448111412 --- /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 000000000000..ed860a4c070a --- /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 000000000000..e476d877adef --- /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, null, 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, null, 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 000000000000..d50155cd2ecd --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tests/Generated/Samples/Samples_LoadTestRunClient.cs @@ -0,0 +1,1119 @@ +// 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", + 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", + 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 000000000000..09e1f796fbad --- /dev/null +++ b/sdk/loadtesting/Azure.Developer.LoadTesting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/loadtesting/ci.yml b/sdk/loadtesting/ci.yml new file mode 100644 index 000000000000..5046481ec78c --- /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/machinelearning/Azure.AI.ChatProtocol/Azure.AI.ChatProtocol.sln b/sdk/machinelearning/Azure.AI.ChatProtocol/Azure.AI.ChatProtocol.sln new file mode 100644 index 000000000000..24a7e22f8cce --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/Azure.AI.ChatProtocol.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.AI.ChatProtocol", "src\Azure.AI.ChatProtocol.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AI.ChatProtocol.Tests", "tests\Azure.AI.ChatProtocol.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/machinelearning/Azure.AI.ChatProtocol/CHANGELOG.md b/sdk/machinelearning/Azure.AI.ChatProtocol/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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/machinelearning/Azure.AI.ChatProtocol/Directory.Build.props b/sdk/machinelearning/Azure.AI.ChatProtocol/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/README.md b/sdk/machinelearning/Azure.AI.ChatProtocol/README.md new file mode 100644 index 000000000000..88ac8d752019 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/README.md @@ -0,0 +1,107 @@ +# Azure.AI.ChatProtocol client library for .NET + +Azure.AI.ChatProtocol 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/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol --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/machinelearning/Azure.AI.ChatProtocol/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/machinelearning/Azure.AI.ChatProtocol/README.png) \ No newline at end of file diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Azure.AI.ChatProtocol.csproj b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Azure.AI.ChatProtocol.csproj new file mode 100644 index 000000000000..8146bc91e25a --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Azure.AI.ChatProtocol.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AI.ChatProtocol client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AI.ChatProtocol for Azure Data Plane + 1.0.0-beta.1 + Azure.AI.ChatProtocol + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolClientBuilderExtensions.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolClientBuilderExtensions.cs new file mode 100644 index 000000000000..ea7717bf6de6 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolClientBuilderExtensions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AI.ChatProtocol; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AIChatProtocolClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The to use. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddChatProtocolClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new ChatProtocolClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The to use. + public static IAzureClientBuilder AddChatProtocolClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new ChatProtocolClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddChatProtocolClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolModelFactory.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolModelFactory.cs new file mode 100644 index 000000000000..d85f4af0e444 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/AIChatProtocolModelFactory.cs @@ -0,0 +1,59 @@ +// 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.AI.ChatProtocol +{ + /// Model factory for models. + public static partial class AIChatProtocolModelFactory + { + /// Initializes a new instance of . + /// The collection of generated completions. + /// A new instance for mocking. + public static ChatCompletion ChatCompletion(IEnumerable choices = null) + { + choices ??= new List(); + + return new ChatCompletion(choices?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the of the chat choice, relative to the other choices in the same completion. + /// + /// The chat message for a given chat completion. + /// 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 . + /// + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The reason this chat completion completed its generation. + /// A new instance for mocking. + public static ChatChoice ChatChoice(long index = default, ChatMessage message = null, BinaryData sessionState = null, IReadOnlyDictionary context = null, FinishReason finishReason = default) + { + context ??= new Dictionary(); + + return new ChatChoice( + index, + message, + sessionState, + context, + finishReason, + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Chat.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Chat.cs new file mode 100644 index 000000000000..d47b23734fea --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Chat.cs @@ -0,0 +1,381 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.ChatProtocol +{ + // Data plane generated sub-client. + /// The Chat sub-client. + public partial class Chat + { + private const string AuthorizationHeader = "api-key"; + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = Array.Empty(); + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// 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 Chat for mocking. + protected Chat() + { + } + + /// Initializes a new instance of Chat. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The token credential to copy. + /// The to use. + internal Chat(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, TokenCredential tokenCredential, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _tokenCredential = tokenCredential; + _endpoint = endpoint; + } + + /// Creates a new streaming chat completion. + /// The route where the endpoint exposes the chat operations. + /// The collection of context messages associated with this completion request. + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> CreateStreamingAsync(string operationRoute, IEnumerable messages, bool stream, BinaryData sessionState = null, IReadOnlyDictionary context = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(messages, nameof(messages)); + + CreateStreamingRequest createStreamingRequest = new CreateStreamingRequest(messages.ToList(), stream, sessionState, context ?? new ChangeTrackingDictionary(), null); + RequestContext context0 = FromCancellationToken(cancellationToken); + Response response = await CreateStreamingAsync(operationRoute, createStreamingRequest.ToRequestContent(), context0).ConfigureAwait(false); + return Response.FromValue(ChatCompletionChunk.FromResponse(response), response); + } + + /// Creates a new streaming chat completion. + /// The route where the endpoint exposes the chat operations. + /// The collection of context messages associated with this completion request. + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response CreateStreaming(string operationRoute, IEnumerable messages, bool stream, BinaryData sessionState = null, IReadOnlyDictionary context = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(messages, nameof(messages)); + + CreateStreamingRequest createStreamingRequest = new CreateStreamingRequest(messages.ToList(), stream, sessionState, context ?? new ChangeTrackingDictionary(), null); + RequestContext context0 = FromCancellationToken(cancellationToken); + Response response = CreateStreaming(operationRoute, createStreamingRequest.ToRequestContent(), context0); + return Response.FromValue(ChatCompletionChunk.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new streaming chat completion. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// The route where the endpoint exposes the chat operations. + /// 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. + internal virtual async Task CreateStreamingAsync(string operationRoute, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Chat.CreateStreaming"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateStreamingRequest(operationRoute, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new streaming chat completion. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// The route where the endpoint exposes the chat operations. + /// 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. + internal virtual Response CreateStreaming(string operationRoute, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Chat.CreateStreaming"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateStreamingRequest(operationRoute, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new chat completion. + /// The route where the endpoint exposes the chat operations. + /// The collection of context messages associated with this completion request. + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateAsync(string operationRoute, IEnumerable messages, bool stream, BinaryData sessionState = null, IReadOnlyDictionary context = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(messages, nameof(messages)); + + CreateRequest createRequest = new CreateRequest(messages.ToList(), stream, sessionState, context ?? new ChangeTrackingDictionary(), null); + RequestContext context0 = FromCancellationToken(cancellationToken); + Response response = await CreateAsync(operationRoute, createRequest.ToRequestContent(), context0).ConfigureAwait(false); + return Response.FromValue(ChatCompletion.FromResponse(response), response); + } + + /// Creates a new chat completion. + /// The route where the endpoint exposes the chat operations. + /// The collection of context messages associated with this completion request. + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response Create(string operationRoute, IEnumerable messages, bool stream, BinaryData sessionState = null, IReadOnlyDictionary context = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(messages, nameof(messages)); + + CreateRequest createRequest = new CreateRequest(messages.ToList(), stream, sessionState, context ?? new ChangeTrackingDictionary(), null); + RequestContext context0 = FromCancellationToken(cancellationToken); + Response response = Create(operationRoute, createRequest.ToRequestContent(), context0); + return Response.FromValue(ChatCompletion.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new chat completion. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// The route where the endpoint exposes the chat operations. + /// 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 CreateAsync(string operationRoute, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Chat.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(operationRoute, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new chat completion. + /// + /// + /// + /// 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. + /// + /// + /// + /// + /// The route where the endpoint exposes the chat operations. + /// 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 Create(string operationRoute, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(operationRoute, nameof(operationRoute)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Chat.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(operationRoute, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateStreamingRequest(string operationRoute, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(operationRoute, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateRequest(string operationRoute, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/", false); + uri.AppendPath(operationRoute, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + 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 _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.Serialization.cs new file mode 100644 index 000000000000..71dfd4257e07 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.Serialization.cs @@ -0,0 +1,231 @@ +// 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.AI.ChatProtocol +{ + public partial class ChatChoice : 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(ChatChoice)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("message"u8); + writer.WriteObjectValue(Message, options); + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Context)) + { + writer.WritePropertyName("context"u8); + writer.WriteStartObject(); + foreach (var item in Context) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + writer.WritePropertyName("finishReason"u8); + writer.WriteStringValue(FinishReason.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatChoice 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(ChatChoice)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatChoice(document.RootElement, options); + } + + internal static ChatChoice DeserializeChatChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long index = default; + ChatMessage message = default; + BinaryData sessionState = default; + IReadOnlyDictionary context = default; + FinishReason finishReason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = ChatMessage.DeserializeChatMessage(property.Value, options); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("context"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + context = dictionary; + continue; + } + if (property.NameEquals("finishReason"u8)) + { + finishReason = new FinishReason(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatChoice( + index, + message, + sessionState, + context ?? new ChangeTrackingDictionary(), + finishReason, + 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(ChatChoice)} does not support writing '{options.Format}' format."); + } + } + + ChatChoice 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatChoice)} 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 ChatChoice FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatChoice(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.cs new file mode 100644 index 000000000000..da67a0a5ea32 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatChoice.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.ChatProtocol +{ + /// The representation of a single generated completion. + public partial class ChatChoice + { + /// + /// 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 index of the of the chat choice, relative to the other choices in the same completion. + /// + /// The chat message for a given chat completion. + /// 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 reason this chat completion completed its generation. + /// is null. + internal ChatChoice(long index, ChatMessage message, FinishReason finishReason) + { + Argument.AssertNotNull(message, nameof(message)); + + Index = index; + Message = message; + Context = new ChangeTrackingDictionary(); + FinishReason = finishReason; + } + + /// Initializes a new instance of . + /// The index of the of the chat choice, relative to the other choices in the same completion. + /// + /// The chat message for a given chat completion. + /// 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 . + /// + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The reason this chat completion completed its generation. + /// Keeps track of any properties unknown to the library. + internal ChatChoice(long index, ChatMessage message, BinaryData sessionState, IReadOnlyDictionary context, FinishReason finishReason, IDictionary serializedAdditionalRawData) + { + Index = index; + Message = message; + SessionState = sessionState; + Context = context; + FinishReason = finishReason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatChoice() + { + } + + /// The index of the of the chat choice, relative to the other choices in the same completion. + public long Index { get; } + /// + /// The chat message for a given chat completion. + /// 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 ChatMessage Message { get; } + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; } + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// 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" }. + /// + /// + /// + /// + public IReadOnlyDictionary Context { get; } + /// The reason this chat completion completed its generation. + public FinishReason FinishReason { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.Serialization.cs new file mode 100644 index 000000000000..4e13530c43b3 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.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.AI.ChatProtocol +{ + public partial class ChatCompletion : 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(ChatCompletion)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatCompletion 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(ChatCompletion)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletion(document.RootElement, options); + } + + internal static ChatCompletion DeserializeChatCompletion(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList choices = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("choices"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatChoice.DeserializeChatChoice(item, options)); + } + choices = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletion(choices, 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(ChatCompletion)} does not support writing '{options.Format}' format."); + } + } + + ChatCompletion 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatCompletion(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletion)} 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 ChatCompletion FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatCompletion(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.cs new file mode 100644 index 000000000000..ca5a1a6cfeee --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletion.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.AI.ChatProtocol +{ + /// Representation of the response to a chat completion request. + public partial class ChatCompletion + { + /// + /// 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 collection of generated completions. + /// is null. + internal ChatCompletion(IEnumerable choices) + { + Argument.AssertNotNull(choices, nameof(choices)); + + Choices = choices.ToList(); + } + + /// Initializes a new instance of . + /// The collection of generated completions. + /// Keeps track of any properties unknown to the library. + internal ChatCompletion(IReadOnlyList choices, IDictionary serializedAdditionalRawData) + { + Choices = choices; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatCompletion() + { + } + + /// The collection of generated completions. + public IReadOnlyList Choices { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.Serialization.cs new file mode 100644 index 000000000000..1c085ff52545 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.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.AI.ChatProtocol +{ + internal partial class ChatCompletionChunk : 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(ChatCompletionChunk)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("choices"u8); + writer.WriteStartArray(); + foreach (var item in Choices) + { + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatCompletionChunk 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(ChatCompletionChunk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatCompletionChunk(document.RootElement, options); + } + + internal static ChatCompletionChunk DeserializeChatCompletionChunk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList choices = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("choices"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChoiceDelta.DeserializeChoiceDelta(item, options)); + } + choices = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChatCompletionChunk(choices, 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(ChatCompletionChunk)} does not support writing '{options.Format}' format."); + } + } + + ChatCompletionChunk 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatCompletionChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatCompletionChunk)} 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 ChatCompletionChunk FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatCompletionChunk(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.cs new file mode 100644 index 000000000000..cafdec9a0eed --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatCompletionChunk.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.AI.ChatProtocol +{ + /// A single response to a streaming completion request. + internal partial class ChatCompletionChunk + { + /// + /// 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 collection of choice deltas received in this chunk. + /// is null. + internal ChatCompletionChunk(IEnumerable choices) + { + Argument.AssertNotNull(choices, nameof(choices)); + + Choices = choices.ToList(); + } + + /// Initializes a new instance of . + /// The collection of choice deltas received in this chunk. + /// Keeps track of any properties unknown to the library. + internal ChatCompletionChunk(IReadOnlyList choices, IDictionary serializedAdditionalRawData) + { + Choices = choices; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatCompletionChunk() + { + } + + /// The collection of choice deltas received in this chunk. + public IReadOnlyList Choices { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.Serialization.cs new file mode 100644 index 000000000000..18579326fef5 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.Serialization.cs @@ -0,0 +1,147 @@ +// 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.AI.ChatProtocol +{ + [PersistableModelProxy(typeof(UnknownChatMessage))] + public partial class ChatMessage : 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(ChatMessage)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatMessage 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(ChatMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } + + internal static ChatMessage DeserializeChatMessage(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 "text": return TextChatMessage.DeserializeTextChatMessage(element, options); + } + } + return UnknownChatMessage.DeserializeUnknownChatMessage(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(ChatMessage)} does not support writing '{options.Format}' format."); + } + } + + ChatMessage 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} 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 ChatMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessage(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.cs new file mode 100644 index 000000000000..e7a9d6fe080c --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessage.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.AI.ChatProtocol +{ + /// + /// A single, role-attributed message within a chat completion interaction. + /// 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 ChatMessage + { + /// + /// 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 . + /// The role associated with the message. + protected ChatMessage(ChatRole role) + { + Role = role; + } + + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + internal ChatMessage(MessageKind kind, ChatRole role, BinaryData sessionState, IDictionary serializedAdditionalRawData) + { + Kind = kind; + Role = role; + SessionState = sessionState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChatMessage() + { + } + + /// The type of the message. If not specified, the message is assumed to be text. + internal MessageKind Kind { get; set; } + /// The role associated with the message. + public ChatRole Role { get; set; } + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; set; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.Serialization.cs new file mode 100644 index 000000000000..162d23af62fd --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.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.Text.Json; +using Azure.Core; + +namespace Azure.AI.ChatProtocol +{ + [PersistableModelProxy(typeof(UnknownChatMessageDelta))] + internal partial class ChatMessageDelta : 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(ChatMessageDelta)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (Optional.IsDefined(Role)) + { + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.Value.ToString()); + } + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChatMessageDelta 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(ChatMessageDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessageDelta(document.RootElement, options); + } + + internal static ChatMessageDelta DeserializeChatMessageDelta(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 "text": return TextChatMessageDelta.DeserializeTextChatMessageDelta(element, options); + } + } + return UnknownChatMessageDelta.DeserializeUnknownChatMessageDelta(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(ChatMessageDelta)} does not support writing '{options.Format}' format."); + } + } + + ChatMessageDelta 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessageDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessageDelta)} 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 ChatMessageDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessageDelta(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.cs new file mode 100644 index 000000000000..3705d977c5e1 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatMessageDelta.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.ChatProtocol +{ + /// + /// The representation of a delta message received in a streaming completion. + /// 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 . + /// + internal abstract partial class ChatMessageDelta + { + /// + /// 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 ChatMessageDelta() + { + } + + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + internal ChatMessageDelta(MessageKind kind, ChatRole? role, BinaryData sessionState, IDictionary serializedAdditionalRawData) + { + Kind = kind; + Role = role; + SessionState = sessionState; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of the message. If not specified, the message is assumed to be text. + internal MessageKind Kind { get; set; } + /// The role associated with the message. + public ChatRole? Role { get; } + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClient.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClient.cs new file mode 100644 index 000000000000..4ae7b64d3396 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClient.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AI.ChatProtocol +{ + // Data plane generated client. + /// Azure APIs for the Azure Chat protocol. + public partial class ChatProtocolClient + { + private const string AuthorizationHeader = "api-key"; + private readonly AzureKeyCredential _keyCredential; + private static readonly string[] AuthorizationScopes = Array.Empty(); + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// 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 ChatProtocolClient for mocking. + protected ChatProtocolClient() + { + } + + /// Initializes a new instance of ChatProtocolClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public ChatProtocolClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new ChatProtocolClientOptions()) + { + } + + /// Initializes a new instance of ChatProtocolClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public ChatProtocolClient(Uri endpoint, TokenCredential credential) : this(endpoint, credential, new ChatProtocolClientOptions()) + { + } + + /// Initializes a new instance of ChatProtocolClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public ChatProtocolClient(Uri endpoint, AzureKeyCredential credential, ChatProtocolClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new ChatProtocolClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of ChatProtocolClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public ChatProtocolClient(Uri endpoint, TokenCredential credential, ChatProtocolClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new ChatProtocolClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + private Chat _cachedChat; + + /// Initializes a new instance of Chat. + public virtual Chat GetChatClient() + { + return Volatile.Read(ref _cachedChat) ?? Interlocked.CompareExchange(ref _cachedChat, new Chat(ClientDiagnostics, _pipeline, _keyCredential, _tokenCredential, _endpoint), null) ?? _cachedChat; + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClientOptions.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClientOptions.cs new file mode 100644 index 000000000000..94b8f8a4f4b8 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatProtocolClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AI.ChatProtocol +{ + /// Client options for ChatProtocolClient. + public partial class ChatProtocolClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2023_10_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2023-10-01-preview". + V2023_10_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of ChatProtocolClientOptions. + public ChatProtocolClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2023_10_01_Preview => "2023-10-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatRole.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatRole.cs new file mode 100644 index 000000000000..50c2381c14d8 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChatRole.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.AI.ChatProtocol +{ + /// A representation of the intended purpose of a message. + public readonly partial struct ChatRole : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ChatRole(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "user"; + private const string SystemValue = "system"; + private const string AssistantValue = "assistant"; + + /// The role that provides input to the completion. + public static ChatRole User { get; } = new ChatRole(UserValue); + /// The role that instructs or configures the behavior of the assistant. + public static ChatRole System { get; } = new ChatRole(SystemValue); + /// The role that provides responses to the system-instructed, user-prompted input. + public static ChatRole Assistant { get; } = new ChatRole(AssistantValue); + /// Determines if two values are the same. + public static bool operator ==(ChatRole left, ChatRole right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ChatRole left, ChatRole right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ChatRole(string value) => new ChatRole(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ChatRole other && Equals(other); + /// + public bool Equals(ChatRole 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.Serialization.cs new file mode 100644 index 000000000000..96205e7c7656 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.Serialization.cs @@ -0,0 +1,238 @@ +// 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.AI.ChatProtocol +{ + internal partial class ChoiceDelta : 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(ChoiceDelta)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Context)) + { + writer.WritePropertyName("context"u8); + writer.WriteStartObject(); + foreach (var item in Context) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(FinishReason)) + { + writer.WritePropertyName("finishReason"u8); + writer.WriteStringValue(FinishReason.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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ChoiceDelta 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(ChoiceDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChoiceDelta(document.RootElement, options); + } + + internal static ChoiceDelta DeserializeChoiceDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long index = default; + ChatMessageDelta delta = default; + BinaryData sessionState = default; + IReadOnlyDictionary context = default; + FinishReason? finishReason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("delta"u8)) + { + delta = ChatMessageDelta.DeserializeChatMessageDelta(property.Value, options); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("context"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + context = dictionary; + continue; + } + if (property.NameEquals("finishReason"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + finishReason = new FinishReason(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ChoiceDelta( + index, + delta, + sessionState, + context ?? new ChangeTrackingDictionary(), + finishReason, + 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(ChoiceDelta)} does not support writing '{options.Format}' format."); + } + } + + ChoiceDelta 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChoiceDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChoiceDelta)} 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 ChoiceDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChoiceDelta(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.cs new file mode 100644 index 000000000000..015dda5e7073 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/ChoiceDelta.cs @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.ChatProtocol +{ + /// The representation of an incremental choice received in a streaming completion. + internal partial class ChoiceDelta + { + /// + /// 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 index of the of the chat choice, relative to the other choices in the same completion. + /// + /// The partial message received for this choice. + /// 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 . + /// + /// is null. + internal ChoiceDelta(long index, ChatMessageDelta delta) + { + Argument.AssertNotNull(delta, nameof(delta)); + + Index = index; + Delta = delta; + Context = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The index of the of the chat choice, relative to the other choices in the same completion. + /// + /// The partial message received for this choice. + /// 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 . + /// + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// The reason this chat completion completed its generation. + /// Keeps track of any properties unknown to the library. + internal ChoiceDelta(long index, ChatMessageDelta delta, BinaryData sessionState, IReadOnlyDictionary context, FinishReason? finishReason, IDictionary serializedAdditionalRawData) + { + Index = index; + Delta = delta; + SessionState = sessionState; + Context = context; + FinishReason = finishReason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ChoiceDelta() + { + } + + /// The index of the of the chat choice, relative to the other choices in the same completion. + public long Index { get; } + /// + /// The partial message received for this choice. + /// 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 ChatMessageDelta Delta { get; } + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; } + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// 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" }. + /// + /// + /// + /// + public IReadOnlyDictionary Context { get; } + /// The reason this chat completion completed its generation. + public FinishReason? FinishReason { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.Serialization.cs new file mode 100644 index 000000000000..65e9e972077c --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.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.AI.ChatProtocol +{ + internal partial class CreateRequest : 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(CreateRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream); + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Context)) + { + writer.WritePropertyName("context"u8); + writer.WriteStartObject(); + foreach (var item in Context) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateRequest 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(CreateRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateRequest(document.RootElement, options); + } + + internal static CreateRequest DeserializeCreateRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList messages = default; + bool stream = default; + BinaryData sessionState = default; + IReadOnlyDictionary context = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("stream"u8)) + { + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("context"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + context = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateRequest(messages, stream, sessionState, context ?? 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(CreateRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateRequest 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateRequest)} 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 CreateRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRequest(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.cs new file mode 100644 index 000000000000..99df8caf782a --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateRequest.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; +using System.Linq; + +namespace Azure.AI.ChatProtocol +{ + /// The CreateRequest. + internal partial class CreateRequest + { + /// + /// 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 collection of context messages associated with this completion request. + /// 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 . + /// + /// is null. + internal CreateRequest(IEnumerable messages) + { + Argument.AssertNotNull(messages, nameof(messages)); + + Messages = messages.ToList(); + Context = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// The collection of context messages associated with this completion request. + /// 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 . + /// + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// Keeps track of any properties unknown to the library. + internal CreateRequest(IReadOnlyList messages, bool stream, BinaryData sessionState, IReadOnlyDictionary context, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Stream = stream; + SessionState = sessionState; + Context = context; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateRequest() + { + } + + /// + /// The collection of context messages associated with this completion request. + /// 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 IReadOnlyList Messages { get; } + /// Indicates whether the completion is a streaming or non-streaming completion. + public bool Stream { get; } = false; + + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; } + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// 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" }. + /// + /// + /// + /// + public IReadOnlyDictionary Context { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.Serialization.cs new file mode 100644 index 000000000000..dfd23f79d86e --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.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.AI.ChatProtocol +{ + internal partial class CreateStreamingRequest : 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(CreateStreamingRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("messages"u8); + writer.WriteStartArray(); + foreach (var item in Messages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream); + if (Optional.IsDefined(SessionState)) + { + writer.WritePropertyName("sessionState"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(SessionState); +#else + using (JsonDocument document = JsonDocument.Parse(SessionState, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Context)) + { + writer.WritePropertyName("context"u8); + writer.WriteStartObject(); + foreach (var item in Context) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + 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, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateStreamingRequest 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(CreateStreamingRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateStreamingRequest(document.RootElement, options); + } + + internal static CreateStreamingRequest DeserializeCreateStreamingRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList messages = default; + bool stream = default; + BinaryData sessionState = default; + IReadOnlyDictionary context = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("messages"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ChatMessage.DeserializeChatMessage(item, options)); + } + messages = array; + continue; + } + if (property.NameEquals("stream"u8)) + { + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("context"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + context = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateStreamingRequest(messages, stream, sessionState, context ?? 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(CreateStreamingRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateStreamingRequest 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateStreamingRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateStreamingRequest)} 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 CreateStreamingRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateStreamingRequest(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.cs new file mode 100644 index 000000000000..934df93a91f3 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/CreateStreamingRequest.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; +using System.Linq; + +namespace Azure.AI.ChatProtocol +{ + /// The CreateStreamingRequest. + internal partial class CreateStreamingRequest + { + /// + /// 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 collection of context messages associated with this completion request. + /// 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 . + /// + /// is null. + internal CreateStreamingRequest(IEnumerable messages) + { + Argument.AssertNotNull(messages, nameof(messages)); + + Messages = messages.ToList(); + Context = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// + /// The collection of context messages associated with this completion request. + /// 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 . + /// + /// Indicates whether the completion is a streaming or non-streaming completion. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// Keeps track of any properties unknown to the library. + internal CreateStreamingRequest(IReadOnlyList messages, bool stream, BinaryData sessionState, IReadOnlyDictionary context, IDictionary serializedAdditionalRawData) + { + Messages = messages; + Stream = stream; + SessionState = sessionState; + Context = context; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateStreamingRequest() + { + } + + /// + /// The collection of context messages associated with this completion request. + /// 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 IReadOnlyList Messages { get; } + /// Indicates whether the completion is a streaming or non-streaming completion. + public bool Stream { get; } = true; + + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// To assign an object to 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" }. + /// + /// + /// + /// + public BinaryData SessionState { get; } + /// + /// Context allows the chat app to receive extra parameters from the client, such as temperature, functions, or + /// customer_info. These parameters are specific to the chat app and not understood by the generic clients. + /// + /// 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" }. + /// + /// + /// + /// + public IReadOnlyDictionary Context { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Docs/Chat.xml b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Docs/Chat.xml new file mode 100644 index 000000000000..afdc935d46b5 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Docs/Chat.xml @@ -0,0 +1,93 @@ + + + + + +This sample shows how to call CreateAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + +Response response = await client.CreateAsync("chat", new ChatMessage[] +{ + new TextChatMessage(ChatRole.User, "Tell me a joke") +}, false); +]]> + + + +This sample shows how to call Create. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + +Response response = client.Create("chat", new ChatMessage[] +{ + new TextChatMessage(ChatRole.User, "Tell me a joke") +}, false); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + kind = "text", + content = "Tell me a joke", + role = "user", + } + }, + stream = false, +}); +Response response = await client.CreateAsync("chat", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("index").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("kind").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("finishReason").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + +using RequestContent content = RequestContent.Create(new +{ + messages = new object[] + { + new + { + kind = "text", + content = "Tell me a joke", + role = "user", + } + }, + stream = false, +}); +Response response = client.Create("chat", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("index").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("kind").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("role").ToString()); +Console.WriteLine(result.GetProperty("choices")[0].GetProperty("finishReason").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/FinishReason.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/FinishReason.cs new file mode 100644 index 000000000000..924be349b066 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/FinishReason.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.AI.ChatProtocol +{ + /// Representation of the reason why a chat session has finished processing. + public readonly partial struct FinishReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FinishReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StoppedValue = "stop"; + private const string TokenLimitReachedValue = "length"; + + /// Completion ended normally. + public static FinishReason Stopped { get; } = new FinishReason(StoppedValue); + /// The completion exhausted available tokens before generation could complete. + public static FinishReason TokenLimitReached { get; } = new FinishReason(TokenLimitReachedValue); + /// Determines if two values are the same. + public static bool operator ==(FinishReason left, FinishReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FinishReason left, FinishReason right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator FinishReason(string value) => new FinishReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FinishReason other && Equals(other); + /// + public bool Equals(FinishReason 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Argument.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..21dc735023fa --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol +{ + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..6405707756aa --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol +{ + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingList.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..6f662933fb67 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol +{ + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..9a5d94ab68da --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// 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.AI.ChatProtocol +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Optional.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..facde37b92f3 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol +{ + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..38aefb708440 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol +{ + 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/MessageKind.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/MessageKind.cs new file mode 100644 index 000000000000..e48bca9a6f53 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/MessageKind.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.AI.ChatProtocol +{ + /// Identifies the type of a message. + internal readonly partial struct MessageKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + + /// The message context is text. + public static MessageKind Text { get; } = new MessageKind(TextValue); + /// Determines if two values are the same. + public static bool operator ==(MessageKind left, MessageKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageKind left, MessageKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MessageKind(string value) => new MessageKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageKind other && Equals(other); + /// + public bool Equals(MessageKind 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/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.Serialization.cs new file mode 100644 index 000000000000..066bc6569e7e --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.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.AI.ChatProtocol +{ + public partial class TextChatMessage : 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(TextChatMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + + TextChatMessage 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(TextChatMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextChatMessage(document.RootElement, options); + } + + internal static TextChatMessage DeserializeTextChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string content = default; + MessageKind kind = default; + ChatRole role = default; + BinaryData sessionState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("content"u8)) + { + content = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new MessageKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new ChatRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextChatMessage(kind, role, sessionState, serializedAdditionalRawData, content); + } + + 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(TextChatMessage)} does not support writing '{options.Format}' format."); + } + } + + TextChatMessage 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextChatMessage)} 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 TextChatMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextChatMessage(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.cs new file mode 100644 index 000000000000..6be3e1174fb8 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessage.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.ChatProtocol +{ + /// A single, role-attributed text message within a chat completion interaction. + public partial class TextChatMessage : ChatMessage + { + /// Initializes a new instance of . + /// The role associated with the message. + /// The text associated with the message. + /// is null. + public TextChatMessage(ChatRole role, string content) : base(role) + { + Argument.AssertNotNull(content, nameof(content)); + + Kind = MessageKind.Text; + Content = content; + } + + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + /// The text associated with the message. + internal TextChatMessage(MessageKind kind, ChatRole role, BinaryData sessionState, IDictionary serializedAdditionalRawData, string content) : base(kind, role, sessionState, serializedAdditionalRawData) + { + Content = content; + } + + /// Initializes a new instance of for deserialization. + internal TextChatMessage() + { + } + + /// The text associated with the message. + public string Content { get; set; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.Serialization.cs new file mode 100644 index 000000000000..03558e7b6531 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.Serialization.cs @@ -0,0 +1,157 @@ +// 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.AI.ChatProtocol +{ + internal partial class TextChatMessageDelta : 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(TextChatMessageDelta)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + } + + TextChatMessageDelta 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(TextChatMessageDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTextChatMessageDelta(document.RootElement, options); + } + + internal static TextChatMessageDelta DeserializeTextChatMessageDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string content = default; + MessageKind kind = default; + ChatRole? role = default; + BinaryData sessionState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("content"u8)) + { + content = property.Value.GetString(); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new MessageKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("role"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + role = new ChatRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TextChatMessageDelta(kind, role, sessionState, serializedAdditionalRawData, content); + } + + 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(TextChatMessageDelta)} does not support writing '{options.Format}' format."); + } + } + + TextChatMessageDelta 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextChatMessageDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TextChatMessageDelta)} 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 TextChatMessageDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTextChatMessageDelta(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.cs new file mode 100644 index 000000000000..f95f521e16c6 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/TextChatMessageDelta.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.ChatProtocol +{ + /// The representation of a delta text message received in a streaming completion. + internal partial class TextChatMessageDelta : ChatMessageDelta + { + /// Initializes a new instance of . + internal TextChatMessageDelta() + { + Kind = MessageKind.Text; + } + + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + /// An incremental part of the text associated with the message. + internal TextChatMessageDelta(MessageKind kind, ChatRole? role, BinaryData sessionState, IDictionary serializedAdditionalRawData, string content) : base(kind, role, sessionState, serializedAdditionalRawData) + { + Content = content; + } + + /// An incremental part of the text associated with the message. + public string Content { get; } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.Serialization.cs new file mode 100644 index 000000000000..baf2e9918fb2 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.Serialization.cs @@ -0,0 +1,142 @@ +// 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.AI.ChatProtocol +{ + internal partial class UnknownChatMessage : 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(ChatMessage)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ChatMessage 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(ChatMessage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessage(document.RootElement, options); + } + + internal static UnknownChatMessage DeserializeUnknownChatMessage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageKind kind = "Unknown"; + ChatRole role = default; + BinaryData sessionState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new MessageKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("role"u8)) + { + role = new ChatRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownChatMessage(kind, role, sessionState, 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(ChatMessage)} does not support writing '{options.Format}' format."); + } + } + + ChatMessage 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessage)} 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 UnknownChatMessage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownChatMessage(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.cs new file mode 100644 index 000000000000..1fedfc73eb7a --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessage.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.AI.ChatProtocol +{ + /// Unknown version of ChatMessage. + internal partial class UnknownChatMessage : ChatMessage + { + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + internal UnknownChatMessage(MessageKind kind, ChatRole role, BinaryData sessionState, IDictionary serializedAdditionalRawData) : base(kind, role, sessionState, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownChatMessage() + { + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.Serialization.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.Serialization.cs new file mode 100644 index 000000000000..3cd8bf84d0cc --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.Serialization.cs @@ -0,0 +1,146 @@ +// 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.AI.ChatProtocol +{ + internal partial class UnknownChatMessageDelta : 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(ChatMessageDelta)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + ChatMessageDelta 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(ChatMessageDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeChatMessageDelta(document.RootElement, options); + } + + internal static UnknownChatMessageDelta DeserializeUnknownChatMessageDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageKind kind = "Unknown"; + ChatRole? role = default; + BinaryData sessionState = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new MessageKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("role"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + role = new ChatRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("sessionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sessionState = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownChatMessageDelta(kind, role, sessionState, 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(ChatMessageDelta)} does not support writing '{options.Format}' format."); + } + } + + ChatMessageDelta 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, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeChatMessageDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ChatMessageDelta)} 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 UnknownChatMessageDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownChatMessageDelta(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/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.cs new file mode 100644 index 000000000000..83ece5167460 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Generated/UnknownChatMessageDelta.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.AI.ChatProtocol +{ + /// Unknown version of ChatMessageDelta. + internal partial class UnknownChatMessageDelta : ChatMessageDelta + { + /// Initializes a new instance of . + /// The type of the message. If not specified, the message is assumed to be text. + /// The role associated with the message. + /// + /// Field that allows the chat app to store and retrieve data, the structure of such data is dependant on the backend + /// being used. The client must send back the data in this field unchanged in subsequent requests, until the chat app + /// sends a new one. The data in this field can be used to implement stateful services, such as remembering previous + /// conversations or user preferences. + /// + /// Keeps track of any properties unknown to the library. + internal UnknownChatMessageDelta(MessageKind kind, ChatRole? role, BinaryData sessionState, IDictionary serializedAdditionalRawData) : base(kind, role, sessionState, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownChatMessageDelta() + { + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/src/Properties/AssemblyInfo.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..c7738bfd4f60 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/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.AI.ChatProtocol.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/machinelearning/Azure.AI.ChatProtocol/tests/Azure.AI.ChatProtocol.Tests.csproj b/sdk/machinelearning/Azure.AI.ChatProtocol/tests/Azure.AI.ChatProtocol.Tests.csproj new file mode 100644 index 000000000000..f0565c97bf4d --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/tests/Azure.AI.ChatProtocol.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/tests/Generated/Samples/Samples_Chat.cs b/sdk/machinelearning/Azure.AI.ChatProtocol/tests/Generated/Samples/Samples_Chat.cs new file mode 100644 index 000000000000..ae0ae5054af5 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/tests/Generated/Samples/Samples_Chat.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AI.ChatProtocol.Samples +{ + public partial class Samples_Chat + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Chat_Create_CreatesAChatCompletionForTheProvidedPromptUsingStreaming() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +kind = "text", +content = "Tell me a joke", +role = "user", +} + }, + stream = false, + }); + Response response = client.Create("chat", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("index").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("finishReason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Chat_Create_CreatesAChatCompletionForTheProvidedPromptUsingStreaming_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + + using RequestContent content = RequestContent.Create(new + { + messages = new object[] + { +new +{ +kind = "text", +content = "Tell me a joke", +role = "user", +} + }, + stream = false, + }); + Response response = await client.CreateAsync("chat", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("index").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("kind").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("message").GetProperty("role").ToString()); + Console.WriteLine(result.GetProperty("choices")[0].GetProperty("finishReason").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Chat_Create_CreatesAChatCompletionForTheProvidedPromptUsingStreaming_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + + Response response = client.Create("chat", new ChatMessage[] + { +new TextChatMessage(ChatRole.User, "Tell me a joke") + }, false); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Chat_Create_CreatesAChatCompletionForTheProvidedPromptUsingStreaming_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Chat client = new ChatProtocolClient(endpoint, credential).GetChatClient(); + + Response response = await client.CreateAsync("chat", new ChatMessage[] + { +new TextChatMessage(ChatRole.User, "Tell me a joke") + }, false); + } + } +} diff --git a/sdk/machinelearning/Azure.AI.ChatProtocol/tsp-location.yaml b/sdk/machinelearning/Azure.AI.ChatProtocol/tsp-location.yaml new file mode 100644 index 000000000000..85fbfbdec4e7 --- /dev/null +++ b/sdk/machinelearning/Azure.AI.ChatProtocol/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/machinelearning/Azure.AI.ChatProtocol +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/machinelearning/ci.yml b/sdk/machinelearning/ci.yml new file mode 100644 index 000000000000..01e1cffcc6d3 --- /dev/null +++ b/sdk/machinelearning/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/machinelearning + - sdk/machinelearning/ci.yml + - sdk/machinelearning/Azure.AI.ChatProtocol + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/machinelearning + - sdk/machinelearning/ci.yml + - sdk/machinelearning/Azure.AI.ChatProtocol + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: machinelearning + ArtifactName: packages + Artifacts: + - name: Azure.AI.ChatProtocol + safeName: AzureAIChatProtocol diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/Configuration.json b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/Configuration.json new file mode 100644 index 000000000000..aa258a8c76eb --- /dev/null +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/Configuration.json @@ -0,0 +1,12 @@ +{ + "output-folder": ".", + "namespace": "Azure.ResourceManager.PlaywrightTesting", + "library-name": "Azure.ResourceManager.PlaywrightTesting", + "flavor": "azure", + "use-model-reader-writer": true, + "shared-source-folders": [ + "../../TempTypeSpecFiles/node_modules/@autorest/csharp/Generator.Shared", + "../../TempTypeSpecFiles/node_modules/@autorest/csharp/Azure.Core.Shared" + ], + "azure-arm": true +} diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tsp-location.yaml b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tsp-location.yaml index bfaa02c7b55e..e5abd849cadc 100644 --- a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tsp-location.yaml +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tsp-location.yaml @@ -1,3 +1,4 @@ -directory: specification/playwrighttesting -commit: c39acac0b3b7ceeee03b594a7b49c9bad6b8e9f2 +directory: specification/playwrighttesting/PlaywrightTesting.Management +commit: 9d9566a1af7781ee2533b606c06875a83f1d2e1f repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tspCodeModel.json b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tspCodeModel.json new file mode 100644 index 000000000000..4f7194acd07d --- /dev/null +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/tspCodeModel.json @@ -0,0 +1,7668 @@ +{ + "$id": "1", + "name": "Microsoft.AzurePlaywrightService", + "apiVersions": [ + "2024-12-01" + ], + "enums": [ + { + "$id": "2", + "kind": "enum", + "name": "PlaywrightTestingQuotaNames", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.QuotaNames", + "valueType": { + "$id": "3", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "4", + "kind": "enumvalue", + "name": "ScalableExecution", + "value": "ScalableExecution", + "valueType": { + "$id": "5", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "doc": "The quota details for scalable execution feature. When enabled, Playwright client workers can connect to cloud-hosted browsers. This can increase the number of parallel workers for a test run, significantly minimizing test completion durations.", + "decorators": [] + }, + { + "$id": "6", + "kind": "enumvalue", + "name": "Reporting", + "value": "Reporting", + "valueType": { + "$id": "7", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "2" + }, + "doc": "The quota details for reporting feature. When enabled, Playwright client will be able to upload and display test results, including artifacts like traces and screenshots, in the Playwright portal. This enables faster and more efficient troubleshooting.", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "The enum for quota name.", + "isFixed": false, + "isFlags": false, + "usage": "Input,Output,Json", + "decorators": [] + }, + { + "$id": "8", + "kind": "enum", + "name": "PlaywrightTestingProvisioningState", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.ProvisioningState", + "valueType": { + "$id": "9", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "10", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$id": "11", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "12", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$id": "13", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "14", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$id": "15", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + }, + { + "$id": "16", + "kind": "enumvalue", + "name": "Creating", + "value": "Creating", + "valueType": { + "$id": "17", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Creation in progress..", + "decorators": [] + }, + { + "$id": "18", + "kind": "enumvalue", + "name": "Deleting", + "value": "Deleting", + "valueType": { + "$id": "19", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Deletion in progress..", + "decorators": [] + }, + { + "$id": "20", + "kind": "enumvalue", + "name": "Accepted", + "value": "Accepted", + "valueType": { + "$id": "21", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "8" + }, + "doc": "Change accepted for processing..", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "The status of the current operation.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "22", + "kind": "enum", + "name": "createdByType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.createdByType", + "valueType": { + "$id": "23", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "24", + "kind": "enumvalue", + "name": "User", + "value": "User", + "valueType": { + "$id": "25", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "22" + }, + "doc": "The entity was created by a user.", + "decorators": [] + }, + { + "$id": "26", + "kind": "enumvalue", + "name": "Application", + "value": "Application", + "valueType": { + "$id": "27", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "22" + }, + "doc": "The entity was created by an application.", + "decorators": [] + }, + { + "$id": "28", + "kind": "enumvalue", + "name": "ManagedIdentity", + "value": "ManagedIdentity", + "valueType": { + "$id": "29", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "22" + }, + "doc": "The entity was created by a managed identity.", + "decorators": [] + }, + { + "$id": "30", + "kind": "enumvalue", + "name": "Key", + "value": "Key", + "valueType": { + "$id": "31", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "22" + }, + "doc": "The entity was created by a key.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The kind of entity that created the resource.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "32", + "kind": "enum", + "name": "PlaywrightTestingFreeTrialState", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.FreeTrialState", + "valueType": { + "$id": "33", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "34", + "kind": "enumvalue", + "name": "Active", + "value": "Active", + "valueType": { + "$id": "35", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "32" + }, + "doc": "The free-trial is Active.", + "decorators": [] + }, + { + "$id": "36", + "kind": "enumvalue", + "name": "Expired", + "value": "Expired", + "valueType": { + "$id": "37", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "32" + }, + "doc": "The free-trial is Expired.", + "decorators": [] + }, + { + "$id": "38", + "kind": "enumvalue", + "name": "NotEligible", + "value": "NotEligible", + "valueType": { + "$id": "39", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "32" + }, + "doc": "The free-trial is Not Eligible.", + "decorators": [] + }, + { + "$id": "40", + "kind": "enumvalue", + "name": "NotRegistered", + "value": "NotRegistered", + "valueType": { + "$id": "41", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "32" + }, + "doc": "The free-trial is Not Registered.", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "The free-trial state.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "42", + "kind": "enum", + "name": "PlaywrightTestingOfferingType", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.OfferingType", + "valueType": { + "$id": "43", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "44", + "kind": "enumvalue", + "name": "NotApplicable", + "value": "NotApplicable", + "valueType": { + "$id": "45", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "42" + }, + "doc": "The offeringType is NotApplicable.", + "decorators": [] + }, + { + "$id": "46", + "kind": "enumvalue", + "name": "PrivatePreview", + "value": "PrivatePreview", + "valueType": { + "$id": "47", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "42" + }, + "doc": "The offeringType is PrivatePreview.", + "decorators": [] + }, + { + "$id": "48", + "kind": "enumvalue", + "name": "PublicPreview", + "value": "PublicPreview", + "valueType": { + "$id": "49", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "42" + }, + "doc": "The offeringType is PublicPreview.", + "decorators": [] + }, + { + "$id": "50", + "kind": "enumvalue", + "name": "GeneralAvailability", + "value": "GeneralAvailability", + "valueType": { + "$id": "51", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "42" + }, + "doc": "The offeringType is GeneralAvailability.", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "Offering type state.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "52", + "kind": "enum", + "name": "PlaywrightTestingEnablementStatus", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.EnablementStatus", + "valueType": { + "$id": "53", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "54", + "kind": "enumvalue", + "name": "Enabled", + "value": "Enabled", + "valueType": { + "$id": "55", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "52" + }, + "doc": "The feature is Enabled.", + "decorators": [] + }, + { + "$id": "56", + "kind": "enumvalue", + "name": "Disabled", + "value": "Disabled", + "valueType": { + "$id": "57", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "52" + }, + "doc": "The feature is Disabled.", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "The enablement status of a feature.", + "isFixed": false, + "isFlags": false, + "usage": "Input,Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "decorators": [] + }, + { + "$id": "58", + "kind": "enum", + "name": "ResourceProvisioningState", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceProvisioningState", + "valueType": { + "$id": "59", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "60", + "kind": "enumvalue", + "name": "Succeeded", + "value": "Succeeded", + "valueType": { + "$id": "61", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "58" + }, + "doc": "Resource has been created.", + "decorators": [] + }, + { + "$id": "62", + "kind": "enumvalue", + "name": "Failed", + "value": "Failed", + "valueType": { + "$id": "63", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "58" + }, + "doc": "Resource creation failed.", + "decorators": [] + }, + { + "$id": "64", + "kind": "enumvalue", + "name": "Canceled", + "value": "Canceled", + "valueType": { + "$id": "65", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "58" + }, + "doc": "Resource creation was canceled.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager", + "doc": "The provisioning state of a resource type.", + "isFixed": false, + "isFlags": false, + "usage": "LroPolling", + "decorators": [] + }, + { + "$id": "66", + "kind": "enum", + "name": "PlaywrightTestingNameUnavailableReason", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityReason", + "valueType": { + "$id": "67", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "68", + "kind": "enumvalue", + "name": "Invalid", + "value": "Invalid", + "valueType": { + "$id": "69", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "66" + }, + "doc": "Name is invalid.", + "decorators": [] + }, + { + "$id": "70", + "kind": "enumvalue", + "name": "AlreadyExists", + "value": "AlreadyExists", + "valueType": { + "$id": "71", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "66" + }, + "doc": "Name already exists.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "Possible reasons for a name not being available.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "72", + "kind": "enum", + "name": "Origin", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Origin", + "valueType": { + "$id": "73", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "74", + "kind": "enumvalue", + "name": "user", + "value": "user", + "valueType": { + "$id": "75", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "72" + }, + "doc": "Indicates the operation is initiated by a user.", + "decorators": [] + }, + { + "$id": "76", + "kind": "enumvalue", + "name": "system", + "value": "system", + "valueType": { + "$id": "77", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "72" + }, + "doc": "Indicates the operation is initiated by a system.", + "decorators": [] + }, + { + "$id": "78", + "kind": "enumvalue", + "name": "user,system", + "value": "user,system", + "valueType": { + "$id": "79", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "72" + }, + "doc": "Indicates the operation is initiated by a user or system.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\"", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "80", + "kind": "enum", + "name": "ActionType", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ActionType", + "valueType": { + "$id": "81", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "82", + "kind": "enumvalue", + "name": "Internal", + "value": "Internal", + "valueType": { + "$id": "83", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "80" + }, + "doc": "Actions are for internal-only APIs.", + "decorators": [] + } + ], + "namespace": "Azure.ResourceManager.CommonTypes", + "doc": "Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs.", + "isFixed": false, + "isFlags": false, + "usage": "Output,Json", + "decorators": [] + }, + { + "$id": "84", + "kind": "enum", + "name": "Versions", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Versions", + "valueType": { + "$id": "85", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "values": [ + { + "$id": "86", + "kind": "enumvalue", + "name": "2024-12-01", + "value": "2024-12-01", + "valueType": { + "$id": "87", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "enumType": { + "$ref": "84" + }, + "doc": "2024-12-01 version", + "decorators": [] + } + ], + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "Microsoft.AzurePlaywrightService Management API Versions.", + "isFixed": true, + "isFlags": false, + "usage": "ApiVersionEnum", + "decorators": [] + } + ], + "models": [ + { + "$id": "88", + "kind": "model", + "name": "PlaywrightTestingAccountQuotas", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuota", + "usage": "Output,Json", + "doc": "A quota resource for a Playwright service account.", + "decorators": [], + "baseModel": { + "$id": "89", + "kind": "model", + "name": "ProxyResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ProxyResource", + "usage": "Output,Json", + "doc": "The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location", + "decorators": [], + "baseModel": { + "$id": "90", + "kind": "model", + "name": "Resource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource", + "usage": "Input,Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "doc": "Common fields that are returned in the response for all Azure Resource Manager resources", + "decorators": [], + "properties": [ + { + "$id": "91", + "kind": "property", + "name": "id", + "serializedName": "id", + "doc": "Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}", + "type": { + "$id": "92", + "kind": "string", + "name": "armResourceIdentifier", + "crossLanguageDefinitionId": "Azure.Core.armResourceIdentifier", + "baseType": { + "$id": "93", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.id", + "serializationOptions": { + "$id": "94", + "json": { + "$id": "95", + "name": "id" + } + } + }, + { + "$id": "96", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource", + "type": { + "$id": "97", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.name", + "serializationOptions": { + "$id": "98", + "json": { + "$id": "99", + "name": "name" + } + } + }, + { + "$id": "100", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"", + "type": { + "$id": "101", + "kind": "string", + "name": "armResourceType", + "crossLanguageDefinitionId": "Azure.Core.armResourceType", + "baseType": { + "$id": "102", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.type", + "serializationOptions": { + "$id": "103", + "json": { + "$id": "104", + "name": "type" + } + } + }, + { + "$id": "105", + "kind": "property", + "name": "systemData", + "serializedName": "systemData", + "doc": "Azure Resource Manager metadata containing createdBy and modifiedBy information.", + "type": { + "$id": "106", + "kind": "model", + "name": "SystemData", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData", + "usage": "Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "doc": "Metadata pertaining to creation and last modification of the resource.", + "decorators": [], + "properties": [ + { + "$id": "107", + "kind": "property", + "name": "createdBy", + "serializedName": "createdBy", + "doc": "The identity that created the resource.", + "type": { + "$id": "108", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdBy", + "serializationOptions": { + "$id": "109", + "json": { + "$id": "110", + "name": "createdBy" + } + } + }, + { + "$id": "111", + "kind": "property", + "name": "createdByType", + "serializedName": "createdByType", + "doc": "The type of identity that created the resource.", + "type": { + "$ref": "22" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdByType", + "serializationOptions": { + "$id": "112", + "json": { + "$id": "113", + "name": "createdByType" + } + } + }, + { + "$id": "114", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "The timestamp of resource creation (UTC).", + "type": { + "$id": "115", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "116", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.createdAt", + "serializationOptions": { + "$id": "117", + "json": { + "$id": "118", + "name": "createdAt" + } + } + }, + { + "$id": "119", + "kind": "property", + "name": "lastModifiedBy", + "serializedName": "lastModifiedBy", + "doc": "The identity that last modified the resource.", + "type": { + "$id": "120", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedBy", + "serializationOptions": { + "$id": "121", + "json": { + "$id": "122", + "name": "lastModifiedBy" + } + } + }, + { + "$id": "123", + "kind": "property", + "name": "lastModifiedByType", + "serializedName": "lastModifiedByType", + "doc": "The type of identity that last modified the resource.", + "type": { + "$ref": "22" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedByType", + "serializationOptions": { + "$id": "124", + "json": { + "$id": "125", + "name": "lastModifiedByType" + } + } + }, + { + "$id": "126", + "kind": "property", + "name": "lastModifiedAt", + "serializedName": "lastModifiedAt", + "doc": "The timestamp of resource last modification (UTC)", + "type": { + "$id": "127", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "128", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.SystemData.lastModifiedAt", + "serializationOptions": { + "$id": "129", + "json": { + "$id": "130", + "name": "lastModifiedAt" + } + } + } + ] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Resource.systemData", + "serializationOptions": { + "$id": "131", + "json": { + "$id": "132", + "name": "systemData" + } + } + } + ] + }, + "properties": [] + }, + "properties": [ + { + "$id": "133", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "134", + "kind": "model", + "name": "PlaywrightTestingAccountQuotaProperties", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotaProperties", + "usage": "Output,Json", + "doc": "The Playwright service account quota resource properties.", + "decorators": [], + "properties": [ + { + "$id": "135", + "kind": "property", + "name": "freeTrial", + "serializedName": "freeTrial", + "doc": "The Playwright service account quota resource free-trial properties.", + "type": { + "$id": "136", + "kind": "model", + "name": "PlaywrightTestingAccountFreeTrialProperties", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties", + "usage": "Output,Json", + "doc": "The Playwright service account quota resource free-trial properties.", + "decorators": [], + "properties": [ + { + "$id": "137", + "kind": "property", + "name": "createdAt", + "serializedName": "createdAt", + "doc": "The free-trial createdAt utcDateTime.", + "type": { + "$id": "138", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "139", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties.createdAt", + "serializationOptions": { + "$id": "140", + "json": { + "$id": "141", + "name": "createdAt" + } + } + }, + { + "$id": "142", + "kind": "property", + "name": "expiryAt", + "serializedName": "expiryAt", + "doc": "The free-trial expiryAt utcDateTime.", + "type": { + "$id": "143", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "144", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties.expiryAt", + "serializationOptions": { + "$id": "145", + "json": { + "$id": "146", + "name": "expiryAt" + } + } + }, + { + "$id": "147", + "kind": "property", + "name": "allocatedValue", + "serializedName": "allocatedValue", + "doc": "The free-trial allocated limit value eg. allocated free minutes.", + "type": { + "$id": "148", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties.allocatedValue", + "serializationOptions": { + "$id": "149", + "json": { + "$id": "150", + "name": "allocatedValue" + } + } + }, + { + "$id": "151", + "kind": "property", + "name": "usedValue", + "serializedName": "usedValue", + "doc": "The free-trial used value eg. used free minutes.", + "type": { + "$id": "152", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties.usedValue", + "serializationOptions": { + "$id": "153", + "json": { + "$id": "154", + "name": "usedValue" + } + } + }, + { + "$id": "155", + "kind": "property", + "name": "percentageUsed", + "serializedName": "percentageUsed", + "doc": "The free-trial percentage used.", + "type": { + "$id": "156", + "kind": "float32", + "name": "float32", + "crossLanguageDefinitionId": "TypeSpec.float32", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountFreeTrialProperties.percentageUsed", + "serializationOptions": { + "$id": "157", + "json": { + "$id": "158", + "name": "percentageUsed" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotaProperties.freeTrial", + "serializationOptions": { + "$id": "159", + "json": { + "$id": "160", + "name": "freeTrial" + } + } + }, + { + "$id": "161", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "8" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotaProperties.provisioningState", + "serializationOptions": { + "$id": "162", + "json": { + "$id": "163", + "name": "provisioningState" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuota.properties", + "serializationOptions": { + "$id": "164", + "json": { + "$id": "165", + "name": "properties" + } + } + } + ] + }, + { + "$ref": "134" + }, + { + "$ref": "136" + }, + { + "$ref": "89" + }, + { + "$ref": "90" + }, + { + "$ref": "106" + }, + { + "$id": "166", + "kind": "model", + "name": "ErrorResponse", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse", + "usage": "Error,Json,Exception", + "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.", + "decorators": [], + "properties": [ + { + "$id": "167", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "The error object.", + "type": { + "$id": "168", + "kind": "model", + "name": "ErrorDetail", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail", + "usage": "Json,Exception,LroPolling", + "doc": "The error detail.", + "decorators": [], + "properties": [ + { + "$id": "169", + "kind": "property", + "name": "code", + "serializedName": "code", + "doc": "The error code.", + "type": { + "$id": "170", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code", + "serializationOptions": { + "$id": "171", + "json": { + "$id": "172", + "name": "code" + } + } + }, + { + "$id": "173", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "The error message.", + "type": { + "$id": "174", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message", + "serializationOptions": { + "$id": "175", + "json": { + "$id": "176", + "name": "message" + } + } + }, + { + "$id": "177", + "kind": "property", + "name": "target", + "serializedName": "target", + "doc": "The error target.", + "type": { + "$id": "178", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target", + "serializationOptions": { + "$id": "179", + "json": { + "$id": "180", + "name": "target" + } + } + }, + { + "$id": "181", + "kind": "property", + "name": "details", + "serializedName": "details", + "doc": "The error details.", + "type": { + "$id": "182", + "kind": "array", + "name": "ArrayErrorDetail", + "valueType": { + "$ref": "168" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details", + "serializationOptions": { + "$id": "183", + "json": { + "$id": "184", + "name": "details" + } + } + }, + { + "$id": "185", + "kind": "property", + "name": "additionalInfo", + "serializedName": "additionalInfo", + "doc": "The error additional info.", + "type": { + "$id": "186", + "kind": "array", + "name": "ArrayErrorAdditionalInfo", + "valueType": { + "$id": "187", + "kind": "model", + "name": "ErrorAdditionalInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo", + "usage": "Json,Exception,LroPolling", + "doc": "The resource management error additional info.", + "decorators": [], + "properties": [ + { + "$id": "188", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The additional info type.", + "type": { + "$id": "189", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type", + "serializationOptions": { + "$id": "190", + "json": { + "$id": "191", + "name": "type" + } + } + }, + { + "$id": "192", + "kind": "property", + "name": "info", + "serializedName": "info", + "doc": "The additional info.", + "type": { + "$id": "193", + "kind": "model", + "name": "ErrorAdditionalInfoInfo", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info.anonymous", + "usage": "Json,Exception,LroPolling", + "decorators": [], + "properties": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info", + "serializationOptions": { + "$id": "194", + "json": { + "$id": "195", + "name": "info" + } + } + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo", + "serializationOptions": { + "$id": "196", + "json": { + "$id": "197", + "name": "additionalInfo" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error", + "serializationOptions": { + "$id": "198", + "json": { + "$id": "199", + "name": "error" + } + } + } + ] + }, + { + "$ref": "168" + }, + { + "$ref": "187" + }, + { + "$ref": "193" + }, + { + "$id": "200", + "kind": "model", + "name": "AccountQuotaListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a AccountQuota list operation.", + "decorators": [], + "properties": [ + { + "$id": "201", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The AccountQuota items on this page", + "type": { + "$id": "202", + "kind": "array", + "name": "ArrayAccountQuota", + "valueType": { + "$ref": "88" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "$id": "203", + "json": { + "$id": "204", + "name": "value" + } + } + }, + { + "$id": "205", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "206", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "207", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "$id": "208", + "json": { + "$id": "209", + "name": "nextLink" + } + } + } + ] + }, + { + "$id": "210", + "kind": "model", + "name": "PlaywrightTestingQuotas", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Quota", + "usage": "Output,Json", + "doc": "A subscription quota resource.", + "decorators": [], + "baseModel": { + "$ref": "89" + }, + "properties": [ + { + "$id": "211", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "212", + "kind": "model", + "name": "PlaywrightTestingQuotaProperties", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.QuotaProperties", + "usage": "Output,Json", + "doc": "The subscription quota resource properties.", + "decorators": [], + "properties": [ + { + "$id": "213", + "kind": "property", + "name": "freeTrial", + "serializedName": "freeTrial", + "doc": "The subscription quota resource free-trial properties.", + "type": { + "$id": "214", + "kind": "model", + "name": "PlaywrightTestingFreeTrialProperties", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.FreeTrialProperties", + "usage": "Output,Json", + "doc": "The subscription quota resource free-trial properties.", + "decorators": [], + "properties": [ + { + "$id": "215", + "kind": "property", + "name": "accountId", + "serializedName": "accountId", + "doc": "The Playwright service account id.", + "type": { + "$id": "216", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.FreeTrialProperties.accountId", + "serializationOptions": { + "$id": "217", + "json": { + "$id": "218", + "name": "accountId" + } + } + }, + { + "$id": "219", + "kind": "property", + "name": "state", + "serializedName": "state", + "doc": "The free-trial state.", + "type": { + "$ref": "32" + }, + "optional": false, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.FreeTrialProperties.state", + "serializationOptions": { + "$id": "220", + "json": { + "$id": "221", + "name": "state" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.QuotaProperties.freeTrial", + "serializationOptions": { + "$id": "222", + "json": { + "$id": "223", + "name": "freeTrial" + } + } + }, + { + "$id": "224", + "kind": "property", + "name": "offeringType", + "serializedName": "offeringType", + "doc": "Indicates the offering type for the subscription.", + "type": { + "$ref": "42" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.QuotaProperties.offeringType", + "serializationOptions": { + "$id": "225", + "json": { + "$id": "226", + "name": "offeringType" + } + } + }, + { + "$id": "227", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "8" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.QuotaProperties.provisioningState", + "serializationOptions": { + "$id": "228", + "json": { + "$id": "229", + "name": "provisioningState" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Quota.properties", + "serializationOptions": { + "$id": "230", + "json": { + "$id": "231", + "name": "properties" + } + } + } + ] + }, + { + "$ref": "212" + }, + { + "$ref": "214" + }, + { + "$id": "232", + "kind": "model", + "name": "QuotaListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a Quota list operation.", + "decorators": [], + "properties": [ + { + "$id": "233", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The Quota items on this page", + "type": { + "$id": "234", + "kind": "array", + "name": "ArrayQuota", + "valueType": { + "$ref": "210" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "$id": "235", + "json": { + "$id": "236", + "name": "value" + } + } + }, + { + "$id": "237", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "238", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "239", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "$id": "240", + "json": { + "$id": "241", + "name": "nextLink" + } + } + } + ] + }, + { + "$id": "242", + "kind": "model", + "name": "PlaywrightTestingAccount", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Account", + "usage": "Input,Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "doc": "A Playwright service account resource.", + "decorators": [], + "baseModel": { + "$id": "243", + "kind": "model", + "name": "TrackedResource", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource", + "usage": "Input,Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "doc": "The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'", + "decorators": [], + "baseModel": { + "$ref": "90" + }, + "properties": [ + { + "$id": "244", + "kind": "property", + "name": "tags", + "serializedName": "tags", + "doc": "Resource tags.", + "type": { + "$id": "245", + "kind": "dict", + "keyType": { + "$id": "246", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "247", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.tags", + "serializationOptions": { + "$id": "248", + "json": { + "$id": "249", + "name": "tags" + } + } + }, + { + "$id": "250", + "kind": "property", + "name": "location", + "serializedName": "location", + "doc": "The geo-location where the resource lives", + "type": { + "$id": "251", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.TrackedResource.location", + "serializationOptions": { + "$id": "252", + "json": { + "$id": "253", + "name": "location" + } + } + } + ] + }, + "properties": [ + { + "$id": "254", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "255", + "kind": "model", + "name": "PlaywrightTestingAccountProperties", + "namespace": "Microsoft.AzurePlaywrightService", + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties", + "usage": "Input,Output,Json,LroInitial,LroPolling,LroFinalEnvelope", + "doc": "Account resource properties.", + "decorators": [], + "properties": [ + { + "$id": "256", + "kind": "property", + "name": "dashboardUri", + "serializedName": "dashboardUri", + "doc": "The Playwright testing dashboard URI for the account resource.", + "type": { + "$id": "257", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.dashboardUri", + "serializationOptions": { + "$id": "258", + "json": { + "$id": "259", + "name": "dashboardUri" + } + } + }, + { + "$id": "260", + "kind": "property", + "name": "regionalAffinity", + "serializedName": "regionalAffinity", + "doc": "This property sets the connection region for Playwright client workers to cloud-hosted browsers. If enabled, workers connect to browsers in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which the workspace was initially created.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.regionalAffinity", + "serializationOptions": { + "$id": "261", + "json": { + "$id": "262", + "name": "regionalAffinity" + } + } + }, + { + "$id": "263", + "kind": "property", + "name": "scalableExecution", + "serializedName": "scalableExecution", + "doc": "When enabled, Playwright client workers can connect to cloud-hosted browsers. This can increase the number of parallel workers for a test run, significantly minimizing test completion durations.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.scalableExecution", + "serializationOptions": { + "$id": "264", + "json": { + "$id": "265", + "name": "scalableExecution" + } + } + }, + { + "$id": "266", + "kind": "property", + "name": "reporting", + "serializedName": "reporting", + "doc": "When enabled, this feature allows the workspace to upload and display test results, including artifacts like traces and screenshots, in the Playwright portal. This enables faster and more efficient troubleshooting.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.reporting", + "serializationOptions": { + "$id": "267", + "json": { + "$id": "268", + "name": "reporting" + } + } + }, + { + "$id": "269", + "kind": "property", + "name": "localAuth", + "serializedName": "localAuth", + "doc": "When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.localAuth", + "serializationOptions": { + "$id": "270", + "json": { + "$id": "271", + "name": "localAuth" + } + } + }, + { + "$id": "272", + "kind": "property", + "name": "provisioningState", + "serializedName": "provisioningState", + "doc": "The status of the last operation.", + "type": { + "$ref": "8" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountProperties.provisioningState", + "serializationOptions": { + "$id": "273", + "json": { + "$id": "274", + "name": "provisioningState" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Account.properties", + "serializationOptions": { + "$id": "275", + "json": { + "$id": "276", + "name": "properties" + } + } + } + ] + }, + { + "$ref": "255" + }, + { + "$ref": "243" + }, + { + "$id": "277", + "kind": "model", + "name": "AccountUpdate", + "namespace": "Azure.ResourceManager.Foundations", + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModel", + "usage": "Input,Json", + "doc": "The type used for update operations of the Account.", + "decorators": [], + "properties": [ + { + "$id": "278", + "kind": "property", + "name": "tags", + "serializedName": "tags", + "doc": "Resource tags.", + "type": { + "$id": "279", + "kind": "dict", + "keyType": { + "$id": "280", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "valueType": { + "$id": "281", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModel.tags", + "serializationOptions": { + "$id": "282", + "json": { + "$id": "283", + "name": "tags" + } + } + }, + { + "$id": "284", + "kind": "property", + "name": "properties", + "serializedName": "properties", + "doc": "The resource-specific properties for this resource.", + "type": { + "$id": "285", + "kind": "model", + "name": "AccountUpdateProperties", + "namespace": "Azure.ResourceManager.Foundations", + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties", + "usage": "Input,Json", + "doc": "The updatable properties of the Account.", + "decorators": [], + "properties": [ + { + "$id": "286", + "kind": "property", + "name": "regionalAffinity", + "serializedName": "regionalAffinity", + "doc": "This property sets the connection region for Playwright client workers to cloud-hosted browsers. If enabled, workers connect to browsers in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which the workspace was initially created.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties.regionalAffinity", + "serializationOptions": { + "$id": "287", + "json": { + "$id": "288", + "name": "regionalAffinity" + } + } + }, + { + "$id": "289", + "kind": "property", + "name": "scalableExecution", + "serializedName": "scalableExecution", + "doc": "When enabled, Playwright client workers can connect to cloud-hosted browsers. This can increase the number of parallel workers for a test run, significantly minimizing test completion durations.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties.scalableExecution", + "serializationOptions": { + "$id": "290", + "json": { + "$id": "291", + "name": "scalableExecution" + } + } + }, + { + "$id": "292", + "kind": "property", + "name": "reporting", + "serializedName": "reporting", + "doc": "When enabled, this feature allows the workspace to upload and display test results, including artifacts like traces and screenshots, in the Playwright portal. This enables faster and more efficient troubleshooting.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties.reporting", + "serializationOptions": { + "$id": "293", + "json": { + "$id": "294", + "name": "reporting" + } + } + }, + { + "$id": "295", + "kind": "property", + "name": "localAuth", + "serializedName": "localAuth", + "doc": "When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations.", + "type": { + "$ref": "52" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModelProperties.localAuth", + "serializationOptions": { + "$id": "296", + "json": { + "$id": "297", + "name": "localAuth" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.Foundations.ResourceUpdateModel.properties", + "serializationOptions": { + "$id": "298", + "json": { + "$id": "299", + "name": "properties" + } + } + } + ] + }, + { + "$ref": "285" + }, + { + "$id": "300", + "kind": "model", + "name": "ArmOperationStatusResourceProvisioningState", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus", + "usage": "LroPolling", + "doc": "Standard Azure Resource Manager operation status response", + "decorators": [], + "properties": [ + { + "$id": "301", + "kind": "property", + "name": "status", + "serializedName": "status", + "doc": "The operation status", + "type": { + "$ref": "58" + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.status", + "serializationOptions": { + "$id": "302", + "json": { + "$id": "303", + "name": "status" + } + } + }, + { + "$id": "304", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operationStatus resource", + "type": { + "$id": "305", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.name", + "serializationOptions": { + "$id": "306", + "json": { + "$id": "307", + "name": "name" + } + } + }, + { + "$id": "308", + "kind": "property", + "name": "startTime", + "serializedName": "startTime", + "doc": "Operation start time", + "type": { + "$id": "309", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "310", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.startTime", + "serializationOptions": { + "$id": "311", + "json": { + "$id": "312", + "name": "startTime" + } + } + }, + { + "$id": "313", + "kind": "property", + "name": "endTime", + "serializedName": "endTime", + "doc": "Operation complete time", + "type": { + "$id": "314", + "kind": "utcDateTime", + "name": "utcDateTime", + "encode": "rfc3339", + "wireType": { + "$id": "315", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "crossLanguageDefinitionId": "TypeSpec.utcDateTime", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.endTime", + "serializationOptions": { + "$id": "316", + "json": { + "$id": "317", + "name": "endTime" + } + } + }, + { + "$id": "318", + "kind": "property", + "name": "percentComplete", + "serializedName": "percentComplete", + "doc": "The progress made toward completing the operation", + "type": { + "$id": "319", + "kind": "float64", + "name": "float64", + "crossLanguageDefinitionId": "TypeSpec.float64", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.percentComplete", + "serializationOptions": { + "$id": "320", + "json": { + "$id": "321", + "name": "percentComplete" + } + } + }, + { + "$id": "322", + "kind": "property", + "name": "error", + "serializedName": "error", + "doc": "Errors that occurred if the operation ended with Canceled or Failed status", + "type": { + "$ref": "168" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.error", + "serializationOptions": { + "$id": "323", + "json": { + "$id": "324", + "name": "error" + } + } + } + ] + }, + { + "$id": "325", + "kind": "model", + "name": "AccountListResult", + "namespace": "Azure.ResourceManager", + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult", + "usage": "Output,Json", + "doc": "The response of a Account list operation.", + "decorators": [], + "properties": [ + { + "$id": "326", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The Account items on this page", + "type": { + "$id": "327", + "kind": "array", + "name": "ArrayAccount", + "valueType": { + "$ref": "242" + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.value", + "serializationOptions": { + "$id": "328", + "json": { + "$id": "329", + "name": "value" + } + } + }, + { + "$id": "330", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "331", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "332", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceListResult.nextLink", + "serializationOptions": { + "$id": "333", + "json": { + "$id": "334", + "name": "nextLink" + } + } + } + ] + }, + { + "$id": "335", + "kind": "model", + "name": "PlaywrightTestingNameAvailabilityRequest", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest", + "usage": "Input,Json", + "doc": "The check availability request body.", + "decorators": [], + "properties": [ + { + "$id": "336", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the resource for which availability needs to be checked.", + "type": { + "$id": "337", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest.name", + "serializationOptions": { + "$id": "338", + "json": { + "$id": "339", + "name": "name" + } + } + }, + { + "$id": "340", + "kind": "property", + "name": "type", + "serializedName": "type", + "doc": "The resource type.", + "type": { + "$id": "341", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityRequest.type", + "serializationOptions": { + "$id": "342", + "json": { + "$id": "343", + "name": "type" + } + } + } + ] + }, + { + "$id": "344", + "kind": "model", + "name": "PlaywrightTestingNameAvailabilityResult", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse", + "usage": "Output,Json", + "doc": "The check availability result.", + "decorators": [], + "properties": [ + { + "$id": "345", + "kind": "property", + "name": "IsNameAvailable", + "serializedName": "nameAvailable", + "doc": "Indicates if the resource name is available.", + "type": { + "$id": "346", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.nameAvailable", + "serializationOptions": { + "$id": "347", + "json": { + "$id": "348", + "name": "nameAvailable" + } + } + }, + { + "$id": "349", + "kind": "property", + "name": "reason", + "serializedName": "reason", + "doc": "The reason why the given name is not available.", + "type": { + "$ref": "66" + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.reason", + "serializationOptions": { + "$id": "350", + "json": { + "$id": "351", + "name": "reason" + } + } + }, + { + "$id": "352", + "kind": "property", + "name": "message", + "serializedName": "message", + "doc": "Detailed reason why the given name is not available.", + "type": { + "$id": "353", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.CheckNameAvailabilityResponse.message", + "serializationOptions": { + "$id": "354", + "json": { + "$id": "355", + "name": "message" + } + } + } + ] + }, + { + "$id": "356", + "kind": "model", + "name": "OperationListResult", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult", + "usage": "Output,Json", + "doc": "A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results.", + "decorators": [], + "properties": [ + { + "$id": "357", + "kind": "property", + "name": "value", + "serializedName": "value", + "doc": "The Operation items on this page", + "type": { + "$id": "358", + "kind": "array", + "name": "ArrayOperation", + "valueType": { + "$id": "359", + "kind": "model", + "name": "Operation", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation", + "usage": "Output,Json", + "doc": "Details of a REST API operation, returned from the Resource Provider Operations API", + "decorators": [], + "properties": [ + { + "$id": "360", + "kind": "property", + "name": "name", + "serializedName": "name", + "doc": "The name of the operation, as per Resource-Based Access Control (RBAC). Examples: \"Microsoft.Compute/virtualMachines/write\", \"Microsoft.Compute/virtualMachines/capture/action\"", + "type": { + "$id": "361", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.name", + "serializationOptions": { + "$id": "362", + "json": { + "$id": "363", + "name": "name" + } + } + }, + { + "$id": "364", + "kind": "property", + "name": "isDataAction", + "serializedName": "isDataAction", + "doc": "Whether the operation applies to data-plane. This is \"true\" for data-plane operations and \"false\" for Azure Resource Manager/control-plane operations.", + "type": { + "$id": "365", + "kind": "boolean", + "name": "boolean", + "crossLanguageDefinitionId": "TypeSpec.boolean", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.isDataAction", + "serializationOptions": { + "$id": "366", + "json": { + "$id": "367", + "name": "isDataAction" + } + } + }, + { + "$id": "368", + "kind": "property", + "name": "display", + "serializedName": "display", + "doc": "Localized display information for this particular operation.", + "type": { + "$id": "369", + "kind": "model", + "name": "OperationDisplay", + "namespace": "Azure.ResourceManager.CommonTypes", + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay", + "usage": "Output,Json", + "doc": "Localized display information for and operation.", + "decorators": [], + "properties": [ + { + "$id": "370", + "kind": "property", + "name": "provider", + "serializedName": "provider", + "doc": "The localized friendly form of the resource provider name, e.g. \"Microsoft Monitoring Insights\" or \"Microsoft Compute\".", + "type": { + "$id": "371", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.provider", + "serializationOptions": { + "$id": "372", + "json": { + "$id": "373", + "name": "provider" + } + } + }, + { + "$id": "374", + "kind": "property", + "name": "resource", + "serializedName": "resource", + "doc": "The localized friendly name of the resource type related to this operation. E.g. \"Virtual Machines\" or \"Job Schedule Collections\".", + "type": { + "$id": "375", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.resource", + "serializationOptions": { + "$id": "376", + "json": { + "$id": "377", + "name": "resource" + } + } + }, + { + "$id": "378", + "kind": "property", + "name": "operation", + "serializedName": "operation", + "doc": "The concise, localized friendly name for the operation; suitable for dropdowns. E.g. \"Create or Update Virtual Machine\", \"Restart Virtual Machine\".", + "type": { + "$id": "379", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.operation", + "serializationOptions": { + "$id": "380", + "json": { + "$id": "381", + "name": "operation" + } + } + }, + { + "$id": "382", + "kind": "property", + "name": "description", + "serializedName": "description", + "doc": "The short, localized friendly description of the operation; suitable for tool tips and detailed views.", + "type": { + "$id": "383", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationDisplay.description", + "serializationOptions": { + "$id": "384", + "json": { + "$id": "385", + "name": "description" + } + } + } + ] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.display", + "serializationOptions": { + "$id": "386", + "json": { + "$id": "387", + "name": "display" + } + } + }, + { + "$id": "388", + "kind": "property", + "name": "origin", + "serializedName": "origin", + "doc": "The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is \"user,system\"", + "type": { + "$ref": "72" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.origin", + "serializationOptions": { + "$id": "389", + "json": { + "$id": "390", + "name": "origin" + } + } + }, + { + "$id": "391", + "kind": "property", + "name": "actionType", + "serializedName": "actionType", + "doc": "Extensible enum. Indicates the action type. \"Internal\" refers to actions that are for internal only APIs.", + "type": { + "$ref": "80" + }, + "optional": true, + "readOnly": true, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.Operation.actionType", + "serializationOptions": { + "$id": "392", + "json": { + "$id": "393", + "name": "actionType" + } + } + } + ] + }, + "crossLanguageDefinitionId": "TypeSpec.Array", + "decorators": [] + }, + "optional": false, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult.value", + "serializationOptions": { + "$id": "394", + "json": { + "$id": "395", + "name": "value" + } + } + }, + { + "$id": "396", + "kind": "property", + "name": "nextLink", + "serializedName": "nextLink", + "doc": "The link to the next page of items", + "type": { + "$id": "397", + "kind": "url", + "name": "ResourceLocation", + "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "baseType": { + "$id": "398", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url", + "decorators": [] + }, + "decorators": [] + }, + "optional": true, + "readOnly": false, + "discriminator": false, + "flatten": false, + "decorators": [], + "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.OperationListResult.nextLink", + "serializationOptions": { + "$id": "399", + "json": { + "$id": "400", + "name": "nextLink" + } + } + } + ] + }, + { + "$ref": "359" + }, + { + "$ref": "369" + } + ], + "clients": [ + { + "$id": "401", + "name": "AzurePlaywrightServiceClient", + "namespace": "Microsoft.AzurePlaywrightService", + "doc": "Microsoft.AzurePlaywrightService Resource Provider Management API.", + "operations": [], + "parameters": [ + { + "$id": "402", + "name": "endpoint", + "nameInRequest": "endpoint", + "doc": "Service host", + "type": { + "$id": "403", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "location": "Uri", + "isApiVersion": false, + "isContentType": false, + "isRequired": true, + "isEndpoint": true, + "skipUrlEncoding": false, + "explode": false, + "kind": "Client", + "defaultValue": { + "$id": "404", + "type": { + "$id": "405", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + } + } + ], + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService" + }, + { + "$id": "406", + "name": "Operations", + "namespace": "Microsoft.AzurePlaywrightService", + "operations": [ + { + "$id": "407", + "name": "list", + "resourceName": "Operations", + "doc": "List the operations for the provider", + "accessibility": "public", + "parameters": [ + { + "$id": "408", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "409", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "410", + "type": { + "$id": "411", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "412", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "413", + "kind": "constant", + "valueType": { + "$id": "414", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "415", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "356" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/providers/Microsoft.AzurePlaywrightService/operations", + "bufferResponse": true, + "paging": { + "$id": "416", + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "$id": "417", + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Operations.list", + "decorators": [], + "examples": [ + { + "$id": "418", + "kind": "http", + "name": "Operations_List", + "description": "Operations_List", + "filePath": "2024-12-01/Operations_List.json", + "parameters": [ + { + "$id": "419", + "parameter": { + "$ref": "408" + }, + "value": { + "$id": "420", + "kind": "string", + "type": { + "$ref": "409" + }, + "value": "2024-12-01" + } + } + ], + "responses": [ + { + "$id": "421", + "response": { + "$ref": "415" + }, + "statusCode": 200, + "bodyValue": { + "$id": "422", + "kind": "model", + "type": { + "$ref": "356" + }, + "value": { + "$id": "423", + "value": { + "$id": "424", + "kind": "array", + "type": { + "$ref": "358" + }, + "value": [ + { + "$id": "425", + "kind": "model", + "type": { + "$ref": "359" + }, + "value": { + "$id": "426", + "name": { + "$id": "427", + "kind": "string", + "type": { + "$ref": "361" + }, + "value": "Microsoft.AzurePlaywrightService/accounts/Write" + }, + "isDataAction": { + "$id": "428", + "kind": "boolean", + "type": { + "$ref": "365" + }, + "value": false + }, + "display": { + "$id": "429", + "kind": "model", + "type": { + "$ref": "369" + }, + "value": { + "$id": "430", + "provider": { + "$id": "431", + "kind": "string", + "type": { + "$ref": "371" + }, + "value": "Microsoft.AzurePlaywrightService" + }, + "resource": { + "$id": "432", + "kind": "string", + "type": { + "$ref": "375" + }, + "value": "accounts" + }, + "operation": { + "$id": "433", + "kind": "string", + "type": { + "$ref": "379" + }, + "value": "Creates or updates the PlaywrightAccounts" + }, + "description": { + "$id": "434", + "kind": "string", + "type": { + "$ref": "383" + }, + "value": "Set PlaywrightAccounts" + } + } + } + } + }, + { + "$id": "435", + "kind": "model", + "type": { + "$ref": "359" + }, + "value": { + "$id": "436", + "name": { + "$id": "437", + "kind": "string", + "type": { + "$ref": "361" + }, + "value": "Microsoft.AzurePlaywrightService/accounts/Delete" + }, + "isDataAction": { + "$id": "438", + "kind": "boolean", + "type": { + "$ref": "365" + }, + "value": false + }, + "display": { + "$id": "439", + "kind": "model", + "type": { + "$ref": "369" + }, + "value": { + "$id": "440", + "provider": { + "$id": "441", + "kind": "string", + "type": { + "$ref": "371" + }, + "value": "Microsoft.AzurePlaywrightService" + }, + "resource": { + "$id": "442", + "kind": "string", + "type": { + "$ref": "375" + }, + "value": "accounts" + }, + "operation": { + "$id": "443", + "kind": "string", + "type": { + "$ref": "379" + }, + "value": "Deletes the PlaywrightAccounts" + }, + "description": { + "$id": "444", + "kind": "string", + "type": { + "$ref": "383" + }, + "value": "Delete PlaywrightAccounts" + } + } + } + } + }, + { + "$id": "445", + "kind": "model", + "type": { + "$ref": "359" + }, + "value": { + "$id": "446", + "name": { + "$id": "447", + "kind": "string", + "type": { + "$ref": "361" + }, + "value": "Microsoft.AzurePlaywrightService/accounts/Read" + }, + "isDataAction": { + "$id": "448", + "kind": "boolean", + "type": { + "$ref": "365" + }, + "value": false + }, + "display": { + "$id": "449", + "kind": "model", + "type": { + "$ref": "369" + }, + "value": { + "$id": "450", + "provider": { + "$id": "451", + "kind": "string", + "type": { + "$ref": "371" + }, + "value": "Microsoft.AzurePlaywrightService" + }, + "resource": { + "$id": "452", + "kind": "string", + "type": { + "$ref": "375" + }, + "value": "accounts" + }, + "operation": { + "$id": "453", + "kind": "string", + "type": { + "$ref": "379" + }, + "value": "Reads the PlaywrightAccounts" + }, + "description": { + "$id": "454", + "kind": "string", + "type": { + "$ref": "383" + }, + "value": "Read PlaywrightAccounts" + } + } + } + } + } + ] + }, + "nextLink": { + "$id": "455", + "kind": "string", + "type": { + "$ref": "397" + }, + "value": "http://nextlink.contoso.com" + } + } + } + } + ] + } + ] + } + ], + "parent": "AzurePlaywrightServiceClient", + "parameters": [ + { + "$id": "456", + "name": "endpoint", + "nameInRequest": "endpoint", + "doc": "Service host", + "type": { + "$id": "457", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "location": "Uri", + "isApiVersion": false, + "isContentType": false, + "isRequired": true, + "isEndpoint": true, + "skipUrlEncoding": false, + "explode": false, + "kind": "Client", + "defaultValue": { + "$id": "458", + "type": { + "$id": "459", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + } + } + ], + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Operations" + }, + { + "$id": "460", + "name": "Accounts", + "namespace": "Microsoft.AzurePlaywrightService", + "operations": [ + { + "$id": "461", + "name": "get", + "resourceName": "Account", + "doc": "Get a Account", + "accessibility": "public", + "parameters": [ + { + "$id": "462", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "463", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "464", + "type": { + "$id": "465", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "466", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "467", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "468", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "469", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "470", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "471", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "472", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "473", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "474", + "kind": "constant", + "valueType": { + "$id": "475", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "476", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "242" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Accounts.get", + "decorators": [] + }, + { + "$id": "477", + "name": "createOrUpdate", + "resourceName": "Account", + "doc": "Create a Account", + "accessibility": "public", + "parameters": [ + { + "$id": "478", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "479", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "480", + "type": { + "$id": "481", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "482", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "483", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "484", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "485", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "486", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "487", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "488", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "489", + "name": "contentType", + "nameInRequest": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$id": "490", + "kind": "constant", + "valueType": { + "$id": "491", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": true, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "492", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "493", + "kind": "constant", + "valueType": { + "$id": "494", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "495", + "name": "resource", + "nameInRequest": "resource", + "doc": "Resource create parameters.", + "type": { + "$ref": "242" + }, + "location": "Body", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "496", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "242" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + }, + { + "$id": "497", + "statusCodes": [ + 201 + ], + "bodyType": { + "$ref": "242" + }, + "headers": [ + { + "$id": "498", + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "499", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PUT", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "longRunning": { + "$id": "500", + "finalStateVia": 0, + "finalResponse": { + "$id": "501", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "242" + } + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Accounts.createOrUpdate", + "decorators": [ + { + "$id": "502", + "name": "Azure.Core.@useFinalStateVia", + "arguments": { + "$id": "503", + "finalState": "azure-async-operation" + } + } + ], + "examples": [ + { + "$id": "504", + "kind": "http", + "name": "Accounts_CreateOrUpdate", + "description": "Accounts_CreateOrUpdate", + "filePath": "2024-12-01/Accounts_CreateOrUpdate.json", + "parameters": [ + { + "$id": "505", + "parameter": { + "$ref": "478" + }, + "value": { + "$id": "506", + "kind": "string", + "type": { + "$ref": "479" + }, + "value": "2024-12-01" + } + }, + { + "$id": "507", + "parameter": { + "$ref": "482" + }, + "value": { + "$id": "508", + "kind": "string", + "type": { + "$ref": "483" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "509", + "parameter": { + "$ref": "485" + }, + "value": { + "$id": "510", + "kind": "string", + "type": { + "$ref": "486" + }, + "value": "dummyrg" + } + }, + { + "$id": "511", + "parameter": { + "$ref": "487" + }, + "value": { + "$id": "512", + "kind": "string", + "type": { + "$ref": "488" + }, + "value": "myPlaywrightAccount" + } + }, + { + "$id": "513", + "parameter": { + "$ref": "495" + }, + "value": { + "$id": "514", + "kind": "model", + "type": { + "$ref": "242" + }, + "value": { + "$id": "515", + "location": { + "$id": "516", + "kind": "string", + "type": { + "$ref": "251" + }, + "value": "westus" + }, + "tags": { + "$id": "517", + "kind": "dict", + "type": { + "$ref": "245" + }, + "value": { + "$id": "518", + "Team": { + "$id": "519", + "kind": "string", + "type": { + "$ref": "247" + }, + "value": "Dev Exp" + } + } + }, + "properties": { + "$id": "520", + "kind": "model", + "type": { + "$ref": "255" + }, + "value": { + "$id": "521", + "regionalAffinity": { + "$id": "522", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + } + } + } + } + } + } + ], + "responses": [ + { + "$id": "523", + "response": { + "$ref": "496" + }, + "statusCode": 200, + "bodyValue": { + "$id": "524", + "kind": "model", + "type": { + "$ref": "242" + }, + "value": { + "$id": "525", + "location": { + "$id": "526", + "kind": "string", + "type": { + "$ref": "251" + }, + "value": "westus" + }, + "properties": { + "$id": "527", + "kind": "model", + "type": { + "$ref": "255" + }, + "value": { + "$id": "528", + "dashboardUri": { + "$id": "529", + "kind": "string", + "type": { + "$ref": "257" + }, + "value": "https://dashboard.00000000-0000-0000-0000-000000000000.domain.com" + }, + "provisioningState": { + "$id": "530", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + }, + "regionalAffinity": { + "$id": "531", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "scalableExecution": { + "$id": "532", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "reporting": { + "$id": "533", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "localAuth": { + "$id": "534", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + } + } + }, + "id": { + "$id": "535", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount" + }, + "name": { + "$id": "536", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "myPlaywrightAccount" + }, + "type": { + "$id": "537", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/accounts" + }, + "tags": { + "$id": "538", + "kind": "dict", + "type": { + "$ref": "245" + }, + "value": { + "$id": "539", + "Team": { + "$id": "540", + "kind": "string", + "type": { + "$ref": "247" + }, + "value": "Dev Exp" + } + } + }, + "systemData": { + "$id": "541", + "kind": "model", + "type": { + "$ref": "106" + }, + "value": { + "$id": "542", + "createdBy": { + "$id": "543", + "kind": "string", + "type": { + "$ref": "108" + }, + "value": "userId1001" + }, + "createdByType": { + "$id": "544", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "createdAt": { + "$id": "545", + "kind": "string", + "type": { + "$ref": "115" + }, + "value": "2021-09-28T12:32:33Z" + }, + "lastModifiedBy": { + "$id": "546", + "kind": "string", + "type": { + "$ref": "120" + }, + "value": "userId1001" + }, + "lastModifiedByType": { + "$id": "547", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "lastModifiedAt": { + "$id": "548", + "kind": "string", + "type": { + "$ref": "127" + }, + "value": "2021-09-28T12:32:33Z" + } + } + } + } + } + }, + { + "$id": "549", + "response": { + "$ref": "497" + }, + "statusCode": 201, + "bodyValue": { + "$id": "550", + "kind": "model", + "type": { + "$ref": "242" + }, + "value": { + "$id": "551", + "location": { + "$id": "552", + "kind": "string", + "type": { + "$ref": "251" + }, + "value": "westus" + }, + "properties": { + "$id": "553", + "kind": "model", + "type": { + "$ref": "255" + }, + "value": { + "$id": "554", + "dashboardUri": { + "$id": "555", + "kind": "string", + "type": { + "$ref": "257" + }, + "value": "https://dashboard.00000000-0000-0000-0000-000000000000.domain.com" + }, + "provisioningState": { + "$id": "556", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + }, + "regionalAffinity": { + "$id": "557", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "scalableExecution": { + "$id": "558", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "reporting": { + "$id": "559", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "localAuth": { + "$id": "560", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + } + } + }, + "id": { + "$id": "561", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount" + }, + "name": { + "$id": "562", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "myPlaywrightAccount" + }, + "type": { + "$id": "563", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/accounts" + }, + "tags": { + "$id": "564", + "kind": "dict", + "type": { + "$ref": "245" + }, + "value": { + "$id": "565", + "Team": { + "$id": "566", + "kind": "string", + "type": { + "$ref": "247" + }, + "value": "Dev Exp" + } + } + }, + "systemData": { + "$id": "567", + "kind": "model", + "type": { + "$ref": "106" + }, + "value": { + "$id": "568", + "createdBy": { + "$id": "569", + "kind": "string", + "type": { + "$ref": "108" + }, + "value": "userId1001" + }, + "createdByType": { + "$id": "570", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "createdAt": { + "$id": "571", + "kind": "string", + "type": { + "$ref": "115" + }, + "value": "2021-09-28T12:32:33Z" + }, + "lastModifiedBy": { + "$id": "572", + "kind": "string", + "type": { + "$ref": "120" + }, + "value": "userId1001" + }, + "lastModifiedByType": { + "$id": "573", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "lastModifiedAt": { + "$id": "574", + "kind": "string", + "type": { + "$ref": "127" + }, + "value": "2021-09-28T12:32:33Z" + } + } + } + } + } + } + ] + } + ] + }, + { + "$id": "575", + "name": "update", + "resourceName": "Account", + "doc": "Update a Account", + "accessibility": "public", + "parameters": [ + { + "$id": "576", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "577", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "578", + "type": { + "$id": "579", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "580", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "581", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "582", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "583", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "584", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "585", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "586", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "587", + "name": "contentType", + "nameInRequest": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$id": "588", + "kind": "constant", + "valueType": { + "$id": "589", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": true, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "590", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "591", + "kind": "constant", + "valueType": { + "$id": "592", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "593", + "name": "properties", + "nameInRequest": "properties", + "doc": "The resource properties to be updated.", + "type": { + "$ref": "277" + }, + "location": "Body", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "594", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "242" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "PATCH", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": false, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Accounts.update", + "decorators": [], + "examples": [ + { + "$id": "595", + "kind": "http", + "name": "Accounts_Update", + "description": "Accounts_Update", + "filePath": "2024-12-01/Accounts_Update.json", + "parameters": [ + { + "$id": "596", + "parameter": { + "$ref": "576" + }, + "value": { + "$id": "597", + "kind": "string", + "type": { + "$ref": "577" + }, + "value": "2024-12-01" + } + }, + { + "$id": "598", + "parameter": { + "$ref": "580" + }, + "value": { + "$id": "599", + "kind": "string", + "type": { + "$ref": "581" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "600", + "parameter": { + "$ref": "583" + }, + "value": { + "$id": "601", + "kind": "string", + "type": { + "$ref": "584" + }, + "value": "dummyrg" + } + }, + { + "$id": "602", + "parameter": { + "$ref": "585" + }, + "value": { + "$id": "603", + "kind": "string", + "type": { + "$ref": "586" + }, + "value": "myPlaywrightAccount" + } + }, + { + "$id": "604", + "parameter": { + "$ref": "593" + }, + "value": { + "$id": "605", + "kind": "model", + "type": { + "$ref": "277" + }, + "value": { + "$id": "606", + "tags": { + "$id": "607", + "kind": "dict", + "type": { + "$ref": "279" + }, + "value": { + "$id": "608", + "Team": { + "$id": "609", + "kind": "string", + "type": { + "$ref": "281" + }, + "value": "Dev Exp" + }, + "Division": { + "$id": "610", + "kind": "string", + "type": { + "$ref": "281" + }, + "value": "LT" + } + } + }, + "properties": { + "$id": "611", + "kind": "model", + "type": { + "$ref": "285" + }, + "value": { + "$id": "612", + "regionalAffinity": { + "$id": "613", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + } + } + } + } + } + } + ], + "responses": [ + { + "$id": "614", + "response": { + "$ref": "594" + }, + "statusCode": 200, + "bodyValue": { + "$id": "615", + "kind": "model", + "type": { + "$ref": "242" + }, + "value": { + "$id": "616", + "location": { + "$id": "617", + "kind": "string", + "type": { + "$ref": "251" + }, + "value": "westus" + }, + "properties": { + "$id": "618", + "kind": "model", + "type": { + "$ref": "255" + }, + "value": { + "$id": "619", + "dashboardUri": { + "$id": "620", + "kind": "string", + "type": { + "$ref": "257" + }, + "value": "https://dashboard.00000000-0000-0000-0000-000000000000.domain.com" + }, + "provisioningState": { + "$id": "621", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + }, + "regionalAffinity": { + "$id": "622", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "scalableExecution": { + "$id": "623", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "reporting": { + "$id": "624", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + }, + "localAuth": { + "$id": "625", + "kind": "string", + "type": { + "$ref": "52" + }, + "value": "Enabled" + } + } + }, + "id": { + "$id": "626", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount" + }, + "name": { + "$id": "627", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "myPlaywrightAccount" + }, + "type": { + "$id": "628", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/accounts" + }, + "tags": { + "$id": "629", + "kind": "dict", + "type": { + "$ref": "245" + }, + "value": { + "$id": "630", + "Team": { + "$id": "631", + "kind": "string", + "type": { + "$ref": "247" + }, + "value": "Dev Exp" + } + } + }, + "systemData": { + "$id": "632", + "kind": "model", + "type": { + "$ref": "106" + }, + "value": { + "$id": "633", + "createdBy": { + "$id": "634", + "kind": "string", + "type": { + "$ref": "108" + }, + "value": "userId1001" + }, + "createdByType": { + "$id": "635", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "createdAt": { + "$id": "636", + "kind": "string", + "type": { + "$ref": "115" + }, + "value": "2021-09-28T12:32:33Z" + }, + "lastModifiedBy": { + "$id": "637", + "kind": "string", + "type": { + "$ref": "120" + }, + "value": "userId1001" + }, + "lastModifiedByType": { + "$id": "638", + "kind": "string", + "type": { + "$ref": "22" + }, + "value": "User" + }, + "lastModifiedAt": { + "$id": "639", + "kind": "string", + "type": { + "$ref": "127" + }, + "value": "2021-09-28T12:32:33Z" + } + } + } + } + } + } + ] + } + ] + }, + { + "$id": "640", + "name": "delete", + "resourceName": "Account", + "doc": "Delete a Account", + "accessibility": "public", + "parameters": [ + { + "$id": "641", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "642", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "643", + "type": { + "$id": "644", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "645", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "646", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "647", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "648", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "649", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "650", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "651", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "652", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "653", + "kind": "constant", + "valueType": { + "$id": "654", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "655", + "statusCodes": [ + 202 + ], + "headers": [ + { + "$id": "656", + "name": "location", + "nameInResponse": "Location", + "doc": "The Location header contains the URL where the status of the long running operation can be checked.", + "type": { + "$id": "657", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + } + }, + { + "$id": "658", + "name": "retryAfter", + "nameInResponse": "Retry-After", + "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.", + "type": { + "$id": "659", + "kind": "int32", + "name": "int32", + "crossLanguageDefinitionId": "TypeSpec.int32", + "decorators": [] + } + } + ], + "isErrorResponse": false + }, + { + "$id": "660", + "statusCodes": [ + 204 + ], + "headers": [], + "isErrorResponse": false + } + ], + "httpMethod": "DELETE", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}", + "bufferResponse": true, + "longRunning": { + "$id": "661", + "finalStateVia": 1, + "finalResponse": { + "$id": "662", + "statusCodes": [ + 204 + ] + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Accounts.delete", + "decorators": [], + "examples": [ + { + "$id": "663", + "kind": "http", + "name": "Accounts_Delete", + "description": "Accounts_Delete", + "filePath": "2024-12-01/Accounts_Delete.json", + "parameters": [ + { + "$id": "664", + "parameter": { + "$ref": "641" + }, + "value": { + "$id": "665", + "kind": "string", + "type": { + "$ref": "642" + }, + "value": "2024-12-01" + } + }, + { + "$id": "666", + "parameter": { + "$ref": "645" + }, + "value": { + "$id": "667", + "kind": "string", + "type": { + "$ref": "646" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "668", + "parameter": { + "$ref": "648" + }, + "value": { + "$id": "669", + "kind": "string", + "type": { + "$ref": "649" + }, + "value": "dummyrg" + } + }, + { + "$id": "670", + "parameter": { + "$ref": "650" + }, + "value": { + "$id": "671", + "kind": "string", + "type": { + "$ref": "651" + }, + "value": "myPlaywrightAccount" + } + } + ], + "responses": [ + { + "$id": "672", + "response": { + "$ref": "655" + }, + "statusCode": 202 + }, + { + "$id": "673", + "response": { + "$ref": "660" + }, + "statusCode": 204 + } + ] + } + ] + }, + { + "$id": "674", + "name": "listByResourceGroup", + "resourceName": "Account", + "doc": "List Account resources by resource group", + "accessibility": "public", + "parameters": [ + { + "$id": "675", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "676", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "677", + "type": { + "$id": "678", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "679", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "680", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "681", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "682", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "683", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "684", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "685", + "kind": "constant", + "valueType": { + "$id": "686", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "687", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "325" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts", + "bufferResponse": true, + "paging": { + "$id": "688", + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "$id": "689", + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Accounts.listByResourceGroup", + "decorators": [] + }, + { + "$id": "690", + "name": "listBySubscription", + "resourceName": "Account", + "doc": "List Account resources by subscription ID", + "accessibility": "public", + "parameters": [ + { + "$id": "691", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "692", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "693", + "type": { + "$id": "694", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "695", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "696", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "697", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "698", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "699", + "kind": "constant", + "valueType": { + "$id": "700", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "701", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "325" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.AzurePlaywrightService/accounts", + "bufferResponse": true, + "paging": { + "$id": "702", + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "$id": "703", + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Azure.ResourceManager.Accounts.listBySubscription", + "decorators": [] + }, + { + "$id": "704", + "name": "CheckPlaywrightTestingNameAvailability", + "resourceName": "Accounts", + "doc": "Adds check global name availability operation, normally used if a resource name must be globally unique.", + "accessibility": "public", + "parameters": [ + { + "$id": "705", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "706", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "707", + "type": { + "$id": "708", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "709", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "710", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "711", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "712", + "name": "contentType", + "nameInRequest": "Content-Type", + "doc": "Body parameter's content type. Known values are application/json", + "type": { + "$id": "713", + "kind": "constant", + "valueType": { + "$id": "714", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": true, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "715", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "716", + "kind": "constant", + "valueType": { + "$id": "717", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "718", + "name": "body", + "nameInRequest": "body", + "doc": "The CheckAvailability request", + "type": { + "$ref": "335" + }, + "location": "Body", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "719", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "344" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "POST", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.AzurePlaywrightService/checkNameAvailability", + "requestMediaTypes": [ + "application/json" + ], + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Accounts.checkNameAvailability", + "decorators": [], + "examples": [ + { + "$id": "720", + "kind": "http", + "name": "Accounts_CheckNameAvailability", + "description": "Accounts_CheckNameAvailability", + "filePath": "2024-12-01/Accounts_CheckNameAvailability.json", + "parameters": [ + { + "$id": "721", + "parameter": { + "$ref": "705" + }, + "value": { + "$id": "722", + "kind": "string", + "type": { + "$ref": "706" + }, + "value": "2024-12-01" + } + }, + { + "$id": "723", + "parameter": { + "$ref": "709" + }, + "value": { + "$id": "724", + "kind": "string", + "type": { + "$ref": "710" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "725", + "parameter": { + "$ref": "718" + }, + "value": { + "$id": "726", + "kind": "model", + "type": { + "$ref": "335" + }, + "value": { + "$id": "727", + "name": { + "$id": "728", + "kind": "string", + "type": { + "$ref": "337" + }, + "value": "dummyName" + }, + "type": { + "$id": "729", + "kind": "string", + "type": { + "$ref": "341" + }, + "value": "Microsoft.AzurePlaywrightService/Accounts" + } + } + } + } + ], + "responses": [ + { + "$id": "730", + "response": { + "$ref": "719" + }, + "statusCode": 200, + "bodyValue": { + "$id": "731", + "kind": "model", + "type": { + "$ref": "344" + }, + "value": { + "$id": "732", + "nameAvailable": { + "$id": "733", + "kind": "boolean", + "type": { + "$ref": "346" + }, + "value": true + }, + "message": { + "$id": "734", + "kind": "string", + "type": { + "$ref": "353" + }, + "value": "Test message." + } + } + } + } + ] + } + ] + } + ], + "parent": "AzurePlaywrightServiceClient", + "parameters": [ + { + "$id": "735", + "name": "endpoint", + "nameInRequest": "endpoint", + "doc": "Service host", + "type": { + "$id": "736", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "location": "Uri", + "isApiVersion": false, + "isContentType": false, + "isRequired": true, + "isEndpoint": true, + "skipUrlEncoding": false, + "explode": false, + "kind": "Client", + "defaultValue": { + "$id": "737", + "type": { + "$id": "738", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + } + } + ], + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Accounts" + }, + { + "$id": "739", + "name": "Quotas", + "namespace": "Microsoft.AzurePlaywrightService", + "operations": [ + { + "$id": "740", + "name": "get", + "resourceName": "Quota", + "doc": "Get subscription quota by name.", + "accessibility": "public", + "parameters": [ + { + "$id": "741", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "742", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "743", + "type": { + "$id": "744", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "745", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "746", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "747", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "748", + "name": "location", + "nameInRequest": "location", + "doc": "The location of quota in ARM Normalized format like eastus, southeastasia etc.", + "type": { + "$id": "749", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "750", + "name": "quotaName", + "nameInRequest": "quotaName", + "doc": "The quota name.", + "type": { + "$ref": "2" + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "751", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "752", + "kind": "constant", + "valueType": { + "$id": "753", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "754", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "210" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.AzurePlaywrightService/locations/{location}/quotas/{quotaName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Quotas.get", + "decorators": [], + "examples": [ + { + "$id": "755", + "kind": "http", + "name": "Quotas_Get", + "description": "Quotas_Get", + "filePath": "2024-12-01/Quotas_Get.json", + "parameters": [ + { + "$id": "756", + "parameter": { + "$ref": "741" + }, + "value": { + "$id": "757", + "kind": "string", + "type": { + "$ref": "742" + }, + "value": "2024-12-01" + } + }, + { + "$id": "758", + "parameter": { + "$ref": "745" + }, + "value": { + "$id": "759", + "kind": "string", + "type": { + "$ref": "746" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "760", + "parameter": { + "$ref": "748" + }, + "value": { + "$id": "761", + "kind": "string", + "type": { + "$ref": "749" + }, + "value": "eastus" + } + }, + { + "$id": "762", + "parameter": { + "$ref": "750" + }, + "value": { + "$id": "763", + "kind": "string", + "type": { + "$ref": "2" + }, + "value": "ScalableExecution" + } + } + ], + "responses": [ + { + "$id": "764", + "response": { + "$ref": "754" + }, + "statusCode": 200, + "bodyValue": { + "$id": "765", + "kind": "model", + "type": { + "$ref": "210" + }, + "value": { + "$id": "766", + "id": { + "$id": "767", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzurePlaywrightService/locations/eastus/quotas/ScalableExecution" + }, + "name": { + "$id": "768", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "ScalableExecution" + }, + "type": { + "$id": "769", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Locations/Quotas" + }, + "properties": { + "$id": "770", + "kind": "model", + "type": { + "$ref": "212" + }, + "value": { + "$id": "771", + "freeTrial": { + "$id": "772", + "kind": "model", + "type": { + "$ref": "214" + }, + "value": { + "$id": "773", + "accountId": { + "$id": "774", + "kind": "string", + "type": { + "$ref": "216" + }, + "value": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + }, + "state": { + "$id": "775", + "kind": "string", + "type": { + "$ref": "32" + }, + "value": "Active" + } + } + }, + "offeringType": { + "$id": "776", + "kind": "string", + "type": { + "$ref": "42" + }, + "value": "NotApplicable" + }, + "provisioningState": { + "$id": "777", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + } + } + } + } + ] + } + ] + }, + { + "$id": "778", + "name": "listBySubscription", + "resourceName": "Quota", + "doc": "List quotas for a given subscription Id.", + "accessibility": "public", + "parameters": [ + { + "$id": "779", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "780", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "781", + "type": { + "$id": "782", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "783", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "784", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "785", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "786", + "name": "location", + "nameInRequest": "location", + "doc": "The location of quota in ARM Normalized format like eastus, southeastasia etc.", + "type": { + "$id": "787", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "788", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "789", + "kind": "constant", + "valueType": { + "$id": "790", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "791", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "232" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/providers/Microsoft.AzurePlaywrightService/locations/{location}/quotas", + "bufferResponse": true, + "paging": { + "$id": "792", + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "$id": "793", + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Quotas.listBySubscription", + "decorators": [], + "examples": [ + { + "$id": "794", + "kind": "http", + "name": "Quotas_ListBySubscription", + "description": "Quotas_ListBySubscription", + "filePath": "2024-12-01/Quotas_ListBySubscription.json", + "parameters": [ + { + "$id": "795", + "parameter": { + "$ref": "779" + }, + "value": { + "$id": "796", + "kind": "string", + "type": { + "$ref": "780" + }, + "value": "2024-12-01" + } + }, + { + "$id": "797", + "parameter": { + "$ref": "783" + }, + "value": { + "$id": "798", + "kind": "string", + "type": { + "$ref": "784" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "799", + "parameter": { + "$ref": "786" + }, + "value": { + "$id": "800", + "kind": "string", + "type": { + "$ref": "787" + }, + "value": "eastus" + } + } + ], + "responses": [ + { + "$id": "801", + "response": { + "$ref": "791" + }, + "statusCode": 200, + "bodyValue": { + "$id": "802", + "kind": "model", + "type": { + "$ref": "232" + }, + "value": { + "$id": "803", + "value": { + "$id": "804", + "kind": "array", + "type": { + "$ref": "234" + }, + "value": [ + { + "$id": "805", + "kind": "model", + "type": { + "$ref": "210" + }, + "value": { + "$id": "806", + "properties": { + "$id": "807", + "kind": "model", + "type": { + "$ref": "212" + }, + "value": { + "$id": "808", + "freeTrial": { + "$id": "809", + "kind": "model", + "type": { + "$ref": "214" + }, + "value": { + "$id": "810", + "accountId": { + "$id": "811", + "kind": "string", + "type": { + "$ref": "216" + }, + "value": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + }, + "state": { + "$id": "812", + "kind": "string", + "type": { + "$ref": "32" + }, + "value": "Active" + } + } + }, + "offeringType": { + "$id": "813", + "kind": "string", + "type": { + "$ref": "42" + }, + "value": "NotApplicable" + }, + "provisioningState": { + "$id": "814", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + }, + "id": { + "$id": "815", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzurePlaywrightService/locations/eastus/quotas/ScalableExecution" + }, + "name": { + "$id": "816", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "ScalableExecution" + }, + "type": { + "$id": "817", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Locations/Quotas" + } + } + }, + { + "$id": "818", + "kind": "model", + "type": { + "$ref": "210" + }, + "value": { + "$id": "819", + "properties": { + "$id": "820", + "kind": "model", + "type": { + "$ref": "212" + }, + "value": { + "$id": "821", + "freeTrial": { + "$id": "822", + "kind": "model", + "type": { + "$ref": "214" + }, + "value": { + "$id": "823", + "accountId": { + "$id": "824", + "kind": "string", + "type": { + "$ref": "216" + }, + "value": "3fa85f64-5717-4562-b3fc-2c963f66afa6" + }, + "state": { + "$id": "825", + "kind": "string", + "type": { + "$ref": "32" + }, + "value": "Active" + } + } + }, + "offeringType": { + "$id": "826", + "kind": "string", + "type": { + "$ref": "42" + }, + "value": "PrivatePreview" + }, + "provisioningState": { + "$id": "827", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + }, + "id": { + "$id": "828", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.AzurePlaywrightService/locations/eastus/quotas/Reporting" + }, + "name": { + "$id": "829", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "Reporting" + }, + "type": { + "$id": "830", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Locations/Quotas" + } + } + } + ] + } + } + } + } + ] + } + ] + } + ], + "parent": "AzurePlaywrightServiceClient", + "parameters": [ + { + "$id": "831", + "name": "endpoint", + "nameInRequest": "endpoint", + "doc": "Service host", + "type": { + "$id": "832", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "location": "Uri", + "isApiVersion": false, + "isContentType": false, + "isRequired": true, + "isEndpoint": true, + "skipUrlEncoding": false, + "explode": false, + "kind": "Client", + "defaultValue": { + "$id": "833", + "type": { + "$id": "834", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + } + } + ], + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.Quotas" + }, + { + "$id": "835", + "name": "AccountQuotas", + "namespace": "Microsoft.AzurePlaywrightService", + "operations": [ + { + "$id": "836", + "name": "get", + "resourceName": "AccountQuota", + "doc": "Get quota by name for an account.", + "accessibility": "public", + "parameters": [ + { + "$id": "837", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "838", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "839", + "type": { + "$id": "840", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "841", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "842", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "843", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "844", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "845", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "846", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "847", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "848", + "name": "quotaName", + "nameInRequest": "quotaName", + "doc": "The Playwright service account quota name.", + "type": { + "$ref": "2" + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "849", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "850", + "kind": "constant", + "valueType": { + "$id": "851", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "852", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "88" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}/quotas/{quotaName}", + "bufferResponse": true, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotas.get", + "decorators": [], + "examples": [ + { + "$id": "853", + "kind": "http", + "name": "AccountQuotas_Get", + "description": "AccountQuotas_Get", + "filePath": "2024-12-01/AccountQuotas_Get.json", + "parameters": [ + { + "$id": "854", + "parameter": { + "$ref": "837" + }, + "value": { + "$id": "855", + "kind": "string", + "type": { + "$ref": "838" + }, + "value": "2024-12-01" + } + }, + { + "$id": "856", + "parameter": { + "$ref": "841" + }, + "value": { + "$id": "857", + "kind": "string", + "type": { + "$ref": "842" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "858", + "parameter": { + "$ref": "844" + }, + "value": { + "$id": "859", + "kind": "string", + "type": { + "$ref": "845" + }, + "value": "dummyrg" + } + }, + { + "$id": "860", + "parameter": { + "$ref": "846" + }, + "value": { + "$id": "861", + "kind": "string", + "type": { + "$ref": "847" + }, + "value": "myPlaywrightAccount" + } + }, + { + "$id": "862", + "parameter": { + "$ref": "848" + }, + "value": { + "$id": "863", + "kind": "string", + "type": { + "$ref": "2" + }, + "value": "ScalableExecution" + } + } + ], + "responses": [ + { + "$id": "864", + "response": { + "$ref": "852" + }, + "statusCode": 200, + "bodyValue": { + "$id": "865", + "kind": "model", + "type": { + "$ref": "88" + }, + "value": { + "$id": "866", + "id": { + "$id": "867", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount/quotas/ScalableExecution" + }, + "name": { + "$id": "868", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "ScalableExecution" + }, + "type": { + "$id": "869", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Accounts/Quotas" + }, + "properties": { + "$id": "870", + "kind": "model", + "type": { + "$ref": "134" + }, + "value": { + "$id": "871", + "freeTrial": { + "$id": "872", + "kind": "model", + "type": { + "$ref": "136" + }, + "value": { + "$id": "873", + "createdAt": { + "$id": "874", + "kind": "string", + "type": { + "$ref": "138" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "expiryAt": { + "$id": "875", + "kind": "string", + "type": { + "$ref": "143" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "allocatedValue": { + "$id": "876", + "kind": "number", + "type": { + "$ref": "148" + }, + "value": 0 + }, + "usedValue": { + "$id": "877", + "kind": "number", + "type": { + "$ref": "152" + }, + "value": 0 + }, + "percentageUsed": { + "$id": "878", + "kind": "number", + "type": { + "$ref": "156" + }, + "value": 100 + } + } + }, + "provisioningState": { + "$id": "879", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + } + } + } + } + ] + } + ] + }, + { + "$id": "880", + "name": "listByAccount", + "resourceName": "AccountQuota", + "doc": "List quotas for a given account.", + "accessibility": "public", + "parameters": [ + { + "$id": "881", + "name": "apiVersion", + "nameInRequest": "api-version", + "doc": "The API version to use for this operation.", + "type": { + "$id": "882", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Query", + "isApiVersion": true, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "defaultValue": { + "$id": "883", + "type": { + "$id": "884", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "2024-12-01" + }, + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "885", + "name": "subscriptionId", + "nameInRequest": "subscriptionId", + "doc": "The ID of the target subscription. The value must be an UUID.", + "type": { + "$id": "886", + "kind": "string", + "name": "uuid", + "crossLanguageDefinitionId": "Azure.Core.uuid", + "baseType": { + "$id": "887", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Client", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "888", + "name": "resourceGroupName", + "nameInRequest": "resourceGroupName", + "doc": "The name of the resource group. The name is case insensitive.", + "type": { + "$id": "889", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "890", + "name": "accountName", + "nameInRequest": "accountName", + "doc": "Name of account.", + "type": { + "$id": "891", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "location": "Path", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Method", + "decorators": [], + "skipUrlEncoding": false + }, + { + "$id": "892", + "name": "accept", + "nameInRequest": "Accept", + "type": { + "$id": "893", + "kind": "constant", + "valueType": { + "$id": "894", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string", + "decorators": [] + }, + "value": "application/json", + "decorators": [] + }, + "location": "Header", + "isApiVersion": false, + "isContentType": false, + "isEndpoint": false, + "explode": false, + "isRequired": true, + "kind": "Constant", + "decorators": [], + "skipUrlEncoding": false + } + ], + "responses": [ + { + "$id": "895", + "statusCodes": [ + 200 + ], + "bodyType": { + "$ref": "200" + }, + "headers": [], + "isErrorResponse": false, + "contentTypes": [ + "application/json" + ] + } + ], + "httpMethod": "GET", + "uri": "{endpoint}", + "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzurePlaywrightService/accounts/{accountName}/quotas", + "bufferResponse": true, + "paging": { + "$id": "896", + "itemPropertySegments": [ + "value" + ], + "nextLink": { + "$id": "897", + "responseSegments": [ + "nextLink" + ], + "responseLocation": "Body" + } + }, + "generateProtocolMethod": true, + "generateConvenienceMethod": true, + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotas.listByAccount", + "decorators": [], + "examples": [ + { + "$id": "898", + "kind": "http", + "name": "AccountQuotas_ListByAccount", + "description": "AccountQuotas_ListByAccount", + "filePath": "2024-12-01/AccountQuotas_ListByAccount.json", + "parameters": [ + { + "$id": "899", + "parameter": { + "$ref": "881" + }, + "value": { + "$id": "900", + "kind": "string", + "type": { + "$ref": "882" + }, + "value": "2024-12-01" + } + }, + { + "$id": "901", + "parameter": { + "$ref": "885" + }, + "value": { + "$id": "902", + "kind": "string", + "type": { + "$ref": "886" + }, + "value": "00000000-0000-0000-0000-000000000000" + } + }, + { + "$id": "903", + "parameter": { + "$ref": "888" + }, + "value": { + "$id": "904", + "kind": "string", + "type": { + "$ref": "889" + }, + "value": "dummyrg" + } + }, + { + "$id": "905", + "parameter": { + "$ref": "890" + }, + "value": { + "$id": "906", + "kind": "string", + "type": { + "$ref": "891" + }, + "value": "myPlaywrightAccount" + } + } + ], + "responses": [ + { + "$id": "907", + "response": { + "$ref": "895" + }, + "statusCode": 200, + "bodyValue": { + "$id": "908", + "kind": "model", + "type": { + "$ref": "200" + }, + "value": { + "$id": "909", + "value": { + "$id": "910", + "kind": "array", + "type": { + "$ref": "202" + }, + "value": [ + { + "$id": "911", + "kind": "model", + "type": { + "$ref": "88" + }, + "value": { + "$id": "912", + "id": { + "$id": "913", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount/quotas/ScalableExecution" + }, + "name": { + "$id": "914", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "ScalableExecution" + }, + "type": { + "$id": "915", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Accounts/Quotas" + }, + "properties": { + "$id": "916", + "kind": "model", + "type": { + "$ref": "134" + }, + "value": { + "$id": "917", + "freeTrial": { + "$id": "918", + "kind": "model", + "type": { + "$ref": "136" + }, + "value": { + "$id": "919", + "createdAt": { + "$id": "920", + "kind": "string", + "type": { + "$ref": "138" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "expiryAt": { + "$id": "921", + "kind": "string", + "type": { + "$ref": "143" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "allocatedValue": { + "$id": "922", + "kind": "number", + "type": { + "$ref": "148" + }, + "value": 0 + }, + "usedValue": { + "$id": "923", + "kind": "number", + "type": { + "$ref": "152" + }, + "value": 0 + }, + "percentageUsed": { + "$id": "924", + "kind": "number", + "type": { + "$ref": "156" + }, + "value": 100 + } + } + }, + "provisioningState": { + "$id": "925", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + } + } + }, + { + "$id": "926", + "kind": "model", + "type": { + "$ref": "88" + }, + "value": { + "$id": "927", + "id": { + "$id": "928", + "kind": "string", + "type": { + "$ref": "92" + }, + "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.AzurePlaywrightService/accounts/myPlaywrightAccount/quotas/Reporting" + }, + "name": { + "$id": "929", + "kind": "string", + "type": { + "$ref": "97" + }, + "value": "Reporting" + }, + "type": { + "$id": "930", + "kind": "string", + "type": { + "$ref": "101" + }, + "value": "Microsoft.AzurePlaywrightService/Accounts/Quotas" + }, + "properties": { + "$id": "931", + "kind": "model", + "type": { + "$ref": "134" + }, + "value": { + "$id": "932", + "freeTrial": { + "$id": "933", + "kind": "model", + "type": { + "$ref": "136" + }, + "value": { + "$id": "934", + "createdAt": { + "$id": "935", + "kind": "string", + "type": { + "$ref": "138" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "expiryAt": { + "$id": "936", + "kind": "string", + "type": { + "$ref": "143" + }, + "value": "2023-08-31T10:19:36.081Z" + }, + "allocatedValue": { + "$id": "937", + "kind": "number", + "type": { + "$ref": "148" + }, + "value": 0 + }, + "usedValue": { + "$id": "938", + "kind": "number", + "type": { + "$ref": "152" + }, + "value": 0 + }, + "percentageUsed": { + "$id": "939", + "kind": "number", + "type": { + "$ref": "156" + }, + "value": 100 + } + } + }, + "provisioningState": { + "$id": "940", + "kind": "string", + "type": { + "$ref": "8" + }, + "value": "Succeeded" + } + } + } + } + } + ] + } + } + } + } + ] + } + ] + } + ], + "parent": "AzurePlaywrightServiceClient", + "parameters": [ + { + "$id": "941", + "name": "endpoint", + "nameInRequest": "endpoint", + "doc": "Service host", + "type": { + "$id": "942", + "kind": "url", + "name": "url", + "crossLanguageDefinitionId": "TypeSpec.url" + }, + "location": "Uri", + "isApiVersion": false, + "isContentType": false, + "isRequired": true, + "isEndpoint": true, + "skipUrlEncoding": false, + "explode": false, + "kind": "Client", + "defaultValue": { + "$id": "943", + "type": { + "$id": "944", + "kind": "string", + "name": "string", + "crossLanguageDefinitionId": "TypeSpec.string" + }, + "value": "https://management.azure.com" + } + } + ], + "decorators": [], + "crossLanguageDefinitionId": "Microsoft.AzurePlaywrightService.AccountQuotas" + } + ], + "auth": { + "$id": "945", + "oAuth2": { + "$id": "946", + "scopes": [ + "user_impersonation" + ] + } + } +} diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 2ca0501b60bd..85d4fb9f75a5 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -11,7 +11,11 @@ trigger: - sdk/storage/ - sdk/storage/Azure.Storage.DataMovement/ - sdk/storage/Azure.Storage.DataMovement.Blobs/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Files/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/ exclude: - sdk/storage/Azure.ResourceManager.Storage/