From 271e86f0163cea91af472554845e8e7a665f1cdd Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 24 Sep 2024 06:47:22 +0000 Subject: [PATCH] CodeGen from PR 30671 in Azure/azure-rest-api-specs Merge 82d88b2f5b3ce64fa5b6e9025067a18eefb04131 into 399cbac2de1bc0acbed4c9a0a864a9c84da3692e --- .../Azure.ResourceManager.ComputeSchedule.sln | 56 ++ .../CHANGELOG.md | 11 + .../Directory.Build.props | 6 + .../README.md | 86 ++ ...ure.ResourceManager.ComputeSchedule.csproj | 10 + .../ArmComputeScheduleModelFactory.cs | 172 ++++ .../Extensions/ComputeScheduleExtensions.cs | 637 +++++++++++++ ...ableComputeScheduleSubscriptionResource.cs | 782 ++++++++++++++++ .../src/Generated/Internal/Argument.cs | 129 +++ .../Internal/ChangeTrackingDictionary.cs | 167 ++++ .../Generated/Internal/ChangeTrackingList.cs | 153 +++ .../Internal/ModelSerializationExtensions.cs | 398 ++++++++ .../src/Generated/Internal/Optional.cs | 51 + .../Internal/Utf8JsonRequestContent.cs | 55 ++ .../CancelOperationsContent.Serialization.cs | 137 +++ .../Models/CancelOperationsContent.cs | 83 ++ .../CancelOperationsResult.Serialization.cs | 129 +++ .../Models/CancelOperationsResult.cs | 76 ++ ...teResourceOperationResult.Serialization.cs | 160 ++++ .../DeallocateResourceOperationResult.cs | 94 ++ .../ExecuteDeallocateContent.Serialization.cs | 135 +++ .../Models/ExecuteDeallocateContent.cs | 96 ++ .../ExecuteHibernateContent.Serialization.cs | 135 +++ .../Models/ExecuteHibernateContent.cs | 96 ++ .../ExecuteStartContent.Serialization.cs | 135 +++ .../Generated/Models/ExecuteStartContent.cs | 96 ++ ...GetOperationErrorsContent.Serialization.cs | 129 +++ .../Models/GetOperationErrorsContent.cs | 76 ++ .../GetOperationErrorsResult.Serialization.cs | 129 +++ .../Models/GetOperationErrorsResult.cs | 76 ++ ...GetOperationStatusContent.Serialization.cs | 137 +++ .../Models/GetOperationStatusContent.cs | 83 ++ .../GetOperationStatusResult.Serialization.cs | 129 +++ .../Models/GetOperationStatusResult.cs | 76 ++ ...teResourceOperationResult.Serialization.cs | 160 ++++ .../HibernateResourceOperationResult.cs | 94 ++ .../OperationErrorDetails.Serialization.cs | 143 +++ .../Generated/Models/OperationErrorDetails.cs | 94 ++ .../OperationErrorsResult.Serialization.cs | 222 +++++ .../Generated/Models/OperationErrorsResult.cs | 90 ++ .../ResourceOperationDetails.Serialization.cs | 235 +++++ .../Models/ResourceOperationDetails.cs | 130 +++ .../ResourceOperationError.Serialization.cs | 127 +++ .../Models/ResourceOperationError.cs | 82 ++ .../ResourceOperationResult.Serialization.cs | 163 ++++ .../Models/ResourceOperationResult.cs | 78 ++ .../Generated/Models/ResourceOperationType.cs | 57 ++ .../Models/ScheduledActionDeadlineType.cs | 54 ++ ...nExecutionParameterDetail.Serialization.cs | 141 +++ ...ScheduledActionExecutionParameterDetail.cs | 69 ++ .../Models/ScheduledActionOperationState.cs | 72 ++ .../ScheduledActionOptimizationPreference.cs | 54 ++ ...rtResourceOperationResult.Serialization.cs | 160 ++++ .../Models/StartResourceOperationResult.cs | 94 ++ .../SubmitDeallocateContent.Serialization.cs | 143 +++ .../Models/SubmitDeallocateContent.cs | 103 ++ .../SubmitHibernateContent.Serialization.cs | 143 +++ .../Models/SubmitHibernateContent.cs | 103 ++ .../SubmitStartContent.Serialization.cs | 143 +++ .../Generated/Models/SubmitStartContent.cs | 103 ++ .../UserRequestResources.Serialization.cs | 141 +++ .../Generated/Models/UserRequestResources.cs | 77 ++ .../UserRequestRetryPolicy.Serialization.cs | 141 +++ .../Models/UserRequestRetryPolicy.cs | 69 ++ .../UserRequestSchedule.Serialization.cs | 135 +++ .../Generated/Models/UserRequestSchedule.cs | 87 ++ .../src/Generated/ProviderConstants.cs | 16 + .../ScheduledActionsRestOperations.cs | 885 ++++++++++++++++++ .../src/Properties/AssemblyInfo.cs | 11 + ...sourceManager.ComputeSchedule.Tests.csproj | 12 + .../tsp-location.yaml | 4 + sdk/computeschedule/ci.yml | 35 + 72 files changed, 9590 insertions(+) create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Azure.ResourceManager.ComputeSchedule.sln create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/CHANGELOG.md create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Directory.Build.props create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/README.md create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Azure.ResourceManager.ComputeSchedule.csproj create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ArmComputeScheduleModelFactory.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/ComputeScheduleExtensions.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/MockableComputeScheduleSubscriptionResource.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Argument.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Optional.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationType.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionDeadlineType.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOperationState.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOptimizationPreference.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.Serialization.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ProviderConstants.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/RestOperations/ScheduledActionsRestOperations.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Properties/AssemblyInfo.cs create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tests/Azure.ResourceManager.ComputeSchedule.Tests.csproj create mode 100644 sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tsp-location.yaml create mode 100644 sdk/computeschedule/ci.yml diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Azure.ResourceManager.ComputeSchedule.sln b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Azure.ResourceManager.ComputeSchedule.sln new file mode 100644 index 000000000000..ed1e40ea8769 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Azure.ResourceManager.ComputeSchedule.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.ResourceManager.ComputeSchedule", "src\Azure.ResourceManager.ComputeSchedule.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ComputeSchedule.Tests", "tests\Azure.ResourceManager.ComputeSchedule.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/computeschedule/Azure.ResourceManager.ComputeSchedule/CHANGELOG.md b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Directory.Build.props b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/README.md b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/README.md new file mode 100644 index 000000000000..3dd446d33b41 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/README.md @@ -0,0 +1,86 @@ +# Azure.ResourceManager.ComputeSchedule client library for .NET + +Azure.ResourceManager.ComputeSchedule 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/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule --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. + +## 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/computeschedule/Azure.ResourceManager.ComputeSchedule/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/computeschedule/Azure.ResourceManager.ComputeSchedule/README.png) diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Azure.ResourceManager.ComputeSchedule.csproj b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Azure.ResourceManager.ComputeSchedule.csproj new file mode 100644 index 000000000000..011195d5e1e5 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Azure.ResourceManager.ComputeSchedule.csproj @@ -0,0 +1,10 @@ + + + This is the Azure.ResourceManager.ComputeSchedule client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.ResourceManager.ComputeSchedule for Azure Data Plane + 1.0.0-beta.1 + Azure.ResourceManager.ComputeSchedule + $(RequiredTargetFrameworks) + true + + diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ArmComputeScheduleModelFactory.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ArmComputeScheduleModelFactory.cs new file mode 100644 index 000000000000..8f3699713c8e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ArmComputeScheduleModelFactory.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; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// Model factory for models. + public static partial class ArmComputeScheduleModelFactory + { + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the deallocate request eg virtual machines. + /// The location of the deallocate request eg westus. + /// The results from the deallocate request if no errors exist. + /// A new instance for mocking. + public static DeallocateResourceOperationResult DeallocateResourceOperationResult(string description = null, string resourceType = null, AzureLocation location = default, IEnumerable results = null) + { + results ??= new List(); + + return new DeallocateResourceOperationResult(description, resourceType, location, results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Unique identifier for the resource involved in the operation, eg ArmId. + /// Resource level error code if it exists. + /// Resource level error details if they exist. + /// Details of the operation performed on a resource. + /// A new instance for mocking. + public static ResourceOperationResult ResourceOperationResult(ResourceIdentifier resourceId = null, string errorCode = null, string errorDetails = null, ResourceOperationDetails operation = null) + { + return new ResourceOperationResult(resourceId, errorCode, errorDetails, operation, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Operation identifier for the unique operation. + /// Unique identifier for the resource involved in the operation, eg ArmId. + /// Type of operation performed on the resources. + /// Subscription id attached to the request. + /// Deadline for the operation. + /// Type of deadline of the operation. + /// Current state of the operation. + /// Timezone for the operation. + /// Operation level errors if they exist. + /// Time the operation was complete if errors are null. + /// Retry policy the user can pass. + /// A new instance for mocking. + public static ResourceOperationDetails ResourceOperationDetails(string operationId = null, ResourceIdentifier resourceId = null, ResourceOperationType opType = default, string subscriptionId = null, DateTimeOffset deadline = default, ScheduledActionDeadlineType deadlineType = default, ScheduledActionOperationState state = default, string timeZone = null, ResourceOperationError resourceOperationError = null, DateTimeOffset? completedOn = null, UserRequestRetryPolicy retryPolicy = null) + { + return new ResourceOperationDetails( + operationId, + resourceId, + opType, + subscriptionId, + deadline, + deadlineType, + state, + timeZone, + resourceOperationError, + completedOn, + retryPolicy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Code for the error eg 404, 500. + /// Detailed message about the error. + /// A new instance for mocking. + public static ResourceOperationError ResourceOperationError(string errorCode = null, string errorDetails = null) + { + return new ResourceOperationError(errorCode, errorDetails, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the Hibernate request eg virtual machines. + /// The location of the Hibernate request eg westus. + /// The results from the Hibernate request if no errors exist. + /// A new instance for mocking. + public static HibernateResourceOperationResult HibernateResourceOperationResult(string description = null, string resourceType = null, AzureLocation location = default, IEnumerable results = null) + { + results ??= new List(); + + return new HibernateResourceOperationResult(description, resourceType, location, results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the start request eg virtual machines. + /// The location of the start request eg westus. + /// The results from the start request if no errors exist. + /// A new instance for mocking. + public static StartResourceOperationResult StartResourceOperationResult(string description = null, string resourceType = null, AzureLocation location = default, IEnumerable results = null) + { + results ??= new List(); + + return new StartResourceOperationResult(description, resourceType, location, results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of resource operations based on their operation ids. + /// A new instance for mocking. + public static GetOperationStatusResult GetOperationStatusResult(IEnumerable results = null) + { + results ??= new List(); + + return new GetOperationStatusResult(results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of resource operations that were successfully cancelled. + /// A new instance for mocking. + public static CancelOperationsResult CancelOperationsResult(IEnumerable results = null) + { + results ??= new List(); + + return new CancelOperationsResult(results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of operationids and their corresponding errors if any. + /// A new instance for mocking. + public static GetOperationErrorsResult GetOperationErrorsResult(IEnumerable results = null) + { + results ??= new List(); + + return new GetOperationErrorsResult(results?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The operationId identifying a vm operation. + /// The creation time of the error result. + /// The activation time of a vm operation. + /// The completion time of the operation if the operation was completed. + /// A list of errors associated with the operationid. + /// Request level error code. + /// Request level error details. + /// A new instance for mocking. + public static OperationErrorsResult OperationErrorsResult(string operationId = null, DateTimeOffset? createdOn = null, DateTimeOffset? activationOn = null, DateTimeOffset? completedOn = null, IEnumerable operationErrors = null, string requestErrorCode = null, string requestErrorDetails = null) + { + operationErrors ??= new List(); + + return new OperationErrorsResult( + operationId, + createdOn, + activationOn, + completedOn, + operationErrors?.ToList(), + requestErrorCode, + requestErrorDetails, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The error code of the operation. + /// The error details of the operation. + /// The timestamp of the error occurence. + /// CRP operationid of the operation for deeper analysis. + /// A new instance for mocking. + public static OperationErrorDetails OperationErrorDetails(string errorCode = null, DateTimeOffset errorDetails = default, DateTimeOffset timeStamp = default, string crpOperationId = null) + { + return new OperationErrorDetails(errorCode, errorDetails, timeStamp, crpOperationId, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/ComputeScheduleExtensions.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/ComputeScheduleExtensions.cs new file mode 100644 index 000000000000..95a3296650ba --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/ComputeScheduleExtensions.cs @@ -0,0 +1,637 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.ResourceManager.ComputeSchedule.Mocking; +using Azure.ResourceManager.ComputeSchedule.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ComputeSchedule +{ + /// A class to add extension methods to Azure.ResourceManager.ComputeSchedule. + public static partial class ComputeScheduleExtensions + { + private static MockableComputeScheduleSubscriptionResource GetMockableComputeScheduleSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableComputeScheduleSubscriptionResource(client, resource.Id)); + } + + /// + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> SubmitVirtualMachineDeallocateAsync(this SubscriptionResource subscriptionResource, string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineDeallocateAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response SubmitVirtualMachineDeallocate(this SubscriptionResource subscriptionResource, string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineDeallocate(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> SubmitVirtualMachineHibernateAsync(this SubscriptionResource subscriptionResource, string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineHibernateAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response SubmitVirtualMachineHibernate(this SubscriptionResource subscriptionResource, string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineHibernate(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesSubmitStart: submitStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> SubmitVirtualMachineStartAsync(this SubscriptionResource subscriptionResource, string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineStartAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesSubmitStart: submitStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response SubmitVirtualMachineStart(this SubscriptionResource subscriptionResource, string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).SubmitVirtualMachineStart(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> ExecuteVirtualMachineDeallocateAsync(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineDeallocateAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response ExecuteVirtualMachineDeallocate(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineDeallocate(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteHibernate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> ExecuteVirtualMachineHibernateAsync(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineHibernateAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteHibernate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response ExecuteVirtualMachineHibernate(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineHibernate(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesExecuteStart: executeStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteStart + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> ExecuteVirtualMachineStartAsync(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineStartAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesExecuteStart: executeStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteStart + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response ExecuteVirtualMachineStart(this SubscriptionResource subscriptionResource, string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).ExecuteVirtualMachineStart(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationStatus + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationStatus + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> GetVirtualMachineOperationStatusAsync(this SubscriptionResource subscriptionResource, string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).GetVirtualMachineOperationStatusAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationStatus + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationStatus + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response GetVirtualMachineOperationStatus(this SubscriptionResource subscriptionResource, string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).GetVirtualMachineOperationStatus(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesCancelOperations + /// + /// + /// Operation Id + /// ScheduledActions_CancelVirtualMachineOperations + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> CancelVirtualMachineOperationsAsync(this SubscriptionResource subscriptionResource, string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).CancelVirtualMachineOperationsAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesCancelOperations + /// + /// + /// Operation Id + /// ScheduledActions_CancelVirtualMachineOperations + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response CancelVirtualMachineOperations(this SubscriptionResource subscriptionResource, string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).CancelVirtualMachineOperations(locationparameter, content, cancellationToken); + } + + /// + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationErrors + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static async Task> GetVirtualMachineOperationErrorsAsync(this SubscriptionResource subscriptionResource, string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return await GetMockableComputeScheduleSubscriptionResource(subscriptionResource).GetVirtualMachineOperationErrorsAsync(locationparameter, content, cancellationToken).ConfigureAwait(false); + } + + /// + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationErrors + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// , or is null. + public static Response GetVirtualMachineOperationErrors(this SubscriptionResource subscriptionResource, string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeScheduleSubscriptionResource(subscriptionResource).GetVirtualMachineOperationErrors(locationparameter, content, cancellationToken); + } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/MockableComputeScheduleSubscriptionResource.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/MockableComputeScheduleSubscriptionResource.cs new file mode 100644 index 000000000000..243b45b2471e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Extensions/MockableComputeScheduleSubscriptionResource.cs @@ -0,0 +1,782 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ComputeSchedule.Models; + +namespace Azure.ResourceManager.ComputeSchedule.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableComputeScheduleSubscriptionResource : ArmResource + { + private ClientDiagnostics _scheduledActionsClientDiagnostics; + private ScheduledActionsRestOperations _scheduledActionsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableComputeScheduleSubscriptionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the resource that is the target of operations. + internal MockableComputeScheduleSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics ScheduledActionsClientDiagnostics => _scheduledActionsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ComputeSchedule", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private ScheduledActionsRestOperations ScheduledActionsRestClient => _scheduledActionsRestClient ??= new ScheduledActionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> SubmitVirtualMachineDeallocateAsync(string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineDeallocate"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.SubmitVirtualMachineDeallocateAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response SubmitVirtualMachineDeallocate(string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineDeallocate"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.SubmitVirtualMachineDeallocate(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> SubmitVirtualMachineHibernateAsync(string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineHibernate"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.SubmitVirtualMachineHibernateAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitHibernate + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response SubmitVirtualMachineHibernate(string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineHibernate"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.SubmitVirtualMachineHibernate(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesSubmitStart: submitStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> SubmitVirtualMachineStartAsync(string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineStart"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.SubmitVirtualMachineStartAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesSubmitStart: submitStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesSubmitStart + /// + /// + /// Operation Id + /// ScheduledActions_SubmitVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response SubmitVirtualMachineStart(string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.SubmitVirtualMachineStart"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.SubmitVirtualMachineStart(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> ExecuteVirtualMachineDeallocateAsync(string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineDeallocate"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.ExecuteVirtualMachineDeallocateAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteDeallocate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineDeallocate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response ExecuteVirtualMachineDeallocate(string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineDeallocate"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.ExecuteVirtualMachineDeallocate(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteHibernate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> ExecuteVirtualMachineHibernateAsync(string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineHibernate"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.ExecuteVirtualMachineHibernateAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteHibernate + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineHibernate + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response ExecuteVirtualMachineHibernate(string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineHibernate"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.ExecuteVirtualMachineHibernate(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteStart: executeStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteStart + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> ExecuteVirtualMachineStartAsync(string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineStart"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.ExecuteVirtualMachineStartAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesExecuteStart: executeStart for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesExecuteStart + /// + /// + /// Operation Id + /// ScheduledActions_ExecuteVirtualMachineStart + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response ExecuteVirtualMachineStart(string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.ExecuteVirtualMachineStart"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.ExecuteVirtualMachineStart(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationStatus + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationStatus + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> GetVirtualMachineOperationStatusAsync(string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.GetVirtualMachineOperationStatus"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.GetVirtualMachineOperationStatusAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationStatus + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationStatus + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response GetVirtualMachineOperationStatus(string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.GetVirtualMachineOperationStatus"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.GetVirtualMachineOperationStatus(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesCancelOperations + /// + /// + /// Operation Id + /// ScheduledActions_CancelVirtualMachineOperations + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CancelVirtualMachineOperationsAsync(string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.CancelVirtualMachineOperations"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.CancelVirtualMachineOperationsAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesCancelOperations + /// + /// + /// Operation Id + /// ScheduledActions_CancelVirtualMachineOperations + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response CancelVirtualMachineOperations(string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.CancelVirtualMachineOperations"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.CancelVirtualMachineOperations(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationErrors + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> GetVirtualMachineOperationErrorsAsync(string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.GetVirtualMachineOperationErrors"); + scope.Start(); + try + { + var response = await ScheduledActionsRestClient.GetVirtualMachineOperationErrorsAsync(Id.SubscriptionId, locationparameter, content, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.ComputeSchedule/locations/{locationparameter}/virtualMachinesGetOperationErrors + /// + /// + /// Operation Id + /// ScheduledActions_GetVirtualMachineOperationErrors + /// + /// + /// Default Api Version + /// 2024-08-15-preview + /// + /// + /// + /// The location name. + /// The request body. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response GetVirtualMachineOperationErrors(string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ScheduledActionsClientDiagnostics.CreateScope("MockableComputeScheduleSubscriptionResource.GetVirtualMachineOperationErrors"); + scope.Start(); + try + { + var response = ScheduledActionsRestClient.GetVirtualMachineOperationErrors(Id.SubscriptionId, locationparameter, content, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Argument.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..8695af015f6b --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule +{ + 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..fc60785059ec --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule +{ + 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingList.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..08ae394e6efa --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule +{ + 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..34b26a7d4b03 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Optional.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..f8a416ed219e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule +{ + 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..f597350b53b0 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule +{ + 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.Serialization.cs new file mode 100644 index 000000000000..72bae802127d --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.Serialization.cs @@ -0,0 +1,137 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class CancelOperationsContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CancelOperationsContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("operationIds"u8); + writer.WriteStartArray(); + foreach (var item in OperationIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CancelOperationsContent 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(CancelOperationsContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCancelOperationsContent(document.RootElement, options); + } + + internal static CancelOperationsContent DeserializeCancelOperationsContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList operationIds = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + operationIds = array; + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CancelOperationsContent(operationIds, correlationid, 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(CancelOperationsContent)} does not support writing '{options.Format}' format."); + } + } + + CancelOperationsContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCancelOperationsContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CancelOperationsContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.cs new file mode 100644 index 000000000000..4e7f196a59d8 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsContent.cs @@ -0,0 +1,83 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// This is the request to cancel running operations in scheduled actions using the operation ids. + public partial class CancelOperationsContent + { + /// + /// 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 list of operation ids to cancel operations on. + /// Correlationid item. + /// or is null. + public CancelOperationsContent(IEnumerable operationIds, string correlationid) + { + Argument.AssertNotNull(operationIds, nameof(operationIds)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + OperationIds = operationIds.ToList(); + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The list of operation ids to cancel operations on. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal CancelOperationsContent(IList operationIds, string correlationid, IDictionary serializedAdditionalRawData) + { + OperationIds = operationIds; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CancelOperationsContent() + { + } + + /// The list of operation ids to cancel operations on. + public IList OperationIds { get; } + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.Serialization.cs new file mode 100644 index 000000000000..05732e401362 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.Serialization.cs @@ -0,0 +1,129 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class CancelOperationsResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CancelOperationsResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CancelOperationsResult 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(CancelOperationsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCancelOperationsResult(document.RootElement, options); + } + + internal static CancelOperationsResult DeserializeCancelOperationsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceOperationResult.DeserializeResourceOperationResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CancelOperationsResult(results, 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(CancelOperationsResult)} does not support writing '{options.Format}' format."); + } + } + + CancelOperationsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCancelOperationsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CancelOperationsResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.cs new file mode 100644 index 000000000000..76a14f30b78e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/CancelOperationsResult.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the response from a cancel operations request. + public partial class CancelOperationsResult + { + /// + /// 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 . + /// An array of resource operations that were successfully cancelled. + /// is null. + internal CancelOperationsResult(IEnumerable results) + { + Argument.AssertNotNull(results, nameof(results)); + + Results = results.ToList(); + } + + /// Initializes a new instance of . + /// An array of resource operations that were successfully cancelled. + /// Keeps track of any properties unknown to the library. + internal CancelOperationsResult(IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CancelOperationsResult() + { + } + + /// An array of resource operations that were successfully cancelled. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.Serialization.cs new file mode 100644 index 000000000000..d9a7c7f85f56 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.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.ResourceManager.ComputeSchedule.Models +{ + public partial class DeallocateResourceOperationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeallocateResourceOperationResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DeallocateResourceOperationResult 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(DeallocateResourceOperationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeallocateResourceOperationResult(document.RootElement, options); + } + + internal static DeallocateResourceOperationResult DeserializeDeallocateResourceOperationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string type = default; + AzureLocation location = default; + IReadOnlyList results = 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("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceOperationResult.DeserializeResourceOperationResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DeallocateResourceOperationResult(description, type, location, results ?? 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(DeallocateResourceOperationResult)} does not support writing '{options.Format}' format."); + } + } + + DeallocateResourceOperationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDeallocateResourceOperationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeallocateResourceOperationResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.cs new file mode 100644 index 000000000000..53dd7b2eee05 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/DeallocateResourceOperationResult.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; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The response from a deallocate request. + public partial class DeallocateResourceOperationResult + { + /// + /// 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 description of the operation response. + /// The type of resources used in the deallocate request eg virtual machines. + /// The location of the deallocate request eg westus. + /// or is null. + internal DeallocateResourceOperationResult(string description, string resourceType, AzureLocation location) + { + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + Description = description; + ResourceType = resourceType; + Location = location; + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the deallocate request eg virtual machines. + /// The location of the deallocate request eg westus. + /// The results from the deallocate request if no errors exist. + /// Keeps track of any properties unknown to the library. + internal DeallocateResourceOperationResult(string description, string resourceType, AzureLocation location, IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Description = description; + ResourceType = resourceType; + Location = location; + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DeallocateResourceOperationResult() + { + } + + /// The description of the operation response. + public string Description { get; } + /// The type of resources used in the deallocate request eg virtual machines. + public string ResourceType { get; } + /// The location of the deallocate request eg westus. + public AzureLocation Location { get; } + /// The results from the deallocate request if no errors exist. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.Serialization.cs new file mode 100644 index 000000000000..ff1c7bc7c4f2 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.Serialization.cs @@ -0,0 +1,135 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ExecuteDeallocateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExecuteDeallocateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ExecuteDeallocateContent 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(ExecuteDeallocateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExecuteDeallocateContent(document.RootElement, options); + } + + internal static ExecuteDeallocateContent DeserializeExecuteDeallocateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExecuteDeallocateContent(executionParameters, resources, correlationid, 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(ExecuteDeallocateContent)} does not support writing '{options.Format}' format."); + } + } + + ExecuteDeallocateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeExecuteDeallocateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExecuteDeallocateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.cs new file mode 100644 index 000000000000..dc805297140d --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteDeallocateContent.cs @@ -0,0 +1,96 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// The ExecuteDeallocateRequest request for executeDeallocate operations. + public partial class ExecuteDeallocateContent + { + /// + /// 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 execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , or is null. + public ExecuteDeallocateContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal ExecuteDeallocateContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ExecuteDeallocateContent() + { + } + + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.Serialization.cs new file mode 100644 index 000000000000..d5334b9da1a7 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.Serialization.cs @@ -0,0 +1,135 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ExecuteHibernateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExecuteHibernateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ExecuteHibernateContent 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(ExecuteHibernateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExecuteHibernateContent(document.RootElement, options); + } + + internal static ExecuteHibernateContent DeserializeExecuteHibernateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExecuteHibernateContent(executionParameters, resources, correlationid, 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(ExecuteHibernateContent)} does not support writing '{options.Format}' format."); + } + } + + ExecuteHibernateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeExecuteHibernateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExecuteHibernateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.cs new file mode 100644 index 000000000000..a7817e1abde2 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteHibernateContent.cs @@ -0,0 +1,96 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// The ExecuteHibernateRequest request for executeHibernate operations. + public partial class ExecuteHibernateContent + { + /// + /// 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 execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , or is null. + public ExecuteHibernateContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal ExecuteHibernateContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ExecuteHibernateContent() + { + } + + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.Serialization.cs new file mode 100644 index 000000000000..58e86b342ac8 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.Serialization.cs @@ -0,0 +1,135 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ExecuteStartContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ExecuteStartContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ExecuteStartContent 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(ExecuteStartContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeExecuteStartContent(document.RootElement, options); + } + + internal static ExecuteStartContent DeserializeExecuteStartContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ExecuteStartContent(executionParameters, resources, correlationid, 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(ExecuteStartContent)} does not support writing '{options.Format}' format."); + } + } + + ExecuteStartContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeExecuteStartContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ExecuteStartContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.cs new file mode 100644 index 000000000000..1f3e6965799c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ExecuteStartContent.cs @@ -0,0 +1,96 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// The ExecuteStartRequest request for executeStart operations. + public partial class ExecuteStartContent + { + /// + /// 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 execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , or is null. + public ExecuteStartContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal ExecuteStartContent(ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ExecuteStartContent() + { + } + + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.Serialization.cs new file mode 100644 index 000000000000..7708a8ccb543 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.Serialization.cs @@ -0,0 +1,129 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class GetOperationErrorsContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetOperationErrorsContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("operationIds"u8); + writer.WriteStartArray(); + foreach (var item in OperationIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + GetOperationErrorsContent 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(GetOperationErrorsContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetOperationErrorsContent(document.RootElement, options); + } + + internal static GetOperationErrorsContent DeserializeGetOperationErrorsContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList operationIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + operationIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetOperationErrorsContent(operationIds, 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(GetOperationErrorsContent)} does not support writing '{options.Format}' format."); + } + } + + GetOperationErrorsContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGetOperationErrorsContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetOperationErrorsContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.cs new file mode 100644 index 000000000000..b59284a55b06 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsContent.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the request to get errors per vm operations. + public partial class GetOperationErrorsContent + { + /// + /// 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 list of operation ids to query errors of. + /// is null. + public GetOperationErrorsContent(IEnumerable operationIds) + { + Argument.AssertNotNull(operationIds, nameof(operationIds)); + + OperationIds = operationIds.ToList(); + } + + /// Initializes a new instance of . + /// The list of operation ids to query errors of. + /// Keeps track of any properties unknown to the library. + internal GetOperationErrorsContent(IList operationIds, IDictionary serializedAdditionalRawData) + { + OperationIds = operationIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetOperationErrorsContent() + { + } + + /// The list of operation ids to query errors of. + public IList OperationIds { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.Serialization.cs new file mode 100644 index 000000000000..b6e96c0f9787 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.Serialization.cs @@ -0,0 +1,129 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class GetOperationErrorsResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetOperationErrorsResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + GetOperationErrorsResult 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(GetOperationErrorsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetOperationErrorsResult(document.RootElement, options); + } + + internal static GetOperationErrorsResult DeserializeGetOperationErrorsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(OperationErrorsResult.DeserializeOperationErrorsResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetOperationErrorsResult(results, 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(GetOperationErrorsResult)} does not support writing '{options.Format}' format."); + } + } + + GetOperationErrorsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGetOperationErrorsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetOperationErrorsResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.cs new file mode 100644 index 000000000000..6ffe0ec4385c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationErrorsResult.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the response from a get operations errors request. + public partial class GetOperationErrorsResult + { + /// + /// 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 . + /// An array of operationids and their corresponding errors if any. + /// is null. + internal GetOperationErrorsResult(IEnumerable results) + { + Argument.AssertNotNull(results, nameof(results)); + + Results = results.ToList(); + } + + /// Initializes a new instance of . + /// An array of operationids and their corresponding errors if any. + /// Keeps track of any properties unknown to the library. + internal GetOperationErrorsResult(IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetOperationErrorsResult() + { + } + + /// An array of operationids and their corresponding errors if any. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.Serialization.cs new file mode 100644 index 000000000000..93654cfdff76 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.Serialization.cs @@ -0,0 +1,137 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class GetOperationStatusContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetOperationStatusContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("operationIds"u8); + writer.WriteStartArray(); + foreach (var item in OperationIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + GetOperationStatusContent 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(GetOperationStatusContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetOperationStatusContent(document.RootElement, options); + } + + internal static GetOperationStatusContent DeserializeGetOperationStatusContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList operationIds = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationIds"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + operationIds = array; + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetOperationStatusContent(operationIds, correlationid, 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(GetOperationStatusContent)} does not support writing '{options.Format}' format."); + } + } + + GetOperationStatusContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGetOperationStatusContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetOperationStatusContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.cs new file mode 100644 index 000000000000..15c23a6cb3e2 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusContent.cs @@ -0,0 +1,83 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// This is the request to get operation status using operationids. + public partial class GetOperationStatusContent + { + /// + /// 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 list of operation ids to get the status of. + /// Correlationid item. + /// or is null. + public GetOperationStatusContent(IEnumerable operationIds, string correlationid) + { + Argument.AssertNotNull(operationIds, nameof(operationIds)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + OperationIds = operationIds.ToList(); + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The list of operation ids to get the status of. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal GetOperationStatusContent(IList operationIds, string correlationid, IDictionary serializedAdditionalRawData) + { + OperationIds = operationIds; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetOperationStatusContent() + { + } + + /// The list of operation ids to get the status of. + public IList OperationIds { get; } + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.Serialization.cs new file mode 100644 index 000000000000..0a59ecebb274 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.Serialization.cs @@ -0,0 +1,129 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class GetOperationStatusResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetOperationStatusResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + GetOperationStatusResult 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(GetOperationStatusResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetOperationStatusResult(document.RootElement, options); + } + + internal static GetOperationStatusResult DeserializeGetOperationStatusResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList results = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("results"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceOperationResult.DeserializeResourceOperationResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetOperationStatusResult(results, 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(GetOperationStatusResult)} does not support writing '{options.Format}' format."); + } + } + + GetOperationStatusResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeGetOperationStatusResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetOperationStatusResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.cs new file mode 100644 index 000000000000..c2000759d64c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/GetOperationStatusResult.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the response from a get operations status request. + public partial class GetOperationStatusResult + { + /// + /// 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 . + /// An array of resource operations based on their operation ids. + /// is null. + internal GetOperationStatusResult(IEnumerable results) + { + Argument.AssertNotNull(results, nameof(results)); + + Results = results.ToList(); + } + + /// Initializes a new instance of . + /// An array of resource operations based on their operation ids. + /// Keeps track of any properties unknown to the library. + internal GetOperationStatusResult(IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetOperationStatusResult() + { + } + + /// An array of resource operations based on their operation ids. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.Serialization.cs new file mode 100644 index 000000000000..74aa2354ea2b --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.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.ResourceManager.ComputeSchedule.Models +{ + public partial class HibernateResourceOperationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(HibernateResourceOperationResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + HibernateResourceOperationResult 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(HibernateResourceOperationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeHibernateResourceOperationResult(document.RootElement, options); + } + + internal static HibernateResourceOperationResult DeserializeHibernateResourceOperationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string type = default; + AzureLocation location = default; + IReadOnlyList results = 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("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceOperationResult.DeserializeResourceOperationResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new HibernateResourceOperationResult(description, type, location, results ?? 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(HibernateResourceOperationResult)} does not support writing '{options.Format}' format."); + } + } + + HibernateResourceOperationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeHibernateResourceOperationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(HibernateResourceOperationResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.cs new file mode 100644 index 000000000000..30bda4ece05c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/HibernateResourceOperationResult.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; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The response from a Hibernate request. + public partial class HibernateResourceOperationResult + { + /// + /// 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 description of the operation response. + /// The type of resources used in the Hibernate request eg virtual machines. + /// The location of the Hibernate request eg westus. + /// or is null. + internal HibernateResourceOperationResult(string description, string resourceType, AzureLocation location) + { + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + Description = description; + ResourceType = resourceType; + Location = location; + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the Hibernate request eg virtual machines. + /// The location of the Hibernate request eg westus. + /// The results from the Hibernate request if no errors exist. + /// Keeps track of any properties unknown to the library. + internal HibernateResourceOperationResult(string description, string resourceType, AzureLocation location, IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Description = description; + ResourceType = resourceType; + Location = location; + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal HibernateResourceOperationResult() + { + } + + /// The description of the operation response. + public string Description { get; } + /// The type of resources used in the Hibernate request eg virtual machines. + public string ResourceType { get; } + /// The location of the Hibernate request eg westus. + public AzureLocation Location { get; } + /// The results from the Hibernate request if no errors exist. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.Serialization.cs new file mode 100644 index 000000000000..08a8469c9f9b --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.Serialization.cs @@ -0,0 +1,143 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class OperationErrorDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationErrorDetails)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("errorCode"u8); + writer.WriteStringValue(ErrorCode); + writer.WritePropertyName("errorDetails"u8); + writer.WriteStringValue(ErrorDetails, "O"); + writer.WritePropertyName("timeStamp"u8); + writer.WriteStringValue(TimeStamp, "O"); + writer.WritePropertyName("crpOperationId"u8); + writer.WriteStringValue(CrpOperationId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationErrorDetails 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(OperationErrorDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationErrorDetails(document.RootElement, options); + } + + internal static OperationErrorDetails DeserializeOperationErrorDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string errorCode = default; + DateTimeOffset errorDetails = default; + DateTimeOffset timeStamp = default; + string crpOperationId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("errorCode"u8)) + { + errorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + errorDetails = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("timeStamp"u8)) + { + timeStamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("crpOperationId"u8)) + { + crpOperationId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationErrorDetails(errorCode, errorDetails, timeStamp, crpOperationId, 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(OperationErrorDetails)} does not support writing '{options.Format}' format."); + } + } + + OperationErrorDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOperationErrorDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationErrorDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.cs new file mode 100644 index 000000000000..dc81465e792c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorDetails.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.ResourceManager.ComputeSchedule.Models +{ + /// This defines a list of operation errors associated with a unique operationId. + public partial class OperationErrorDetails + { + /// + /// 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 error code of the operation. + /// The error details of the operation. + /// The timestamp of the error occurence. + /// CRP operationid of the operation for deeper analysis. + /// or is null. + internal OperationErrorDetails(string errorCode, DateTimeOffset errorDetails, DateTimeOffset timeStamp, string crpOperationId) + { + Argument.AssertNotNull(errorCode, nameof(errorCode)); + Argument.AssertNotNull(crpOperationId, nameof(crpOperationId)); + + ErrorCode = errorCode; + ErrorDetails = errorDetails; + TimeStamp = timeStamp; + CrpOperationId = crpOperationId; + } + + /// Initializes a new instance of . + /// The error code of the operation. + /// The error details of the operation. + /// The timestamp of the error occurence. + /// CRP operationid of the operation for deeper analysis. + /// Keeps track of any properties unknown to the library. + internal OperationErrorDetails(string errorCode, DateTimeOffset errorDetails, DateTimeOffset timeStamp, string crpOperationId, IDictionary serializedAdditionalRawData) + { + ErrorCode = errorCode; + ErrorDetails = errorDetails; + TimeStamp = timeStamp; + CrpOperationId = crpOperationId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationErrorDetails() + { + } + + /// The error code of the operation. + public string ErrorCode { get; } + /// The error details of the operation. + public DateTimeOffset ErrorDetails { get; } + /// The timestamp of the error occurence. + public DateTimeOffset TimeStamp { get; } + /// CRP operationid of the operation for deeper analysis. + public string CrpOperationId { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.Serialization.cs new file mode 100644 index 000000000000..32733cded89f --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.Serialization.cs @@ -0,0 +1,222 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class OperationErrorsResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationErrorsResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OperationId)) + { + writer.WritePropertyName("operationId"u8); + writer.WriteStringValue(OperationId); + } + if (Optional.IsDefined(CreatedOn)) + { + writer.WritePropertyName("creationTime"u8); + writer.WriteStringValue(CreatedOn.Value, "O"); + } + if (Optional.IsDefined(ActivationOn)) + { + writer.WritePropertyName("activationTime"u8); + writer.WriteStringValue(ActivationOn.Value, "O"); + } + if (Optional.IsDefined(CompletedOn)) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedOn.Value, "O"); + } + if (Optional.IsCollectionDefined(OperationErrors)) + { + writer.WritePropertyName("operationErrors"u8); + writer.WriteStartArray(); + foreach (var item in OperationErrors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(RequestErrorCode)) + { + writer.WritePropertyName("requestErrorCode"u8); + writer.WriteStringValue(RequestErrorCode); + } + if (Optional.IsDefined(RequestErrorDetails)) + { + writer.WritePropertyName("requestErrorDetails"u8); + writer.WriteStringValue(RequestErrorDetails); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationErrorsResult 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(OperationErrorsResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationErrorsResult(document.RootElement, options); + } + + internal static OperationErrorsResult DeserializeOperationErrorsResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string operationId = default; + DateTimeOffset? creationTime = default; + DateTimeOffset? activationTime = default; + DateTimeOffset? completedAt = default; + IReadOnlyList operationErrors = default; + string requestErrorCode = default; + string requestErrorDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationId"u8)) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("creationTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + creationTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("activationTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + activationTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("operationErrors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(OperationErrorDetails.DeserializeOperationErrorDetails(item, options)); + } + operationErrors = array; + continue; + } + if (property.NameEquals("requestErrorCode"u8)) + { + requestErrorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestErrorDetails"u8)) + { + requestErrorDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationErrorsResult( + operationId, + creationTime, + activationTime, + completedAt, + operationErrors ?? new ChangeTrackingList(), + requestErrorCode, + requestErrorDetails, + 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(OperationErrorsResult)} does not support writing '{options.Format}' format."); + } + } + + OperationErrorsResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOperationErrorsResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationErrorsResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.cs new file mode 100644 index 000000000000..7f25f008e673 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/OperationErrorsResult.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// This is the first level of operation errors from the request when clients get errors per vm operation. + public partial class OperationErrorsResult + { + /// + /// 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 OperationErrorsResult() + { + OperationErrors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The operationId identifying a vm operation. + /// The creation time of the error result. + /// The activation time of a vm operation. + /// The completion time of the operation if the operation was completed. + /// A list of errors associated with the operationid. + /// Request level error code. + /// Request level error details. + /// Keeps track of any properties unknown to the library. + internal OperationErrorsResult(string operationId, DateTimeOffset? createdOn, DateTimeOffset? activationOn, DateTimeOffset? completedOn, IReadOnlyList operationErrors, string requestErrorCode, string requestErrorDetails, IDictionary serializedAdditionalRawData) + { + OperationId = operationId; + CreatedOn = createdOn; + ActivationOn = activationOn; + CompletedOn = completedOn; + OperationErrors = operationErrors; + RequestErrorCode = requestErrorCode; + RequestErrorDetails = requestErrorDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The operationId identifying a vm operation. + public string OperationId { get; } + /// The creation time of the error result. + public DateTimeOffset? CreatedOn { get; } + /// The activation time of a vm operation. + public DateTimeOffset? ActivationOn { get; } + /// The completion time of the operation if the operation was completed. + public DateTimeOffset? CompletedOn { get; } + /// A list of errors associated with the operationid. + public IReadOnlyList OperationErrors { get; } + /// Request level error code. + public string RequestErrorCode { get; } + /// Request level error details. + public string RequestErrorDetails { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.Serialization.cs new file mode 100644 index 000000000000..4aa0e24533b5 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.Serialization.cs @@ -0,0 +1,235 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ResourceOperationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceOperationDetails)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("operationId"u8); + writer.WriteStringValue(OperationId); + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + writer.WritePropertyName("opType"u8); + writer.WriteStringValue(OpType.ToString()); + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + writer.WritePropertyName("deadline"u8); + writer.WriteStringValue(Deadline, "O"); + writer.WritePropertyName("deadlineType"u8); + writer.WriteStringValue(DeadlineType.ToString()); + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.ToString()); + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + } + if (Optional.IsDefined(ResourceOperationError)) + { + writer.WritePropertyName("resourceOperationError"u8); + writer.WriteObjectValue(ResourceOperationError, options); + } + if (Optional.IsDefined(CompletedOn)) + { + writer.WritePropertyName("completedAt"u8); + writer.WriteStringValue(CompletedOn.Value, "O"); + } + if (Optional.IsDefined(RetryPolicy)) + { + writer.WritePropertyName("retryPolicy"u8); + writer.WriteObjectValue(RetryPolicy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ResourceOperationDetails 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(ResourceOperationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceOperationDetails(document.RootElement, options); + } + + internal static ResourceOperationDetails DeserializeResourceOperationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string operationId = default; + ResourceIdentifier resourceId = default; + ResourceOperationType opType = default; + string subscriptionId = default; + DateTimeOffset deadline = default; + ScheduledActionDeadlineType deadlineType = default; + ScheduledActionOperationState state = default; + string timeZone = default; + ResourceOperationError resourceOperationError = default; + DateTimeOffset? completedAt = default; + UserRequestRetryPolicy retryPolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("operationId"u8)) + { + operationId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceId"u8)) + { + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("opType"u8)) + { + opType = new ResourceOperationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("deadline"u8)) + { + deadline = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("deadlineType"u8)) + { + deadlineType = new ScheduledActionDeadlineType(property.Value.GetString()); + continue; + } + if (property.NameEquals("state"u8)) + { + state = new ScheduledActionOperationState(property.Value.GetString()); + continue; + } + if (property.NameEquals("timeZone"u8)) + { + timeZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceOperationError"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceOperationError = ResourceOperationError.DeserializeResourceOperationError(property.Value, options); + continue; + } + if (property.NameEquals("completedAt"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + completedAt = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("retryPolicy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retryPolicy = UserRequestRetryPolicy.DeserializeUserRequestRetryPolicy(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceOperationDetails( + operationId, + resourceId, + opType, + subscriptionId, + deadline, + deadlineType, + state, + timeZone, + resourceOperationError, + completedAt, + retryPolicy, + 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(ResourceOperationDetails)} does not support writing '{options.Format}' format."); + } + } + + ResourceOperationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceOperationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceOperationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.cs new file mode 100644 index 000000000000..5dd4a0e5db92 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationDetails.cs @@ -0,0 +1,130 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + /// The details of a response from an operation on a resource. + public partial class ResourceOperationDetails + { + /// + /// 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 . + /// Operation identifier for the unique operation. + /// Unique identifier for the resource involved in the operation, eg ArmId. + /// Type of operation performed on the resources. + /// Subscription id attached to the request. + /// Deadline for the operation. + /// Type of deadline of the operation. + /// Current state of the operation. + /// , or is null. + internal ResourceOperationDetails(string operationId, ResourceIdentifier resourceId, ResourceOperationType opType, string subscriptionId, DateTimeOffset deadline, ScheduledActionDeadlineType deadlineType, ScheduledActionOperationState state) + { + Argument.AssertNotNull(operationId, nameof(operationId)); + Argument.AssertNotNull(resourceId, nameof(resourceId)); + Argument.AssertNotNull(subscriptionId, nameof(subscriptionId)); + + OperationId = operationId; + ResourceId = resourceId; + OpType = opType; + SubscriptionId = subscriptionId; + Deadline = deadline; + DeadlineType = deadlineType; + State = state; + } + + /// Initializes a new instance of . + /// Operation identifier for the unique operation. + /// Unique identifier for the resource involved in the operation, eg ArmId. + /// Type of operation performed on the resources. + /// Subscription id attached to the request. + /// Deadline for the operation. + /// Type of deadline of the operation. + /// Current state of the operation. + /// Timezone for the operation. + /// Operation level errors if they exist. + /// Time the operation was complete if errors are null. + /// Retry policy the user can pass. + /// Keeps track of any properties unknown to the library. + internal ResourceOperationDetails(string operationId, ResourceIdentifier resourceId, ResourceOperationType opType, string subscriptionId, DateTimeOffset deadline, ScheduledActionDeadlineType deadlineType, ScheduledActionOperationState state, string timeZone, ResourceOperationError resourceOperationError, DateTimeOffset? completedOn, UserRequestRetryPolicy retryPolicy, IDictionary serializedAdditionalRawData) + { + OperationId = operationId; + ResourceId = resourceId; + OpType = opType; + SubscriptionId = subscriptionId; + Deadline = deadline; + DeadlineType = deadlineType; + State = state; + TimeZone = timeZone; + ResourceOperationError = resourceOperationError; + CompletedOn = completedOn; + RetryPolicy = retryPolicy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceOperationDetails() + { + } + + /// Operation identifier for the unique operation. + public string OperationId { get; } + /// Unique identifier for the resource involved in the operation, eg ArmId. + public ResourceIdentifier ResourceId { get; } + /// Type of operation performed on the resources. + public ResourceOperationType OpType { get; } + /// Subscription id attached to the request. + public string SubscriptionId { get; } + /// Deadline for the operation. + public DateTimeOffset Deadline { get; } + /// Type of deadline of the operation. + public ScheduledActionDeadlineType DeadlineType { get; } + /// Current state of the operation. + public ScheduledActionOperationState State { get; } + /// Timezone for the operation. + public string TimeZone { get; } + /// Operation level errors if they exist. + public ResourceOperationError ResourceOperationError { get; } + /// Time the operation was complete if errors are null. + public DateTimeOffset? CompletedOn { get; } + /// Retry policy the user can pass. + public UserRequestRetryPolicy RetryPolicy { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.Serialization.cs new file mode 100644 index 000000000000..bdc9472c4342 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.Serialization.cs @@ -0,0 +1,127 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ResourceOperationError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceOperationError)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("errorCode"u8); + writer.WriteStringValue(ErrorCode); + writer.WritePropertyName("errorDetails"u8); + writer.WriteStringValue(ErrorDetails); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ResourceOperationError 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(ResourceOperationError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceOperationError(document.RootElement, options); + } + + internal static ResourceOperationError DeserializeResourceOperationError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string errorCode = default; + string errorDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("errorCode"u8)) + { + errorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + errorDetails = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceOperationError(errorCode, errorDetails, 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(ResourceOperationError)} does not support writing '{options.Format}' format."); + } + } + + ResourceOperationError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceOperationError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceOperationError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.cs new file mode 100644 index 000000000000..f2d52aeba4bf --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationError.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// These describe errors that occur at the resource level. + public partial class ResourceOperationError + { + /// + /// 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 . + /// Code for the error eg 404, 500. + /// Detailed message about the error. + /// or is null. + internal ResourceOperationError(string errorCode, string errorDetails) + { + Argument.AssertNotNull(errorCode, nameof(errorCode)); + Argument.AssertNotNull(errorDetails, nameof(errorDetails)); + + ErrorCode = errorCode; + ErrorDetails = errorDetails; + } + + /// Initializes a new instance of . + /// Code for the error eg 404, 500. + /// Detailed message about the error. + /// Keeps track of any properties unknown to the library. + internal ResourceOperationError(string errorCode, string errorDetails, IDictionary serializedAdditionalRawData) + { + ErrorCode = errorCode; + ErrorDetails = errorDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ResourceOperationError() + { + } + + /// Code for the error eg 404, 500. + public string ErrorCode { get; } + /// Detailed message about the error. + public string ErrorDetails { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.Serialization.cs new file mode 100644 index 000000000000..6bdfcfa35dac --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.Serialization.cs @@ -0,0 +1,163 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ResourceOperationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ResourceOperationResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (Optional.IsDefined(ErrorCode)) + { + writer.WritePropertyName("errorCode"u8); + writer.WriteStringValue(ErrorCode); + } + if (Optional.IsDefined(ErrorDetails)) + { + writer.WritePropertyName("errorDetails"u8); + writer.WriteStringValue(ErrorDetails); + } + if (Optional.IsDefined(Operation)) + { + writer.WritePropertyName("operation"u8); + writer.WriteObjectValue(Operation, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ResourceOperationResult 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(ResourceOperationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeResourceOperationResult(document.RootElement, options); + } + + internal static ResourceOperationResult DeserializeResourceOperationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier resourceId = default; + string errorCode = default; + string errorDetails = default; + ResourceOperationDetails operation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("errorCode"u8)) + { + errorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorDetails"u8)) + { + errorDetails = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + operation = ResourceOperationDetails.DeserializeResourceOperationDetails(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ResourceOperationResult(resourceId, errorCode, errorDetails, operation, 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(ResourceOperationResult)} does not support writing '{options.Format}' format."); + } + } + + ResourceOperationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeResourceOperationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ResourceOperationResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.cs new file mode 100644 index 000000000000..64d699509e9e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationResult.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// High level response from an operation on a resource. + public partial class ResourceOperationResult + { + /// + /// 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 ResourceOperationResult() + { + } + + /// Initializes a new instance of . + /// Unique identifier for the resource involved in the operation, eg ArmId. + /// Resource level error code if it exists. + /// Resource level error details if they exist. + /// Details of the operation performed on a resource. + /// Keeps track of any properties unknown to the library. + internal ResourceOperationResult(ResourceIdentifier resourceId, string errorCode, string errorDetails, ResourceOperationDetails operation, IDictionary serializedAdditionalRawData) + { + ResourceId = resourceId; + ErrorCode = errorCode; + ErrorDetails = errorDetails; + Operation = operation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Unique identifier for the resource involved in the operation, eg ArmId. + public ResourceIdentifier ResourceId { get; } + /// Resource level error code if it exists. + public string ErrorCode { get; } + /// Resource level error details if they exist. + public string ErrorDetails { get; } + /// Details of the operation performed on a resource. + public ResourceOperationDetails Operation { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationType.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationType.cs new file mode 100644 index 000000000000..df921b6555df --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ResourceOperationType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The kind of operation types that can be performed on resources using ScheduledActions. + public readonly partial struct ResourceOperationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ResourceOperationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string StartValue = "Start"; + private const string DeallocateValue = "Deallocate"; + private const string HibernateValue = "Hibernate"; + + /// The default value for this enum type. + public static ResourceOperationType Unknown { get; } = new ResourceOperationType(UnknownValue); + /// Start operations on the resources. + public static ResourceOperationType Start { get; } = new ResourceOperationType(StartValue); + /// Deallocate operations on the resources. + public static ResourceOperationType Deallocate { get; } = new ResourceOperationType(DeallocateValue); + /// Hibernate operations on the resources. + public static ResourceOperationType Hibernate { get; } = new ResourceOperationType(HibernateValue); + /// Determines if two values are the same. + public static bool operator ==(ResourceOperationType left, ResourceOperationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ResourceOperationType left, ResourceOperationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ResourceOperationType(string value) => new ResourceOperationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ResourceOperationType other && Equals(other); + /// + public bool Equals(ResourceOperationType 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionDeadlineType.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionDeadlineType.cs new file mode 100644 index 000000000000..527c2d9cd0be --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionDeadlineType.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.ResourceManager.ComputeSchedule.Models +{ + /// The types of deadlines supported by ScheduledActions. + public readonly partial struct ScheduledActionDeadlineType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ScheduledActionDeadlineType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string InitiateAtValue = "InitiateAt"; + private const string CompleteByValue = "CompleteBy"; + + /// Default value of Unknown. + public static ScheduledActionDeadlineType Unknown { get; } = new ScheduledActionDeadlineType(UnknownValue); + /// Initiate the operation at the given deadline. + public static ScheduledActionDeadlineType InitiateAt { get; } = new ScheduledActionDeadlineType(InitiateAtValue); + /// Complete the operation by the given deadline. + public static ScheduledActionDeadlineType CompleteBy { get; } = new ScheduledActionDeadlineType(CompleteByValue); + /// Determines if two values are the same. + public static bool operator ==(ScheduledActionDeadlineType left, ScheduledActionDeadlineType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ScheduledActionDeadlineType left, ScheduledActionDeadlineType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ScheduledActionDeadlineType(string value) => new ScheduledActionDeadlineType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScheduledActionDeadlineType other && Equals(other); + /// + public bool Equals(ScheduledActionDeadlineType 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.Serialization.cs new file mode 100644 index 000000000000..f746bd79997f --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.Serialization.cs @@ -0,0 +1,141 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class ScheduledActionExecutionParameterDetail : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduledActionExecutionParameterDetail)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OptimizationPreference)) + { + writer.WritePropertyName("optimizationPreference"u8); + writer.WriteStringValue(OptimizationPreference.Value.ToString()); + } + if (Optional.IsDefined(RetryPolicy)) + { + writer.WritePropertyName("retryPolicy"u8); + writer.WriteObjectValue(RetryPolicy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ScheduledActionExecutionParameterDetail 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(ScheduledActionExecutionParameterDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduledActionExecutionParameterDetail(document.RootElement, options); + } + + internal static ScheduledActionExecutionParameterDetail DeserializeScheduledActionExecutionParameterDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScheduledActionOptimizationPreference? optimizationPreference = default; + UserRequestRetryPolicy retryPolicy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("optimizationPreference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + optimizationPreference = new ScheduledActionOptimizationPreference(property.Value.GetString()); + continue; + } + if (property.NameEquals("retryPolicy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retryPolicy = UserRequestRetryPolicy.DeserializeUserRequestRetryPolicy(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ScheduledActionExecutionParameterDetail(optimizationPreference, retryPolicy, 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(ScheduledActionExecutionParameterDetail)} does not support writing '{options.Format}' format."); + } + } + + ScheduledActionExecutionParameterDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeScheduledActionExecutionParameterDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduledActionExecutionParameterDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.cs new file mode 100644 index 000000000000..7ade0616ea80 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionExecutionParameterDetail.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.ResourceManager.ComputeSchedule.Models +{ + /// Extra details needed to run the user's request. + public partial class ScheduledActionExecutionParameterDetail + { + /// + /// 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 ScheduledActionExecutionParameterDetail() + { + } + + /// Initializes a new instance of . + /// Details that could optimize the user's request. + /// Retry policy the user can pass. + /// Keeps track of any properties unknown to the library. + internal ScheduledActionExecutionParameterDetail(ScheduledActionOptimizationPreference? optimizationPreference, UserRequestRetryPolicy retryPolicy, IDictionary serializedAdditionalRawData) + { + OptimizationPreference = optimizationPreference; + RetryPolicy = retryPolicy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Details that could optimize the user's request. + public ScheduledActionOptimizationPreference? OptimizationPreference { get; set; } + /// Retry policy the user can pass. + public UserRequestRetryPolicy RetryPolicy { get; set; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOperationState.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOperationState.cs new file mode 100644 index 000000000000..2b52edb19491 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOperationState.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// Values that define the states of operations in Scheduled Actions. + public readonly partial struct ScheduledActionOperationState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ScheduledActionOperationState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string PendingSchedulingValue = "PendingScheduling"; + private const string ScheduledValue = "Scheduled"; + private const string PendingExecutionValue = "PendingExecution"; + private const string ExecutingValue = "Executing"; + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CancelledValue = "Cancelled"; + private const string BlockedValue = "Blocked"; + + /// The default value for the operation state enum. + public static ScheduledActionOperationState Unknown { get; } = new ScheduledActionOperationState(UnknownValue); + /// Operations that are pending scheduling. + public static ScheduledActionOperationState PendingScheduling { get; } = new ScheduledActionOperationState(PendingSchedulingValue); + /// Operations that have been scheduled. + public static ScheduledActionOperationState Scheduled { get; } = new ScheduledActionOperationState(ScheduledValue); + /// Operations that are waiting to be executed. + public static ScheduledActionOperationState PendingExecution { get; } = new ScheduledActionOperationState(PendingExecutionValue); + /// Operations that are in the process of being executed. + public static ScheduledActionOperationState Executing { get; } = new ScheduledActionOperationState(ExecutingValue); + /// Operations that suceeded. + public static ScheduledActionOperationState Succeeded { get; } = new ScheduledActionOperationState(SucceededValue); + /// Operations that have failed. + public static ScheduledActionOperationState Failed { get; } = new ScheduledActionOperationState(FailedValue); + /// Operations that have been cancelled by the user. + public static ScheduledActionOperationState Cancelled { get; } = new ScheduledActionOperationState(CancelledValue); + /// Operations that are blocked. + public static ScheduledActionOperationState Blocked { get; } = new ScheduledActionOperationState(BlockedValue); + /// Determines if two values are the same. + public static bool operator ==(ScheduledActionOperationState left, ScheduledActionOperationState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ScheduledActionOperationState left, ScheduledActionOperationState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ScheduledActionOperationState(string value) => new ScheduledActionOperationState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScheduledActionOperationState other && Equals(other); + /// + public bool Equals(ScheduledActionOperationState 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOptimizationPreference.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOptimizationPreference.cs new file mode 100644 index 000000000000..a9802b655c3d --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/ScheduledActionOptimizationPreference.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.ResourceManager.ComputeSchedule.Models +{ + /// The preferences customers can select to optimize their requests to ScheduledActions. + public readonly partial struct ScheduledActionOptimizationPreference : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ScheduledActionOptimizationPreference(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CostValue = "Cost"; + private const string AvailabilityValue = "Availability"; + private const string CostAvailabilityBalancedValue = "CostAvailabilityBalanced"; + + /// Optimize while considering cost savings. + public static ScheduledActionOptimizationPreference Cost { get; } = new ScheduledActionOptimizationPreference(CostValue); + /// Optimize while considering availability of resources. + public static ScheduledActionOptimizationPreference Availability { get; } = new ScheduledActionOptimizationPreference(AvailabilityValue); + /// Optimize while considering a balance of cost and availability. + public static ScheduledActionOptimizationPreference CostAvailabilityBalanced { get; } = new ScheduledActionOptimizationPreference(CostAvailabilityBalancedValue); + /// Determines if two values are the same. + public static bool operator ==(ScheduledActionOptimizationPreference left, ScheduledActionOptimizationPreference right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ScheduledActionOptimizationPreference left, ScheduledActionOptimizationPreference right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ScheduledActionOptimizationPreference(string value) => new ScheduledActionOptimizationPreference(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScheduledActionOptimizationPreference other && Equals(other); + /// + public bool Equals(ScheduledActionOptimizationPreference 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/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.Serialization.cs new file mode 100644 index 000000000000..46cab8bf532e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.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.ResourceManager.ComputeSchedule.Models +{ + public partial class StartResourceOperationResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StartResourceOperationResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + if (Optional.IsCollectionDefined(Results)) + { + writer.WritePropertyName("results"u8); + writer.WriteStartArray(); + foreach (var item in Results) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + StartResourceOperationResult 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(StartResourceOperationResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStartResourceOperationResult(document.RootElement, options); + } + + internal static StartResourceOperationResult DeserializeStartResourceOperationResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string description = default; + string type = default; + AzureLocation location = default; + IReadOnlyList results = 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("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + continue; + } + if (property.NameEquals("results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ResourceOperationResult.DeserializeResourceOperationResult(item, options)); + } + results = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StartResourceOperationResult(description, type, location, results ?? 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(StartResourceOperationResult)} does not support writing '{options.Format}' format."); + } + } + + StartResourceOperationResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeStartResourceOperationResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StartResourceOperationResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.cs new file mode 100644 index 000000000000..70152dd089af --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/StartResourceOperationResult.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; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The response from a start request. + public partial class StartResourceOperationResult + { + /// + /// 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 description of the operation response. + /// The type of resources used in the start request eg virtual machines. + /// The location of the start request eg westus. + /// or is null. + internal StartResourceOperationResult(string description, string resourceType, AzureLocation location) + { + Argument.AssertNotNull(description, nameof(description)); + Argument.AssertNotNull(resourceType, nameof(resourceType)); + + Description = description; + ResourceType = resourceType; + Location = location; + Results = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The description of the operation response. + /// The type of resources used in the start request eg virtual machines. + /// The location of the start request eg westus. + /// The results from the start request if no errors exist. + /// Keeps track of any properties unknown to the library. + internal StartResourceOperationResult(string description, string resourceType, AzureLocation location, IReadOnlyList results, IDictionary serializedAdditionalRawData) + { + Description = description; + ResourceType = resourceType; + Location = location; + Results = results; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal StartResourceOperationResult() + { + } + + /// The description of the operation response. + public string Description { get; } + /// The type of resources used in the start request eg virtual machines. + public string ResourceType { get; } + /// The location of the start request eg westus. + public AzureLocation Location { get; } + /// The results from the start request if no errors exist. + public IReadOnlyList Results { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.Serialization.cs new file mode 100644 index 000000000000..e20d0fee4154 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.Serialization.cs @@ -0,0 +1,143 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class SubmitDeallocateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitDeallocateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("schedule"u8); + writer.WriteObjectValue(Schedule, options); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SubmitDeallocateContent 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(SubmitDeallocateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitDeallocateContent(document.RootElement, options); + } + + internal static SubmitDeallocateContent DeserializeSubmitDeallocateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UserRequestSchedule schedule = default; + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("schedule"u8)) + { + schedule = UserRequestSchedule.DeserializeUserRequestSchedule(property.Value, options); + continue; + } + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubmitDeallocateContent(schedule, executionParameters, resources, correlationid, 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(SubmitDeallocateContent)} does not support writing '{options.Format}' format."); + } + } + + SubmitDeallocateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSubmitDeallocateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitDeallocateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.cs new file mode 100644 index 000000000000..999a1ffda59a --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitDeallocateContent.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.ResourceManager.ComputeSchedule.Models +{ + /// The deallocate request for resources. + public partial class SubmitDeallocateContent + { + /// + /// 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 schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , , or is null. + public SubmitDeallocateContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(schedule, nameof(schedule)); + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal SubmitDeallocateContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubmitDeallocateContent() + { + } + + /// The schedule for the request. + public UserRequestSchedule Schedule { get; } + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.Serialization.cs new file mode 100644 index 000000000000..3a05534f90f3 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.Serialization.cs @@ -0,0 +1,143 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class SubmitHibernateContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitHibernateContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("schedule"u8); + writer.WriteObjectValue(Schedule, options); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SubmitHibernateContent 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(SubmitHibernateContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitHibernateContent(document.RootElement, options); + } + + internal static SubmitHibernateContent DeserializeSubmitHibernateContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UserRequestSchedule schedule = default; + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("schedule"u8)) + { + schedule = UserRequestSchedule.DeserializeUserRequestSchedule(property.Value, options); + continue; + } + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubmitHibernateContent(schedule, executionParameters, resources, correlationid, 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(SubmitHibernateContent)} does not support writing '{options.Format}' format."); + } + } + + SubmitHibernateContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSubmitHibernateContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitHibernateContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.cs new file mode 100644 index 000000000000..3d544c3c29be --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitHibernateContent.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the request for hibernate. + public partial class SubmitHibernateContent + { + /// + /// 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 schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , , or is null. + public SubmitHibernateContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(schedule, nameof(schedule)); + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal SubmitHibernateContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubmitHibernateContent() + { + } + + /// The schedule for the request. + public UserRequestSchedule Schedule { get; } + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.Serialization.cs new file mode 100644 index 000000000000..fa8983299214 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.Serialization.cs @@ -0,0 +1,143 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class SubmitStartContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SubmitStartContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("schedule"u8); + writer.WriteObjectValue(Schedule, options); + writer.WritePropertyName("executionParameters"u8); + writer.WriteObjectValue(ExecutionParameters, options); + writer.WritePropertyName("resources"u8); + writer.WriteObjectValue(Resources, options); + writer.WritePropertyName("correlationid"u8); + writer.WriteStringValue(Correlationid); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SubmitStartContent 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(SubmitStartContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSubmitStartContent(document.RootElement, options); + } + + internal static SubmitStartContent DeserializeSubmitStartContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UserRequestSchedule schedule = default; + ScheduledActionExecutionParameterDetail executionParameters = default; + UserRequestResources resources = default; + string correlationid = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("schedule"u8)) + { + schedule = UserRequestSchedule.DeserializeUserRequestSchedule(property.Value, options); + continue; + } + if (property.NameEquals("executionParameters"u8)) + { + executionParameters = ScheduledActionExecutionParameterDetail.DeserializeScheduledActionExecutionParameterDetail(property.Value, options); + continue; + } + if (property.NameEquals("resources"u8)) + { + resources = UserRequestResources.DeserializeUserRequestResources(property.Value, options); + continue; + } + if (property.NameEquals("correlationid"u8)) + { + correlationid = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SubmitStartContent(schedule, executionParameters, resources, correlationid, 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(SubmitStartContent)} does not support writing '{options.Format}' format."); + } + } + + SubmitStartContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSubmitStartContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SubmitStartContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.cs new file mode 100644 index 000000000000..9a2d061e6a1c --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/SubmitStartContent.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.ResourceManager.ComputeSchedule.Models +{ + /// This is the request for start. + public partial class SubmitStartContent + { + /// + /// 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 schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// , , or is null. + public SubmitStartContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid) + { + Argument.AssertNotNull(schedule, nameof(schedule)); + Argument.AssertNotNull(executionParameters, nameof(executionParameters)); + Argument.AssertNotNull(resources, nameof(resources)); + Argument.AssertNotNull(correlationid, nameof(correlationid)); + + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + } + + /// Initializes a new instance of . + /// The schedule for the request. + /// The execution parameters for the request. + /// The resources for the request. + /// Correlationid item. + /// Keeps track of any properties unknown to the library. + internal SubmitStartContent(UserRequestSchedule schedule, ScheduledActionExecutionParameterDetail executionParameters, UserRequestResources resources, string correlationid, IDictionary serializedAdditionalRawData) + { + Schedule = schedule; + ExecutionParameters = executionParameters; + Resources = resources; + Correlationid = correlationid; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SubmitStartContent() + { + } + + /// The schedule for the request. + public UserRequestSchedule Schedule { get; } + /// The execution parameters for the request. + public ScheduledActionExecutionParameterDetail ExecutionParameters { get; } + /// The resources for the request. + internal UserRequestResources Resources { get; } + /// The resource ids used for the request. + public IList ResourcesIds + { + get => Resources?.Ids; + } + + /// Correlationid item. + public string Correlationid { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.Serialization.cs new file mode 100644 index 000000000000..5f89e94e1e76 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.Serialization.cs @@ -0,0 +1,141 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class UserRequestResources : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserRequestResources)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("ids"u8); + writer.WriteStartArray(); + foreach (var item in Ids) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UserRequestResources 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(UserRequestResources)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserRequestResources(document.RootElement, options); + } + + internal static UserRequestResources DeserializeUserRequestResources(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList ids = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ids"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(new ResourceIdentifier(item.GetString())); + } + } + ids = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UserRequestResources(ids, 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(UserRequestResources)} does not support writing '{options.Format}' format."); + } + } + + UserRequestResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUserRequestResources(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserRequestResources)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.cs new file mode 100644 index 000000000000..e4f9ec4a7e76 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestResources.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; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The resources needed for the user request. + public partial class UserRequestResources + { + /// + /// 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 ids used for the request. + /// is null. + public UserRequestResources(IEnumerable ids) + { + Argument.AssertNotNull(ids, nameof(ids)); + + Ids = ids.ToList(); + } + + /// Initializes a new instance of . + /// The resource ids used for the request. + /// Keeps track of any properties unknown to the library. + internal UserRequestResources(IList ids, IDictionary serializedAdditionalRawData) + { + Ids = ids; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal UserRequestResources() + { + } + + /// The resource ids used for the request. + public IList Ids { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.Serialization.cs new file mode 100644 index 000000000000..4099ea4aab6f --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.Serialization.cs @@ -0,0 +1,141 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class UserRequestRetryPolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserRequestRetryPolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(RetryCount)) + { + writer.WritePropertyName("retryCount"u8); + writer.WriteNumberValue(RetryCount.Value); + } + if (Optional.IsDefined(RetryWindowInMinutes)) + { + writer.WritePropertyName("retryWindowInMinutes"u8); + writer.WriteNumberValue(RetryWindowInMinutes.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UserRequestRetryPolicy 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(UserRequestRetryPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserRequestRetryPolicy(document.RootElement, options); + } + + internal static UserRequestRetryPolicy DeserializeUserRequestRetryPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? retryCount = default; + int? retryWindowInMinutes = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("retryCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retryCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("retryWindowInMinutes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retryWindowInMinutes = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UserRequestRetryPolicy(retryCount, retryWindowInMinutes, 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(UserRequestRetryPolicy)} does not support writing '{options.Format}' format."); + } + } + + UserRequestRetryPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUserRequestRetryPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserRequestRetryPolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.cs new file mode 100644 index 000000000000..e993f3c7cf3e --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestRetryPolicy.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.ResourceManager.ComputeSchedule.Models +{ + /// The retry policy for the user request. + public partial class UserRequestRetryPolicy + { + /// + /// 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 UserRequestRetryPolicy() + { + } + + /// Initializes a new instance of . + /// Retry count for user request. + /// Retry window in minutes for user request. + /// Keeps track of any properties unknown to the library. + internal UserRequestRetryPolicy(int? retryCount, int? retryWindowInMinutes, IDictionary serializedAdditionalRawData) + { + RetryCount = retryCount; + RetryWindowInMinutes = retryWindowInMinutes; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Retry count for user request. + public int? RetryCount { get; set; } + /// Retry window in minutes for user request. + public int? RetryWindowInMinutes { get; set; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.Serialization.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.Serialization.cs new file mode 100644 index 000000000000..2e270d710f9a --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.Serialization.cs @@ -0,0 +1,135 @@ +// 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.ResourceManager.ComputeSchedule.Models +{ + public partial class UserRequestSchedule : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UserRequestSchedule)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("deadLine"u8); + writer.WriteStringValue(DeadLine, "O"); + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + writer.WritePropertyName("deadlineType"u8); + writer.WriteStringValue(DeadlineType.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UserRequestSchedule 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(UserRequestSchedule)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUserRequestSchedule(document.RootElement, options); + } + + internal static UserRequestSchedule DeserializeUserRequestSchedule(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset deadLine = default; + string timeZone = default; + ScheduledActionDeadlineType deadlineType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("deadLine"u8)) + { + deadLine = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("timeZone"u8)) + { + timeZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("deadlineType"u8)) + { + deadlineType = new ScheduledActionDeadlineType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UserRequestSchedule(deadLine, timeZone, deadlineType, 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(UserRequestSchedule)} does not support writing '{options.Format}' format."); + } + } + + UserRequestSchedule IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUserRequestSchedule(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UserRequestSchedule)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.cs new file mode 100644 index 000000000000..c3297f8e10c9 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/Models/UserRequestSchedule.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeSchedule.Models +{ + /// The schedule details for the user request. + public partial class UserRequestSchedule + { + /// + /// 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 deadline for the operation. + /// The timezone for the operation. + /// The deadlinetype of the operation, this can either be InitiateAt or CompleteBy. + /// is null. + public UserRequestSchedule(DateTimeOffset deadLine, string timeZone, ScheduledActionDeadlineType deadlineType) + { + Argument.AssertNotNull(timeZone, nameof(timeZone)); + + DeadLine = deadLine; + TimeZone = timeZone; + DeadlineType = deadlineType; + } + + /// Initializes a new instance of . + /// The deadline for the operation. + /// The timezone for the operation. + /// The deadlinetype of the operation, this can either be InitiateAt or CompleteBy. + /// Keeps track of any properties unknown to the library. + internal UserRequestSchedule(DateTimeOffset deadLine, string timeZone, ScheduledActionDeadlineType deadlineType, IDictionary serializedAdditionalRawData) + { + DeadLine = deadLine; + TimeZone = timeZone; + DeadlineType = deadlineType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal UserRequestSchedule() + { + } + + /// The deadline for the operation. + public DateTimeOffset DeadLine { get; } + /// The timezone for the operation. + public string TimeZone { get; } + /// The deadlinetype of the operation, this can either be InitiateAt or CompleteBy. + public ScheduledActionDeadlineType DeadlineType { get; } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ProviderConstants.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..5467c626f981 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/ProviderConstants.cs @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ComputeSchedule +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/RestOperations/ScheduledActionsRestOperations.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/RestOperations/ScheduledActionsRestOperations.cs new file mode 100644 index 000000000000..2e8e1f9c4f63 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Generated/RestOperations/ScheduledActionsRestOperations.cs @@ -0,0 +1,885 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ComputeSchedule.Models; + +namespace Azure.ResourceManager.ComputeSchedule +{ + internal partial class ScheduledActionsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of ScheduledActionsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// The to use. + /// The API version to use for this operation. + /// or is null. + public ScheduledActionsRestOperations(HttpPipeline pipeline, string applicationId, Uri endpoint = null, string apiVersion = default) + { + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? new Uri("https://management.azure.com"); + _apiVersion = apiVersion ?? "2024-08-15-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateSubmitVirtualMachineDeallocateRequestUri(string subscriptionId, string locationparameter, SubmitDeallocateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitDeallocate", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateSubmitVirtualMachineDeallocateRequest(string subscriptionId, string locationparameter, SubmitDeallocateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitDeallocate", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> SubmitVirtualMachineDeallocateAsync(string subscriptionId, string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineDeallocateRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeallocateResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeallocateResourceOperationResult.DeserializeDeallocateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesSubmitDeallocate: submitDeallocate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response SubmitVirtualMachineDeallocate(string subscriptionId, string locationparameter, SubmitDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineDeallocateRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeallocateResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeallocateResourceOperationResult.DeserializeDeallocateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateSubmitVirtualMachineHibernateRequestUri(string subscriptionId, string locationparameter, SubmitHibernateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitHibernate", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateSubmitVirtualMachineHibernateRequest(string subscriptionId, string locationparameter, SubmitHibernateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitHibernate", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> SubmitVirtualMachineHibernateAsync(string subscriptionId, string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineHibernateRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HibernateResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = HibernateResourceOperationResult.DeserializeHibernateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesSubmitHibernate: submitHibernate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response SubmitVirtualMachineHibernate(string subscriptionId, string locationparameter, SubmitHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineHibernateRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HibernateResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = HibernateResourceOperationResult.DeserializeHibernateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateSubmitVirtualMachineStartRequestUri(string subscriptionId, string locationparameter, SubmitStartContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitStart", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateSubmitVirtualMachineStartRequest(string subscriptionId, string locationparameter, SubmitStartContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesSubmitStart", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesSubmitStart: submitStart for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> SubmitVirtualMachineStartAsync(string subscriptionId, string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineStartRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StartResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StartResourceOperationResult.DeserializeStartResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesSubmitStart: submitStart for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response SubmitVirtualMachineStart(string subscriptionId, string locationparameter, SubmitStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateSubmitVirtualMachineStartRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StartResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StartResourceOperationResult.DeserializeStartResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateExecuteVirtualMachineDeallocateRequestUri(string subscriptionId, string locationparameter, ExecuteDeallocateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteDeallocate", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateExecuteVirtualMachineDeallocateRequest(string subscriptionId, string locationparameter, ExecuteDeallocateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteDeallocate", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ExecuteVirtualMachineDeallocateAsync(string subscriptionId, string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineDeallocateRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + DeallocateResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = DeallocateResourceOperationResult.DeserializeDeallocateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesExecuteDeallocate: executeDeallocate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ExecuteVirtualMachineDeallocate(string subscriptionId, string locationparameter, ExecuteDeallocateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineDeallocateRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + DeallocateResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = DeallocateResourceOperationResult.DeserializeDeallocateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateExecuteVirtualMachineHibernateRequestUri(string subscriptionId, string locationparameter, ExecuteHibernateContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteHibernate", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateExecuteVirtualMachineHibernateRequest(string subscriptionId, string locationparameter, ExecuteHibernateContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteHibernate", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ExecuteVirtualMachineHibernateAsync(string subscriptionId, string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineHibernateRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + HibernateResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = HibernateResourceOperationResult.DeserializeHibernateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesExecuteHibernate: executeHibernate for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ExecuteVirtualMachineHibernate(string subscriptionId, string locationparameter, ExecuteHibernateContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineHibernateRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + HibernateResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = HibernateResourceOperationResult.DeserializeHibernateResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateExecuteVirtualMachineStartRequestUri(string subscriptionId, string locationparameter, ExecuteStartContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteStart", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateExecuteVirtualMachineStartRequest(string subscriptionId, string locationparameter, ExecuteStartContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesExecuteStart", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesExecuteStart: executeStart for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ExecuteVirtualMachineStartAsync(string subscriptionId, string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineStartRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + StartResourceOperationResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = StartResourceOperationResult.DeserializeStartResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesExecuteStart: executeStart for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ExecuteVirtualMachineStart(string subscriptionId, string locationparameter, ExecuteStartContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateExecuteVirtualMachineStartRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + StartResourceOperationResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = StartResourceOperationResult.DeserializeStartResourceOperationResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetVirtualMachineOperationStatusRequestUri(string subscriptionId, string locationparameter, GetOperationStatusContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesGetOperationStatus", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetVirtualMachineOperationStatusRequest(string subscriptionId, string locationparameter, GetOperationStatusContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesGetOperationStatus", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> GetVirtualMachineOperationStatusAsync(string subscriptionId, string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGetVirtualMachineOperationStatusRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GetOperationStatusResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GetOperationStatusResult.DeserializeGetOperationStatusResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesGetOperationStatus: getOperationStatus for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response GetVirtualMachineOperationStatus(string subscriptionId, string locationparameter, GetOperationStatusContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGetVirtualMachineOperationStatusRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GetOperationStatusResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GetOperationStatusResult.DeserializeGetOperationStatusResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCancelVirtualMachineOperationsRequestUri(string subscriptionId, string locationparameter, CancelOperationsContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesCancelOperations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCancelVirtualMachineOperationsRequest(string subscriptionId, string locationparameter, CancelOperationsContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesCancelOperations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> CancelVirtualMachineOperationsAsync(string subscriptionId, string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCancelVirtualMachineOperationsRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + CancelOperationsResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = CancelOperationsResult.DeserializeCancelOperationsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesCancelOperations: cancelOperations for a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response CancelVirtualMachineOperations(string subscriptionId, string locationparameter, CancelOperationsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateCancelVirtualMachineOperationsRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + CancelOperationsResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = CancelOperationsResult.DeserializeCancelOperationsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateGetVirtualMachineOperationErrorsRequestUri(string subscriptionId, string locationparameter, GetOperationErrorsContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesGetOperationErrors", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetVirtualMachineOperationErrorsRequest(string subscriptionId, string locationparameter, GetOperationErrorsContent content) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.ComputeSchedule/locations/", false); + uri.AppendPath(locationparameter, true); + uri.AppendPath("/virtualMachinesGetOperationErrors", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content0 = new Utf8JsonRequestContent(); + content0.JsonWriter.WriteObjectValue(content, ModelSerializationExtensions.WireOptions); + request.Content = content0; + _userAgent.Apply(message); + return message; + } + + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> GetVirtualMachineOperationErrorsAsync(string subscriptionId, string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGetVirtualMachineOperationErrorsRequest(subscriptionId, locationparameter, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + GetOperationErrorsResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = GetOperationErrorsResult.DeserializeGetOperationErrorsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// virtualMachinesGetOperationErrors: getOperationErrors associated with an operation on a virtual machine. + /// The ID of the target subscription. The value must be an UUID. + /// The location name. + /// The request body. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response GetVirtualMachineOperationErrors(string subscriptionId, string locationparameter, GetOperationErrorsContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(locationparameter, nameof(locationparameter)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateGetVirtualMachineOperationErrorsRequest(subscriptionId, locationparameter, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + GetOperationErrorsResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = GetOperationErrorsResult.DeserializeGetOperationErrorsResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Properties/AssemblyInfo.cs b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..13d1629cbb24 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/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.ResourceManager.ComputeSchedule.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/computeschedule/Azure.ResourceManager.ComputeSchedule/tests/Azure.ResourceManager.ComputeSchedule.Tests.csproj b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tests/Azure.ResourceManager.ComputeSchedule.Tests.csproj new file mode 100644 index 000000000000..a4b3c437fc65 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tests/Azure.ResourceManager.ComputeSchedule.Tests.csproj @@ -0,0 +1,12 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + diff --git a/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tsp-location.yaml b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tsp-location.yaml new file mode 100644 index 000000000000..ba3052e576a8 --- /dev/null +++ b/sdk/computeschedule/Azure.ResourceManager.ComputeSchedule/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/computeschedule/ComputeSchedule.Management +commit: e6d487a031c060d5d333c1ee745032205def6680 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/computeschedule/ci.yml b/sdk/computeschedule/ci.yml new file mode 100644 index 000000000000..5c2dd96b41b9 --- /dev/null +++ b/sdk/computeschedule/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/computeschedule + - sdk/computeschedule/ci.yml + - sdk/computeschedule/Azure.ResourceManager.ComputeSchedule + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/computeschedule + - sdk/computeschedule/ci.yml + - sdk/computeschedule/Azure.ResourceManager.ComputeSchedule + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: computeschedule + ArtifactName: packages + Artifacts: + - name: Azure.ResourceManager.ComputeSchedule + safeName: AzureResourceManagerComputeSchedule