diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/Azure.ResourceManager.Migrate.sln b/sdk/migrate/Azure.ResourceManager.Migrate/Azure.ResourceManager.Migrate.sln new file mode 100644 index 000000000000..495165badd49 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/Azure.ResourceManager.Migrate.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.ResourceManager.Migrate.Samples", "samples\Azure.ResourceManager.Migrate.Samples.csproj", "{7A2DFF15-5746-49F4-BD0F-C6C35337088A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Migrate", "src\Azure.ResourceManager.Migrate.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.Migrate.Tests", "tests\Azure.ResourceManager.Migrate.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 + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A2DFF15-5746-49F4-BD0F-C6C35337088A}.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/migrate/Azure.ResourceManager.Migrate/CHANGELOG.md b/sdk/migrate/Azure.ResourceManager.Migrate/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/Directory.Build.props b/sdk/migrate/Azure.ResourceManager.Migrate/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/README.md b/sdk/migrate/Azure.ResourceManager.Migrate/README.md new file mode 100644 index 000000000000..63c311d9cf81 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/README.md @@ -0,0 +1,80 @@ +# Microsoft Azure Migrate management client library for .NET + +**[Describe the service briefly first.]** + +This library follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities: + + - Support MSAL.NET, Azure.Identity is out of box for supporting MSAL.NET. + - Support [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. + - HTTP pipeline with custom policies. + - Better error-handling. + - Support uniform telemetry across all languages. + +## Getting started + +### Install the package + +Install the Microsoft Azure Migrate management library for .NET with [NuGet](https://www.nuget.org/): + +```dotnetcli +dotnet add package Azure.ResourceManager.Migrate --prerelease +``` + +### Prerequisites + +* You must have an [Microsoft Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +To create an authenticated client and start interacting with Microsoft Azure resources, see the [quickstart guide here](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). + +## Key concepts + +Key concepts of the Microsoft Azure SDK for .NET can be found [here](https://azure.github.io/azure-sdk/dotnet_introduction.html) + +## Documentation + +Documentation is available to help you learn how to use this package: + +- [Quickstart](https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md). +- [API References](https://learn.microsoft.com/dotnet/api/?view=azure-dotnet). +- [Authentication](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/README.md). + +## Examples + +Code samples for using the management library for .NET can be found in the following locations +- [.NET Management Library Code Samples](https://aka.ms/azuresdk-net-mgmt-samples) + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +For more information about Microsoft Azure SDK, see [this website](https://azure.github.io/azure-sdk/). + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ \ No newline at end of file diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/assets.json b/sdk/migrate/Azure.ResourceManager.Migrate/assets.json new file mode 100644 index 000000000000..7eb82a025442 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/assets.json @@ -0,0 +1,7 @@ + +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "net", + "TagPrefix": "net/migrate/Azure.ResourceManager.Migrate", + "Tag": "" +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Azure.ResourceManager.Migrate.Samples.csproj b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Azure.ResourceManager.Migrate.Samples.csproj new file mode 100644 index 000000000000..c8b72c599c4a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Azure.ResourceManager.Migrate.Samples.csproj @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Collection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Collection.cs new file mode 100644 index 000000000000..ceb677eed395 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Collection.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_AssessedMachineV2Collection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_AssessedMachinesV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/AssessedMachinesV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AssessedMachineV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this AssessedMachineV2Resource + AssessedMachineV2Collection collection = machineAssessmentV2.GetAssessedMachineV2s(); + + // invoke the operation + string assessedMachineName = "machine1"; + AssessedMachineV2Resource result = await collection.GetAsync(assessedMachineName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssessedMachineV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_AssessedMachinesV2OperationsListByParentMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/AssessedMachinesV2Operations_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "AssessedMachineV2_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this AssessedMachineV2Resource + AssessedMachineV2Collection collection = machineAssessmentV2.GetAssessedMachineV2s(); + + // invoke the operation and iterate over the result + int? pageSize = 13; + string continuationToken = "lsuhpxtnundds"; + int? totalRecordCount = 28; + await foreach (AssessedMachineV2Resource item in collection.GetAllAsync(pageSize: pageSize, continuationToken: continuationToken, totalRecordCount: totalRecordCount)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssessedMachineV2Data resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_AssessedMachinesV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/AssessedMachinesV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AssessedMachineV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this AssessedMachineV2Resource + AssessedMachineV2Collection collection = machineAssessmentV2.GetAssessedMachineV2s(); + + // invoke the operation + string assessedMachineName = "machine1"; + bool result = await collection.ExistsAsync(assessedMachineName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_AssessedMachinesV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/AssessedMachinesV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AssessedMachineV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this AssessedMachineV2Resource + AssessedMachineV2Collection collection = machineAssessmentV2.GetAssessedMachineV2s(); + + // invoke the operation + string assessedMachineName = "machine1"; + NullableResponse response = await collection.GetIfExistsAsync(assessedMachineName); + AssessedMachineV2Resource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssessedMachineV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Resource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Resource.cs new file mode 100644 index 000000000000..7966b6779ca5 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_AssessedMachineV2Resource.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_AssessedMachineV2Resource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_AssessedMachinesV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/AssessedMachinesV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AssessedMachineV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AssessedMachineV2Resource created on azure + // for more information of creating AssessedMachineV2Resource, please refer to the document of AssessedMachineV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + string assessedMachineName = "machine1"; + ResourceIdentifier assessedMachineV2ResourceId = AssessedMachineV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName, assessedMachineName); + AssessedMachineV2Resource assessedMachineV2 = client.GetAssessedMachineV2Resource(assessedMachineV2ResourceId); + + // invoke the operation + AssessedMachineV2Resource result = await assessedMachineV2.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssessedMachineV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Collection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Collection.cs new file mode 100644 index 000000000000..e93275e0376f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Collection.cs @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineAssessmentV2Collection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_MachineAssessmentsV2OperationsCreateMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Create_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineAssessmentV2Resource + string projectName = "contosoProject"; + MachineAssessmentV2Collection collection = resourceGroupResource.GetMachineAssessmentV2s(projectName); + + // invoke the operation + string assessmentName = "assessmentName"; + MachineAssessmentV2Data data = new MachineAssessmentV2Data + { + Properties = new MachineAssessmentV2Properties + { + Scope = new Scope + { + ScopeType = ScopeType.ServerGroupId, + ServerGroupId = "f", + AzureResourceGraphQuery = "hfhwuqalmenpcttboxvo", + }, + Settings = new MachineAssessmentSettings + { + AzureLocation = "rsequlcso", + Currency = AzureCurrency.Unknown, + ScalingFactor = 9F, + DiscountPercentage = 5F, + SizingCriterion = AssessmentSizingCriterion.PerformanceBased, + PerformanceData = new PerformanceData + { + Percentile = new Percentile("Unknown"), + TimeRange = TimeRange.Day, + PerfDataStartOn = DateTimeOffset.Parse("2025-02-21T05:47:51.336Z"), + PerfDataEndOn = DateTimeOffset.Parse("2025-02-21T05:47:51.336Z"), + }, + SavingsSettings = new SavingsSettings + { + SavingsOptions = SavingsOption.None, + AzureOfferCode = AzureOffer.Unknown, + }, + BillingSettings = new BillingSettings + { + LicensingProgram = LicensingProgram.Retail, + SubscriptionId = "lee", + }, + EnvironmentType = EnvironmentType.Production, + AzureSecurityOfferingType = AzureSecurityOfferingType.NO, + AzureDiskTypes = { AzureDiskType.Unknown }, + AzurePricingTier = AzurePricingTier.Standard, + AzureStorageRedundancy = AzureStorageRedundancy.Unknown, + AzureHybridUseBenefit = AzureHybridUseBenefit.Unknown, + LinuxAzureHybridUseBenefit = AzureHybridUseBenefit.Unknown, + AzureVmFamilies = { AzureVmFamily.Unknown }, + VmUptime = new VmUptime + { + DaysPerMonth = 9, + HoursPerDay = 10, + }, + }, + Details = new AssessmentDetails(), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assessmentName, data); + MachineAssessmentV2Resource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineAssessmentsV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineAssessmentV2Resource + string projectName = "contosoProject"; + MachineAssessmentV2Collection collection = resourceGroupResource.GetMachineAssessmentV2s(projectName); + + // invoke the operation + string assessmentName = "assessmentName"; + MachineAssessmentV2Resource result = await collection.GetAsync(assessmentName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_MachineAssessmentsV2OperationsListByParentMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineAssessmentV2Resource + string projectName = "contosoProject"; + MachineAssessmentV2Collection collection = resourceGroupResource.GetMachineAssessmentV2s(projectName); + + // invoke the operation and iterate over the result + await foreach (MachineAssessmentV2Resource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_MachineAssessmentsV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineAssessmentV2Resource + string projectName = "contosoProject"; + MachineAssessmentV2Collection collection = resourceGroupResource.GetMachineAssessmentV2s(projectName); + + // invoke the operation + string assessmentName = "assessmentName"; + bool result = await collection.ExistsAsync(assessmentName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_MachineAssessmentsV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineAssessmentV2Resource + string projectName = "contosoProject"; + MachineAssessmentV2Collection collection = resourceGroupResource.GetMachineAssessmentV2s(projectName); + + // invoke the operation + string assessmentName = "assessmentName"; + NullableResponse response = await collection.GetIfExistsAsync(assessmentName); + MachineAssessmentV2Resource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Resource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Resource.cs new file mode 100644 index 000000000000..93a730e77754 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2Resource.cs @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Migrate.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineAssessmentV2Resource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineAssessmentsV2OperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // invoke the operation + MachineAssessmentV2Resource result = await machineAssessmentV2.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_MachineAssessmentsV2OperationsDeleteMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // invoke the operation + await machineAssessmentV2.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_MachineAssessmentsV2OperationsCreateMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_Create_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // invoke the operation + MachineAssessmentV2Data data = new MachineAssessmentV2Data + { + Properties = new MachineAssessmentV2Properties + { + Scope = new Scope + { + ScopeType = ScopeType.ServerGroupId, + ServerGroupId = "f", + AzureResourceGraphQuery = "hfhwuqalmenpcttboxvo", + }, + Settings = new MachineAssessmentSettings + { + AzureLocation = "rsequlcso", + Currency = AzureCurrency.Unknown, + ScalingFactor = 9F, + DiscountPercentage = 5F, + SizingCriterion = AssessmentSizingCriterion.PerformanceBased, + PerformanceData = new PerformanceData + { + Percentile = new Percentile("Unknown"), + TimeRange = TimeRange.Day, + PerfDataStartOn = DateTimeOffset.Parse("2025-02-21T05:47:51.336Z"), + PerfDataEndOn = DateTimeOffset.Parse("2025-02-21T05:47:51.336Z"), + }, + SavingsSettings = new SavingsSettings + { + SavingsOptions = SavingsOption.None, + AzureOfferCode = AzureOffer.Unknown, + }, + BillingSettings = new BillingSettings + { + LicensingProgram = LicensingProgram.Retail, + SubscriptionId = "lee", + }, + EnvironmentType = EnvironmentType.Production, + AzureSecurityOfferingType = AzureSecurityOfferingType.NO, + AzureDiskTypes = { AzureDiskType.Unknown }, + AzurePricingTier = AzurePricingTier.Standard, + AzureStorageRedundancy = AzureStorageRedundancy.Unknown, + AzureHybridUseBenefit = AzureHybridUseBenefit.Unknown, + LinuxAzureHybridUseBenefit = AzureHybridUseBenefit.Unknown, + AzureVmFamilies = { AzureVmFamily.Unknown }, + VmUptime = new VmUptime + { + DaysPerMonth = 9, + HoursPerDay = 10, + }, + }, + Details = new AssessmentDetails(), + }, + }; + ArmOperation lro = await machineAssessmentV2.UpdateAsync(WaitUntil.Completed, data); + MachineAssessmentV2Resource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task DownloadUrl_GetDownloadURLForTheAssessmentReport() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentsV2Operations_DownloadUrl_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentsV2Operations_DownloadUrl" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // invoke the operation + DownloadUrlContent content = new DownloadUrlContent(); + ArmOperation lro = await machineAssessmentV2.DownloadUrlAsync(WaitUntil.Completed, content); + DownloadUri result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryCollection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryCollection.cs new file mode 100644 index 000000000000..9d704d70c9dc --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryCollection.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineAssessmentV2SummaryCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineAssessmentV2SummaryOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentV2SummaryOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2Summary_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this MachineAssessmentV2SummaryResource + MachineAssessmentV2SummaryCollection collection = machineAssessmentV2.GetMachineAssessmentV2Summaries(); + + // invoke the operation + string summaryName = "PaaSPreferred"; + MachineAssessmentV2SummaryResource result = await collection.GetAsync(summaryName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2SummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_MachineAssessmentV2SummaryOperationsListByParentMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentV2SummaryOperations_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2Summary_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this MachineAssessmentV2SummaryResource + MachineAssessmentV2SummaryCollection collection = machineAssessmentV2.GetMachineAssessmentV2Summaries(); + + // invoke the operation and iterate over the result + await foreach (MachineAssessmentV2SummaryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2SummaryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_MachineAssessmentV2SummaryOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentV2SummaryOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2Summary_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this MachineAssessmentV2SummaryResource + MachineAssessmentV2SummaryCollection collection = machineAssessmentV2.GetMachineAssessmentV2Summaries(); + + // invoke the operation + string summaryName = "PaaSPreferred"; + bool result = await collection.ExistsAsync(summaryName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_MachineAssessmentV2SummaryOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentV2SummaryOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2Summary_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2Resource created on azure + // for more information of creating MachineAssessmentV2Resource, please refer to the document of MachineAssessmentV2Resource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + ResourceIdentifier machineAssessmentV2ResourceId = MachineAssessmentV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName); + MachineAssessmentV2Resource machineAssessmentV2 = client.GetMachineAssessmentV2Resource(machineAssessmentV2ResourceId); + + // get the collection of this MachineAssessmentV2SummaryResource + MachineAssessmentV2SummaryCollection collection = machineAssessmentV2.GetMachineAssessmentV2Summaries(); + + // invoke the operation + string summaryName = "PaaSPreferred"; + NullableResponse response = await collection.GetIfExistsAsync(summaryName); + MachineAssessmentV2SummaryResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2SummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryResource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryResource.cs new file mode 100644 index 000000000000..ddec47394136 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineAssessmentV2SummaryResource.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineAssessmentV2SummaryResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineAssessmentV2SummaryOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineAssessmentV2SummaryOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineAssessmentV2Summary_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineAssessmentV2SummaryResource created on azure + // for more information of creating MachineAssessmentV2SummaryResource, please refer to the document of MachineAssessmentV2SummaryResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + string assessmentName = "assessmentName"; + string summaryName = "PaaSPreferred"; + ResourceIdentifier machineAssessmentV2SummaryResourceId = MachineAssessmentV2SummaryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, assessmentName, summaryName); + MachineAssessmentV2SummaryResource machineAssessmentV2Summary = client.GetMachineAssessmentV2SummaryResource(machineAssessmentV2SummaryResourceId); + + // invoke the operation + MachineAssessmentV2SummaryResource result = await machineAssessmentV2Summary.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineAssessmentV2SummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionCollection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionCollection.cs new file mode 100644 index 000000000000..c5ac346d6d0e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionCollection.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineGraphAssessmentOptionCollection + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineGraphAssessmentOptionsOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineGraphAssessmentOptionsOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineGraphAssessmentOptions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineGraphAssessmentOptionResource + string projectName = "contosoProject"; + MachineGraphAssessmentOptionCollection collection = resourceGroupResource.GetMachineGraphAssessmentOptions(projectName); + + // invoke the operation + MachineGraphAssessmentOptionResource result = await collection.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineGraphAssessmentOptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_MachineGraphAssessmentOptionsOperationsListByParentMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineGraphAssessmentOptionsOperations_ListByParent_MaximumSet_Gen.json + // this example is just showing the usage of "MachineGraphAssessmentOptions_ListByParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineGraphAssessmentOptionResource + string projectName = "contosoProject"; + MachineGraphAssessmentOptionCollection collection = resourceGroupResource.GetMachineGraphAssessmentOptions(projectName); + + // invoke the operation and iterate over the result + await foreach (MachineGraphAssessmentOptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineGraphAssessmentOptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_MachineGraphAssessmentOptionsOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineGraphAssessmentOptionsOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineGraphAssessmentOptions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineGraphAssessmentOptionResource + string projectName = "contosoProject"; + MachineGraphAssessmentOptionCollection collection = resourceGroupResource.GetMachineGraphAssessmentOptions(projectName); + + // invoke the operation + bool result = await collection.ExistsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_MachineGraphAssessmentOptionsOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineGraphAssessmentOptionsOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineGraphAssessmentOptions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this MachineGraphAssessmentOptionResource + string projectName = "contosoProject"; + MachineGraphAssessmentOptionCollection collection = resourceGroupResource.GetMachineGraphAssessmentOptions(projectName); + + // invoke the operation + NullableResponse response = await collection.GetIfExistsAsync(); + MachineGraphAssessmentOptionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineGraphAssessmentOptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionResource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionResource.cs new file mode 100644 index 000000000000..9c1d9800b130 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/samples/Generated/Samples/Sample_MachineGraphAssessmentOptionResource.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.ResourceManager.Migrate.Samples +{ + public partial class Sample_MachineGraphAssessmentOptionResource + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_MachineGraphAssessmentOptionsOperationsGetMaximumSet() + { + // Generated from example definition: 2024-03-03-preview/MachineGraphAssessmentOptionsOperations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "MachineGraphAssessmentOptions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineGraphAssessmentOptionResource created on azure + // for more information of creating MachineGraphAssessmentOptionResource, please refer to the document of MachineGraphAssessmentOptionResource + string subscriptionId = "AEDD0824-BBE9-4E7C-8909-F46C68EA6BB9"; + string resourceGroupName = "rgmachineAssessments"; + string projectName = "contosoProject"; + ResourceIdentifier machineGraphAssessmentOptionResourceId = MachineGraphAssessmentOptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName); + MachineGraphAssessmentOptionResource machineGraphAssessmentOption = client.GetMachineGraphAssessmentOptionResource(machineGraphAssessmentOptionResourceId); + + // invoke the operation + MachineGraphAssessmentOptionResource result = await machineGraphAssessmentOption.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineGraphAssessmentOptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Azure.ResourceManager.Migrate.csproj b/sdk/migrate/Azure.ResourceManager.Migrate/src/Azure.ResourceManager.Migrate.csproj new file mode 100644 index 000000000000..1e9a2162550b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Azure.ResourceManager.Migrate.csproj @@ -0,0 +1,8 @@ + + + Azure Resource Manager client SDK for Azure resource provider Migrate. + 1.0.0-beta.1 + azure;management;arm;resource manager;migrate + Azure.ResourceManager.Migrate + + diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/ArmMigrateModelFactory.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/ArmMigrateModelFactory.cs new file mode 100644 index 000000000000..880eb99f8fcd --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/ArmMigrateModelFactory.cs @@ -0,0 +1,688 @@ +// 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; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Model factory for models. + public static partial class ArmMigrateModelFactory + { + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static MachineAssessmentV2Data MachineAssessmentV2Data(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, MachineAssessmentV2Properties properties = null) + { + return new MachineAssessmentV2Data( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Gets or sets the scope of assessment. + /// Gets or sets the settings for the assessment. + /// Gets or sets the details of the assessment. + /// A new instance for mocking. + public static MachineAssessmentV2Properties MachineAssessmentV2Properties(ProvisioningState? provisioningState = null, Scope scope = null, MachineAssessmentSettings settings = null, AssessmentDetails details = null) + { + return new MachineAssessmentV2Properties(provisioningState, scope, settings, details, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Confidence Rating in Percentage. + /// Last time when rates were queried. + /// Date and Time when assessment was created. + /// Date and Time when assessment was last updated. + /// Whether assessment is in valid state and all machines have been assessed. + /// A new instance for mocking. + public static AssessmentDetails AssessmentDetails(float? confidenceRatingInPercentage = null, DateTimeOffset? pricesTimestamp = null, DateTimeOffset? createdTimestamp = null, DateTimeOffset? updatedTimestamp = null, AssessmentStatus? status = null) + { + return new AssessmentDetails( + confidenceRatingInPercentage, + pricesTimestamp, + createdTimestamp, + updatedTimestamp, + status, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Hyperlink to download report. + /// Expiry date of download url. + /// A new instance for mocking. + public static DownloadUri DownloadUri(string assessmentReportUri = null, DateTimeOffset expireOn = default) + { + return new DownloadUri(assessmentReportUri, expireOn, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static AssessedMachineV2Data AssessedMachineV2Data(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, AssessedMachineV2Properties properties = null) + { + return new AssessedMachineV2Data( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The workload type. + /// The linkages list. + /// The recommendation list. + /// The assessed machine extended details. + /// When was machine first created. + /// When was machine last updated. + /// A new instance for mocking. + public static AssessedMachineV2Properties AssessedMachineV2Properties(MigrateWorkloadType? workloadType = null, IEnumerable linkages = null, IEnumerable recommendations = null, AssessedMachineExtendedDetails extendedDetails = null, DateTimeOffset? createdTimestamp = null, DateTimeOffset? updatedTimestamp = null) + { + linkages ??= new List(); + recommendations ??= new List(); + + return new AssessedMachineV2Properties( + workloadType, + linkages?.ToList(), + recommendations?.ToList(), + extendedDetails, + createdTimestamp, + updatedTimestamp, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The workload name. + /// The linkage type. + /// The linkage kind. + /// The arm id. + /// A new instance for mocking. + public static Linkages Linkages(string workloadName = null, LinkageType? linkageType = null, LinkageKind? kind = null, string armId = null) + { + return new Linkages(workloadName, linkageType, kind, armId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The configuration data. + /// The recommended details. + /// The migration Platform. + /// The confidence score. + /// The migration suitability. + /// The security suitability. + /// The total cost details. + /// The total cost details. + /// The migration issues list. + /// The Skus list. + /// VM Security Suitability Results. + /// Recommended security type for the VM. + /// A new instance for mocking. + public static MachineAssessmentRecommendation MachineAssessmentRecommendation(Configuration configuration = null, IEnumerable recommendedForStrategies = null, MigrationPlatform? migrationPlatform = null, float? confidenceScore = null, CloudSuitabilityCommon? migrationSuitabilityReadiness = null, CloudSuitabilityCommon? securitySuitabilityReadiness = null, IEnumerable totalCost = null, IEnumerable totalSavings = null, IEnumerable migrationIssues = null, IEnumerable skus = null, IEnumerable vmSecuritySuitabilityResults = null, AzureVmSecurityType? recommendedVmSecurityType = null) + { + recommendedForStrategies ??= new List(); + totalCost ??= new List(); + totalSavings ??= new List(); + migrationIssues ??= new List(); + skus ??= new List(); + vmSecuritySuitabilityResults ??= new List(); + + return new MachineAssessmentRecommendation( + configuration, + recommendedForStrategies != null ? new RecommendedFor(recommendedForStrategies?.ToList(), serializedAdditionalRawData: null) : null, + migrationPlatform, + confidenceScore, + migrationSuitabilityReadiness != null ? new MigrationSuitability(migrationSuitabilityReadiness, serializedAdditionalRawData: null) : null, + securitySuitabilityReadiness != null ? new SecuritySuitability(securitySuitabilityReadiness, serializedAdditionalRawData: null) : null, + totalCost?.ToList(), + totalSavings?.ToList(), + migrationIssues?.ToList(), + skus?.ToList(), + vmSecuritySuitabilityResults?.ToList(), + recommendedVmSecurityType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The azure target. + /// The azure target. + /// A new instance for mocking. + public static Configuration Configuration(AzureTarget? azureTarget = null, AssessmentSizingCriterion? sizingCriterion = null) + { + return new Configuration(azureTarget, sizingCriterion, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The savings options. + /// The sku cost details per azure offer type. + /// A new instance for mocking. + public static CostDetailsCommon CostDetailsCommon(SavingsOption? savingOptions = null, IEnumerable costDetail = null) + { + costDetail ??= new List(); + + return new CostDetailsCommon(savingOptions, costDetail?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// A new instance for mocking. + public static NameValuePairCostType NameValuePairCostType(CostType? name = null, float? value = null) + { + return new NameValuePairCostType(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The savings options. + /// The sku cost details per azure offer type. + /// A new instance for mocking. + public static SavingsDetailsCommon SavingsDetailsCommon(SavingsOption? savingOptions = null, IEnumerable savingsDetail = null) + { + savingsDetail ??= new List(); + + return new SavingsDetailsCommon(savingOptions, savingsDetail?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// A new instance for mocking. + public static NameValuePairSavingsType NameValuePairSavingsType(SavingsType? name = null, float? value = null) + { + return new NameValuePairSavingsType(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The issue id. + /// The issue category. + /// The issue description. + /// The possible causes. + /// The recommended action. + /// The more information list. + /// A new instance for mocking. + public static MigrationIssues MigrationIssues(string issueCode = null, MigrationIssuesCategory? issueCategory = null, string issueDescription = null, string possibleCause = null, IEnumerable recommendedActions = null, IEnumerable moreInformation = null) + { + recommendedActions ??= new List(); + moreInformation ??= new List(); + + return new MigrationIssues( + issueCode, + issueCategory, + issueDescription, + possibleCause, + recommendedActions?.ToList(), + moreInformation?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The title of the information. + /// The URL of the information. + /// A new instance for mocking. + public static MoreInformation MoreInformation(string title = null, string uri = null) + { + return new MoreInformation(title, uri, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The Sku kind. + /// The resource uri. + /// The sku name. + /// The sku id. + /// The sku type. + /// The source name. + /// The sku details. + /// A new instance for mocking. + public static SkusMigrationSuitability SkusMigrationSuitability(SkuKind? kind = null, string resourceUri = null, string displayName = null, string id = null, SkuType? type = null, IEnumerable sources = null, SkuDetails details = null) + { + sources ??= new List(); + + return new SkusMigrationSuitability( + kind, + resourceUri, + displayName, + id, + type, + sources?.ToList(), + details, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The sku name. + /// The sku type. + /// A new instance for mocking. + public static SourceRecommendationMigrationSuitability SourceRecommendationMigrationSuitability(string name = null, CloudSuitabilityCommon? migrationSuitabilityReadiness = null) + { + return new SourceRecommendationMigrationSuitability(name, migrationSuitabilityReadiness != null ? new MigrationSuitability(migrationSuitabilityReadiness, serializedAdditionalRawData: null) : null, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The sku type. + /// The sku name. + /// The capabilities. + /// The sku cost details. + /// The sku savings details. + /// A new instance for mocking. + public static SkuDetails SkuDetails(SkuType? skuType = null, string skuName = null, IEnumerable capabilities = null, IEnumerable totalCost = null, IEnumerable totalSavings = null) + { + capabilities ??= new List(); + totalCost ??= new List(); + totalSavings ??= new List(); + + return new SkuDetails( + skuType, + skuName, + capabilities?.ToList(), + totalCost?.ToList(), + totalSavings?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// A new instance for mocking. + public static NameValuePair NameValuePair(string name = null, string value = null) + { + return new NameValuePair(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets and sets the security type for this secure VM. + /// Gets the suitability for this secure VM. + /// Gets the security suitability details for this VM. + /// A new instance for mocking. + public static VmSecuritySuitability VmSecuritySuitability(AzureVmSecurityType vmSecurityType = default, CloudSuitabilityCommon securitySuitability = default, IEnumerable securitySuitabilityDetails = null) + { + securitySuitabilityDetails ??= new List(); + + return new VmSecuritySuitability(vmSecurityType, securitySuitability, securitySuitabilityDetails?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Display Name of the Machine. + /// Gets the product support status related details. + /// Dictionary of disks attached to the machine. Key is ID of disk. Value is a disk object. + /// Gets or sets the processor details of the host. + /// + /// List of Network Adapters that were assessed as part of this machine's + /// assessment. + /// + /// Assessed machine type. + /// Boot type of machine discovered in private data center. + /// Operating system as reported by datacenter management solution. + /// Operating system as reported by datacenter management solution. + /// Operating system version as reported by datacenter management solution. + /// Operating system architecture as reported by datacenter management solution. + /// Description for the machine. + /// Megabytes of memory found allocated for the machine in private data center. + /// Number of CPU cores found on the machine. + /// + /// Percentile of Percentage of Cores Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + /// + /// Percentile of Percentage of Memory Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + /// List of errors for this machine. + /// A new instance for mocking. + public static AssessedMachineExtendedDetails AssessedMachineExtendedDetails(string displayName = null, ProductSupportStatus productSupportStatus = null, IEnumerable disks = null, ProcessorInfo hostProcessor = null, IEnumerable networkAdapters = null, AssessedMachineType? assessedMachineType = null, MachineBootType? bootType = null, string operatingSystemType = null, string operatingSystemName = null, string operatingSystemVersion = null, GuestOperatingSystemArchitecture? operatingSystemArchitecture = null, string description = null, float? megabytesOfMemory = null, int? numberOfCores = null, float? percentageCoresUtilization = null, float? percentageMemoryUtilization = null, IEnumerable errors = null) + { + disks ??= new List(); + networkAdapters ??= new List(); + errors ??= new List(); + + return new AssessedMachineExtendedDetails( + displayName, + productSupportStatus, + disks?.ToList(), + hostProcessor, + networkAdapters?.ToList(), + assessedMachineType, + bootType, + operatingSystemType, + operatingSystemName, + operatingSystemVersion, + operatingSystemArchitecture, + description, + megabytesOfMemory, + numberOfCores, + percentageCoresUtilization, + percentageMemoryUtilization, + errors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets current version of ServicePack. + /// Gets or sets ServicePack of the product. + /// Gets or sets the Extended Security Update ESU status. + /// Gets or sets the support status of the product. + /// Gets or sets the ETA. + /// Gets or sets the current ESU support year. + /// Gets or sets the main stream end date of the product. + /// Gets or sets the extended support end date of the product. + /// Gets or sets the extended security update year 1 end date of the product. + /// Gets or sets the extended security update year 2 end date of the product. + /// Gets or sets the extended security update year 3 end date of the product. + /// A new instance for mocking. + public static ProductSupportStatus ProductSupportStatus(string currentVersion = null, string servicePackStatus = null, string esuStatus = null, string supportStatus = null, int? eta = null, string currentEsuYear = null, DateTimeOffset? mainstreamEndOn = null, DateTimeOffset? extendedSupportEndOn = null, DateTimeOffset? extendedSecurityUpdateYear1EndOn = null, DateTimeOffset? extendedSecurityUpdateYear2EndOn = null, DateTimeOffset? extendedSecurityUpdateYear3EndOn = null) + { + return new ProductSupportStatus( + currentVersion, + servicePackStatus, + esuStatus, + supportStatus, + eta, + currentEsuYear, + mainstreamEndOn, + extendedSupportEndOn, + extendedSecurityUpdateYear1EndOn, + extendedSecurityUpdateYear2EndOn, + extendedSecurityUpdateYear3EndOn, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The disk name. + /// The disk display name. + /// Gets the gigabytes provisioned. + /// Gets the megabytes per second of read. + /// Gets the megabytes per second of write. + /// Gets the number of read operations per second. + /// Gets the number of write operations per second. + /// A new instance for mocking. + public static AssessedDiskDataV3 AssessedDiskDataV3(string name = null, string displayName = null, float? gigabytesProvisioned = null, float? megabytesPerSecondOfRead = null, float? megabytesPerSecondOfWrite = null, float? numberOfReadOperationsPerSecond = null, float? numberOfWriteOperationsPerSecond = null) + { + return new AssessedDiskDataV3( + name, + displayName, + gigabytesProvisioned, + megabytesPerSecondOfRead, + megabytesPerSecondOfWrite, + numberOfReadOperationsPerSecond, + numberOfWriteOperationsPerSecond, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets the name \ model of a processor. + /// Gets or sets the number of sockets. + /// Gets or sets the number of cores in a socket. + /// A new instance for mocking. + public static ProcessorInfo ProcessorInfo(string name = null, int? numberOfSockets = null, int? numberOfCoresPerSocket = null) + { + return new ProcessorInfo(name, numberOfSockets, numberOfCoresPerSocket, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The disk name. + /// Gets the net gigabytes transmitted per month. + /// Gets the mac address. + /// Gets the ip addresses. + /// Gets the megabytes per second received. + /// Gets the megabytes per second transmitted. + /// Display Name of the Machine. + /// A new instance for mocking. + public static AssessedMachineNetworkAdaptersV3 AssessedMachineNetworkAdaptersV3(string name = null, float? netGigabytesTransmittedPerMonth = null, string macAddress = null, IEnumerable ipAddresses = null, float? megabytesPerSecondRecieved = null, float? megabytesPerSecondTransmitted = null, string displayName = null) + { + ipAddresses ??= new List(); + + return new AssessedMachineNetworkAdaptersV3( + name, + netGigabytesTransmittedPerMonth, + macAddress, + ipAddresses?.ToList(), + megabytesPerSecondRecieved, + megabytesPerSecondTransmitted, + displayName, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets the error ID. + /// Gets the error code. + /// Gets the Run as account ID. + /// Gets the Appliance name. + /// Gets the error message. + /// Gets the error summary message. + /// Gets the agent scenario where this error occurred. + /// Gets the error possible causes. + /// Gets the recommended action for the error. + /// Gets the error severity. + /// Gets the error message parameters. + /// Gets the time stamp when the error was updated. + /// Gets the type of assessment impacted by this error. + /// A new instance for mocking. + public static Error Error(int? id = null, string code = null, string runAsAccountId = null, string applianceName = null, string message = null, string summaryMessage = null, string agentScenario = null, string possibleCauses = null, string recommendedAction = null, string severity = null, IEnumerable messageParameters = null, DateTimeOffset? updatedTimeStamp = null, string impactedAssessmentType = null) + { + messageParameters ??= new List(); + + return new Error( + id, + code, + runAsAccountId, + applianceName, + message, + summaryMessage, + agentScenario, + possibleCauses, + recommendedAction, + severity, + messageParameters?.ToList(), + updatedTimeStamp, + impactedAssessmentType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static MachineAssessmentV2SummaryData MachineAssessmentV2SummaryData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, SummaryProperties properties = null) + { + return new MachineAssessmentV2SummaryData( + id, + name, + resourceType, + systemData, + properties, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The summary type. + /// The summary name. + /// The source details list. + /// The target details list. + /// The target source mapping. + /// The cost components. + /// The cost components. + /// A new instance for mocking. + public static SummaryProperties SummaryProperties(SummaryType? summaryType = null, string summaryName = null, IEnumerable sources = null, IEnumerable targets = null, IEnumerable targetSourceMapping = null, IEnumerable costComponents = null, IEnumerable savingsComponents = null) + { + sources ??= new List(); + targets ??= new List(); + targetSourceMapping ??= new List(); + costComponents ??= new List(); + savingsComponents ??= new List(); + + return new SummaryProperties( + summaryType, + summaryName, + sources?.ToList(), + targets?.ToList(), + targetSourceMapping?.ToList(), + costComponents?.ToList(), + savingsComponents?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The source name. + /// The source type. + /// The migration platform. + /// The count of a type of source. + /// A new instance for mocking. + public static SourceDetails SourceDetails(AssessmentSource? sourceName = null, MigrateWorkloadType? sourceType = null, MigrationPlatform? platform = null, int? count = null) + { + return new SourceDetails(sourceName, sourceType, platform, count, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The target name. + /// The target type. + /// The migration platform. + /// The count of a type of source. + /// A new instance for mocking. + public static TargetDetails TargetDetails(AzureTarget? targetName = null, MigrateWorkloadType? targetType = null, MigrationPlatform? platform = null, int? count = null) + { + return new TargetDetails(targetName, targetType, platform, count, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The source name. + /// The target name. + /// The count of a type of source. + /// The count of a type of target. + /// The migration details. + /// The management details. + /// The cost details. + /// The savings details. + /// The confidence score. + /// A new instance for mocking. + public static TargetSourcePair TargetSourcePair(AssessmentSource? sourceRef = null, AzureTarget? targetRef = null, int? sourceCount = null, int? targetCount = null, MigrationDetails migrationDetails = null, IEnumerable managementDetails = null, IEnumerable costDetails = null, IEnumerable savingsDetails = null, double? confidenceScore = null) + { + managementDetails ??= new List(); + costDetails ??= new List(); + savingsDetails ??= new List(); + + return new TargetSourcePair( + sourceRef, + targetRef, + sourceCount, + targetCount, + migrationDetails, + managementDetails?.ToList(), + costDetails?.ToList(), + savingsDetails?.ToList(), + confidenceScore, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The readiness summary. + /// The migration type. + /// A new instance for mocking. + public static MigrationDetails MigrationDetails(IEnumerable readinessSummary = null, MigrationType? migrationType = null) + { + readinessSummary ??= new List(); + + return new MigrationDetails(readinessSummary?.ToList(), migrationType, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// A new instance for mocking. + public static NameValuePairCloudSuitabilityCommon NameValuePairCloudSuitabilityCommon(CloudSuitabilityCommon? name = null, int? value = null) + { + return new NameValuePairCloudSuitabilityCommon(name, value, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The management summary name. + /// The management suitability summary. + /// A new instance for mocking. + public static ManagementDetails ManagementDetails(AzureManagementOfferingType? name = null, IEnumerable readinessSummary = null) + { + readinessSummary ??= new List(); + + return new ManagementDetails(name, readinessSummary?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// A new instance for mocking. + public static MachineGraphAssessmentOptionData MachineGraphAssessmentOptionData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IReadOnlyDictionary machineGraphAssessmentOptionsEdges = null) + { + machineGraphAssessmentOptionsEdges ??= new Dictionary(); + + return new MachineGraphAssessmentOptionData( + id, + name, + resourceType, + systemData, + machineGraphAssessmentOptionsEdges != null ? new MachineGraphAssessmentOptionsProperties(machineGraphAssessmentOptionsEdges, serializedAdditionalRawData: null) : null, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Gets or sets the Azure Locations. + /// Gets or sets the Azure Currency. + /// Gets or sets the Assessment Savings Options. + /// Gets or sets the Licensing Program. + /// Gets or sets the Azure VM families. + /// Gets or sets the Azure VM family categories. + /// Gets or sets the premium disk support. + /// Gets or sets the premium disk support. + /// Gets or sets the Azure Offer Code. + /// Gets or sets the Azure VM security options. + /// A new instance for mocking. + public static MachineAssessmentOptionsOutboundEdgeGroup MachineAssessmentOptionsOutboundEdgeGroup(IEnumerable targetLocations = null, IEnumerable currencies = null, IEnumerable savingsOptions = null, IEnumerable licensingProgram = null, IEnumerable azureVmFamilies = null, IEnumerable azureVmFamilyCategories = null, IEnumerable premiumDiskSupport = null, IEnumerable ultraDiskSupport = null, IEnumerable azureOfferCode = null, IEnumerable azureVmSecurityOptions = null) + { + targetLocations ??= new List(); + currencies ??= new List(); + savingsOptions ??= new List(); + licensingProgram ??= new List(); + azureVmFamilies ??= new List(); + azureVmFamilyCategories ??= new List(); + premiumDiskSupport ??= new List(); + ultraDiskSupport ??= new List(); + azureOfferCode ??= new List(); + azureVmSecurityOptions ??= new List(); + + return new MachineAssessmentOptionsOutboundEdgeGroup( + targetLocations?.ToList(), + currencies?.ToList(), + savingsOptions?.ToList(), + licensingProgram?.ToList(), + azureVmFamilies?.ToList(), + azureVmFamilyCategories?.ToList(), + premiumDiskSupport?.ToList(), + ultraDiskSupport?.ToList(), + azureOfferCode?.ToList(), + azureVmSecurityOptions?.ToList(), + serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Collection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Collection.cs new file mode 100644 index 000000000000..18b71872ce96 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Collection.cs @@ -0,0 +1,403 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get an instance call the GetAssessedMachineV2s method from an instance of . + /// + public partial class AssessedMachineV2Collection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics; + private readonly AssessedMachinesV2RestOperations _assessedMachineV2AssessedMachinesV2OperationsRestClient; + + /// Initializes a new instance of the class for mocking. + protected AssessedMachineV2Collection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal AssessedMachineV2Collection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", AssessedMachineV2Resource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(AssessedMachineV2Resource.ResourceType, out string assessedMachineV2AssessedMachinesV2OperationsApiVersion); + _assessedMachineV2AssessedMachinesV2OperationsRestClient = new AssessedMachinesV2RestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, assessedMachineV2AssessedMachinesV2OperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != MachineAssessmentV2Resource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, MachineAssessmentV2Resource.ResourceType), nameof(id)); + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.Get"); + scope.Start(); + try + { + var response = await _assessedMachineV2AssessedMachinesV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.Get"); + scope.Start(); + try + { + var response = _assessedMachineV2AssessedMachinesV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List AssessedMachineV2 resources by MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines + /// + /// + /// Operation Id + /// AssessedMachineV2_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _assessedMachineV2AssessedMachinesV2OperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, pageSizeHint, continuationToken, totalRecordCount); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _assessedMachineV2AssessedMachinesV2OperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, pageSizeHint, continuationToken, totalRecordCount); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new AssessedMachineV2Resource(Client, AssessedMachineV2Data.DeserializeAssessedMachineV2Data(e)), _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics, Pipeline, "AssessedMachineV2Collection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List AssessedMachineV2 resources by MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines + /// + /// + /// Operation Id + /// AssessedMachineV2_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _assessedMachineV2AssessedMachinesV2OperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, pageSizeHint, continuationToken, totalRecordCount); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _assessedMachineV2AssessedMachinesV2OperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, filter, pageSizeHint, continuationToken, totalRecordCount); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new AssessedMachineV2Resource(Client, AssessedMachineV2Data.DeserializeAssessedMachineV2Data(e)), _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics, Pipeline, "AssessedMachineV2Collection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.Exists"); + scope.Start(); + try + { + var response = await _assessedMachineV2AssessedMachinesV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.Exists"); + scope.Start(); + try + { + var response = _assessedMachineV2AssessedMachinesV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.GetIfExists"); + scope.Start(); + try + { + var response = await _assessedMachineV2AssessedMachinesV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Collection.GetIfExists"); + scope.Start(); + try + { + var response = _assessedMachineV2AssessedMachinesV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, assessedMachineName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.Serialization.cs new file mode 100644 index 000000000000..e911eb602144 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + public partial class AssessedMachineV2Data : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedMachineV2Data)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + AssessedMachineV2Data 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(AssessedMachineV2Data)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedMachineV2Data(document.RootElement, options); + } + + internal static AssessedMachineV2Data DeserializeAssessedMachineV2Data(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AssessedMachineV2Properties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = AssessedMachineV2Properties.DeserializeAssessedMachineV2Properties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedMachineV2Data( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssessedMachineV2Data)} does not support writing '{options.Format}' format."); + } + } + + AssessedMachineV2Data IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedMachineV2Data(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedMachineV2Data)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.cs new file mode 100644 index 000000000000..5f4badcf3e96 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Data.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing the AssessedMachineV2 data model. + /// Machine assessment V2 Assessed Machine resource. + /// + public partial class AssessedMachineV2Data : ResourceData + { + /// + /// 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 AssessedMachineV2Data() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal AssessedMachineV2Data(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, AssessedMachineV2Properties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public AssessedMachineV2Properties Properties { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.Serialization.cs new file mode 100644 index 000000000000..05932de2afb4 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Migrate +{ + public partial class AssessedMachineV2Resource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + AssessedMachineV2Data IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + AssessedMachineV2Data IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.cs new file mode 100644 index 000000000000..00d4bc293a72 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/AssessedMachineV2Resource.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A Class representing an AssessedMachineV2 along with the instance operations that can be performed on it. + /// If you have a you can construct an + /// from an instance of using the GetAssessedMachineV2Resource method. + /// Otherwise you can get one from its parent resource using the GetAssessedMachineV2 method. + /// + public partial class AssessedMachineV2Resource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The projectName. + /// The assessmentName. + /// The assessedMachineName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string assessedMachineName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics; + private readonly AssessedMachinesV2RestOperations _assessedMachineV2AssessedMachinesV2OperationsRestClient; + private readonly AssessedMachineV2Data _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Migrate/assessmentProjects/assessments/assessedMachines"; + + /// Initializes a new instance of the class for mocking. + protected AssessedMachineV2Resource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal AssessedMachineV2Resource(ArmClient client, AssessedMachineV2Data data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// 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 AssessedMachineV2Resource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string assessedMachineV2AssessedMachinesV2OperationsApiVersion); + _assessedMachineV2AssessedMachinesV2OperationsRestClient = new AssessedMachinesV2RestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, assessedMachineV2AssessedMachinesV2OperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual AssessedMachineV2Data Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Resource.Get"); + scope.Start(); + try + { + var response = await _assessedMachineV2AssessedMachinesV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _assessedMachineV2AssessedMachinesV2OperationsClientDiagnostics.CreateScope("AssessedMachineV2Resource.Get"); + scope.Start(); + try + { + var response = _assessedMachineV2AssessedMachinesV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new AssessedMachineV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MigrateExtensions.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MigrateExtensions.cs new file mode 100644 index 000000000000..f9ff265e1d12 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MigrateExtensions.cs @@ -0,0 +1,298 @@ +// 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.ResourceManager.Migrate.Mocking; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Migrate +{ + /// A class to add extension methods to Azure.ResourceManager.Migrate. + public static partial class MigrateExtensions + { + private static MockableMigrateArmClient GetMockableMigrateArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableMigrateArmClient(client0)); + } + + private static MockableMigrateResourceGroupResource GetMockableMigrateResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableMigrateResourceGroupResource(client, resource.Id)); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static MachineAssessmentV2Resource GetMachineAssessmentV2Resource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMigrateArmClient(client).GetMachineAssessmentV2Resource(id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static AssessedMachineV2Resource GetAssessedMachineV2Resource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMigrateArmClient(client).GetAssessedMachineV2Resource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static MachineAssessmentV2SummaryResource GetMachineAssessmentV2SummaryResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMigrateArmClient(client).GetMachineAssessmentV2SummaryResource(id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The resource ID of the resource to get. + /// is null. + /// Returns a object. + public static MachineGraphAssessmentOptionResource GetMachineGraphAssessmentOptionResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableMigrateArmClient(client).GetMachineGraphAssessmentOptionResource(id); + } + + /// + /// Gets a collection of MachineAssessmentV2Resources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// An object representing collection of MachineAssessmentV2Resources and their operations over a MachineAssessmentV2Resource. + public static MachineAssessmentV2Collection GetMachineAssessmentV2s(this ResourceGroupResource resourceGroupResource, string projectName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineAssessmentV2s(projectName); + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetMachineAssessmentV2Async(this ResourceGroupResource resourceGroupResource, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineAssessmentV2Async(projectName, assessmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetMachineAssessmentV2(this ResourceGroupResource resourceGroupResource, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineAssessmentV2(projectName, assessmentName, cancellationToken); + } + + /// + /// Gets a collection of MachineGraphAssessmentOptionResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// An object representing collection of MachineGraphAssessmentOptionResources and their operations over a MachineGraphAssessmentOptionResource. + public static MachineGraphAssessmentOptionCollection GetMachineGraphAssessmentOptions(this ResourceGroupResource resourceGroupResource, string projectName) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineGraphAssessmentOptions(projectName); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetMachineGraphAssessmentOptionAsync(this ResourceGroupResource resourceGroupResource, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineGraphAssessmentOptionAsync(projectName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// Assessment Project Name. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetMachineGraphAssessmentOption(this ResourceGroupResource resourceGroupResource, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableMigrateResourceGroupResource(resourceGroupResource).GetMachineGraphAssessmentOption(projectName, cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateArmClient.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateArmClient.cs new file mode 100644 index 000000000000..6b99b215234a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateArmClient.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableMigrateArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMigrateArmClient() + { + } + + /// 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 MockableMigrateArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableMigrateArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual MachineAssessmentV2Resource GetMachineAssessmentV2Resource(ResourceIdentifier id) + { + MachineAssessmentV2Resource.ValidateResourceId(id); + return new MachineAssessmentV2Resource(Client, id); + } + + /// + /// Gets an object representing an along with the instance operations that can be performed on it but with no data. + /// You can use to create an from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual AssessedMachineV2Resource GetAssessedMachineV2Resource(ResourceIdentifier id) + { + AssessedMachineV2Resource.ValidateResourceId(id); + return new AssessedMachineV2Resource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual MachineAssessmentV2SummaryResource GetMachineAssessmentV2SummaryResource(ResourceIdentifier id) + { + MachineAssessmentV2SummaryResource.ValidateResourceId(id); + return new MachineAssessmentV2SummaryResource(Client, id); + } + + /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. + /// You can use to create a from its components. + /// + /// The resource ID of the resource to get. + /// Returns a object. + public virtual MachineGraphAssessmentOptionResource GetMachineGraphAssessmentOptionResource(ResourceIdentifier id) + { + MachineGraphAssessmentOptionResource.ValidateResourceId(id); + return new MachineGraphAssessmentOptionResource(Client, id); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateResourceGroupResource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateResourceGroupResource.cs new file mode 100644 index 000000000000..ceda310de2d3 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Extensions/MockableMigrateResourceGroupResource.cs @@ -0,0 +1,182 @@ +// 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; + +namespace Azure.ResourceManager.Migrate.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableMigrateResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableMigrateResourceGroupResource() + { + } + + /// 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 MockableMigrateResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of MachineAssessmentV2Resources in the ResourceGroupResource. + /// Assessment Project Name. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// An object representing collection of MachineAssessmentV2Resources and their operations over a MachineAssessmentV2Resource. + public virtual MachineAssessmentV2Collection GetMachineAssessmentV2s(string projectName) + { + return new MachineAssessmentV2Collection(Client, Id, projectName); + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMachineAssessmentV2Async(string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + return await GetMachineAssessmentV2s(projectName).GetAsync(assessmentName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMachineAssessmentV2(string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + return GetMachineAssessmentV2s(projectName).Get(assessmentName, cancellationToken); + } + + /// Gets a collection of MachineGraphAssessmentOptionResources in the ResourceGroupResource. + /// Assessment Project Name. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// An object representing collection of MachineGraphAssessmentOptionResources and their operations over a MachineGraphAssessmentOptionResource. + public virtual MachineGraphAssessmentOptionCollection GetMachineGraphAssessmentOptions(string projectName) + { + return new MachineGraphAssessmentOptionCollection(Client, Id, projectName); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Assessment Project Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMachineGraphAssessmentOptionAsync(string projectName, CancellationToken cancellationToken = default) + { + return await GetMachineGraphAssessmentOptions(projectName).GetAsync(cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Assessment Project Name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMachineGraphAssessmentOption(string projectName, CancellationToken cancellationToken = default) + { + return GetMachineGraphAssessmentOptions(projectName).Get(cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Argument.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..0182a5196211 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..a66f9d42e55e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ChangeTrackingList.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..47489526e8bf --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..8f874b8eacb2 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Optional.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..e41b97ffe4ae --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..6922a99f93ea --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + 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/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/DownloadUriOperationSource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/DownloadUriOperationSource.cs new file mode 100644 index 000000000000..0386533eec64 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/DownloadUriOperationSource.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.ResourceManager.Migrate.Models; + +namespace Azure.ResourceManager.Migrate +{ + internal class DownloadUriOperationSource : IOperationSource + { + DownloadUri IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + return DownloadUri.DeserializeDownloadUri(document.RootElement); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + return DownloadUri.DeserializeDownloadUri(document.RootElement); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MachineAssessmentV2OperationSource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MachineAssessmentV2OperationSource.cs new file mode 100644 index 000000000000..056469277cc7 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MachineAssessmentV2OperationSource.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.ClientModel.Primitives; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate +{ + internal class MachineAssessmentV2OperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal MachineAssessmentV2OperationSource(ArmClient client) + { + _client = client; + } + + MachineAssessmentV2Resource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content); + return new MachineAssessmentV2Resource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + var data = ModelReaderWriter.Read(response.Content); + return await Task.FromResult(new MachineAssessmentV2Resource(_client, data)).ConfigureAwait(false); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperation.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperation.cs new file mode 100644 index 000000000000..74c14408f3f1 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperation.cs @@ -0,0 +1,94 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ +#pragma warning disable SA1649 // File name should match first type name + internal class MigrateArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of MigrateArmOperation for mocking. + protected MigrateArmOperation() + { + } + + internal MigrateArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal MigrateArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "MigrateArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); + + /// + public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); + + /// + public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperationOfT.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperationOfT.cs new file mode 100644 index 000000000000..c7dc7329573a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/LongRunningOperation/MigrateArmOperationOfT.cs @@ -0,0 +1,100 @@ +// 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.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ +#pragma warning disable SA1649 // File name should match first type name + internal class MigrateArmOperation : ArmOperation +#pragma warning restore SA1649 // File name should match first type name + { + private readonly OperationInternal _operation; + private readonly RehydrationToken? _completeRehydrationToken; + private readonly NextLinkOperationImplementation _nextLinkOperation; + private readonly string _operationId; + + /// Initializes a new instance of MigrateArmOperation for mocking. + protected MigrateArmOperation() + { + } + + internal MigrateArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal MigrateArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) + { + var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + { + _nextLinkOperation = nextLinkOperationValue; + _operationId = _nextLinkOperation.OperationId; + } + else + { + _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); + _operationId = GetOperationId(_completeRehydrationToken); + } + _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "MigrateArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + } + + private string GetOperationId(RehydrationToken? rehydrationToken) + { + if (rehydrationToken is null) + { + return null; + } + var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json).ToObjectFromJson>(); + return lroDetails["id"]; + } + /// + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// + public override T Value => _operation.Value; + + /// + public override bool HasValue => _operation.HasValue; + + /// + public override bool HasCompleted => _operation.HasCompleted; + + /// + public override Response GetRawResponse() => _operation.RawResponse; + + /// + public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); + + /// + public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); + + /// + public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); + + /// + public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); + + /// + public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Collection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Collection.cs new file mode 100644 index 000000000000..fe6d41dd3a47 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Collection.cs @@ -0,0 +1,499 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetMachineAssessmentV2s method from an instance of . + /// + public partial class MachineAssessmentV2Collection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics; + private readonly MachineAssessmentsV2RestOperations _machineAssessmentV2MachineAssessmentsV2OperationsRestClient; + private readonly string _projectName; + + /// Initializes a new instance of the class for mocking. + protected MachineAssessmentV2Collection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + /// Assessment Project Name. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal MachineAssessmentV2Collection(ArmClient client, ResourceIdentifier id, string projectName) : base(client, id) + { + _projectName = projectName; + _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", MachineAssessmentV2Resource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(MachineAssessmentV2Resource.ResourceType, out string machineAssessmentV2MachineAssessmentsV2OperationsApiVersion); + _machineAssessmentV2MachineAssessmentsV2OperationsRestClient = new MachineAssessmentsV2RestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineAssessmentV2MachineAssessmentsV2OperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Create a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Create + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Machine Assessment V2 ARM name. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string assessmentName, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, data, cancellationToken).ConfigureAwait(false); + var operation = new MigrateArmOperation(new MachineAssessmentV2OperationSource(Client), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Create + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Machine Assessment V2 ARM name. + /// Resource create parameters. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string assessmentName, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, data, cancellationToken); + var operation = new MigrateArmOperation(new MachineAssessmentV2OperationSource(Client), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.Get"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.Get"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List MachineAssessmentV2 resources by AssessmentProject + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments + /// + /// + /// Operation Id + /// MachineAssessmentV2_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _projectName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new MachineAssessmentV2Resource(Client, MachineAssessmentV2Data.DeserializeMachineAssessmentV2Data(e)), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, "MachineAssessmentV2Collection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List MachineAssessmentV2 resources by AssessmentProject + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments + /// + /// + /// Operation Id + /// MachineAssessmentV2_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _projectName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new MachineAssessmentV2Resource(Client, MachineAssessmentV2Data.DeserializeMachineAssessmentV2Data(e)), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, "MachineAssessmentV2Collection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.Exists"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.Exists"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.GetIfExists"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Collection.GetIfExists"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, assessmentName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.Serialization.cs new file mode 100644 index 000000000000..d23f7194fe1d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineAssessmentV2Data : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentV2Data)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + MachineAssessmentV2Data 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(MachineAssessmentV2Data)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentV2Data(document.RootElement, options); + } + + internal static MachineAssessmentV2Data DeserializeMachineAssessmentV2Data(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MachineAssessmentV2Properties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = MachineAssessmentV2Properties.DeserializeMachineAssessmentV2Properties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentV2Data( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2Data)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentV2Data IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentV2Data(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2Data)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.cs new file mode 100644 index 000000000000..359fb4b3faa7 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Data.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing the MachineAssessmentV2 data model. + /// Machine assessment V2 resource. + /// + public partial class MachineAssessmentV2Data : ResourceData + { + /// + /// 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 MachineAssessmentV2Data() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentV2Data(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, MachineAssessmentV2Properties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public MachineAssessmentV2Properties Properties { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.Serialization.cs new file mode 100644 index 000000000000..53f719161461 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineAssessmentV2Resource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + MachineAssessmentV2Data IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + MachineAssessmentV2Data IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.cs new file mode 100644 index 000000000000..3135bc6f9239 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2Resource.cs @@ -0,0 +1,583 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A Class representing a MachineAssessmentV2 along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetMachineAssessmentV2Resource method. + /// Otherwise you can get one from its parent resource using the GetMachineAssessmentV2 method. + /// + public partial class MachineAssessmentV2Resource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The projectName. + /// The assessmentName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics; + private readonly MachineAssessmentsV2RestOperations _machineAssessmentV2MachineAssessmentsV2OperationsRestClient; + private readonly MachineAssessmentV2Data _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Migrate/assessmentProjects/assessments"; + + /// Initializes a new instance of the class for mocking. + protected MachineAssessmentV2Resource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal MachineAssessmentV2Resource(ArmClient client, MachineAssessmentV2Data data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// 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 MachineAssessmentV2Resource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string machineAssessmentV2MachineAssessmentsV2OperationsApiVersion); + _machineAssessmentV2MachineAssessmentsV2OperationsRestClient = new MachineAssessmentsV2RestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineAssessmentV2MachineAssessmentsV2OperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual MachineAssessmentV2Data Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// Gets a collection of AssessedMachineV2Resources in the MachineAssessmentV2. + /// An object representing collection of AssessedMachineV2Resources and their operations over a AssessedMachineV2Resource. + public virtual AssessedMachineV2Collection GetAssessedMachineV2s() + { + return GetCachedClient(client => new AssessedMachineV2Collection(client, Id)); + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetAssessedMachineV2Async(string assessedMachineName, CancellationToken cancellationToken = default) + { + return await GetAssessedMachineV2s().GetAsync(assessedMachineName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a AssessedMachineV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/assessedMachines/{assessedMachineName} + /// + /// + /// Operation Id + /// AssessedMachineV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetAssessedMachineV2(string assessedMachineName, CancellationToken cancellationToken = default) + { + return GetAssessedMachineV2s().Get(assessedMachineName, cancellationToken); + } + + /// Gets a collection of MachineAssessmentV2SummaryResources in the MachineAssessmentV2. + /// An object representing collection of MachineAssessmentV2SummaryResources and their operations over a MachineAssessmentV2SummaryResource. + public virtual MachineAssessmentV2SummaryCollection GetMachineAssessmentV2Summaries() + { + return GetCachedClient(client => new MachineAssessmentV2SummaryCollection(client, Id)); + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetMachineAssessmentV2SummaryAsync(string summaryName, CancellationToken cancellationToken = default) + { + return await GetMachineAssessmentV2Summaries().GetAsync(summaryName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetMachineAssessmentV2Summary(string summaryName, CancellationToken cancellationToken = default) + { + return GetMachineAssessmentV2Summaries().Get(summaryName, cancellationToken); + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Get"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Get"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2Resource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Delete + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Delete"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + var uri = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new MigrateArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Delete + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The cancellation token to use. + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Delete"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); + var uri = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateDeleteRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Delete, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); + var operation = new MigrateArmOperation(response, rehydrationToken); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Create + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Update"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false); + var operation = new MigrateArmOperation(new MachineAssessmentV2OperationSource(Client), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Create a MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName} + /// + /// + /// Operation Id + /// MachineAssessmentV2_Create + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// Resource create parameters. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.Update"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); + var operation = new MigrateArmOperation(new MachineAssessmentV2OperationSource(Client), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the URL for downloading the assessment in a report format. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/downloadUrl + /// + /// + /// Operation Id + /// MachineAssessmentsV2Operations_DownloadUrl + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual async Task> DownloadUrlAsync(WaitUntil waitUntil, DownloadUrlContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.DownloadUrl"); + scope.Start(); + try + { + var response = await _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.DownloadUrlAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken).ConfigureAwait(false); + var operation = new MigrateArmOperation(new DownloadUriOperationSource(), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateDownloadUrlRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get the URL for downloading the assessment in a report format. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/downloadUrl + /// + /// + /// Operation Id + /// MachineAssessmentsV2Operations_DownloadUrl + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The content of the action request. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation DownloadUrl(WaitUntil waitUntil, DownloadUrlContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics.CreateScope("MachineAssessmentV2Resource.DownloadUrl"); + scope.Start(); + try + { + var response = _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.DownloadUrl(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content, cancellationToken); + var operation = new MigrateArmOperation(new DownloadUriOperationSource(), _machineAssessmentV2MachineAssessmentsV2OperationsClientDiagnostics, Pipeline, _machineAssessmentV2MachineAssessmentsV2OperationsRestClient.CreateDownloadUrlRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, content).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryCollection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryCollection.cs new file mode 100644 index 000000000000..36c5298a7263 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryCollection.cs @@ -0,0 +1,395 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetMachineAssessmentV2Summaries method from an instance of . + /// + public partial class MachineAssessmentV2SummaryCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics; + private readonly MachineAssessmentV2SummaryRestOperations _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MachineAssessmentV2SummaryCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + internal MachineAssessmentV2SummaryCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", MachineAssessmentV2SummaryResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(MachineAssessmentV2SummaryResource.ResourceType, out string machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsApiVersion); + _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient = new MachineAssessmentV2SummaryRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != MachineAssessmentV2Resource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, MachineAssessmentV2Resource.ResourceType), nameof(id)); + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.Get"); + scope.Start(); + try + { + var response = await _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.Get"); + scope.Start(); + try + { + var response = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new MachineAssessmentV2SummaryResource(Client, MachineAssessmentV2SummaryData.DeserializeMachineAssessmentV2SummaryData(e)), _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics, Pipeline, "MachineAssessmentV2SummaryCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2 + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new MachineAssessmentV2SummaryResource(Client, MachineAssessmentV2SummaryData.DeserializeMachineAssessmentV2SummaryData(e)), _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics, Pipeline, "MachineAssessmentV2SummaryCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.Exists"); + scope.Start(); + try + { + var response = await _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.Exists"); + scope.Start(); + try + { + var response = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryCollection.GetIfExists"); + scope.Start(); + try + { + var response = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, summaryName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.Serialization.cs new file mode 100644 index 000000000000..e5177e584e46 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineAssessmentV2SummaryData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentV2SummaryData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + MachineAssessmentV2SummaryData 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(MachineAssessmentV2SummaryData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentV2SummaryData(document.RootElement, options); + } + + internal static MachineAssessmentV2SummaryData DeserializeMachineAssessmentV2SummaryData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SummaryProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = SummaryProperties.DeserializeSummaryProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentV2SummaryData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2SummaryData)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentV2SummaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentV2SummaryData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2SummaryData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.cs new file mode 100644 index 000000000000..ca64809fc56b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryData.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing the MachineAssessmentV2Summary data model. + /// Machine Assessment REST resource. + /// + public partial class MachineAssessmentV2SummaryData : ResourceData + { + /// + /// 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 MachineAssessmentV2SummaryData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentV2SummaryData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, SummaryProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + public SummaryProperties Properties { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.Serialization.cs new file mode 100644 index 000000000000..206a893deeaf --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineAssessmentV2SummaryResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + MachineAssessmentV2SummaryData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + MachineAssessmentV2SummaryData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.cs new file mode 100644 index 000000000000..8f0fd8559bce --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineAssessmentV2SummaryResource.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A Class representing a MachineAssessmentV2Summary along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetMachineAssessmentV2SummaryResource method. + /// Otherwise you can get one from its parent resource using the GetMachineAssessmentV2Summary method. + /// + public partial class MachineAssessmentV2SummaryResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The projectName. + /// The assessmentName. + /// The summaryName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string summaryName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics; + private readonly MachineAssessmentV2SummaryRestOperations _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient; + private readonly MachineAssessmentV2SummaryData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Migrate/assessmentProjects/assessments/summaries"; + + /// Initializes a new instance of the class for mocking. + protected MachineAssessmentV2SummaryResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal MachineAssessmentV2SummaryResource(ArmClient client, MachineAssessmentV2SummaryData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// 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 MachineAssessmentV2SummaryResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsApiVersion); + _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient = new MachineAssessmentV2SummaryRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual MachineAssessmentV2SummaryData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryResource.Get"); + scope.Start(); + try + { + var response = await _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineAssessmentV2Summary + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessments/{assessmentName}/summaries/{summaryName} + /// + /// + /// Operation Id + /// MachineAssessmentV2Summary_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsClientDiagnostics.CreateScope("MachineAssessmentV2SummaryResource.Get"); + scope.Start(); + try + { + var response = _machineAssessmentV2SummaryMachineAssessmentV2SummaryOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineAssessmentV2SummaryResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionCollection.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionCollection.cs new file mode 100644 index 000000000000..e6370b66e85b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionCollection.cs @@ -0,0 +1,371 @@ +// 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.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing a collection of and their operations. + /// Each in the collection will belong to the same instance of . + /// To get a instance call the GetMachineGraphAssessmentOptions method from an instance of . + /// + public partial class MachineGraphAssessmentOptionCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics; + private readonly MachineGraphAssessmentOptionsRestOperations _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient; + private readonly string _projectName; + + /// Initializes a new instance of the class for mocking. + protected MachineGraphAssessmentOptionCollection() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The identifier of the parent resource that is the target of operations. + /// Assessment Project Name. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal MachineGraphAssessmentOptionCollection(ArmClient client, ResourceIdentifier id, string projectName) : base(client, id) + { + _projectName = projectName; + _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", MachineGraphAssessmentOptionResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(MachineGraphAssessmentOptionResource.ResourceType, out string machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsApiVersion); + _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient = new MachineGraphAssessmentOptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceGroupResource.ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.Get"); + scope.Start(); + try + { + var response = await _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.Get"); + scope.Start(); + try + { + var response = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List MachineGraphAssessmentOptions resources by AssessmentProject + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _projectName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new MachineGraphAssessmentOptionResource(Client, MachineGraphAssessmentOptionData.DeserializeMachineGraphAssessmentOptionData(e)), _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics, Pipeline, "MachineGraphAssessmentOptionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List MachineGraphAssessmentOptions resources by AssessmentProject + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_ListByParent + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetAll(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.CreateListByParentRequest(Id.SubscriptionId, Id.ResourceGroupName, _projectName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.CreateListByParentNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, _projectName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new MachineGraphAssessmentOptionResource(Client, MachineGraphAssessmentOptionData.DeserializeMachineGraphAssessmentOptionData(e)), _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics, Pipeline, "MachineGraphAssessmentOptionCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> ExistsAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.Exists"); + scope.Start(); + try + { + var response = await _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Exists(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.Exists"); + scope.Start(); + try + { + var response = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken: cancellationToken); + return Response.FromValue(response.Value != null, response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetIfExistsAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Tries to get details for this resource from the service. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual NullableResponse GetIfExists(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionCollection.GetIfExists"); + scope.Start(); + try + { + var response = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, _projectName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetAll().GetEnumerator(); + } + + IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) + { + return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.Serialization.cs new file mode 100644 index 000000000000..08b23403370a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.Serialization.cs @@ -0,0 +1,155 @@ +// 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; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineGraphAssessmentOptionData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionData)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + } + + MachineGraphAssessmentOptionData 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(MachineGraphAssessmentOptionData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineGraphAssessmentOptionData(document.RootElement, options); + } + + internal static MachineGraphAssessmentOptionData DeserializeMachineGraphAssessmentOptionData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MachineGraphAssessmentOptionsProperties properties = default; + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = MachineGraphAssessmentOptionsProperties.DeserializeMachineGraphAssessmentOptionsProperties(property.Value, options); + continue; + } + if (property.NameEquals("id"u8)) + { + id = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ResourceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("systemData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineGraphAssessmentOptionData( + id, + name, + type, + systemData, + properties, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionData)} does not support writing '{options.Format}' format."); + } + } + + MachineGraphAssessmentOptionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineGraphAssessmentOptionData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.cs new file mode 100644 index 000000000000..7e38c51f68a3 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionData.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Migrate.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A class representing the MachineGraphAssessmentOption data model. + /// Machine Assessment REST resource. + /// + public partial class MachineGraphAssessmentOptionData : ResourceData + { + /// + /// 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 MachineGraphAssessmentOptionData() + { + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The resource-specific properties for this resource. + /// Keeps track of any properties unknown to the library. + internal MachineGraphAssessmentOptionData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, MachineGraphAssessmentOptionsProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The resource-specific properties for this resource. + internal MachineGraphAssessmentOptionsProperties Properties { get; } + /// Gets or sets the edges. + public IReadOnlyDictionary MachineGraphAssessmentOptionsEdges + { + get => Properties?.Edges; + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.Serialization.cs new file mode 100644 index 000000000000..07017f123cef --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.Serialization.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; + +namespace Azure.ResourceManager.Migrate +{ + public partial class MachineGraphAssessmentOptionResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + MachineGraphAssessmentOptionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + MachineGraphAssessmentOptionData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.cs new file mode 100644 index 000000000000..e08cd9a7353d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/MachineGraphAssessmentOptionResource.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.Migrate +{ + /// + /// A Class representing a MachineGraphAssessmentOption along with the instance operations that can be performed on it. + /// If you have a you can construct a + /// from an instance of using the GetMachineGraphAssessmentOptionResource method. + /// Otherwise you can get one from its parent resource using the GetMachineGraphAssessmentOption method. + /// + public partial class MachineGraphAssessmentOptionResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The projectName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string projectName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics; + private readonly MachineGraphAssessmentOptionsRestOperations _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient; + private readonly MachineGraphAssessmentOptionData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.Migrate/assessmentProjects/assessmentOptions"; + + /// Initializes a new instance of the class for mocking. + protected MachineGraphAssessmentOptionResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal MachineGraphAssessmentOptionResource(ArmClient client, MachineGraphAssessmentOptionData data) : this(client, data.Id) + { + HasData = true; + _data = data; + } + + /// 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 MachineGraphAssessmentOptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Migrate", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsApiVersion); + _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient = new MachineGraphAssessmentOptionsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsApiVersion); +#if DEBUG + ValidateResourceId(Id); +#endif + } + + /// Gets whether or not the current instance has data. + public virtual bool HasData { get; } + + /// Gets the data representing this Feature. + /// Throws if there is no data loaded in the current instance. + public virtual MachineGraphAssessmentOptionData Data + { + get + { + if (!HasData) + throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + return _data; + } + } + + internal static void ValidateResourceId(ResourceIdentifier id) + { + if (id.ResourceType != ResourceType) + throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionResource.Get"); + scope.Start(); + try + { + var response = await _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a MachineGraphAssessmentOptions + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/assessmentProjects/{projectName}/assessmentOptions/default + /// + /// + /// Operation Id + /// MachineGraphAssessmentOptions_Get + /// + /// + /// Default Api Version + /// 2024-03-03-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsClientDiagnostics.CreateScope("MachineGraphAssessmentOptionResource.Get"); + scope.Start(); + try + { + var response = _machineGraphAssessmentOptionMachineGraphAssessmentOptionsOperationsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new MachineGraphAssessmentOptionResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.Serialization.cs new file mode 100644 index 000000000000..696ad627644f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + public partial class AssessedDiskDataV3 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedDiskDataV3)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (Optional.IsDefined(GigabytesProvisioned)) + { + writer.WritePropertyName("gigabytesProvisioned"u8); + writer.WriteNumberValue(GigabytesProvisioned.Value); + } + if (Optional.IsDefined(MegabytesPerSecondOfRead)) + { + writer.WritePropertyName("megabytesPerSecondOfRead"u8); + writer.WriteNumberValue(MegabytesPerSecondOfRead.Value); + } + if (Optional.IsDefined(MegabytesPerSecondOfWrite)) + { + writer.WritePropertyName("megabytesPerSecondOfWrite"u8); + writer.WriteNumberValue(MegabytesPerSecondOfWrite.Value); + } + if (Optional.IsDefined(NumberOfReadOperationsPerSecond)) + { + writer.WritePropertyName("numberOfReadOperationsPerSecond"u8); + writer.WriteNumberValue(NumberOfReadOperationsPerSecond.Value); + } + if (Optional.IsDefined(NumberOfWriteOperationsPerSecond)) + { + writer.WritePropertyName("numberOfWriteOperationsPerSecond"u8); + writer.WriteNumberValue(NumberOfWriteOperationsPerSecond.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessedDiskDataV3 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(AssessedDiskDataV3)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedDiskDataV3(document.RootElement, options); + } + + internal static AssessedDiskDataV3 DeserializeAssessedDiskDataV3(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string displayName = default; + float? gigabytesProvisioned = default; + float? megabytesPerSecondOfRead = default; + float? megabytesPerSecondOfWrite = default; + float? numberOfReadOperationsPerSecond = default; + float? numberOfWriteOperationsPerSecond = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("gigabytesProvisioned"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gigabytesProvisioned = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("megabytesPerSecondOfRead"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + megabytesPerSecondOfRead = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("megabytesPerSecondOfWrite"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + megabytesPerSecondOfWrite = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("numberOfReadOperationsPerSecond"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfReadOperationsPerSecond = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("numberOfWriteOperationsPerSecond"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfWriteOperationsPerSecond = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedDiskDataV3( + name, + displayName, + gigabytesProvisioned, + megabytesPerSecondOfRead, + megabytesPerSecondOfWrite, + numberOfReadOperationsPerSecond, + numberOfWriteOperationsPerSecond, + 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(AssessedDiskDataV3)} does not support writing '{options.Format}' format."); + } + } + + AssessedDiskDataV3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedDiskDataV3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedDiskDataV3)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.cs new file mode 100644 index 000000000000..fd0e09834935 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedDiskDataV3.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Assessed disk data for normalized contract. + public partial class AssessedDiskDataV3 + { + /// + /// 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 AssessedDiskDataV3() + { + } + + /// Initializes a new instance of . + /// The disk name. + /// The disk display name. + /// Gets the gigabytes provisioned. + /// Gets the megabytes per second of read. + /// Gets the megabytes per second of write. + /// Gets the number of read operations per second. + /// Gets the number of write operations per second. + /// Keeps track of any properties unknown to the library. + internal AssessedDiskDataV3(string name, string displayName, float? gigabytesProvisioned, float? megabytesPerSecondOfRead, float? megabytesPerSecondOfWrite, float? numberOfReadOperationsPerSecond, float? numberOfWriteOperationsPerSecond, IDictionary serializedAdditionalRawData) + { + Name = name; + DisplayName = displayName; + GigabytesProvisioned = gigabytesProvisioned; + MegabytesPerSecondOfRead = megabytesPerSecondOfRead; + MegabytesPerSecondOfWrite = megabytesPerSecondOfWrite; + NumberOfReadOperationsPerSecond = numberOfReadOperationsPerSecond; + NumberOfWriteOperationsPerSecond = numberOfWriteOperationsPerSecond; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The disk name. + public string Name { get; } + /// The disk display name. + public string DisplayName { get; } + /// Gets the gigabytes provisioned. + public float? GigabytesProvisioned { get; } + /// Gets the megabytes per second of read. + public float? MegabytesPerSecondOfRead { get; } + /// Gets the megabytes per second of write. + public float? MegabytesPerSecondOfWrite { get; } + /// Gets the number of read operations per second. + public float? NumberOfReadOperationsPerSecond { get; } + /// Gets the number of write operations per second. + public float? NumberOfWriteOperationsPerSecond { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.Serialization.cs new file mode 100644 index 000000000000..c7454ec129fc --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.Serialization.cs @@ -0,0 +1,401 @@ +// 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.Migrate.Models +{ + public partial class AssessedMachineExtendedDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedMachineExtendedDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(ProductSupportStatus)) + { + writer.WritePropertyName("productSupportStatus"u8); + writer.WriteObjectValue(ProductSupportStatus, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Disks)) + { + writer.WritePropertyName("disks"u8); + writer.WriteStartArray(); + foreach (var item in Disks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(HostProcessor)) + { + writer.WritePropertyName("hostProcessor"u8); + writer.WriteObjectValue(HostProcessor, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(NetworkAdapters)) + { + writer.WritePropertyName("networkAdapters"u8); + writer.WriteStartArray(); + foreach (var item in NetworkAdapters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(AssessedMachineType)) + { + writer.WritePropertyName("assessedMachineType"u8); + writer.WriteStringValue(AssessedMachineType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(BootType)) + { + writer.WritePropertyName("bootType"u8); + writer.WriteStringValue(BootType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(OperatingSystemType)) + { + writer.WritePropertyName("operatingSystemType"u8); + writer.WriteStringValue(OperatingSystemType); + } + if (options.Format != "W" && Optional.IsDefined(OperatingSystemName)) + { + writer.WritePropertyName("operatingSystemName"u8); + writer.WriteStringValue(OperatingSystemName); + } + if (options.Format != "W" && Optional.IsDefined(OperatingSystemVersion)) + { + writer.WritePropertyName("operatingSystemVersion"u8); + writer.WriteStringValue(OperatingSystemVersion); + } + if (options.Format != "W" && Optional.IsDefined(OperatingSystemArchitecture)) + { + writer.WritePropertyName("operatingSystemArchitecture"u8); + writer.WriteStringValue(OperatingSystemArchitecture.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(MegabytesOfMemory)) + { + writer.WritePropertyName("megabytesOfMemory"u8); + writer.WriteNumberValue(MegabytesOfMemory.Value); + } + if (options.Format != "W" && Optional.IsDefined(NumberOfCores)) + { + writer.WritePropertyName("numberOfCores"u8); + writer.WriteNumberValue(NumberOfCores.Value); + } + if (options.Format != "W" && Optional.IsDefined(PercentageCoresUtilization)) + { + writer.WritePropertyName("percentageCoresUtilization"u8); + writer.WriteNumberValue(PercentageCoresUtilization.Value); + } + if (options.Format != "W" && Optional.IsDefined(PercentageMemoryUtilization)) + { + writer.WritePropertyName("percentageMemoryUtilization"u8); + writer.WriteNumberValue(PercentageMemoryUtilization.Value); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteStartArray(); + foreach (var item in Errors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessedMachineExtendedDetails 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(AssessedMachineExtendedDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedMachineExtendedDetails(document.RootElement, options); + } + + internal static AssessedMachineExtendedDetails DeserializeAssessedMachineExtendedDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string displayName = default; + ProductSupportStatus productSupportStatus = default; + IReadOnlyList disks = default; + ProcessorInfo hostProcessor = default; + IReadOnlyList networkAdapters = default; + AssessedMachineType? assessedMachineType = default; + MachineBootType? bootType = default; + string operatingSystemType = default; + string operatingSystemName = default; + string operatingSystemVersion = default; + GuestOperatingSystemArchitecture? operatingSystemArchitecture = default; + string description = default; + float? megabytesOfMemory = default; + int? numberOfCores = default; + float? percentageCoresUtilization = default; + float? percentageMemoryUtilization = default; + IReadOnlyList errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("productSupportStatus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + productSupportStatus = ProductSupportStatus.DeserializeProductSupportStatus(property.Value, options); + continue; + } + if (property.NameEquals("disks"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AssessedDiskDataV3.DeserializeAssessedDiskDataV3(item, options)); + } + disks = array; + continue; + } + if (property.NameEquals("hostProcessor"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hostProcessor = ProcessorInfo.DeserializeProcessorInfo(property.Value, options); + continue; + } + if (property.NameEquals("networkAdapters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AssessedMachineNetworkAdaptersV3.DeserializeAssessedMachineNetworkAdaptersV3(item, options)); + } + networkAdapters = array; + continue; + } + if (property.NameEquals("assessedMachineType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + assessedMachineType = new AssessedMachineType(property.Value.GetString()); + continue; + } + if (property.NameEquals("bootType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bootType = new MachineBootType(property.Value.GetString()); + continue; + } + if (property.NameEquals("operatingSystemType"u8)) + { + operatingSystemType = property.Value.GetString(); + continue; + } + if (property.NameEquals("operatingSystemName"u8)) + { + operatingSystemName = property.Value.GetString(); + continue; + } + if (property.NameEquals("operatingSystemVersion"u8)) + { + operatingSystemVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("operatingSystemArchitecture"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + operatingSystemArchitecture = new GuestOperatingSystemArchitecture(property.Value.GetString()); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("megabytesOfMemory"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + megabytesOfMemory = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("numberOfCores"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfCores = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("percentageCoresUtilization"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + percentageCoresUtilization = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("percentageMemoryUtilization"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + percentageMemoryUtilization = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Error.DeserializeError(item, options)); + } + errors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedMachineExtendedDetails( + displayName, + productSupportStatus, + disks ?? new ChangeTrackingList(), + hostProcessor, + networkAdapters ?? new ChangeTrackingList(), + assessedMachineType, + bootType, + operatingSystemType, + operatingSystemName, + operatingSystemVersion, + operatingSystemArchitecture, + description, + megabytesOfMemory, + numberOfCores, + percentageCoresUtilization, + percentageMemoryUtilization, + errors ?? 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(AssessedMachineExtendedDetails)} does not support writing '{options.Format}' format."); + } + } + + AssessedMachineExtendedDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedMachineExtendedDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedMachineExtendedDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.cs new file mode 100644 index 000000000000..d4a5a98f37e2 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineExtendedDetails.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The assessed machine extended details. + public partial class AssessedMachineExtendedDetails + { + /// + /// 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 AssessedMachineExtendedDetails() + { + Disks = new ChangeTrackingList(); + NetworkAdapters = new ChangeTrackingList(); + Errors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Display Name of the Machine. + /// Gets the product support status related details. + /// Dictionary of disks attached to the machine. Key is ID of disk. Value is a disk object. + /// Gets or sets the processor details of the host. + /// + /// List of Network Adapters that were assessed as part of this machine's + /// assessment. + /// + /// Assessed machine type. + /// Boot type of machine discovered in private data center. + /// Operating system as reported by datacenter management solution. + /// Operating system as reported by datacenter management solution. + /// Operating system version as reported by datacenter management solution. + /// Operating system architecture as reported by datacenter management solution. + /// Description for the machine. + /// Megabytes of memory found allocated for the machine in private data center. + /// Number of CPU cores found on the machine. + /// + /// Percentile of Percentage of Cores Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + /// + /// Percentile of Percentage of Memory Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + /// List of errors for this machine. + /// Keeps track of any properties unknown to the library. + internal AssessedMachineExtendedDetails(string displayName, ProductSupportStatus productSupportStatus, IReadOnlyList disks, ProcessorInfo hostProcessor, IReadOnlyList networkAdapters, AssessedMachineType? assessedMachineType, MachineBootType? bootType, string operatingSystemType, string operatingSystemName, string operatingSystemVersion, GuestOperatingSystemArchitecture? operatingSystemArchitecture, string description, float? megabytesOfMemory, int? numberOfCores, float? percentageCoresUtilization, float? percentageMemoryUtilization, IReadOnlyList errors, IDictionary serializedAdditionalRawData) + { + DisplayName = displayName; + ProductSupportStatus = productSupportStatus; + Disks = disks; + HostProcessor = hostProcessor; + NetworkAdapters = networkAdapters; + AssessedMachineType = assessedMachineType; + BootType = bootType; + OperatingSystemType = operatingSystemType; + OperatingSystemName = operatingSystemName; + OperatingSystemVersion = operatingSystemVersion; + OperatingSystemArchitecture = operatingSystemArchitecture; + Description = description; + MegabytesOfMemory = megabytesOfMemory; + NumberOfCores = numberOfCores; + PercentageCoresUtilization = percentageCoresUtilization; + PercentageMemoryUtilization = percentageMemoryUtilization; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Display Name of the Machine. + public string DisplayName { get; } + /// Gets the product support status related details. + public ProductSupportStatus ProductSupportStatus { get; } + /// Dictionary of disks attached to the machine. Key is ID of disk. Value is a disk object. + public IReadOnlyList Disks { get; } + /// Gets or sets the processor details of the host. + public ProcessorInfo HostProcessor { get; } + /// + /// List of Network Adapters that were assessed as part of this machine's + /// assessment. + /// + public IReadOnlyList NetworkAdapters { get; } + /// Assessed machine type. + public AssessedMachineType? AssessedMachineType { get; } + /// Boot type of machine discovered in private data center. + public MachineBootType? BootType { get; } + /// Operating system as reported by datacenter management solution. + public string OperatingSystemType { get; } + /// Operating system as reported by datacenter management solution. + public string OperatingSystemName { get; } + /// Operating system version as reported by datacenter management solution. + public string OperatingSystemVersion { get; } + /// Operating system architecture as reported by datacenter management solution. + public GuestOperatingSystemArchitecture? OperatingSystemArchitecture { get; } + /// Description for the machine. + public string Description { get; } + /// Megabytes of memory found allocated for the machine in private data center. + public float? MegabytesOfMemory { get; } + /// Number of CPU cores found on the machine. + public int? NumberOfCores { get; } + /// + /// Percentile of Percentage of Cores Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + public float? PercentageCoresUtilization { get; } + /// + /// Percentile of Percentage of Memory Utilized noted during time period T. + /// Here N and T are settings on Assessment. + /// + public float? PercentageMemoryUtilization { get; } + /// List of errors for this machine. + public IReadOnlyList Errors { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.Serialization.cs new file mode 100644 index 000000000000..0e5fe63327ca --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Migrate.Models +{ + public partial class AssessedMachineNetworkAdaptersV3 : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedMachineNetworkAdaptersV3)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(NetGigabytesTransmittedPerMonth)) + { + writer.WritePropertyName("netGigabytesTransmittedPerMonth"u8); + writer.WriteNumberValue(NetGigabytesTransmittedPerMonth.Value); + } + if (Optional.IsDefined(MacAddress)) + { + writer.WritePropertyName("macAddress"u8); + writer.WriteStringValue(MacAddress); + } + if (options.Format != "W" && Optional.IsCollectionDefined(IPAddresses)) + { + writer.WritePropertyName("ipAddresses"u8); + writer.WriteStartArray(); + foreach (var item in IPAddresses) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(MegabytesPerSecondRecieved)) + { + writer.WritePropertyName("megabytesPerSecondRecieved"u8); + writer.WriteNumberValue(MegabytesPerSecondRecieved.Value); + } + if (Optional.IsDefined(MegabytesPerSecondTransmitted)) + { + writer.WritePropertyName("megabytesPerSecondTransmitted"u8); + writer.WriteNumberValue(MegabytesPerSecondTransmitted.Value); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessedMachineNetworkAdaptersV3 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(AssessedMachineNetworkAdaptersV3)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedMachineNetworkAdaptersV3(document.RootElement, options); + } + + internal static AssessedMachineNetworkAdaptersV3 DeserializeAssessedMachineNetworkAdaptersV3(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + float? netGigabytesTransmittedPerMonth = default; + string macAddress = default; + IReadOnlyList ipAddresses = default; + float? megabytesPerSecondRecieved = default; + float? megabytesPerSecondTransmitted = default; + string displayName = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("netGigabytesTransmittedPerMonth"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + netGigabytesTransmittedPerMonth = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("macAddress"u8)) + { + macAddress = property.Value.GetString(); + continue; + } + if (property.NameEquals("ipAddresses"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ipAddresses = array; + continue; + } + if (property.NameEquals("megabytesPerSecondRecieved"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + megabytesPerSecondRecieved = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("megabytesPerSecondTransmitted"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + megabytesPerSecondTransmitted = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedMachineNetworkAdaptersV3( + name, + netGigabytesTransmittedPerMonth, + macAddress, + ipAddresses ?? new ChangeTrackingList(), + megabytesPerSecondRecieved, + megabytesPerSecondTransmitted, + displayName, + 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(AssessedMachineNetworkAdaptersV3)} does not support writing '{options.Format}' format."); + } + } + + AssessedMachineNetworkAdaptersV3 IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedMachineNetworkAdaptersV3(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedMachineNetworkAdaptersV3)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.cs new file mode 100644 index 000000000000..a2894ec5837f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineNetworkAdaptersV3.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.Migrate.Models +{ + /// Assessed network adapter data for normalized contract for sql machines. + public partial class AssessedMachineNetworkAdaptersV3 + { + /// + /// 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 AssessedMachineNetworkAdaptersV3() + { + IPAddresses = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The disk name. + /// Gets the net gigabytes transmitted per month. + /// Gets the mac address. + /// Gets the ip addresses. + /// Gets the megabytes per second received. + /// Gets the megabytes per second transmitted. + /// Display Name of the Machine. + /// Keeps track of any properties unknown to the library. + internal AssessedMachineNetworkAdaptersV3(string name, float? netGigabytesTransmittedPerMonth, string macAddress, IReadOnlyList ipAddresses, float? megabytesPerSecondRecieved, float? megabytesPerSecondTransmitted, string displayName, IDictionary serializedAdditionalRawData) + { + Name = name; + NetGigabytesTransmittedPerMonth = netGigabytesTransmittedPerMonth; + MacAddress = macAddress; + IPAddresses = ipAddresses; + MegabytesPerSecondRecieved = megabytesPerSecondRecieved; + MegabytesPerSecondTransmitted = megabytesPerSecondTransmitted; + DisplayName = displayName; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The disk name. + public string Name { get; } + /// Gets the net gigabytes transmitted per month. + public float? NetGigabytesTransmittedPerMonth { get; } + /// Gets the mac address. + public string MacAddress { get; } + /// Gets the ip addresses. + public IReadOnlyList IPAddresses { get; } + /// Gets the megabytes per second received. + public float? MegabytesPerSecondRecieved { get; } + /// Gets the megabytes per second transmitted. + public float? MegabytesPerSecondTransmitted { get; } + /// Display Name of the Machine. + public string DisplayName { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineType.cs new file mode 100644 index 000000000000..843499dfe477 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineType.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.Migrate.Models +{ + /// Assessed machine type. + public readonly partial struct AssessedMachineType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssessedMachineType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string AssessedMachineValue = "AssessedMachine"; + private const string AvsAssessedMachineValue = "AvsAssessedMachine"; + private const string SqlAssessedMachineValue = "SqlAssessedMachine"; + + /// Unknown - Assessed machine type. + public static AssessedMachineType Unknown { get; } = new AssessedMachineType(UnknownValue); + /// AssessedMachine - Assessed machine type. + public static AssessedMachineType AssessedMachine { get; } = new AssessedMachineType(AssessedMachineValue); + /// AvsAssessedMachine - Assessed machine type. + public static AssessedMachineType AvsAssessedMachine { get; } = new AssessedMachineType(AvsAssessedMachineValue); + /// SqlAssessedMachine - Assessed machine type. + public static AssessedMachineType SqlAssessedMachine { get; } = new AssessedMachineType(SqlAssessedMachineValue); + /// Determines if two values are the same. + public static bool operator ==(AssessedMachineType left, AssessedMachineType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssessedMachineType left, AssessedMachineType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssessedMachineType(string value) => new AssessedMachineType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssessedMachineType other && Equals(other); + /// + public bool Equals(AssessedMachineType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.Serialization.cs new file mode 100644 index 000000000000..959ff6977abb --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.Migrate.Models +{ + internal partial class AssessedMachineV2ListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedMachineV2ListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessedMachineV2ListResult 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(AssessedMachineV2ListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedMachineV2ListResult(document.RootElement, options); + } + + internal static AssessedMachineV2ListResult DeserializeAssessedMachineV2ListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AssessedMachineV2Data.DeserializeAssessedMachineV2Data(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedMachineV2ListResult(value, nextLink, 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(AssessedMachineV2ListResult)} does not support writing '{options.Format}' format."); + } + } + + AssessedMachineV2ListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedMachineV2ListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedMachineV2ListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.cs new file mode 100644 index 000000000000..b48e0ae32271 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2ListResult.cs @@ -0,0 +1,80 @@ +// 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.Migrate.Models +{ + /// The response of a AssessedMachineV2 list operation. + internal partial class AssessedMachineV2ListResult + { + /// + /// 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 AssessedMachineV2 items on this page. + /// is null. + internal AssessedMachineV2ListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The AssessedMachineV2 items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal AssessedMachineV2ListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AssessedMachineV2ListResult() + { + } + + /// The AssessedMachineV2 items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.Serialization.cs new file mode 100644 index 000000000000..ebebbc770db0 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.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.Migrate.Models +{ + public partial class AssessedMachineV2Properties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessedMachineV2Properties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(WorkloadType)) + { + writer.WritePropertyName("workloadType"u8); + writer.WriteStringValue(WorkloadType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Linkages)) + { + writer.WritePropertyName("linkages"u8); + writer.WriteStartArray(); + foreach (var item in Linkages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Recommendations)) + { + writer.WritePropertyName("recommendations"u8); + writer.WriteStartArray(); + foreach (var item in Recommendations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ExtendedDetails)) + { + writer.WritePropertyName("extendedDetails"u8); + writer.WriteObjectValue(ExtendedDetails, options); + } + if (options.Format != "W" && Optional.IsDefined(CreatedTimestamp)) + { + writer.WritePropertyName("createdTimestamp"u8); + writer.WriteStringValue(CreatedTimestamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedTimestamp)) + { + writer.WritePropertyName("updatedTimestamp"u8); + writer.WriteStringValue(UpdatedTimestamp.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessedMachineV2Properties 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(AssessedMachineV2Properties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessedMachineV2Properties(document.RootElement, options); + } + + internal static AssessedMachineV2Properties DeserializeAssessedMachineV2Properties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MigrateWorkloadType? workloadType = default; + IReadOnlyList linkages = default; + IReadOnlyList recommendations = default; + AssessedMachineExtendedDetails extendedDetails = default; + DateTimeOffset? createdTimestamp = default; + DateTimeOffset? updatedTimestamp = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("workloadType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + workloadType = new MigrateWorkloadType(property.Value.GetString()); + continue; + } + if (property.NameEquals("linkages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.Linkages.DeserializeLinkages(item, options)); + } + linkages = array; + continue; + } + if (property.NameEquals("recommendations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MachineAssessmentRecommendation.DeserializeMachineAssessmentRecommendation(item, options)); + } + recommendations = array; + continue; + } + if (property.NameEquals("extendedDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extendedDetails = AssessedMachineExtendedDetails.DeserializeAssessedMachineExtendedDetails(property.Value, options); + continue; + } + if (property.NameEquals("createdTimestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("updatedTimestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessedMachineV2Properties( + workloadType, + linkages ?? new ChangeTrackingList(), + recommendations ?? new ChangeTrackingList(), + extendedDetails, + createdTimestamp, + updatedTimestamp, + 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(AssessedMachineV2Properties)} does not support writing '{options.Format}' format."); + } + } + + AssessedMachineV2Properties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessedMachineV2Properties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessedMachineV2Properties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.cs new file mode 100644 index 000000000000..3530c3b261e1 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessedMachineV2Properties.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.Migrate.Models +{ + /// Assessed machine properties class. + public partial class AssessedMachineV2Properties + { + /// + /// 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 AssessedMachineV2Properties() + { + Linkages = new ChangeTrackingList(); + Recommendations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The workload type. + /// The linkages list. + /// The recommendation list. + /// The assessed machine extended details. + /// When was machine first created. + /// When was machine last updated. + /// Keeps track of any properties unknown to the library. + internal AssessedMachineV2Properties(MigrateWorkloadType? workloadType, IReadOnlyList linkages, IReadOnlyList recommendations, AssessedMachineExtendedDetails extendedDetails, DateTimeOffset? createdTimestamp, DateTimeOffset? updatedTimestamp, IDictionary serializedAdditionalRawData) + { + WorkloadType = workloadType; + Linkages = linkages; + Recommendations = recommendations; + ExtendedDetails = extendedDetails; + CreatedTimestamp = createdTimestamp; + UpdatedTimestamp = updatedTimestamp; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The workload type. + public MigrateWorkloadType? WorkloadType { get; } + /// The linkages list. + public IReadOnlyList Linkages { get; } + /// The recommendation list. + public IReadOnlyList Recommendations { get; } + /// The assessed machine extended details. + public AssessedMachineExtendedDetails ExtendedDetails { get; } + /// When was machine first created. + public DateTimeOffset? CreatedTimestamp { get; } + /// When was machine last updated. + public DateTimeOffset? UpdatedTimestamp { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.Serialization.cs new file mode 100644 index 000000000000..84bfea229fee --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.Serialization.cs @@ -0,0 +1,199 @@ +// 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.Migrate.Models +{ + public partial class AssessmentDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssessmentDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ConfidenceRatingInPercentage)) + { + writer.WritePropertyName("confidenceRatingInPercentage"u8); + writer.WriteNumberValue(ConfidenceRatingInPercentage.Value); + } + if (options.Format != "W" && Optional.IsDefined(PricesTimestamp)) + { + writer.WritePropertyName("pricesTimestamp"u8); + writer.WriteStringValue(PricesTimestamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(CreatedTimestamp)) + { + writer.WritePropertyName("createdTimestamp"u8); + writer.WriteStringValue(CreatedTimestamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedTimestamp)) + { + writer.WritePropertyName("updatedTimestamp"u8); + writer.WriteStringValue(UpdatedTimestamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AssessmentDetails 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(AssessmentDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssessmentDetails(document.RootElement, options); + } + + internal static AssessmentDetails DeserializeAssessmentDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float? confidenceRatingInPercentage = default; + DateTimeOffset? pricesTimestamp = default; + DateTimeOffset? createdTimestamp = default; + DateTimeOffset? updatedTimestamp = default; + AssessmentStatus? status = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("confidenceRatingInPercentage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceRatingInPercentage = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("pricesTimestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pricesTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("createdTimestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("updatedTimestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedTimestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new AssessmentStatus(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssessmentDetails( + confidenceRatingInPercentage, + pricesTimestamp, + createdTimestamp, + updatedTimestamp, + status, + 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(AssessmentDetails)} does not support writing '{options.Format}' format."); + } + } + + AssessmentDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAssessmentDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssessmentDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.cs new file mode 100644 index 000000000000..7fe80c02965e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentDetails.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Assessment details class. + public partial class AssessmentDetails + { + /// + /// 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 AssessmentDetails() + { + } + + /// Initializes a new instance of . + /// Confidence Rating in Percentage. + /// Last time when rates were queried. + /// Date and Time when assessment was created. + /// Date and Time when assessment was last updated. + /// Whether assessment is in valid state and all machines have been assessed. + /// Keeps track of any properties unknown to the library. + internal AssessmentDetails(float? confidenceRatingInPercentage, DateTimeOffset? pricesTimestamp, DateTimeOffset? createdTimestamp, DateTimeOffset? updatedTimestamp, AssessmentStatus? status, IDictionary serializedAdditionalRawData) + { + ConfidenceRatingInPercentage = confidenceRatingInPercentage; + PricesTimestamp = pricesTimestamp; + CreatedTimestamp = createdTimestamp; + UpdatedTimestamp = updatedTimestamp; + Status = status; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Confidence Rating in Percentage. + public float? ConfidenceRatingInPercentage { get; } + /// Last time when rates were queried. + public DateTimeOffset? PricesTimestamp { get; } + /// Date and Time when assessment was created. + public DateTimeOffset? CreatedTimestamp { get; } + /// Date and Time when assessment was last updated. + public DateTimeOffset? UpdatedTimestamp { get; } + /// Whether assessment is in valid state and all machines have been assessed. + public AssessmentStatus? Status { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSizingCriterion.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSizingCriterion.cs new file mode 100644 index 000000000000..367b023bed90 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSizingCriterion.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Assessment Sizing Criteria. + public readonly partial struct AssessmentSizingCriterion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssessmentSizingCriterion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PerformanceBasedValue = "PerformanceBased"; + private const string AsOnPremisesValue = "AsOnPremises"; + + /// Performance Data based Sizing. + public static AssessmentSizingCriterion PerformanceBased { get; } = new AssessmentSizingCriterion(PerformanceBasedValue); + /// As On Premises or Static Data based Sizing. + public static AssessmentSizingCriterion AsOnPremises { get; } = new AssessmentSizingCriterion(AsOnPremisesValue); + /// Determines if two values are the same. + public static bool operator ==(AssessmentSizingCriterion left, AssessmentSizingCriterion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssessmentSizingCriterion left, AssessmentSizingCriterion right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssessmentSizingCriterion(string value) => new AssessmentSizingCriterion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssessmentSizingCriterion other && Equals(other); + /// + public bool Equals(AssessmentSizingCriterion 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSource.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSource.cs new file mode 100644 index 000000000000..b43395708522 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentSource.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Assessment Source. + public readonly partial struct AssessmentSource : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssessmentSource(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string MachineValue = "Machine"; + private const string IISValue = "IIS"; + private const string TomCatValue = "TomCat"; + private const string OracleServerValue = "OracleServer"; + private const string OracleDatabaseValue = "OracleDatabase"; + private const string SAPInstanceValue = "SAPInstance"; + private const string SpringbootApplicationValue = "SpringbootApplication"; + private const string MySQLServerValue = "MySQLServer"; + private const string SqlInstanceValue = "SqlInstance"; + private const string SqlDatabaseValue = "SqlDatabase"; + private const string WebAppsValue = "WebApps"; + + /// Unknown - Assessment Source. + public static AssessmentSource Unknown { get; } = new AssessmentSource(UnknownValue); + /// Machine - Assessment Source. + public static AssessmentSource Machine { get; } = new AssessmentSource(MachineValue); + /// IIS - Assessment Source. + public static AssessmentSource IIS { get; } = new AssessmentSource(IISValue); + /// TomCat - Assessment Source. + public static AssessmentSource TomCat { get; } = new AssessmentSource(TomCatValue); + /// OracleServer - Assessment Source. + public static AssessmentSource OracleServer { get; } = new AssessmentSource(OracleServerValue); + /// OracleDatabase - Assessment Source. + public static AssessmentSource OracleDatabase { get; } = new AssessmentSource(OracleDatabaseValue); + /// SAPInstance - Assessment Source. + public static AssessmentSource SAPInstance { get; } = new AssessmentSource(SAPInstanceValue); + /// SpringbootApplication - Assessment Source. + public static AssessmentSource SpringbootApplication { get; } = new AssessmentSource(SpringbootApplicationValue); + /// MySQLServer - Assessment Source. + public static AssessmentSource MySQLServer { get; } = new AssessmentSource(MySQLServerValue); + /// SqlInstance - Assessment Source. + public static AssessmentSource SqlInstance { get; } = new AssessmentSource(SqlInstanceValue); + /// SqlDatabase - Assessment Source. + public static AssessmentSource SqlDatabase { get; } = new AssessmentSource(SqlDatabaseValue); + /// WebApps - Assessment Source. + public static AssessmentSource WebApps { get; } = new AssessmentSource(WebAppsValue); + /// Determines if two values are the same. + public static bool operator ==(AssessmentSource left, AssessmentSource right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssessmentSource left, AssessmentSource right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssessmentSource(string value) => new AssessmentSource(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssessmentSource other && Equals(other); + /// + public bool Equals(AssessmentSource 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentStatus.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentStatus.cs new file mode 100644 index 000000000000..d9730d5c1d38 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AssessmentStatus.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.Migrate.Models +{ + /// Assessment Status. + public readonly partial struct AssessmentStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssessmentStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CreatedValue = "Created"; + private const string UpdatedValue = "Updated"; + private const string RunningValue = "Running"; + private const string CompletedValue = "Completed"; + private const string InvalidValue = "Invalid"; + private const string OutOfSyncValue = "OutOfSync"; + private const string OutDatedValue = "OutDated"; + private const string DeletedValue = "Deleted"; + private const string FailedValue = "Failed"; + + /// Assessment is Created. + public static AssessmentStatus Created { get; } = new AssessmentStatus(CreatedValue); + /// Assessment is Updated. + public static AssessmentStatus Updated { get; } = new AssessmentStatus(UpdatedValue); + /// Assessment is currently running. + public static AssessmentStatus Running { get; } = new AssessmentStatus(RunningValue); + /// Assessment is Completed or Ready. + public static AssessmentStatus Completed { get; } = new AssessmentStatus(CompletedValue); + /// Assessment is Failed i.e. it is now invalid. + public static AssessmentStatus Invalid { get; } = new AssessmentStatus(InvalidValue); + /// Assessment is Out of Sync. + public static AssessmentStatus OutOfSync { get; } = new AssessmentStatus(OutOfSyncValue); + /// Assessment is Out Dated. + public static AssessmentStatus OutDated { get; } = new AssessmentStatus(OutDatedValue); + /// Assessment is Deleted. + public static AssessmentStatus Deleted { get; } = new AssessmentStatus(DeletedValue); + /// Assessment has Failed. + public static AssessmentStatus Failed { get; } = new AssessmentStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(AssessmentStatus left, AssessmentStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssessmentStatus left, AssessmentStatus right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AssessmentStatus(string value) => new AssessmentStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssessmentStatus other && Equals(other); + /// + public bool Equals(AssessmentStatus 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureCurrency.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureCurrency.cs new file mode 100644 index 000000000000..8602013b1a0e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureCurrency.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Currency for Azure. + public readonly partial struct AzureCurrency : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureCurrency(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string USDValue = "USD"; + private const string DKKValue = "DKK"; + private const string CADValue = "CAD"; + private const string IdRValue = "IDR"; + private const string JPYValue = "JPY"; + private const string KRWValue = "KRW"; + private const string NZDValue = "NZD"; + private const string NOKValue = "NOK"; + private const string RUBValue = "RUB"; + private const string SARValue = "SAR"; + private const string ZARValue = "ZAR"; + private const string SEKValue = "SEK"; + private const string TRYValue = "TRY"; + private const string GBPValue = "GBP"; + private const string MXNValue = "MXN"; + private const string MYRValue = "MYR"; + private const string INRValue = "INR"; + private const string HKDValue = "HKD"; + private const string BRLValue = "BRL"; + private const string TWDValue = "TWD"; + private const string EURValue = "EUR"; + private const string CHFValue = "CHF"; + private const string ARSValue = "ARS"; + private const string AUDValue = "AUD"; + private const string CNYValue = "CNY"; + + /// Unknown Currency for Azure. + public static AzureCurrency Unknown { get; } = new AzureCurrency(UnknownValue); + /// USD Currency for Azure. + public static AzureCurrency USD { get; } = new AzureCurrency(USDValue); + /// DKK Currency for Azure. + public static AzureCurrency DKK { get; } = new AzureCurrency(DKKValue); + /// CAD Currency for Azure. + public static AzureCurrency CAD { get; } = new AzureCurrency(CADValue); + /// IDR Currency for Azure. + public static AzureCurrency IdR { get; } = new AzureCurrency(IdRValue); + /// JPY Currency for Azure. + public static AzureCurrency JPY { get; } = new AzureCurrency(JPYValue); + /// KRW Currency for Azure. + public static AzureCurrency KRW { get; } = new AzureCurrency(KRWValue); + /// NZD Currency for Azure. + public static AzureCurrency NZD { get; } = new AzureCurrency(NZDValue); + /// NOK Currency for Azure. + public static AzureCurrency NOK { get; } = new AzureCurrency(NOKValue); + /// RUB Currency for Azure. + public static AzureCurrency RUB { get; } = new AzureCurrency(RUBValue); + /// SAR Currency for Azure. + public static AzureCurrency SAR { get; } = new AzureCurrency(SARValue); + /// ZAR Currency for Azure. + public static AzureCurrency ZAR { get; } = new AzureCurrency(ZARValue); + /// SEK Currency for Azure. + public static AzureCurrency SEK { get; } = new AzureCurrency(SEKValue); + /// TRY Currency for Azure. + public static AzureCurrency TRY { get; } = new AzureCurrency(TRYValue); + /// GBP Currency for Azure. + public static AzureCurrency GBP { get; } = new AzureCurrency(GBPValue); + /// MXN Currency for Azure. + public static AzureCurrency MXN { get; } = new AzureCurrency(MXNValue); + /// MYR Currency for Azure. + public static AzureCurrency MYR { get; } = new AzureCurrency(MYRValue); + /// INR Currency for Azure. + public static AzureCurrency INR { get; } = new AzureCurrency(INRValue); + /// HKD Currency for Azure. + public static AzureCurrency HKD { get; } = new AzureCurrency(HKDValue); + /// BRL Currency for Azure. + public static AzureCurrency BRL { get; } = new AzureCurrency(BRLValue); + /// TWD Currency for Azure. + public static AzureCurrency TWD { get; } = new AzureCurrency(TWDValue); + /// EUR Currency for Azure. + public static AzureCurrency EUR { get; } = new AzureCurrency(EURValue); + /// CHF Currency for Azure. + public static AzureCurrency CHF { get; } = new AzureCurrency(CHFValue); + /// ARS Currency for Azure. + public static AzureCurrency ARS { get; } = new AzureCurrency(ARSValue); + /// AUD Currency for Azure. + public static AzureCurrency AUD { get; } = new AzureCurrency(AUDValue); + /// CNY Currency for Azure. + public static AzureCurrency CNY { get; } = new AzureCurrency(CNYValue); + /// Determines if two values are the same. + public static bool operator ==(AzureCurrency left, AzureCurrency right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureCurrency left, AzureCurrency right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureCurrency(string value) => new AzureCurrency(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureCurrency other && Equals(other); + /// + public bool Equals(AzureCurrency 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureDiskType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureDiskType.cs new file mode 100644 index 000000000000..bd231891921c --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureDiskType.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Disk Type. + public readonly partial struct AzureDiskType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureDiskType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string StandardValue = "Standard"; + private const string StandardSSDValue = "StandardSSD"; + private const string PremiumValue = "Premium"; + private const string StandardOrPremiumValue = "StandardOrPremium"; + private const string UltraValue = "Ultra"; + private const string PremiumV2Value = "PremiumV2"; + + /// Unknown Azure Disk Type. + public static AzureDiskType Unknown { get; } = new AzureDiskType(UnknownValue); + /// Standard Azure Disk Type. + public static AzureDiskType Standard { get; } = new AzureDiskType(StandardValue); + /// StandardSSD Azure Disk Type. + public static AzureDiskType StandardSSD { get; } = new AzureDiskType(StandardSSDValue); + /// Premium Azure Disk Type. + public static AzureDiskType Premium { get; } = new AzureDiskType(PremiumValue); + /// StandardOrPremium Azure Disk Type. + public static AzureDiskType StandardOrPremium { get; } = new AzureDiskType(StandardOrPremiumValue); + /// Ultra Azure Disk Type. + public static AzureDiskType Ultra { get; } = new AzureDiskType(UltraValue); + /// PremiumV2 Azure Disk Type. + public static AzureDiskType PremiumV2 { get; } = new AzureDiskType(PremiumV2Value); + /// Determines if two values are the same. + public static bool operator ==(AzureDiskType left, AzureDiskType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureDiskType left, AzureDiskType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureDiskType(string value) => new AzureDiskType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureDiskType other && Equals(other); + /// + public bool Equals(AzureDiskType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureHybridUseBenefit.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureHybridUseBenefit.cs new file mode 100644 index 000000000000..0e58b039ef15 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureHybridUseBenefit.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.Migrate.Models +{ + /// Azure Hybrid Use Benefit. + public readonly partial struct AzureHybridUseBenefit : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureHybridUseBenefit(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string YesValue = "Yes"; + private const string NoValue = "No"; + + /// Unknown Azure Hybrid Use Benefit. + public static AzureHybridUseBenefit Unknown { get; } = new AzureHybridUseBenefit(UnknownValue); + /// Yes Azure Hybrid Use Benefit. + public static AzureHybridUseBenefit Yes { get; } = new AzureHybridUseBenefit(YesValue); + /// No Azure Hybrid Use Benefit. + public static AzureHybridUseBenefit No { get; } = new AzureHybridUseBenefit(NoValue); + /// Determines if two values are the same. + public static bool operator ==(AzureHybridUseBenefit left, AzureHybridUseBenefit right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureHybridUseBenefit left, AzureHybridUseBenefit right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureHybridUseBenefit(string value) => new AzureHybridUseBenefit(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureHybridUseBenefit other && Equals(other); + /// + public bool Equals(AzureHybridUseBenefit 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureLocation.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureLocation.cs new file mode 100644 index 000000000000..f8066c2f2576 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureLocation.cs @@ -0,0 +1,246 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Location for Azure. + public readonly partial struct AzureLocation : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureLocation(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string EastAsiaValue = "EastAsia"; + private const string SoutheastAsiaValue = "SoutheastAsia"; + private const string AustraliaEastValue = "AustraliaEast"; + private const string AustraliaSoutheastValue = "AustraliaSoutheast"; + private const string BrazilSouthValue = "BrazilSouth"; + private const string CanadaCentralValue = "CanadaCentral"; + private const string CanadaEastValue = "CanadaEast"; + private const string WestEuropeValue = "WestEurope"; + private const string NorthEuropeValue = "NorthEurope"; + private const string CentralIndiaValue = "CentralIndia"; + private const string SouthIndiaValue = "SouthIndia"; + private const string WestIndiaValue = "WestIndia"; + private const string JapanEastValue = "JapanEast"; + private const string JapanWestValue = "JapanWest"; + private const string KoreaCentralValue = "KoreaCentral"; + private const string KoreaSouthValue = "KoreaSouth"; + private const string UkWestValue = "UkWest"; + private const string UkSouthValue = "UkSouth"; + private const string NorthCentralUsValue = "NorthCentralUs"; + private const string EastUsValue = "EastUs"; + private const string WestUs2Value = "WestUs2"; + private const string SouthCentralUsValue = "SouthCentralUs"; + private const string CentralUsValue = "CentralUs"; + private const string EastUs2Value = "EastUs2"; + private const string WestUsValue = "WestUs"; + private const string WestCentralUsValue = "WestCentralUs"; + private const string GermanyCentralValue = "GermanyCentral"; + private const string GermanyNortheastValue = "GermanyNortheast"; + private const string ChinaNorthValue = "ChinaNorth"; + private const string ChinaEastValue = "ChinaEast"; + private const string USGovArizonaValue = "USGovArizona"; + private const string USGovTexasValue = "USGovTexas"; + private const string USGovIowaValue = "USGovIowa"; + private const string USGovVirginiaValue = "USGovVirginia"; + private const string USDoDCentralValue = "USDoDCentral"; + private const string USDoDEastValue = "USDoDEast"; + private const string FranceCentralValue = "FranceCentral"; + private const string AustraliaCentralValue = "AustraliaCentral"; + private const string SouthAfricaNorthValue = "SouthAfricaNorth"; + private const string FranceSouthValue = "FranceSouth"; + private const string AustraliaCentral2Value = "AustraliaCentral2"; + private const string SouthAfricaWestValue = "SouthAfricaWest"; + private const string GermanyNorthValue = "GermanyNorth"; + private const string GermanyWestCentralValue = "GermanyWestCentral"; + private const string NorwayEastValue = "NorwayEast"; + private const string NorwayWestValue = "NorwayWest"; + private const string ChinaEast2Value = "ChinaEast2"; + private const string ChinaNorth2Value = "ChinaNorth2"; + private const string SwitzerlandNorthValue = "SwitzerlandNorth"; + private const string SwitzerlandWestValue = "SwitzerlandWest"; + private const string UAENorthValue = "UAENorth"; + private const string UAECentralValue = "UAECentral"; + private const string UsNatEastValue = "UsNatEast"; + private const string UsNatWestValue = "UsNatWest"; + private const string UsSecEastValue = "UsSecEast"; + private const string UsSecCentralValue = "UsSecCentral"; + private const string UsSecWestValue = "UsSecWest"; + private const string SwedenCentralValue = "SwedenCentral"; + private const string QatarCentralValue = "QatarCentral"; + private const string JioIndiaWestValue = "JioIndiaWest"; + private const string ItalyNorthValue = "ItalyNorth"; + private const string PolandCentralValue = "PolandCentral"; + private const string IsraelCentralValue = "IsraelCentral"; + private const string MexicoCentralValue = "MexicoCentral"; + private const string NewZealandNorthValue = "NewZealandNorth"; + private const string SpainCentralValue = "SpainCentral"; + + /// Unknown Location for Azure. + public static AzureLocation Unknown { get; } = new AzureLocation(UnknownValue); + /// EastAsia Location for Azure. + public static AzureLocation EastAsia { get; } = new AzureLocation(EastAsiaValue); + /// SoutheastAsia Location for Azure. + public static AzureLocation SoutheastAsia { get; } = new AzureLocation(SoutheastAsiaValue); + /// AustraliaEast Location for Azure. + public static AzureLocation AustraliaEast { get; } = new AzureLocation(AustraliaEastValue); + /// AustraliaSoutheast Location for Azure. + public static AzureLocation AustraliaSoutheast { get; } = new AzureLocation(AustraliaSoutheastValue); + /// BrazilSouth Location for Azure. + public static AzureLocation BrazilSouth { get; } = new AzureLocation(BrazilSouthValue); + /// CanadaCentral Location for Azure. + public static AzureLocation CanadaCentral { get; } = new AzureLocation(CanadaCentralValue); + /// CanadaEast Location for Azure. + public static AzureLocation CanadaEast { get; } = new AzureLocation(CanadaEastValue); + /// WestEurope Location for Azure. + public static AzureLocation WestEurope { get; } = new AzureLocation(WestEuropeValue); + /// NorthEurope Location for Azure. + public static AzureLocation NorthEurope { get; } = new AzureLocation(NorthEuropeValue); + /// CentralIndia Location for Azure. + public static AzureLocation CentralIndia { get; } = new AzureLocation(CentralIndiaValue); + /// SouthIndia Location for Azure. + public static AzureLocation SouthIndia { get; } = new AzureLocation(SouthIndiaValue); + /// WestIndia Location for Azure. + public static AzureLocation WestIndia { get; } = new AzureLocation(WestIndiaValue); + /// JapanEast Location for Azure. + public static AzureLocation JapanEast { get; } = new AzureLocation(JapanEastValue); + /// JapanWest Location for Azure. + public static AzureLocation JapanWest { get; } = new AzureLocation(JapanWestValue); + /// KoreaCentral Location for Azure. + public static AzureLocation KoreaCentral { get; } = new AzureLocation(KoreaCentralValue); + /// KoreaSouth Location for Azure. + public static AzureLocation KoreaSouth { get; } = new AzureLocation(KoreaSouthValue); + /// UkWest Location for Azure. + public static AzureLocation UkWest { get; } = new AzureLocation(UkWestValue); + /// UkSouth Location for Azure. + public static AzureLocation UkSouth { get; } = new AzureLocation(UkSouthValue); + /// NorthCentralUs Location for Azure. + public static AzureLocation NorthCentralUs { get; } = new AzureLocation(NorthCentralUsValue); + /// EastUs Location for Azure. + public static AzureLocation EastUs { get; } = new AzureLocation(EastUsValue); + /// WestUs2 Location for Azure. + public static AzureLocation WestUs2 { get; } = new AzureLocation(WestUs2Value); + /// SouthCentralUs Location for Azure. + public static AzureLocation SouthCentralUs { get; } = new AzureLocation(SouthCentralUsValue); + /// CentralUs Location for Azure. + public static AzureLocation CentralUs { get; } = new AzureLocation(CentralUsValue); + /// EastUs2 Location for Azure. + public static AzureLocation EastUs2 { get; } = new AzureLocation(EastUs2Value); + /// WestUs Location for Azure. + public static AzureLocation WestUs { get; } = new AzureLocation(WestUsValue); + /// WestCentralUs Location for Azure. + public static AzureLocation WestCentralUs { get; } = new AzureLocation(WestCentralUsValue); + /// GermanyCentral Location for Azure. + public static AzureLocation GermanyCentral { get; } = new AzureLocation(GermanyCentralValue); + /// GermanyNortheast Location for Azure. + public static AzureLocation GermanyNortheast { get; } = new AzureLocation(GermanyNortheastValue); + /// ChinaNorth Location for Azure. + public static AzureLocation ChinaNorth { get; } = new AzureLocation(ChinaNorthValue); + /// ChinaEast Location for Azure. + public static AzureLocation ChinaEast { get; } = new AzureLocation(ChinaEastValue); + /// USGovArizona Location for Azure. + public static AzureLocation USGovArizona { get; } = new AzureLocation(USGovArizonaValue); + /// USGovTexas Location for Azure. + public static AzureLocation USGovTexas { get; } = new AzureLocation(USGovTexasValue); + /// USGovIowa Location for Azure. + public static AzureLocation USGovIowa { get; } = new AzureLocation(USGovIowaValue); + /// USGovVirginia Location for Azure. + public static AzureLocation USGovVirginia { get; } = new AzureLocation(USGovVirginiaValue); + /// USDoDCentral Location for Azure. + public static AzureLocation USDoDCentral { get; } = new AzureLocation(USDoDCentralValue); + /// USDoDEast Location for Azure. + public static AzureLocation USDoDEast { get; } = new AzureLocation(USDoDEastValue); + /// FranceCentral Location for Azure. + public static AzureLocation FranceCentral { get; } = new AzureLocation(FranceCentralValue); + /// AustraliaCentral Location for Azure. + public static AzureLocation AustraliaCentral { get; } = new AzureLocation(AustraliaCentralValue); + /// SouthAfricaNorth Location for Azure. + public static AzureLocation SouthAfricaNorth { get; } = new AzureLocation(SouthAfricaNorthValue); + /// FranceSouth Location for Azure. + public static AzureLocation FranceSouth { get; } = new AzureLocation(FranceSouthValue); + /// AustraliaCentral2 Location for Azure. + public static AzureLocation AustraliaCentral2 { get; } = new AzureLocation(AustraliaCentral2Value); + /// SouthAfricaWest Location for Azure. + public static AzureLocation SouthAfricaWest { get; } = new AzureLocation(SouthAfricaWestValue); + /// GermanyNorth Location for Azure. + public static AzureLocation GermanyNorth { get; } = new AzureLocation(GermanyNorthValue); + /// GermanyWestCentral Location for Azure. + public static AzureLocation GermanyWestCentral { get; } = new AzureLocation(GermanyWestCentralValue); + /// NorwayEast Location for Azure. + public static AzureLocation NorwayEast { get; } = new AzureLocation(NorwayEastValue); + /// NorwayWest Location for Azure. + public static AzureLocation NorwayWest { get; } = new AzureLocation(NorwayWestValue); + /// ChinaEast2 Location for Azure. + public static AzureLocation ChinaEast2 { get; } = new AzureLocation(ChinaEast2Value); + /// ChinaNorth2 Location for Azure. + public static AzureLocation ChinaNorth2 { get; } = new AzureLocation(ChinaNorth2Value); + /// SwitzerlandNorth Location for Azure. + public static AzureLocation SwitzerlandNorth { get; } = new AzureLocation(SwitzerlandNorthValue); + /// SwitzerlandWest Location for Azure. + public static AzureLocation SwitzerlandWest { get; } = new AzureLocation(SwitzerlandWestValue); + /// UAENorth Location for Azure. + public static AzureLocation UAENorth { get; } = new AzureLocation(UAENorthValue); + /// UAECentral Location for Azure. + public static AzureLocation UAECentral { get; } = new AzureLocation(UAECentralValue); + /// UsNatEast Location for Azure. + public static AzureLocation UsNatEast { get; } = new AzureLocation(UsNatEastValue); + /// UsNatWest Location for Azure. + public static AzureLocation UsNatWest { get; } = new AzureLocation(UsNatWestValue); + /// UsSecEast Location for Azure. + public static AzureLocation UsSecEast { get; } = new AzureLocation(UsSecEastValue); + /// UsSecCentral Location for Azure. + public static AzureLocation UsSecCentral { get; } = new AzureLocation(UsSecCentralValue); + /// UsSecWest Location for Azure. + public static AzureLocation UsSecWest { get; } = new AzureLocation(UsSecWestValue); + /// SwedenCentral Location for Azure. + public static AzureLocation SwedenCentral { get; } = new AzureLocation(SwedenCentralValue); + /// QatarCentral Location for Azure. + public static AzureLocation QatarCentral { get; } = new AzureLocation(QatarCentralValue); + /// JioIndiaWest Location for Azure. + public static AzureLocation JioIndiaWest { get; } = new AzureLocation(JioIndiaWestValue); + /// ItalyNorth Location for Azure. + public static AzureLocation ItalyNorth { get; } = new AzureLocation(ItalyNorthValue); + /// PolandCentral Location for Azure. + public static AzureLocation PolandCentral { get; } = new AzureLocation(PolandCentralValue); + /// IsraelCentral Location for Azure. + public static AzureLocation IsraelCentral { get; } = new AzureLocation(IsraelCentralValue); + /// MexicoCentral Location for Azure. + public static AzureLocation MexicoCentral { get; } = new AzureLocation(MexicoCentralValue); + /// NewZealandNorth Location for Azure. + public static AzureLocation NewZealandNorth { get; } = new AzureLocation(NewZealandNorthValue); + /// SpainCentral Location for Azure. + public static AzureLocation SpainCentral { get; } = new AzureLocation(SpainCentralValue); + /// Determines if two values are the same. + public static bool operator ==(AzureLocation left, AzureLocation right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureLocation left, AzureLocation right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureLocation(string value) => new AzureLocation(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureLocation other && Equals(other); + /// + public bool Equals(AzureLocation 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureManagementOfferingType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureManagementOfferingType.cs new file mode 100644 index 000000000000..9051809d1ebd --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureManagementOfferingType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure management Offering type. + public readonly partial struct AzureManagementOfferingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureManagementOfferingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoValue = "No"; + private const string SCOMMIValue = "SCOMMI"; + private const string AzMonValue = "AzMon"; + private const string AUMValue = "AUM"; + private const string AzureBackupValue = "AzureBackup"; + + /// No - Azure management Offering type. + public static AzureManagementOfferingType No { get; } = new AzureManagementOfferingType(NoValue); + /// SCOMMI - Azure management Offering type. + public static AzureManagementOfferingType SCOMMI { get; } = new AzureManagementOfferingType(SCOMMIValue); + /// AzMon - Azure management Offering type. + public static AzureManagementOfferingType AzMon { get; } = new AzureManagementOfferingType(AzMonValue); + /// AUM - Azure management Offering type. + public static AzureManagementOfferingType AUM { get; } = new AzureManagementOfferingType(AUMValue); + /// AzureBackup - Azure management Offering type. + public static AzureManagementOfferingType AzureBackup { get; } = new AzureManagementOfferingType(AzureBackupValue); + /// Determines if two values are the same. + public static bool operator ==(AzureManagementOfferingType left, AzureManagementOfferingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureManagementOfferingType left, AzureManagementOfferingType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureManagementOfferingType(string value) => new AzureManagementOfferingType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureManagementOfferingType other && Equals(other); + /// + public bool Equals(AzureManagementOfferingType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureOffer.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureOffer.cs new file mode 100644 index 000000000000..5d40b2fe83f6 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureOffer.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Offer. + public readonly partial struct AzureOffer : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureOffer(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string Msazr0003PValue = "MSAZR0003P"; + private const string Msazr0023PValue = "MSAZR0023P"; + private const string Msmcazr0044PValue = "MSMCAZR0044P"; + private const string Msmcazr0059PValue = "MSMCAZR0059P"; + private const string Msmcazr0060PValue = "MSMCAZR0060P"; + private const string Msmcazr0063PValue = "MSMCAZR0063P"; + private const string Msazrusgov0003PValue = "MSAZRUSGOV0003P"; + private const string EAValue = "EA"; + private const string SavingsPlan1YearValue = "SavingsPlan1Year"; + private const string SavingsPlan3YearValue = "SavingsPlan3Year"; + + /// Unknown - Azure Offer. + public static AzureOffer Unknown { get; } = new AzureOffer(UnknownValue); + /// MSAZR0003P Azure Offer. + public static AzureOffer Msazr0003P { get; } = new AzureOffer(Msazr0003PValue); + /// MSAZR0023P Azure Offer. + public static AzureOffer Msazr0023P { get; } = new AzureOffer(Msazr0023PValue); + /// MSMCAZR0044P Azure Offer. + public static AzureOffer Msmcazr0044P { get; } = new AzureOffer(Msmcazr0044PValue); + /// MSMCAZR0059P Azure Offer. + public static AzureOffer Msmcazr0059P { get; } = new AzureOffer(Msmcazr0059PValue); + /// MSMCAZR0060P Azure Offer. + public static AzureOffer Msmcazr0060P { get; } = new AzureOffer(Msmcazr0060PValue); + /// MSMCAZR0063P Azure Offer. + public static AzureOffer Msmcazr0063P { get; } = new AzureOffer(Msmcazr0063PValue); + /// MSAZRUSGOV0003P Azure Offer. + public static AzureOffer Msazrusgov0003P { get; } = new AzureOffer(Msazrusgov0003PValue); + /// EA Azure Offer. + public static AzureOffer EA { get; } = new AzureOffer(EAValue); + /// SavingsPlan1Year Azure Offer. + public static AzureOffer SavingsPlan1Year { get; } = new AzureOffer(SavingsPlan1YearValue); + /// SavingsPlan3Year Azure Offer. + public static AzureOffer SavingsPlan3Year { get; } = new AzureOffer(SavingsPlan3YearValue); + /// Determines if two values are the same. + public static bool operator ==(AzureOffer left, AzureOffer right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureOffer left, AzureOffer right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureOffer(string value) => new AzureOffer(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureOffer other && Equals(other); + /// + public bool Equals(AzureOffer 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzurePricingTier.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzurePricingTier.cs new file mode 100644 index 000000000000..f9a1fb4174dc --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzurePricingTier.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Pricing Tier. + public readonly partial struct AzurePricingTier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzurePricingTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StandardValue = "Standard"; + private const string BasicValue = "Basic"; + + /// Standard Azure Pricing Tier. + public static AzurePricingTier Standard { get; } = new AzurePricingTier(StandardValue); + /// Basic Azure Pricing Tier. + public static AzurePricingTier Basic { get; } = new AzurePricingTier(BasicValue); + /// Determines if two values are the same. + public static bool operator ==(AzurePricingTier left, AzurePricingTier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzurePricingTier left, AzurePricingTier right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzurePricingTier(string value) => new AzurePricingTier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzurePricingTier other && Equals(other); + /// + public bool Equals(AzurePricingTier 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureSecurityOfferingType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureSecurityOfferingType.cs new file mode 100644 index 000000000000..fa306a2273f8 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureSecurityOfferingType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Security Offering Type. + public readonly partial struct AzureSecurityOfferingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureSecurityOfferingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NOValue = "NO"; + private const string MDCValue = "MDC"; + + /// NO - Azure Security Offering Type. + public static AzureSecurityOfferingType NO { get; } = new AzureSecurityOfferingType(NOValue); + /// MDC - Azure Security Offering Type. + public static AzureSecurityOfferingType MDC { get; } = new AzureSecurityOfferingType(MDCValue); + /// Determines if two values are the same. + public static bool operator ==(AzureSecurityOfferingType left, AzureSecurityOfferingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureSecurityOfferingType left, AzureSecurityOfferingType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureSecurityOfferingType(string value) => new AzureSecurityOfferingType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureSecurityOfferingType other && Equals(other); + /// + public bool Equals(AzureSecurityOfferingType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureStorageRedundancy.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureStorageRedundancy.cs new file mode 100644 index 000000000000..f738547ff658 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureStorageRedundancy.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Storage Redundancy. + public readonly partial struct AzureStorageRedundancy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureStorageRedundancy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string LocallyRedundantValue = "LocallyRedundant"; + private const string ZoneRedundantValue = "ZoneRedundant"; + private const string GeoRedundantValue = "GeoRedundant"; + private const string ReadAccessGeoRedundantValue = "ReadAccessGeoRedundant"; + + /// Unknown Azure Storage Redundancy. + public static AzureStorageRedundancy Unknown { get; } = new AzureStorageRedundancy(UnknownValue); + /// LocallyRedundant Azure Storage Redundancy. + public static AzureStorageRedundancy LocallyRedundant { get; } = new AzureStorageRedundancy(LocallyRedundantValue); + /// ZoneRedundant Azure Storage Redundancy. + public static AzureStorageRedundancy ZoneRedundant { get; } = new AzureStorageRedundancy(ZoneRedundantValue); + /// GeoRedundant Azure Storage Redundancy. + public static AzureStorageRedundancy GeoRedundant { get; } = new AzureStorageRedundancy(GeoRedundantValue); + /// ReadAccessGeoRedundant Azure Storage Redundancy. + public static AzureStorageRedundancy ReadAccessGeoRedundant { get; } = new AzureStorageRedundancy(ReadAccessGeoRedundantValue); + /// Determines if two values are the same. + public static bool operator ==(AzureStorageRedundancy left, AzureStorageRedundancy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureStorageRedundancy left, AzureStorageRedundancy right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureStorageRedundancy(string value) => new AzureStorageRedundancy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureStorageRedundancy other && Equals(other); + /// + public bool Equals(AzureStorageRedundancy 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureTarget.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureTarget.cs new file mode 100644 index 000000000000..88dd6282ff39 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureTarget.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Target. + public readonly partial struct AzureTarget : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureTarget(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string SqlDatabaseValue = "SqlDatabase"; + private const string SqlMIValue = "SqlMI"; + private const string FlexServerPGValue = "FlexServerPG"; + private const string OracleIaasVmValue = "OracleIaasVM"; + private const string AzureSpringAppsValue = "AzureSpringApps"; + private const string SAPAzureInstanceValue = "SAPAzureInstance"; + private const string AKSValue = "AKS"; + private const string MySQLAzureFlexServerValue = "MySQLAzureFlexServer"; + private const string AzureSQLVMValue = "AzureSQLVM"; + private const string AzureVmValue = "AzureVM"; + private const string AzureAppServiceValue = "AzureAppService"; + private const string AzureAppServiceContainerValue = "AzureAppServiceContainer"; + private const string AvsValue = "Avs"; + + /// Unknown - Azure Target. + public static AzureTarget Unknown { get; } = new AzureTarget(UnknownValue); + /// SqlDatabase - Azure Target. + public static AzureTarget SqlDatabase { get; } = new AzureTarget(SqlDatabaseValue); + /// SqlMI - Azure Target. + public static AzureTarget SqlMI { get; } = new AzureTarget(SqlMIValue); + /// FlexServerPG - Azure Target. + public static AzureTarget FlexServerPG { get; } = new AzureTarget(FlexServerPGValue); + /// OracleIaasVM - Azure Target. + public static AzureTarget OracleIaasVm { get; } = new AzureTarget(OracleIaasVmValue); + /// AzureSpringApps - Azure Target. + public static AzureTarget AzureSpringApps { get; } = new AzureTarget(AzureSpringAppsValue); + /// SAPAzureInstance - Azure Target. + public static AzureTarget SAPAzureInstance { get; } = new AzureTarget(SAPAzureInstanceValue); + /// AKS - Azure Target. + public static AzureTarget AKS { get; } = new AzureTarget(AKSValue); + /// MySQLAzureFlexServer - Azure Target. + public static AzureTarget MySQLAzureFlexServer { get; } = new AzureTarget(MySQLAzureFlexServerValue); + /// AzureSQLVM - Azure Target. + public static AzureTarget AzureSQLVM { get; } = new AzureTarget(AzureSQLVMValue); + /// AzureVM - Azure Target. + public static AzureTarget AzureVm { get; } = new AzureTarget(AzureVmValue); + /// AzureAppService - Azure Target. + public static AzureTarget AzureAppService { get; } = new AzureTarget(AzureAppServiceValue); + /// AzureAppServiceContainer - Azure Target. + public static AzureTarget AzureAppServiceContainer { get; } = new AzureTarget(AzureAppServiceContainerValue); + /// Avs - Azure Target. + public static AzureTarget Avs { get; } = new AzureTarget(AvsValue); + /// Determines if two values are the same. + public static bool operator ==(AzureTarget left, AzureTarget right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureTarget left, AzureTarget right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureTarget(string value) => new AzureTarget(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureTarget other && Equals(other); + /// + public bool Equals(AzureTarget 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmFamily.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmFamily.cs new file mode 100644 index 000000000000..89011165fe17 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmFamily.cs @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure VM Family. + public readonly partial struct AzureVmFamily : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureVmFamily(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string BasicA0A4Value = "Basic_A0_A4"; + private const string StandardA0A7Value = "Standard_A0_A7"; + private const string StandardA8A11Value = "Standard_A8_A11"; + private const string Av2SeriesValue = "Av2_series"; + private const string DSeriesValue = "D_series"; + private const string Dv2SeriesValue = "Dv2_series"; + private const string DSSeriesValue = "DS_series"; + private const string DSv2SeriesValue = "DSv2_series"; + private const string FSeriesValue = "F_series"; + private const string FsSeriesValue = "Fs_series"; + private const string GSeriesValue = "G_series"; + private const string GSSeriesValue = "GS_series"; + private const string HSeriesValue = "H_series"; + private const string LsSeriesValue = "Ls_series"; + private const string Dsv3SeriesValue = "Dsv3_series"; + private const string Dv3SeriesValue = "Dv3_series"; + private const string Fsv2SeriesValue = "Fsv2_series"; + private const string Ev3SeriesValue = "Ev3_series"; + private const string Esv3SeriesValue = "Esv3_series"; + private const string MSeriesValue = "M_series"; + private const string DCSeriesValue = "DC_Series"; + private const string Lsv2SeriesValue = "Lsv2_series"; + private const string Ev4SeriesValue = "Ev4_series"; + private const string Esv4SeriesValue = "Esv4_series"; + private const string Edv4SeriesValue = "Edv4_series"; + private const string Edsv4SeriesValue = "Edsv4_series"; + private const string Dv4SeriesValue = "Dv4_series"; + private const string Dsv4SeriesValue = "Dsv4_series"; + private const string Ddv4SeriesValue = "Ddv4_series"; + private const string Ddsv4SeriesValue = "Ddsv4_series"; + private const string Easv4SeriesValue = "Easv4_series"; + private const string Dasv4SeriesValue = "Dasv4_series"; + private const string Mv2SeriesValue = "Mv2_series"; + private const string Eav4SeriesValue = "Eav4_series"; + private const string Dav4SeriesValue = "Dav4_series"; + private const string Msv2SeriesValue = "Msv2_series"; + private const string Mdsv2SeriesValue = "Mdsv2_series"; + private const string Dv5SeriesValue = "Dv5_series"; + private const string Dsv5SeriesValue = "Dsv5_series"; + private const string Ddv5SeriesValue = "Ddv5_series"; + private const string Ddsv5SeriesValue = "Ddsv5_series"; + private const string Dasv5SeriesValue = "Dasv5_series"; + private const string Dadsv5SeriesValue = "Dadsv5_series"; + private const string Ev5SeriesValue = "Ev5_series"; + private const string Esv5SeriesValue = "Esv5_series"; + private const string Edv5SeriesValue = "Edv5_series"; + private const string Edsv5SeriesValue = "Edsv5_series"; + private const string Easv5SeriesValue = "Easv5_series"; + private const string Eadsv5SeriesValue = "Eadsv5_series"; + private const string Ebsv5SeriesValue = "Ebsv5_series"; + private const string Ebdsv5SeriesValue = "Ebdsv5_series"; + + /// Unknown - Azure VM Family. + public static AzureVmFamily Unknown { get; } = new AzureVmFamily(UnknownValue); + /// Basic_A0_A4. + public static AzureVmFamily BasicA0A4 { get; } = new AzureVmFamily(BasicA0A4Value); + /// Standard_A0_A7. + public static AzureVmFamily StandardA0A7 { get; } = new AzureVmFamily(StandardA0A7Value); + /// Standard_A8_A11. + public static AzureVmFamily StandardA8A11 { get; } = new AzureVmFamily(StandardA8A11Value); + /// Av2_series. + public static AzureVmFamily Av2Series { get; } = new AzureVmFamily(Av2SeriesValue); + /// D_series. + public static AzureVmFamily DSeries { get; } = new AzureVmFamily(DSeriesValue); + /// Dv2_series. + public static AzureVmFamily Dv2Series { get; } = new AzureVmFamily(Dv2SeriesValue); + /// DS_series. + public static AzureVmFamily DSSeries { get; } = new AzureVmFamily(DSSeriesValue); + /// DSv2_series. + public static AzureVmFamily DSv2Series { get; } = new AzureVmFamily(DSv2SeriesValue); + /// F_series. + public static AzureVmFamily FSeries { get; } = new AzureVmFamily(FSeriesValue); + /// Fs_series. + public static AzureVmFamily FsSeries { get; } = new AzureVmFamily(FsSeriesValue); + /// G_series. + public static AzureVmFamily GSeries { get; } = new AzureVmFamily(GSeriesValue); + /// GS_series. + public static AzureVmFamily GSSeries { get; } = new AzureVmFamily(GSSeriesValue); + /// H_series. + public static AzureVmFamily HSeries { get; } = new AzureVmFamily(HSeriesValue); + /// Ls_series. + public static AzureVmFamily LsSeries { get; } = new AzureVmFamily(LsSeriesValue); + /// Dsv3_series. + public static AzureVmFamily Dsv3Series { get; } = new AzureVmFamily(Dsv3SeriesValue); + /// Dv3_series. + public static AzureVmFamily Dv3Series { get; } = new AzureVmFamily(Dv3SeriesValue); + /// Fsv2_series. + public static AzureVmFamily Fsv2Series { get; } = new AzureVmFamily(Fsv2SeriesValue); + /// Ev3_series. + public static AzureVmFamily Ev3Series { get; } = new AzureVmFamily(Ev3SeriesValue); + /// Esv3_series. + public static AzureVmFamily Esv3Series { get; } = new AzureVmFamily(Esv3SeriesValue); + /// M_series. + public static AzureVmFamily MSeries { get; } = new AzureVmFamily(MSeriesValue); + /// DC_Series. + public static AzureVmFamily DCSeries { get; } = new AzureVmFamily(DCSeriesValue); + /// Lsv2_series. + public static AzureVmFamily Lsv2Series { get; } = new AzureVmFamily(Lsv2SeriesValue); + /// Ev4_series. + public static AzureVmFamily Ev4Series { get; } = new AzureVmFamily(Ev4SeriesValue); + /// Esv4_series. + public static AzureVmFamily Esv4Series { get; } = new AzureVmFamily(Esv4SeriesValue); + /// Edv4_series. + public static AzureVmFamily Edv4Series { get; } = new AzureVmFamily(Edv4SeriesValue); + /// Edsv4_series. + public static AzureVmFamily Edsv4Series { get; } = new AzureVmFamily(Edsv4SeriesValue); + /// Dv4_series. + public static AzureVmFamily Dv4Series { get; } = new AzureVmFamily(Dv4SeriesValue); + /// Dsv4_series. + public static AzureVmFamily Dsv4Series { get; } = new AzureVmFamily(Dsv4SeriesValue); + /// Ddv4_series. + public static AzureVmFamily Ddv4Series { get; } = new AzureVmFamily(Ddv4SeriesValue); + /// Ddsv4_series. + public static AzureVmFamily Ddsv4Series { get; } = new AzureVmFamily(Ddsv4SeriesValue); + /// Easv4_series. + public static AzureVmFamily Easv4Series { get; } = new AzureVmFamily(Easv4SeriesValue); + /// Dasv4_series. + public static AzureVmFamily Dasv4Series { get; } = new AzureVmFamily(Dasv4SeriesValue); + /// Mv2_series. + public static AzureVmFamily Mv2Series { get; } = new AzureVmFamily(Mv2SeriesValue); + /// Eav4_series. + public static AzureVmFamily Eav4Series { get; } = new AzureVmFamily(Eav4SeriesValue); + /// Dav4_series. + public static AzureVmFamily Dav4Series { get; } = new AzureVmFamily(Dav4SeriesValue); + /// Msv2_series. + public static AzureVmFamily Msv2Series { get; } = new AzureVmFamily(Msv2SeriesValue); + /// Mdsv2_series. + public static AzureVmFamily Mdsv2Series { get; } = new AzureVmFamily(Mdsv2SeriesValue); + /// Dv5_series. + public static AzureVmFamily Dv5Series { get; } = new AzureVmFamily(Dv5SeriesValue); + /// Dsv5_series. + public static AzureVmFamily Dsv5Series { get; } = new AzureVmFamily(Dsv5SeriesValue); + /// Ddv5_series. + public static AzureVmFamily Ddv5Series { get; } = new AzureVmFamily(Ddv5SeriesValue); + /// Ddsv5_series. + public static AzureVmFamily Ddsv5Series { get; } = new AzureVmFamily(Ddsv5SeriesValue); + /// Dasv5_series. + public static AzureVmFamily Dasv5Series { get; } = new AzureVmFamily(Dasv5SeriesValue); + /// Dadsv5_series. + public static AzureVmFamily Dadsv5Series { get; } = new AzureVmFamily(Dadsv5SeriesValue); + /// Ev5_series. + public static AzureVmFamily Ev5Series { get; } = new AzureVmFamily(Ev5SeriesValue); + /// Esv5_series. + public static AzureVmFamily Esv5Series { get; } = new AzureVmFamily(Esv5SeriesValue); + /// Edv5_series. + public static AzureVmFamily Edv5Series { get; } = new AzureVmFamily(Edv5SeriesValue); + /// Edsv5_series. + public static AzureVmFamily Edsv5Series { get; } = new AzureVmFamily(Edsv5SeriesValue); + /// Easv5_series. + public static AzureVmFamily Easv5Series { get; } = new AzureVmFamily(Easv5SeriesValue); + /// Eadsv5_series. + public static AzureVmFamily Eadsv5Series { get; } = new AzureVmFamily(Eadsv5SeriesValue); + /// Ebsv5_series. + public static AzureVmFamily Ebsv5Series { get; } = new AzureVmFamily(Ebsv5SeriesValue); + /// Ebdsv5_series. + public static AzureVmFamily Ebdsv5Series { get; } = new AzureVmFamily(Ebdsv5SeriesValue); + /// Determines if two values are the same. + public static bool operator ==(AzureVmFamily left, AzureVmFamily right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureVmFamily left, AzureVmFamily right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureVmFamily(string value) => new AzureVmFamily(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureVmFamily other && Equals(other); + /// + public bool Equals(AzureVmFamily 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecuritySuitabilityDetail.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecuritySuitabilityDetail.cs new file mode 100644 index 000000000000..b6d108ad0ecd --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecuritySuitabilityDetail.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Azure Vm Security Suitability Detail. + public readonly partial struct AzureVmSecuritySuitabilityDetail : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureVmSecuritySuitabilityDetail(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string NotApplicableValue = "NotApplicable"; + private const string GuestOperatingSystemNotSupportedValue = "GuestOperatingSystemNotSupported"; + private const string BootTypeNotSupportedValue = "BootTypeNotSupported"; + private const string DiskSizeLargeValue = "DiskSizeLarge"; + private const string AllDiskSizeExceeds4TBValue = "AllDiskSizeExceeds4TB"; + private const string AnyDiskSizeExceeds4TBValue = "AnyDiskSizeExceeds4TB"; + private const string AnyDiskSizeExceeds4TBConditionalValue = "AnyDiskSizeExceeds4TBConditional"; + private const string OSNotSupportedValue = "OSNotSupported"; + private const string StandardReadyValue = "StandardReady"; + private const string TVMReadyValue = "TVMReady"; + private const string StandardNotReadyOSNotSupportedValue = "StandardNotReadyOSNotSupported"; + private const string TVMNotReadyOSNotSupportedValue = "TVMNotReadyOSNotSupported"; + private const string StandardNotReady2TBBiosBootValue = "StandardNotReady2TBBiosBoot"; + private const string AllDiskSizeExceeds2TBValue = "AllDiskSizeExceeds2TB"; + private const string DiskSize2TBConditionalReadyBiosBootValue = "DiskSize2TBConditionalReadyBiosBoot"; + private const string TVMCannotMigrateOSNotSupportedValue = "TVMCannotMigrateOSNotSupported"; + private const string StandardCannotMigrateOSNotSupportedValue = "StandardCannotMigrateOSNotSupported"; + private const string StandardCanMigrateValue = "StandardCanMigrate"; + private const string TVMCanMigrateConditionalValue = "TVMCanMigrateConditional"; + private const string OSNameCannotBeReadValue = "OSNameCannotBeRead"; + private const string TVMNotSupportedForBiosBootValue = "TVMNotSupportedForBiosBoot"; + + /// Unknown - Azure Vm Security Suitability Detail. + public static AzureVmSecuritySuitabilityDetail Unknown { get; } = new AzureVmSecuritySuitabilityDetail(UnknownValue); + /// NotApplicable - Azure Vm Security Suitability Detail. + public static AzureVmSecuritySuitabilityDetail NotApplicable { get; } = new AzureVmSecuritySuitabilityDetail(NotApplicableValue); + /// GuestOperatingSystemNotSupported Azure Vm Security Suitability Detail. + public static AzureVmSecuritySuitabilityDetail GuestOperatingSystemNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(GuestOperatingSystemNotSupportedValue); + /// BootTypeNotSupported Azure Vm Security Suitability Detail. + public static AzureVmSecuritySuitabilityDetail BootTypeNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(BootTypeNotSupportedValue); + /// DiskSizeLarge Azure Vm Security Suitability Detail. + public static AzureVmSecuritySuitabilityDetail DiskSizeLarge { get; } = new AzureVmSecuritySuitabilityDetail(DiskSizeLargeValue); + /// Azure does not support VM with OS disk size greater than 4TB. + public static AzureVmSecuritySuitabilityDetail AllDiskSizeExceeds4TB { get; } = new AzureVmSecuritySuitabilityDetail(AllDiskSizeExceeds4TBValue); + /// Azure does not support VM with OS disk size greater than 4TB. If OS disk size is less than 4TB, proceed with migration. + public static AzureVmSecuritySuitabilityDetail AnyDiskSizeExceeds4TB { get; } = new AzureVmSecuritySuitabilityDetail(AnyDiskSizeExceeds4TBValue); + /// Azure does not support VM with any disk size greater than 4TB. Please proceed only if you know the OS disk size is less than 4TB. + public static AzureVmSecuritySuitabilityDetail AnyDiskSizeExceeds4TBConditional { get; } = new AzureVmSecuritySuitabilityDetail(AnyDiskSizeExceeds4TBConditionalValue); + /// The VM is not ready to be migrated to Azure because the OS is not supported. + public static AzureVmSecuritySuitabilityDetail OSNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(OSNotSupportedValue); + /// The VM is ready to be migrated to Azure with standard VM security type. + public static AzureVmSecuritySuitabilityDetail StandardReady { get; } = new AzureVmSecuritySuitabilityDetail(StandardReadyValue); + /// The VM is ready to be migrated to Azure with Trusted launch VM security type. + public static AzureVmSecuritySuitabilityDetail TVMReady { get; } = new AzureVmSecuritySuitabilityDetail(TVMReadyValue); + /// The VM is not ready to be migrated to Azure with standard VM security type because the OS is not supported. + public static AzureVmSecuritySuitabilityDetail StandardNotReadyOSNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(StandardNotReadyOSNotSupportedValue); + /// The VM is not ready to be migrated to Azure with Trusted launch VM security type because the OS is not supported for Trusted launch VM. Get more information [here]. + public static AzureVmSecuritySuitabilityDetail TVMNotReadyOSNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(TVMNotReadyOSNotSupportedValue); + /// The VM is not ready to be migrated to Azure with standard VM security type. Azure does not support OS disk size greater than 2TB for VMs with BIOS boot type. + public static AzureVmSecuritySuitabilityDetail StandardNotReady2TBBiosBoot { get; } = new AzureVmSecuritySuitabilityDetail(StandardNotReady2TBBiosBootValue); + /// The VM is not ready to be migrated to Azure with Trusted launch VM security type. Azure does not support OS disk size greater than 2TB for VMs with BIOS boot type. + public static AzureVmSecuritySuitabilityDetail AllDiskSizeExceeds2TB { get; } = new AzureVmSecuritySuitabilityDetail(AllDiskSizeExceeds2TBValue); + /// The VM readiness is unknown. Azure does not support OS disk size greater than 2TB for VMs with BIOS boot type. Please proceed with migration only if OS disk size is less than 2TB. + public static AzureVmSecuritySuitabilityDetail DiskSize2TBConditionalReadyBiosBoot { get; } = new AzureVmSecuritySuitabilityDetail(DiskSize2TBConditionalReadyBiosBootValue); + /// The VM cannot be migrated to Trusted launch VM because the OS is not supported. Learn more [here]. + public static AzureVmSecuritySuitabilityDetail TVMCannotMigrateOSNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(TVMCannotMigrateOSNotSupportedValue); + /// The VM cannot be migrated to Azure because the OS is not supported. + public static AzureVmSecuritySuitabilityDetail StandardCannotMigrateOSNotSupported { get; } = new AzureVmSecuritySuitabilityDetail(StandardCannotMigrateOSNotSupportedValue); + /// The VM can be migrated to Azure with standard VM security type. + public static AzureVmSecuritySuitabilityDetail StandardCanMigrate { get; } = new AzureVmSecuritySuitabilityDetail(StandardCanMigrateValue); + /// The VM can be migrated to Trusted launch VM. Currently, Azure Migrate does not support migration to Trusted launch for VM with BIOS boot type. You can convert the VM post-migration to Trusted Launch VM. The steps are mentioned in this documentation. + public static AzureVmSecuritySuitabilityDetail TVMCanMigrateConditional { get; } = new AzureVmSecuritySuitabilityDetail(TVMCanMigrateConditionalValue); + /// Readiness is marked as unknown because the OS name cannot be read. + public static AzureVmSecuritySuitabilityDetail OSNameCannotBeRead { get; } = new AzureVmSecuritySuitabilityDetail(OSNameCannotBeReadValue); + /// Migration to Trusted Launch VM is not supported for BIOS boot type VMs at this time. + public static AzureVmSecuritySuitabilityDetail TVMNotSupportedForBiosBoot { get; } = new AzureVmSecuritySuitabilityDetail(TVMNotSupportedForBiosBootValue); + /// Determines if two values are the same. + public static bool operator ==(AzureVmSecuritySuitabilityDetail left, AzureVmSecuritySuitabilityDetail right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureVmSecuritySuitabilityDetail left, AzureVmSecuritySuitabilityDetail right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureVmSecuritySuitabilityDetail(string value) => new AzureVmSecuritySuitabilityDetail(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureVmSecuritySuitabilityDetail other && Equals(other); + /// + public bool Equals(AzureVmSecuritySuitabilityDetail 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecurityType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecurityType.cs new file mode 100644 index 000000000000..2d406a1293df --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/AzureVmSecurityType.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.Migrate.Models +{ + /// Azure Vm Security Type. + public readonly partial struct AzureVmSecurityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AzureVmSecurityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string StandardValue = "Standard"; + private const string TVMValue = "TVM"; + private const string CVMValue = "CVM"; + + /// Unknown - Azure Vm Security Type. + public static AzureVmSecurityType Unknown { get; } = new AzureVmSecurityType(UnknownValue); + /// Standard Azure Vm Security Type. + public static AzureVmSecurityType Standard { get; } = new AzureVmSecurityType(StandardValue); + /// TVM Azure Vm Security Type. + public static AzureVmSecurityType TVM { get; } = new AzureVmSecurityType(TVMValue); + /// CVM Azure Vm Security Type. + public static AzureVmSecurityType CVM { get; } = new AzureVmSecurityType(CVMValue); + /// Determines if two values are the same. + public static bool operator ==(AzureVmSecurityType left, AzureVmSecurityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AzureVmSecurityType left, AzureVmSecurityType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AzureVmSecurityType(string value) => new AzureVmSecurityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AzureVmSecurityType other && Equals(other); + /// + public bool Equals(AzureVmSecurityType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.Serialization.cs new file mode 100644 index 000000000000..acb41acbd0d1 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.Serialization.cs @@ -0,0 +1,144 @@ +// 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.Migrate.Models +{ + public partial class BillingSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BillingSettings)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(LicensingProgram)) + { + writer.WritePropertyName("licensingProgram"u8); + writer.WriteStringValue(LicensingProgram.Value.ToString()); + } + if (Optional.IsDefined(SubscriptionId)) + { + writer.WritePropertyName("subscriptionId"u8); + writer.WriteStringValue(SubscriptionId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + BillingSettings 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(BillingSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBillingSettings(document.RootElement, options); + } + + internal static BillingSettings DeserializeBillingSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LicensingProgram? licensingProgram = default; + string subscriptionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("licensingProgram"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + licensingProgram = new LicensingProgram(property.Value.GetString()); + continue; + } + if (property.NameEquals("subscriptionId"u8)) + { + subscriptionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BillingSettings(licensingProgram, subscriptionId, 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(BillingSettings)} does not support writing '{options.Format}' format."); + } + } + + BillingSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBillingSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BillingSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.cs new file mode 100644 index 000000000000..4af43c60367e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/BillingSettings.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.Migrate.Models +{ + /// Billing settings class. + public partial class BillingSettings + { + /// + /// 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 BillingSettings() + { + } + + /// Initializes a new instance of . + /// Gets or sets the licensing program. + /// Gets or sets the subscription ID for licensing program selected. + /// Keeps track of any properties unknown to the library. + internal BillingSettings(LicensingProgram? licensingProgram, string subscriptionId, IDictionary serializedAdditionalRawData) + { + LicensingProgram = licensingProgram; + SubscriptionId = subscriptionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the licensing program. + public LicensingProgram? LicensingProgram { get; set; } + /// Gets or sets the subscription ID for licensing program selected. + public string SubscriptionId { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CloudSuitabilityCommon.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CloudSuitabilityCommon.cs new file mode 100644 index 000000000000..f5e2e8468e2d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CloudSuitabilityCommon.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Cloud Suitability Common. + public readonly partial struct CloudSuitabilityCommon : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CloudSuitabilityCommon(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string NotSuitableValue = "NotSuitable"; + private const string SuitableValue = "Suitable"; + private const string ConditionallySuitableValue = "ConditionallySuitable"; + private const string ReadinessUnknownValue = "ReadinessUnknown"; + private const string SuitableWithWarningsValue = "SuitableWithWarnings"; + + /// Unknown - Cloud Suitability Common. + public static CloudSuitabilityCommon Unknown { get; } = new CloudSuitabilityCommon(UnknownValue); + /// NotSuitable - Cloud Suitability Common. + public static CloudSuitabilityCommon NotSuitable { get; } = new CloudSuitabilityCommon(NotSuitableValue); + /// Suitable - Cloud Suitability Common. + public static CloudSuitabilityCommon Suitable { get; } = new CloudSuitabilityCommon(SuitableValue); + /// ConditionallySuitable - Cloud Suitability Common. + public static CloudSuitabilityCommon ConditionallySuitable { get; } = new CloudSuitabilityCommon(ConditionallySuitableValue); + /// ReadinessUnknown - Cloud Suitability Common. + public static CloudSuitabilityCommon ReadinessUnknown { get; } = new CloudSuitabilityCommon(ReadinessUnknownValue); + /// SuitableWithWarnings - Cloud Suitability Common. + public static CloudSuitabilityCommon SuitableWithWarnings { get; } = new CloudSuitabilityCommon(SuitableWithWarningsValue); + /// Determines if two values are the same. + public static bool operator ==(CloudSuitabilityCommon left, CloudSuitabilityCommon right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CloudSuitabilityCommon left, CloudSuitabilityCommon right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CloudSuitabilityCommon(string value) => new CloudSuitabilityCommon(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CloudSuitabilityCommon other && Equals(other); + /// + public bool Equals(CloudSuitabilityCommon 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.Serialization.cs new file mode 100644 index 000000000000..488e4f7211c7 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class Configuration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Configuration)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(AzureTarget)) + { + writer.WritePropertyName("azureTarget"u8); + writer.WriteStringValue(AzureTarget.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SizingCriterion)) + { + writer.WritePropertyName("sizingCriterion"u8); + writer.WriteStringValue(SizingCriterion.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Configuration 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(Configuration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeConfiguration(document.RootElement, options); + } + + internal static Configuration DeserializeConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureTarget? azureTarget = default; + AssessmentSizingCriterion? sizingCriterion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azureTarget"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureTarget = new AzureTarget(property.Value.GetString()); + continue; + } + if (property.NameEquals("sizingCriterion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sizingCriterion = new AssessmentSizingCriterion(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Configuration(azureTarget, sizingCriterion, 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(Configuration)} does not support writing '{options.Format}' format."); + } + } + + Configuration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Configuration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.cs new file mode 100644 index 000000000000..385bb975125a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Configuration.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.Migrate.Models +{ + /// Configuration details. + public partial class Configuration + { + /// + /// 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 Configuration() + { + } + + /// Initializes a new instance of . + /// The azure target. + /// The azure target. + /// Keeps track of any properties unknown to the library. + internal Configuration(AzureTarget? azureTarget, AssessmentSizingCriterion? sizingCriterion, IDictionary serializedAdditionalRawData) + { + AzureTarget = azureTarget; + SizingCriterion = sizingCriterion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The azure target. + public AzureTarget? AzureTarget { get; } + /// The azure target. + public AssessmentSizingCriterion? SizingCriterion { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.Serialization.cs new file mode 100644 index 000000000000..a7b6e54aeecb --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Migrate.Models +{ + public partial class CostDetailsCommon : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CostDetailsCommon)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SavingOptions)) + { + writer.WritePropertyName("savingOptions"u8); + writer.WriteStringValue(SavingOptions.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(CostDetail)) + { + writer.WritePropertyName("costDetail"u8); + writer.WriteStartArray(); + foreach (var item in CostDetail) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CostDetailsCommon 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(CostDetailsCommon)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCostDetailsCommon(document.RootElement, options); + } + + internal static CostDetailsCommon DeserializeCostDetailsCommon(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SavingsOption? savingOptions = default; + IReadOnlyList costDetail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("savingOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + savingOptions = new SavingsOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("costDetail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePairCostType.DeserializeNameValuePairCostType(item, options)); + } + costDetail = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CostDetailsCommon(savingOptions, costDetail ?? 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(CostDetailsCommon)} does not support writing '{options.Format}' format."); + } + } + + CostDetailsCommon IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCostDetailsCommon(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CostDetailsCommon)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.cs new file mode 100644 index 000000000000..d3622f49c7b9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostDetailsCommon.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The cost details. + public partial class CostDetailsCommon + { + /// + /// 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 CostDetailsCommon() + { + CostDetail = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The savings options. + /// The sku cost details per azure offer type. + /// Keeps track of any properties unknown to the library. + internal CostDetailsCommon(SavingsOption? savingOptions, IReadOnlyList costDetail, IDictionary serializedAdditionalRawData) + { + SavingOptions = savingOptions; + CostDetail = costDetail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The savings options. + public SavingsOption? SavingOptions { get; } + /// The sku cost details per azure offer type. + public IReadOnlyList CostDetail { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostType.cs new file mode 100644 index 000000000000..5dd1094db057 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/CostType.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Cost type. + public readonly partial struct CostType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CostType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MonthlyStorageCostValue = "MonthlyStorageCost"; + private const string MonthlyComputeCostValue = "MonthlyComputeCost"; + private const string MonthlyLicensingCostValue = "MonthlyLicensingCost"; + private const string MonthlySecurityCostValue = "MonthlySecurityCost"; + private const string MonthlyManagementCostValue = "MonthlyManagementCost"; + private const string MonitoringServiceValue = "MonitoringService"; + private const string DataProtectionServiceValue = "DataProtectionService"; + private const string PatchingServiceValue = "PatchingService"; + private const string MonthlyAzureHybridCostValue = "MonthlyAzureHybridCost"; + private const string MonthlyPremiumV2StorageCostValue = "MonthlyPremiumV2StorageCost"; + private const string MonthlyLinuxAzureHybridCostValue = "MonthlyLinuxAzureHybridCost"; + private const string MonthlyUltraStorageCostValue = "MonthlyUltraStorageCost"; + private const string MonthlyStandardSsdStorageCostValue = "MonthlyStandardSsdStorageCost"; + private const string MonthlyBandwidthCostValue = "MonthlyBandwidthCost"; + private const string MonthlyPremiumStorageCostValue = "MonthlyPremiumStorageCost"; + private const string MonthlyUltraDiskCostValue = "MonthlyUltraDiskCost"; + private const string MonthlyStandardHddStorageCostValue = "MonthlyStandardHddStorageCost"; + private const string MonthlyAvsExternalStorageCostValue = "MonthlyAvsExternalStorageCost"; + private const string MonthlyAvsNetworkCostValue = "MonthlyAvsNetworkCost"; + private const string MonthlyAvsNodeCostValue = "MonthlyAvsNodeCost"; + private const string TotalMonthlyCostValue = "TotalMonthlyCost"; + + /// MonthlyStorageCost - Cost type. + public static CostType MonthlyStorageCost { get; } = new CostType(MonthlyStorageCostValue); + /// MonthlyComputeCost - Cost type. + public static CostType MonthlyComputeCost { get; } = new CostType(MonthlyComputeCostValue); + /// MonthlyLicensingCost - Cost type. + public static CostType MonthlyLicensingCost { get; } = new CostType(MonthlyLicensingCostValue); + /// MonthlySecurityCost - Cost type. + public static CostType MonthlySecurityCost { get; } = new CostType(MonthlySecurityCostValue); + /// MonthlyManagementCost - Cost type. + public static CostType MonthlyManagementCost { get; } = new CostType(MonthlyManagementCostValue); + /// MonitoringService - Cost type. + public static CostType MonitoringService { get; } = new CostType(MonitoringServiceValue); + /// DataProtectionService - Cost type. + public static CostType DataProtectionService { get; } = new CostType(DataProtectionServiceValue); + /// PatchingService - Cost type. + public static CostType PatchingService { get; } = new CostType(PatchingServiceValue); + /// MonthlyAzureHybridCost - Cost type. + public static CostType MonthlyAzureHybridCost { get; } = new CostType(MonthlyAzureHybridCostValue); + /// MonthlyPremiumV2StorageCost - Cost type. + public static CostType MonthlyPremiumV2StorageCost { get; } = new CostType(MonthlyPremiumV2StorageCostValue); + /// MonthlyLinuxAzureHybridCost - Cost type. + public static CostType MonthlyLinuxAzureHybridCost { get; } = new CostType(MonthlyLinuxAzureHybridCostValue); + /// MonthlyUltraStorageCost - Cost type. + public static CostType MonthlyUltraStorageCost { get; } = new CostType(MonthlyUltraStorageCostValue); + /// MonthlyStandardSsdStorageCost - Cost type. + public static CostType MonthlyStandardSsdStorageCost { get; } = new CostType(MonthlyStandardSsdStorageCostValue); + /// MonthlyBandwidthCost - Cost type. + public static CostType MonthlyBandwidthCost { get; } = new CostType(MonthlyBandwidthCostValue); + /// MonthlyPremiumStorageCost - Cost type. + public static CostType MonthlyPremiumStorageCost { get; } = new CostType(MonthlyPremiumStorageCostValue); + /// MonthlyUltraDiskCost - Cost type. + public static CostType MonthlyUltraDiskCost { get; } = new CostType(MonthlyUltraDiskCostValue); + /// MonthlyStandardHddStorageCost - Cost type. + public static CostType MonthlyStandardHddStorageCost { get; } = new CostType(MonthlyStandardHddStorageCostValue); + /// MonthlyAvsExternalStorageCost - Cost type. + public static CostType MonthlyAvsExternalStorageCost { get; } = new CostType(MonthlyAvsExternalStorageCostValue); + /// MonthlyAvsNetworkCost - Cost type. + public static CostType MonthlyAvsNetworkCost { get; } = new CostType(MonthlyAvsNetworkCostValue); + /// MonthlyAvsNodeCost - Cost type. + public static CostType MonthlyAvsNodeCost { get; } = new CostType(MonthlyAvsNodeCostValue); + /// TotalMonthlyCost - Cost type. + public static CostType TotalMonthlyCost { get; } = new CostType(TotalMonthlyCostValue); + /// Determines if two values are the same. + public static bool operator ==(CostType left, CostType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CostType left, CostType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator CostType(string value) => new CostType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CostType other && Equals(other); + /// + public bool Equals(CostType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.Serialization.cs new file mode 100644 index 000000000000..03ba25513355 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.Serialization.cs @@ -0,0 +1,140 @@ +// 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.Migrate.Models +{ + public partial class DownloadUri : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DownloadUri)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("assessmentReportUrl"u8); + writer.WriteStringValue(AssessmentReportUri); + } + if (options.Format != "W") + { + writer.WritePropertyName("expirationTime"u8); + writer.WriteStringValue(ExpireOn, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DownloadUri 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(DownloadUri)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDownloadUri(document.RootElement, options); + } + + internal static DownloadUri DeserializeDownloadUri(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string assessmentReportUrl = default; + DateTimeOffset expirationTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("assessmentReportUrl"u8)) + { + assessmentReportUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("expirationTime"u8)) + { + expirationTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DownloadUri(assessmentReportUrl, expirationTime, 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(DownloadUri)} does not support writing '{options.Format}' format."); + } + } + + DownloadUri IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDownloadUri(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DownloadUri)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.cs new file mode 100644 index 000000000000..0c9097700df3 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUri.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Data model of Download URL for assessment report. + public partial class DownloadUri + { + /// + /// 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 . + /// Hyperlink to download report. + /// Expiry date of download url. + internal DownloadUri(string assessmentReportUri, DateTimeOffset expireOn) + { + AssessmentReportUri = assessmentReportUri; + ExpireOn = expireOn; + } + + /// Initializes a new instance of . + /// Hyperlink to download report. + /// Expiry date of download url. + /// Keeps track of any properties unknown to the library. + internal DownloadUri(string assessmentReportUri, DateTimeOffset expireOn, IDictionary serializedAdditionalRawData) + { + AssessmentReportUri = assessmentReportUri; + ExpireOn = expireOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DownloadUri() + { + } + + /// Hyperlink to download report. + public string AssessmentReportUri { get; } + /// Expiry date of download url. + public DateTimeOffset ExpireOn { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.Serialization.cs new file mode 100644 index 000000000000..566a552c5f00 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.Serialization.cs @@ -0,0 +1,118 @@ +// 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.Migrate.Models +{ + public partial class DownloadUrlContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DownloadUrlContent)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DownloadUrlContent 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(DownloadUrlContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDownloadUrlContent(document.RootElement, options); + } + + internal static DownloadUrlContent DeserializeDownloadUrlContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DownloadUrlContent(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(DownloadUrlContent)} does not support writing '{options.Format}' format."); + } + } + + DownloadUrlContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDownloadUrlContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DownloadUrlContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.cs new file mode 100644 index 000000000000..3462a4b54d91 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/DownloadUrlContent.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The DownloadUrlContent. + public partial class DownloadUrlContent + { + /// + /// 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 DownloadUrlContent() + { + } + + /// Initializes a new instance of . + /// Keeps track of any properties unknown to the library. + internal DownloadUrlContent(IDictionary serializedAdditionalRawData) + { + _serializedAdditionalRawData = serializedAdditionalRawData; + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/EnvironmentType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/EnvironmentType.cs new file mode 100644 index 000000000000..0c77a9404ede --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/EnvironmentType.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.Migrate.Models +{ + /// Environment Type. + public readonly partial struct EnvironmentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EnvironmentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ProductionValue = "Production"; + private const string UnknownValue = "Unknown"; + private const string DevTestValue = "DevTest"; + + /// Production - Environment Type. + public static EnvironmentType Production { get; } = new EnvironmentType(ProductionValue); + /// Unknown - Environment Type. + public static EnvironmentType Unknown { get; } = new EnvironmentType(UnknownValue); + /// DevTest - Environment Type. + public static EnvironmentType DevTest { get; } = new EnvironmentType(DevTestValue); + /// Determines if two values are the same. + public static bool operator ==(EnvironmentType left, EnvironmentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EnvironmentType left, EnvironmentType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator EnvironmentType(string value) => new EnvironmentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EnvironmentType other && Equals(other); + /// + public bool Equals(EnvironmentType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.Serialization.cs new file mode 100644 index 000000000000..547946bbcc82 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.Serialization.cs @@ -0,0 +1,297 @@ +// 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.Migrate.Models +{ + public partial class Error : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Error)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteNumberValue(Id.Value); + } + if (options.Format != "W" && Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (options.Format != "W" && Optional.IsDefined(RunAsAccountId)) + { + writer.WritePropertyName("runAsAccountId"u8); + writer.WriteStringValue(RunAsAccountId); + } + if (options.Format != "W" && Optional.IsDefined(ApplianceName)) + { + writer.WritePropertyName("applianceName"u8); + writer.WriteStringValue(ApplianceName); + } + if (options.Format != "W" && Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && Optional.IsDefined(SummaryMessage)) + { + writer.WritePropertyName("summaryMessage"u8); + writer.WriteStringValue(SummaryMessage); + } + if (options.Format != "W" && Optional.IsDefined(AgentScenario)) + { + writer.WritePropertyName("agentScenario"u8); + writer.WriteStringValue(AgentScenario); + } + if (options.Format != "W" && Optional.IsDefined(PossibleCauses)) + { + writer.WritePropertyName("possibleCauses"u8); + writer.WriteStringValue(PossibleCauses); + } + if (options.Format != "W" && Optional.IsDefined(RecommendedAction)) + { + writer.WritePropertyName("recommendedAction"u8); + writer.WriteStringValue(RecommendedAction); + } + if (options.Format != "W" && Optional.IsDefined(Severity)) + { + writer.WritePropertyName("severity"u8); + writer.WriteStringValue(Severity); + } + if (options.Format != "W" && Optional.IsCollectionDefined(MessageParameters)) + { + writer.WritePropertyName("messageParameters"u8); + writer.WriteStartArray(); + foreach (var item in MessageParameters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(UpdatedTimeStamp)) + { + writer.WritePropertyName("updatedTimeStamp"u8); + writer.WriteStringValue(UpdatedTimeStamp.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ImpactedAssessmentType)) + { + writer.WritePropertyName("impactedAssessmentType"u8); + writer.WriteStringValue(ImpactedAssessmentType); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Error 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(Error)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeError(document.RootElement, options); + } + + internal static Error DeserializeError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? id = default; + string code = default; + string runAsAccountId = default; + string applianceName = default; + string message = default; + string summaryMessage = default; + string agentScenario = default; + string possibleCauses = default; + string recommendedAction = default; + string severity = default; + IReadOnlyList messageParameters = default; + DateTimeOffset? updatedTimeStamp = default; + string impactedAssessmentType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("runAsAccountId"u8)) + { + runAsAccountId = property.Value.GetString(); + continue; + } + if (property.NameEquals("applianceName"u8)) + { + applianceName = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("summaryMessage"u8)) + { + summaryMessage = property.Value.GetString(); + continue; + } + if (property.NameEquals("agentScenario"u8)) + { + agentScenario = property.Value.GetString(); + continue; + } + if (property.NameEquals("possibleCauses"u8)) + { + possibleCauses = property.Value.GetString(); + continue; + } + if (property.NameEquals("recommendedAction"u8)) + { + recommendedAction = property.Value.GetString(); + continue; + } + if (property.NameEquals("severity"u8)) + { + severity = property.Value.GetString(); + continue; + } + if (property.NameEquals("messageParameters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePair.DeserializeNameValuePair(item, options)); + } + messageParameters = array; + continue; + } + if (property.NameEquals("updatedTimeStamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + updatedTimeStamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("impactedAssessmentType"u8)) + { + impactedAssessmentType = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Error( + id, + code, + runAsAccountId, + applianceName, + message, + summaryMessage, + agentScenario, + possibleCauses, + recommendedAction, + severity, + messageParameters ?? new ChangeTrackingList(), + updatedTimeStamp, + impactedAssessmentType, + 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(Error)} does not support writing '{options.Format}' format."); + } + } + + Error IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Error)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.cs new file mode 100644 index 000000000000..ae513844062b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Error.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Error web model class. + public partial class Error + { + /// + /// 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 Error() + { + MessageParameters = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Gets the error ID. + /// Gets the error code. + /// Gets the Run as account ID. + /// Gets the Appliance name. + /// Gets the error message. + /// Gets the error summary message. + /// Gets the agent scenario where this error occurred. + /// Gets the error possible causes. + /// Gets the recommended action for the error. + /// Gets the error severity. + /// Gets the error message parameters. + /// Gets the time stamp when the error was updated. + /// Gets the type of assessment impacted by this error. + /// Keeps track of any properties unknown to the library. + internal Error(int? id, string code, string runAsAccountId, string applianceName, string message, string summaryMessage, string agentScenario, string possibleCauses, string recommendedAction, string severity, IReadOnlyList messageParameters, DateTimeOffset? updatedTimeStamp, string impactedAssessmentType, IDictionary serializedAdditionalRawData) + { + Id = id; + Code = code; + RunAsAccountId = runAsAccountId; + ApplianceName = applianceName; + Message = message; + SummaryMessage = summaryMessage; + AgentScenario = agentScenario; + PossibleCauses = possibleCauses; + RecommendedAction = recommendedAction; + Severity = severity; + MessageParameters = messageParameters; + UpdatedTimeStamp = updatedTimeStamp; + ImpactedAssessmentType = impactedAssessmentType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets the error ID. + public int? Id { get; } + /// Gets the error code. + public string Code { get; } + /// Gets the Run as account ID. + public string RunAsAccountId { get; } + /// Gets the Appliance name. + public string ApplianceName { get; } + /// Gets the error message. + public string Message { get; } + /// Gets the error summary message. + public string SummaryMessage { get; } + /// Gets the agent scenario where this error occurred. + public string AgentScenario { get; } + /// Gets the error possible causes. + public string PossibleCauses { get; } + /// Gets the recommended action for the error. + public string RecommendedAction { get; } + /// Gets the error severity. + public string Severity { get; } + /// Gets the error message parameters. + public IReadOnlyList MessageParameters { get; } + /// Gets the time stamp when the error was updated. + public DateTimeOffset? UpdatedTimeStamp { get; } + /// Gets the type of assessment impacted by this error. + public string ImpactedAssessmentType { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/GuestOperatingSystemArchitecture.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/GuestOperatingSystemArchitecture.cs new file mode 100644 index 000000000000..f191f5bb3c2b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/GuestOperatingSystemArchitecture.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.Migrate.Models +{ + /// Guest operating system architecture. + public readonly partial struct GuestOperatingSystemArchitecture : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GuestOperatingSystemArchitecture(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string X86Value = "X86"; + private const string X64Value = "X64"; + + /// Unknown - Guest operating system architecture. + public static GuestOperatingSystemArchitecture Unknown { get; } = new GuestOperatingSystemArchitecture(UnknownValue); + /// X86 - Guest operating system architecture. + public static GuestOperatingSystemArchitecture X86 { get; } = new GuestOperatingSystemArchitecture(X86Value); + /// X64 - Guest operating system architecture. + public static GuestOperatingSystemArchitecture X64 { get; } = new GuestOperatingSystemArchitecture(X64Value); + /// Determines if two values are the same. + public static bool operator ==(GuestOperatingSystemArchitecture left, GuestOperatingSystemArchitecture right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GuestOperatingSystemArchitecture left, GuestOperatingSystemArchitecture right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator GuestOperatingSystemArchitecture(string value) => new GuestOperatingSystemArchitecture(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GuestOperatingSystemArchitecture other && Equals(other); + /// + public bool Equals(GuestOperatingSystemArchitecture 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LicensingProgram.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LicensingProgram.cs new file mode 100644 index 000000000000..bf5709377e3d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LicensingProgram.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.Migrate.Models +{ + /// The licensing program. + public readonly partial struct LicensingProgram : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LicensingProgram(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RetailValue = "Retail"; + private const string UnknownValue = "Unknown"; + private const string EAValue = "EA"; + private const string MCAValue = "MCA"; + + /// Retail/Pay as you go. + public static LicensingProgram Retail { get; } = new LicensingProgram(RetailValue); + /// Not known. + public static LicensingProgram Unknown { get; } = new LicensingProgram(UnknownValue); + /// Enterprise agreement. + public static LicensingProgram EA { get; } = new LicensingProgram(EAValue); + /// Microsoft customer agreement. + public static LicensingProgram MCA { get; } = new LicensingProgram(MCAValue); + /// Determines if two values are the same. + public static bool operator ==(LicensingProgram left, LicensingProgram right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LicensingProgram left, LicensingProgram right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LicensingProgram(string value) => new LicensingProgram(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LicensingProgram other && Equals(other); + /// + public bool Equals(LicensingProgram 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageKind.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageKind.cs new file mode 100644 index 000000000000..2ceb37fe1c72 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageKind.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Linkage kind. + public readonly partial struct LinkageKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LinkageKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string MachineValue = "Machine"; + private const string ServerValue = "Server"; + private const string InstanceValue = "Instance"; + private const string WebServerValue = "WebServer"; + private const string WebApplicationValue = "WebApplication"; + private const string DatabaseValue = "Database"; + + /// Unknown - Linkage kind. + public static LinkageKind Unknown { get; } = new LinkageKind(UnknownValue); + /// Machine - Linkage kind. + public static LinkageKind Machine { get; } = new LinkageKind(MachineValue); + /// Server - Linkage kind. + public static LinkageKind Server { get; } = new LinkageKind(ServerValue); + /// Instance - Linkage kind. + public static LinkageKind Instance { get; } = new LinkageKind(InstanceValue); + /// WebServer - Linkage kind. + public static LinkageKind WebServer { get; } = new LinkageKind(WebServerValue); + /// WebApplication - Linkage kind. + public static LinkageKind WebApplication { get; } = new LinkageKind(WebApplicationValue); + /// Database - Linkage kind. + public static LinkageKind Database { get; } = new LinkageKind(DatabaseValue); + /// Determines if two values are the same. + public static bool operator ==(LinkageKind left, LinkageKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LinkageKind left, LinkageKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LinkageKind(string value) => new LinkageKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LinkageKind other && Equals(other); + /// + public bool Equals(LinkageKind 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageType.cs new file mode 100644 index 000000000000..ae51813ee21b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/LinkageType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Linkage type. + public readonly partial struct LinkageType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LinkageType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ParentValue = "Parent"; + private const string SourceValue = "Source"; + + /// Parent - Linkage type. + public static LinkageType Parent { get; } = new LinkageType(ParentValue); + /// Source - Linkage type. + public static LinkageType Source { get; } = new LinkageType(SourceValue); + /// Determines if two values are the same. + public static bool operator ==(LinkageType left, LinkageType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LinkageType left, LinkageType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LinkageType(string value) => new LinkageType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LinkageType other && Equals(other); + /// + public bool Equals(LinkageType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.Serialization.cs new file mode 100644 index 000000000000..146eb6d30666 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + public partial class Linkages : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Linkages)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(WorkloadName)) + { + writer.WritePropertyName("workloadName"u8); + writer.WriteStringValue(WorkloadName); + } + if (options.Format != "W" && Optional.IsDefined(LinkageType)) + { + writer.WritePropertyName("linkageType"u8); + writer.WriteStringValue(LinkageType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ArmId)) + { + writer.WritePropertyName("armId"u8); + writer.WriteStringValue(ArmId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Linkages 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(Linkages)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLinkages(document.RootElement, options); + } + + internal static Linkages DeserializeLinkages(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string workloadName = default; + LinkageType? linkageType = default; + LinkageKind? kind = default; + string armId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("workloadName"u8)) + { + workloadName = property.Value.GetString(); + continue; + } + if (property.NameEquals("linkageType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + linkageType = new LinkageType(property.Value.GetString()); + continue; + } + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new LinkageKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("armId"u8)) + { + armId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Linkages(workloadName, linkageType, kind, armId, 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(Linkages)} does not support writing '{options.Format}' format."); + } + } + + Linkages IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLinkages(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Linkages)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.cs new file mode 100644 index 000000000000..c5ed925ab22b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Linkages.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Linkages details. + public partial class Linkages + { + /// + /// 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 Linkages() + { + } + + /// Initializes a new instance of . + /// The workload name. + /// The linkage type. + /// The linkage kind. + /// The arm id. + /// Keeps track of any properties unknown to the library. + internal Linkages(string workloadName, LinkageType? linkageType, LinkageKind? kind, string armId, IDictionary serializedAdditionalRawData) + { + WorkloadName = workloadName; + LinkageType = linkageType; + Kind = kind; + ArmId = armId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The workload name. + public string WorkloadName { get; } + /// The linkage type. + public LinkageType? LinkageType { get; } + /// The linkage kind. + public LinkageKind? Kind { get; } + /// The arm id. + public string ArmId { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.Serialization.cs new file mode 100644 index 000000000000..99cbffbbeff1 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.Serialization.cs @@ -0,0 +1,309 @@ +// 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.Migrate.Models +{ + public partial class MachineAssessmentOptionsOutboundEdgeGroup : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentOptionsOutboundEdgeGroup)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("targetLocations"u8); + writer.WriteStartArray(); + foreach (var item in TargetLocations) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("currencies"u8); + writer.WriteStartArray(); + foreach (var item in Currencies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("savingsOptions"u8); + writer.WriteStartArray(); + foreach (var item in SavingsOptions) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("licensingProgram"u8); + writer.WriteStartArray(); + foreach (var item in LicensingProgram) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("azureVmFamilies"u8); + writer.WriteStartArray(); + foreach (var item in AzureVmFamilies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("azureVmFamilyCategories"u8); + writer.WriteStartArray(); + foreach (var item in AzureVmFamilyCategories) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("premiumDiskSupport"u8); + writer.WriteStartArray(); + foreach (var item in PremiumDiskSupport) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("ultraDiskSupport"u8); + writer.WriteStartArray(); + foreach (var item in UltraDiskSupport) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("azureOfferCode"u8); + writer.WriteStartArray(); + foreach (var item in AzureOfferCode) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + writer.WritePropertyName("azureVmSecurityOptions"u8); + writer.WriteStartArray(); + foreach (var item in AzureVmSecurityOptions) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentOptionsOutboundEdgeGroup 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(MachineAssessmentOptionsOutboundEdgeGroup)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentOptionsOutboundEdgeGroup(document.RootElement, options); + } + + internal static MachineAssessmentOptionsOutboundEdgeGroup DeserializeMachineAssessmentOptionsOutboundEdgeGroup(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList targetLocations = default; + IReadOnlyList currencies = default; + IReadOnlyList savingsOptions = default; + IReadOnlyList licensingProgram = default; + IReadOnlyList azureVmFamilies = default; + IReadOnlyList azureVmFamilyCategories = default; + IReadOnlyList premiumDiskSupport = default; + IReadOnlyList ultraDiskSupport = default; + IReadOnlyList azureOfferCode = default; + IReadOnlyList azureVmSecurityOptions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("targetLocations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureLocation(item.GetString())); + } + targetLocations = array; + continue; + } + if (property.NameEquals("currencies"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureCurrency(item.GetString())); + } + currencies = array; + continue; + } + if (property.NameEquals("savingsOptions"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new SavingsOption(item.GetString())); + } + savingsOptions = array; + continue; + } + if (property.NameEquals("licensingProgram"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new LicensingProgram(item.GetString())); + } + licensingProgram = array; + continue; + } + if (property.NameEquals("azureVmFamilies"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureVmFamily(item.GetString())); + } + azureVmFamilies = array; + continue; + } + if (property.NameEquals("azureVmFamilyCategories"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new VmFamilyCategoryItem(item.GetString())); + } + azureVmFamilyCategories = array; + continue; + } + if (property.NameEquals("premiumDiskSupport"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new PremiumDiskSupport(item.GetString())); + } + premiumDiskSupport = array; + continue; + } + if (property.NameEquals("ultraDiskSupport"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new UltraDiskSupport(item.GetString())); + } + ultraDiskSupport = array; + continue; + } + if (property.NameEquals("azureOfferCode"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureOffer(item.GetString())); + } + azureOfferCode = array; + continue; + } + if (property.NameEquals("azureVmSecurityOptions"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureVmSecurityType(item.GetString())); + } + azureVmSecurityOptions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentOptionsOutboundEdgeGroup( + targetLocations, + currencies, + savingsOptions, + licensingProgram, + azureVmFamilies, + azureVmFamilyCategories, + premiumDiskSupport, + ultraDiskSupport, + azureOfferCode, + azureVmSecurityOptions, + 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(MachineAssessmentOptionsOutboundEdgeGroup)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentOptionsOutboundEdgeGroup IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentOptionsOutboundEdgeGroup(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentOptionsOutboundEdgeGroup)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.cs new file mode 100644 index 000000000000..8af19f04c54a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentOptionsOutboundEdgeGroup.cs @@ -0,0 +1,139 @@ +// 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.Migrate.Models +{ + /// A class that represents the outbound edges from a given node. + public partial class MachineAssessmentOptionsOutboundEdgeGroup + { + /// + /// 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 . + /// Gets or sets the Azure Locations. + /// Gets or sets the Azure Currency. + /// Gets or sets the Assessment Savings Options. + /// Gets or sets the Licensing Program. + /// Gets or sets the Azure VM families. + /// Gets or sets the Azure VM family categories. + /// Gets or sets the premium disk support. + /// Gets or sets the premium disk support. + /// Gets or sets the Azure Offer Code. + /// Gets or sets the Azure VM security options. + /// , , , , , , , , or is null. + internal MachineAssessmentOptionsOutboundEdgeGroup(IEnumerable targetLocations, IEnumerable currencies, IEnumerable savingsOptions, IEnumerable licensingProgram, IEnumerable azureVmFamilies, IEnumerable azureVmFamilyCategories, IEnumerable premiumDiskSupport, IEnumerable ultraDiskSupport, IEnumerable azureOfferCode, IEnumerable azureVmSecurityOptions) + { + Argument.AssertNotNull(targetLocations, nameof(targetLocations)); + Argument.AssertNotNull(currencies, nameof(currencies)); + Argument.AssertNotNull(savingsOptions, nameof(savingsOptions)); + Argument.AssertNotNull(licensingProgram, nameof(licensingProgram)); + Argument.AssertNotNull(azureVmFamilies, nameof(azureVmFamilies)); + Argument.AssertNotNull(azureVmFamilyCategories, nameof(azureVmFamilyCategories)); + Argument.AssertNotNull(premiumDiskSupport, nameof(premiumDiskSupport)); + Argument.AssertNotNull(ultraDiskSupport, nameof(ultraDiskSupport)); + Argument.AssertNotNull(azureOfferCode, nameof(azureOfferCode)); + Argument.AssertNotNull(azureVmSecurityOptions, nameof(azureVmSecurityOptions)); + + TargetLocations = targetLocations.ToList(); + Currencies = currencies.ToList(); + SavingsOptions = savingsOptions.ToList(); + LicensingProgram = licensingProgram.ToList(); + AzureVmFamilies = azureVmFamilies.ToList(); + AzureVmFamilyCategories = azureVmFamilyCategories.ToList(); + PremiumDiskSupport = premiumDiskSupport.ToList(); + UltraDiskSupport = ultraDiskSupport.ToList(); + AzureOfferCode = azureOfferCode.ToList(); + AzureVmSecurityOptions = azureVmSecurityOptions.ToList(); + } + + /// Initializes a new instance of . + /// Gets or sets the Azure Locations. + /// Gets or sets the Azure Currency. + /// Gets or sets the Assessment Savings Options. + /// Gets or sets the Licensing Program. + /// Gets or sets the Azure VM families. + /// Gets or sets the Azure VM family categories. + /// Gets or sets the premium disk support. + /// Gets or sets the premium disk support. + /// Gets or sets the Azure Offer Code. + /// Gets or sets the Azure VM security options. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentOptionsOutboundEdgeGroup(IReadOnlyList targetLocations, IReadOnlyList currencies, IReadOnlyList savingsOptions, IReadOnlyList licensingProgram, IReadOnlyList azureVmFamilies, IReadOnlyList azureVmFamilyCategories, IReadOnlyList premiumDiskSupport, IReadOnlyList ultraDiskSupport, IReadOnlyList azureOfferCode, IReadOnlyList azureVmSecurityOptions, IDictionary serializedAdditionalRawData) + { + TargetLocations = targetLocations; + Currencies = currencies; + SavingsOptions = savingsOptions; + LicensingProgram = licensingProgram; + AzureVmFamilies = azureVmFamilies; + AzureVmFamilyCategories = azureVmFamilyCategories; + PremiumDiskSupport = premiumDiskSupport; + UltraDiskSupport = ultraDiskSupport; + AzureOfferCode = azureOfferCode; + AzureVmSecurityOptions = azureVmSecurityOptions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MachineAssessmentOptionsOutboundEdgeGroup() + { + } + + /// Gets or sets the Azure Locations. + public IReadOnlyList TargetLocations { get; } + /// Gets or sets the Azure Currency. + public IReadOnlyList Currencies { get; } + /// Gets or sets the Assessment Savings Options. + public IReadOnlyList SavingsOptions { get; } + /// Gets or sets the Licensing Program. + public IReadOnlyList LicensingProgram { get; } + /// Gets or sets the Azure VM families. + public IReadOnlyList AzureVmFamilies { get; } + /// Gets or sets the Azure VM family categories. + public IReadOnlyList AzureVmFamilyCategories { get; } + /// Gets or sets the premium disk support. + public IReadOnlyList PremiumDiskSupport { get; } + /// Gets or sets the premium disk support. + public IReadOnlyList UltraDiskSupport { get; } + /// Gets or sets the Azure Offer Code. + public IReadOnlyList AzureOfferCode { get; } + /// Gets or sets the Azure VM security options. + public IReadOnlyList AzureVmSecurityOptions { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.Serialization.cs new file mode 100644 index 000000000000..58d13ebdbfe9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.Serialization.cs @@ -0,0 +1,361 @@ +// 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.Migrate.Models +{ + public partial class MachineAssessmentRecommendation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentRecommendation)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Configuration)) + { + writer.WritePropertyName("configuration"u8); + writer.WriteObjectValue(Configuration, options); + } + if (options.Format != "W" && Optional.IsDefined(RecommendedFor)) + { + writer.WritePropertyName("recommendedFor"u8); + writer.WriteObjectValue(RecommendedFor, options); + } + if (options.Format != "W" && Optional.IsDefined(MigrationPlatform)) + { + writer.WritePropertyName("migrationPlatform"u8); + writer.WriteStringValue(MigrationPlatform.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ConfidenceScore)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(ConfidenceScore.Value); + } + if (options.Format != "W" && Optional.IsDefined(MigrationSuitability)) + { + writer.WritePropertyName("migrationSuitability"u8); + writer.WriteObjectValue(MigrationSuitability, options); + } + if (options.Format != "W" && Optional.IsDefined(SecuritySuitability)) + { + writer.WritePropertyName("securitySuitability"u8); + writer.WriteObjectValue(SecuritySuitability, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TotalCost)) + { + writer.WritePropertyName("totalCost"u8); + writer.WriteStartArray(); + foreach (var item in TotalCost) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TotalSavings)) + { + writer.WritePropertyName("totalSavings"u8); + writer.WriteStartArray(); + foreach (var item in TotalSavings) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(MigrationIssues)) + { + writer.WritePropertyName("migrationIssues"u8); + writer.WriteStartArray(); + foreach (var item in MigrationIssues) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Skus)) + { + writer.WritePropertyName("skus"u8); + writer.WriteStartArray(); + foreach (var item in Skus) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(VmSecuritySuitabilityResults)) + { + writer.WritePropertyName("vmSecuritySuitabilityResults"u8); + writer.WriteStartArray(); + foreach (var item in VmSecuritySuitabilityResults) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(RecommendedVmSecurityType)) + { + writer.WritePropertyName("recommendedVmSecurityType"u8); + writer.WriteStringValue(RecommendedVmSecurityType.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentRecommendation 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(MachineAssessmentRecommendation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentRecommendation(document.RootElement, options); + } + + internal static MachineAssessmentRecommendation DeserializeMachineAssessmentRecommendation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Configuration configuration = default; + RecommendedFor recommendedFor = default; + MigrationPlatform? migrationPlatform = default; + float? confidenceScore = default; + MigrationSuitability migrationSuitability = default; + SecuritySuitability securitySuitability = default; + IReadOnlyList totalCost = default; + IReadOnlyList totalSavings = default; + IReadOnlyList migrationIssues = default; + IReadOnlyList skus = default; + IReadOnlyList vmSecuritySuitabilityResults = default; + AzureVmSecurityType? recommendedVmSecurityType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("configuration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + configuration = Configuration.DeserializeConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("recommendedFor"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recommendedFor = RecommendedFor.DeserializeRecommendedFor(property.Value, options); + continue; + } + if (property.NameEquals("migrationPlatform"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + migrationPlatform = new MigrationPlatform(property.Value.GetString()); + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("migrationSuitability"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + migrationSuitability = MigrationSuitability.DeserializeMigrationSuitability(property.Value, options); + continue; + } + if (property.NameEquals("securitySuitability"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securitySuitability = SecuritySuitability.DeserializeSecuritySuitability(property.Value, options); + continue; + } + if (property.NameEquals("totalCost"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CostDetailsCommon.DeserializeCostDetailsCommon(item, options)); + } + totalCost = array; + continue; + } + if (property.NameEquals("totalSavings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SavingsDetailsCommon.DeserializeSavingsDetailsCommon(item, options)); + } + totalSavings = array; + continue; + } + if (property.NameEquals("migrationIssues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.MigrationIssues.DeserializeMigrationIssues(item, options)); + } + migrationIssues = array; + continue; + } + if (property.NameEquals("skus"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SkusMigrationSuitability.DeserializeSkusMigrationSuitability(item, options)); + } + skus = array; + continue; + } + if (property.NameEquals("vmSecuritySuitabilityResults"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VmSecuritySuitability.DeserializeVmSecuritySuitability(item, options)); + } + vmSecuritySuitabilityResults = array; + continue; + } + if (property.NameEquals("recommendedVmSecurityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + recommendedVmSecurityType = new AzureVmSecurityType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentRecommendation( + configuration, + recommendedFor, + migrationPlatform, + confidenceScore, + migrationSuitability, + securitySuitability, + totalCost ?? new ChangeTrackingList(), + totalSavings ?? new ChangeTrackingList(), + migrationIssues ?? new ChangeTrackingList(), + skus ?? new ChangeTrackingList(), + vmSecuritySuitabilityResults ?? new ChangeTrackingList(), + recommendedVmSecurityType, + 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(MachineAssessmentRecommendation)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentRecommendation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentRecommendation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentRecommendation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.cs new file mode 100644 index 000000000000..80ce2c4d6c25 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentRecommendation.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Machine Assessment Recommendation with additional properties. + public partial class MachineAssessmentRecommendation + { + /// + /// 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 MachineAssessmentRecommendation() + { + TotalCost = new ChangeTrackingList(); + TotalSavings = new ChangeTrackingList(); + MigrationIssues = new ChangeTrackingList(); + Skus = new ChangeTrackingList(); + VmSecuritySuitabilityResults = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The configuration data. + /// The recommended details. + /// The migration Platform. + /// The confidence score. + /// The migration suitability. + /// The security suitability. + /// The total cost details. + /// The total cost details. + /// The migration issues list. + /// The Skus list. + /// VM Security Suitability Results. + /// Recommended security type for the VM. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentRecommendation(Configuration configuration, RecommendedFor recommendedFor, MigrationPlatform? migrationPlatform, float? confidenceScore, MigrationSuitability migrationSuitability, SecuritySuitability securitySuitability, IReadOnlyList totalCost, IReadOnlyList totalSavings, IReadOnlyList migrationIssues, IReadOnlyList skus, IReadOnlyList vmSecuritySuitabilityResults, AzureVmSecurityType? recommendedVmSecurityType, IDictionary serializedAdditionalRawData) + { + Configuration = configuration; + RecommendedFor = recommendedFor; + MigrationPlatform = migrationPlatform; + ConfidenceScore = confidenceScore; + MigrationSuitability = migrationSuitability; + SecuritySuitability = securitySuitability; + TotalCost = totalCost; + TotalSavings = totalSavings; + MigrationIssues = migrationIssues; + Skus = skus; + VmSecuritySuitabilityResults = vmSecuritySuitabilityResults; + RecommendedVmSecurityType = recommendedVmSecurityType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The configuration data. + public Configuration Configuration { get; } + /// The recommended details. + internal RecommendedFor RecommendedFor { get; } + /// The list of strategy type. + public IReadOnlyList RecommendedForStrategies + { + get => RecommendedFor?.Strategies; + } + + /// The migration Platform. + public MigrationPlatform? MigrationPlatform { get; } + /// The confidence score. + public float? ConfidenceScore { get; } + /// The migration suitability. + internal MigrationSuitability MigrationSuitability { get; } + /// The migration suitability. + public CloudSuitabilityCommon? MigrationSuitabilityReadiness + { + get => MigrationSuitability?.Readiness; + } + + /// The security suitability. + internal SecuritySuitability SecuritySuitability { get; } + /// The security suitability. + public CloudSuitabilityCommon? SecuritySuitabilityReadiness + { + get => SecuritySuitability?.Readiness; + } + + /// The total cost details. + public IReadOnlyList TotalCost { get; } + /// The total cost details. + public IReadOnlyList TotalSavings { get; } + /// The migration issues list. + public IReadOnlyList MigrationIssues { get; } + /// The Skus list. + public IReadOnlyList Skus { get; } + /// VM Security Suitability Results. + public IReadOnlyList VmSecuritySuitabilityResults { get; } + /// Recommended security type for the VM. + public AzureVmSecurityType? RecommendedVmSecurityType { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.Serialization.cs new file mode 100644 index 000000000000..222a57285be3 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.Serialization.cs @@ -0,0 +1,433 @@ +// 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.Migrate.Models +{ + public partial class MachineAssessmentSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentSettings)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(AzureLocation)) + { + writer.WritePropertyName("azureLocation"u8); + writer.WriteStringValue(AzureLocation); + } + if (Optional.IsDefined(Currency)) + { + writer.WritePropertyName("currency"u8); + writer.WriteStringValue(Currency.Value.ToString()); + } + if (Optional.IsDefined(ScalingFactor)) + { + writer.WritePropertyName("scalingFactor"u8); + writer.WriteNumberValue(ScalingFactor.Value); + } + if (Optional.IsDefined(DiscountPercentage)) + { + writer.WritePropertyName("discountPercentage"u8); + writer.WriteNumberValue(DiscountPercentage.Value); + } + if (Optional.IsDefined(SizingCriterion)) + { + writer.WritePropertyName("sizingCriterion"u8); + writer.WriteStringValue(SizingCriterion.Value.ToString()); + } + if (Optional.IsDefined(PerformanceData)) + { + writer.WritePropertyName("performanceData"u8); + writer.WriteObjectValue(PerformanceData, options); + } + if (Optional.IsDefined(SavingsSettings)) + { + writer.WritePropertyName("savingsSettings"u8); + writer.WriteObjectValue(SavingsSettings, options); + } + if (Optional.IsDefined(BillingSettings)) + { + writer.WritePropertyName("billingSettings"u8); + writer.WriteObjectValue(BillingSettings, options); + } + if (Optional.IsDefined(EnvironmentType)) + { + writer.WritePropertyName("environmentType"u8); + writer.WriteStringValue(EnvironmentType.Value.ToString()); + } + if (Optional.IsDefined(AzureSecurityOfferingType)) + { + writer.WritePropertyName("azureSecurityOfferingType"u8); + writer.WriteStringValue(AzureSecurityOfferingType.Value.ToString()); + } + if (Optional.IsCollectionDefined(AzureDiskTypes)) + { + writer.WritePropertyName("azureDiskTypes"u8); + writer.WriteStartArray(); + foreach (var item in AzureDiskTypes) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AzurePricingTier)) + { + writer.WritePropertyName("azurePricingTier"u8); + writer.WriteStringValue(AzurePricingTier.Value.ToString()); + } + if (Optional.IsDefined(AzureStorageRedundancy)) + { + writer.WritePropertyName("azureStorageRedundancy"u8); + writer.WriteStringValue(AzureStorageRedundancy.Value.ToString()); + } + if (Optional.IsDefined(AzureHybridUseBenefit)) + { + writer.WritePropertyName("azureHybridUseBenefit"u8); + writer.WriteStringValue(AzureHybridUseBenefit.Value.ToString()); + } + if (Optional.IsDefined(LinuxAzureHybridUseBenefit)) + { + writer.WritePropertyName("linuxAzureHybridUseBenefit"u8); + writer.WriteStringValue(LinuxAzureHybridUseBenefit.Value.ToString()); + } + if (Optional.IsCollectionDefined(AzureVmFamilies)) + { + writer.WritePropertyName("azureVmFamilies"u8); + writer.WriteStartArray(); + foreach (var item in AzureVmFamilies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(VmUptime)) + { + writer.WritePropertyName("vmUptime"u8); + writer.WriteObjectValue(VmUptime, options); + } + if (Optional.IsCollectionDefined(AzureVmSecurityOptions)) + { + writer.WritePropertyName("azureVmSecurityOptions"u8); + writer.WriteStartArray(); + foreach (var item in AzureVmSecurityOptions) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentSettings 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(MachineAssessmentSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentSettings(document.RootElement, options); + } + + internal static MachineAssessmentSettings DeserializeMachineAssessmentSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string azureLocation = default; + AzureCurrency? currency = default; + float? scalingFactor = default; + float? discountPercentage = default; + AssessmentSizingCriterion? sizingCriterion = default; + PerformanceData performanceData = default; + SavingsSettings savingsSettings = default; + BillingSettings billingSettings = default; + EnvironmentType? environmentType = default; + AzureSecurityOfferingType? azureSecurityOfferingType = default; + IList azureDiskTypes = default; + AzurePricingTier? azurePricingTier = default; + AzureStorageRedundancy? azureStorageRedundancy = default; + AzureHybridUseBenefit? azureHybridUseBenefit = default; + AzureHybridUseBenefit? linuxAzureHybridUseBenefit = default; + IList azureVmFamilies = default; + VmUptime vmUptime = default; + IList azureVmSecurityOptions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("azureLocation"u8)) + { + azureLocation = property.Value.GetString(); + continue; + } + if (property.NameEquals("currency"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + currency = new AzureCurrency(property.Value.GetString()); + continue; + } + if (property.NameEquals("scalingFactor"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scalingFactor = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("discountPercentage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + discountPercentage = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("sizingCriterion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sizingCriterion = new AssessmentSizingCriterion(property.Value.GetString()); + continue; + } + if (property.NameEquals("performanceData"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + performanceData = PerformanceData.DeserializePerformanceData(property.Value, options); + continue; + } + if (property.NameEquals("savingsSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + savingsSettings = SavingsSettings.DeserializeSavingsSettings(property.Value, options); + continue; + } + if (property.NameEquals("billingSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + billingSettings = BillingSettings.DeserializeBillingSettings(property.Value, options); + continue; + } + if (property.NameEquals("environmentType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + environmentType = new EnvironmentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureSecurityOfferingType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureSecurityOfferingType = new AzureSecurityOfferingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureDiskTypes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureDiskType(item.GetString())); + } + azureDiskTypes = array; + continue; + } + if (property.NameEquals("azurePricingTier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azurePricingTier = new AzurePricingTier(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureStorageRedundancy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureStorageRedundancy = new AzureStorageRedundancy(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureHybridUseBenefit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureHybridUseBenefit = new AzureHybridUseBenefit(property.Value.GetString()); + continue; + } + if (property.NameEquals("linuxAzureHybridUseBenefit"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + linuxAzureHybridUseBenefit = new AzureHybridUseBenefit(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureVmFamilies"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureVmFamily(item.GetString())); + } + azureVmFamilies = array; + continue; + } + if (property.NameEquals("vmUptime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vmUptime = VmUptime.DeserializeVmUptime(property.Value, options); + continue; + } + if (property.NameEquals("azureVmSecurityOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureVmSecurityType(item.GetString())); + } + azureVmSecurityOptions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentSettings( + azureLocation, + currency, + scalingFactor, + discountPercentage, + sizingCriterion, + performanceData, + savingsSettings, + billingSettings, + environmentType, + azureSecurityOfferingType, + azureDiskTypes ?? new ChangeTrackingList(), + azurePricingTier, + azureStorageRedundancy, + azureHybridUseBenefit, + linuxAzureHybridUseBenefit, + azureVmFamilies ?? new ChangeTrackingList(), + vmUptime, + azureVmSecurityOptions ?? 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(MachineAssessmentSettings)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.cs new file mode 100644 index 000000000000..1ce0be519b51 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentSettings.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Properties of an assessment. + public partial class MachineAssessmentSettings + { + /// + /// 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 MachineAssessmentSettings() + { + AzureDiskTypes = new ChangeTrackingList(); + AzureVmFamilies = new ChangeTrackingList(); + AzureVmSecurityOptions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Azure Location or Azure region where to which the machines will be migrated. + /// Currency in which prices should be reported. + /// + /// Percentage of buffer that user wants on performance metrics when recommending + /// Azure sizes. + /// + /// Custom discount percentage. + /// Assessment sizing criterion. + /// Gets or sets the performance data. + /// Gets or sets the savings settings. + /// Gets or sets the billing settings. + /// Gets or sets user configurable setting to display the environment type. + /// The azure security offering type. + /// The disk type for the assessment. + /// Gets or sets Azure Pricing Tier - Free, Basic, etc. + /// Gets or sets the Azure Storage Redundancy. Example: Locally Redundant Storage. + /// + /// Gets or sets the user configurable setting to display the azure hybrid use + /// benefit. + /// + /// + /// Gets or sets the user configurable setting to display the linux azure hybrid use + /// benefit. + /// + /// Gets or sets the Azure VM families. + /// + /// Gets or sets the duration for which the VMs are up in the on-premises + /// environment. + /// + /// Gets or sets the Azure VM security options. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentSettings(string azureLocation, AzureCurrency? currency, float? scalingFactor, float? discountPercentage, AssessmentSizingCriterion? sizingCriterion, PerformanceData performanceData, SavingsSettings savingsSettings, BillingSettings billingSettings, EnvironmentType? environmentType, AzureSecurityOfferingType? azureSecurityOfferingType, IList azureDiskTypes, AzurePricingTier? azurePricingTier, AzureStorageRedundancy? azureStorageRedundancy, AzureHybridUseBenefit? azureHybridUseBenefit, AzureHybridUseBenefit? linuxAzureHybridUseBenefit, IList azureVmFamilies, VmUptime vmUptime, IList azureVmSecurityOptions, IDictionary serializedAdditionalRawData) + { + AzureLocation = azureLocation; + Currency = currency; + ScalingFactor = scalingFactor; + DiscountPercentage = discountPercentage; + SizingCriterion = sizingCriterion; + PerformanceData = performanceData; + SavingsSettings = savingsSettings; + BillingSettings = billingSettings; + EnvironmentType = environmentType; + AzureSecurityOfferingType = azureSecurityOfferingType; + AzureDiskTypes = azureDiskTypes; + AzurePricingTier = azurePricingTier; + AzureStorageRedundancy = azureStorageRedundancy; + AzureHybridUseBenefit = azureHybridUseBenefit; + LinuxAzureHybridUseBenefit = linuxAzureHybridUseBenefit; + AzureVmFamilies = azureVmFamilies; + VmUptime = vmUptime; + AzureVmSecurityOptions = azureVmSecurityOptions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Azure Location or Azure region where to which the machines will be migrated. + public string AzureLocation { get; set; } + /// Currency in which prices should be reported. + public AzureCurrency? Currency { get; set; } + /// + /// Percentage of buffer that user wants on performance metrics when recommending + /// Azure sizes. + /// + public float? ScalingFactor { get; set; } + /// Custom discount percentage. + public float? DiscountPercentage { get; set; } + /// Assessment sizing criterion. + public AssessmentSizingCriterion? SizingCriterion { get; set; } + /// Gets or sets the performance data. + public PerformanceData PerformanceData { get; set; } + /// Gets or sets the savings settings. + public SavingsSettings SavingsSettings { get; set; } + /// Gets or sets the billing settings. + public BillingSettings BillingSettings { get; set; } + /// Gets or sets user configurable setting to display the environment type. + public EnvironmentType? EnvironmentType { get; set; } + /// The azure security offering type. + public AzureSecurityOfferingType? AzureSecurityOfferingType { get; set; } + /// The disk type for the assessment. + public IList AzureDiskTypes { get; } + /// Gets or sets Azure Pricing Tier - Free, Basic, etc. + public AzurePricingTier? AzurePricingTier { get; set; } + /// Gets or sets the Azure Storage Redundancy. Example: Locally Redundant Storage. + public AzureStorageRedundancy? AzureStorageRedundancy { get; set; } + /// + /// Gets or sets the user configurable setting to display the azure hybrid use + /// benefit. + /// + public AzureHybridUseBenefit? AzureHybridUseBenefit { get; set; } + /// + /// Gets or sets the user configurable setting to display the linux azure hybrid use + /// benefit. + /// + public AzureHybridUseBenefit? LinuxAzureHybridUseBenefit { get; set; } + /// Gets or sets the Azure VM families. + public IList AzureVmFamilies { get; } + /// + /// Gets or sets the duration for which the VMs are up in the on-premises + /// environment. + /// + public VmUptime VmUptime { get; set; } + /// Gets or sets the Azure VM security options. + public IList AzureVmSecurityOptions { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.Serialization.cs new file mode 100644 index 000000000000..e337eb133f8e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.Migrate.Models +{ + internal partial class MachineAssessmentV2ListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentV2ListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentV2ListResult 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(MachineAssessmentV2ListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentV2ListResult(document.RootElement, options); + } + + internal static MachineAssessmentV2ListResult DeserializeMachineAssessmentV2ListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MachineAssessmentV2Data.DeserializeMachineAssessmentV2Data(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentV2ListResult(value, nextLink, 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(MachineAssessmentV2ListResult)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentV2ListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentV2ListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2ListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.cs new file mode 100644 index 000000000000..add88e81f18b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2ListResult.cs @@ -0,0 +1,80 @@ +// 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.Migrate.Models +{ + /// The response of a MachineAssessmentV2 list operation. + internal partial class MachineAssessmentV2ListResult + { + /// + /// 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 MachineAssessmentV2 items on this page. + /// is null. + internal MachineAssessmentV2ListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The MachineAssessmentV2 items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentV2ListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MachineAssessmentV2ListResult() + { + } + + /// The MachineAssessmentV2 items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.Serialization.cs new file mode 100644 index 000000000000..3f05d07b766b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.Serialization.cs @@ -0,0 +1,178 @@ +// 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.Migrate.Models +{ + public partial class MachineAssessmentV2Properties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentV2Properties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(Scope)) + { + writer.WritePropertyName("scope"u8); + writer.WriteObjectValue(Scope, options); + } + if (Optional.IsDefined(Settings)) + { + writer.WritePropertyName("settings"u8); + writer.WriteObjectValue(Settings, options); + } + if (Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteObjectValue(Details, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentV2Properties 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(MachineAssessmentV2Properties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentV2Properties(document.RootElement, options); + } + + internal static MachineAssessmentV2Properties DeserializeMachineAssessmentV2Properties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + Scope scope = default; + MachineAssessmentSettings settings = default; + AssessmentDetails details = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisioningState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisioningState = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("scope"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scope = Scope.DeserializeScope(property.Value, options); + continue; + } + if (property.NameEquals("settings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + settings = MachineAssessmentSettings.DeserializeMachineAssessmentSettings(property.Value, options); + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = AssessmentDetails.DeserializeAssessmentDetails(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentV2Properties(provisioningState, scope, settings, details, 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(MachineAssessmentV2Properties)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentV2Properties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentV2Properties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2Properties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.cs new file mode 100644 index 000000000000..e446f24b5c12 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2Properties.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Assessment properties class. + public partial class MachineAssessmentV2Properties + { + /// + /// 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 MachineAssessmentV2Properties() + { + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Gets or sets the scope of assessment. + /// Gets or sets the settings for the assessment. + /// Gets or sets the details of the assessment. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentV2Properties(ProvisioningState? provisioningState, Scope scope, MachineAssessmentSettings settings, AssessmentDetails details, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + Scope = scope; + Settings = settings; + Details = details; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + /// Gets or sets the scope of assessment. + public Scope Scope { get; set; } + /// Gets or sets the settings for the assessment. + public MachineAssessmentSettings Settings { get; set; } + /// Gets or sets the details of the assessment. + public AssessmentDetails Details { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.Serialization.cs new file mode 100644 index 000000000000..9c921b98701d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.Migrate.Models +{ + internal partial class MachineAssessmentV2SummaryListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineAssessmentV2SummaryListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineAssessmentV2SummaryListResult 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(MachineAssessmentV2SummaryListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineAssessmentV2SummaryListResult(document.RootElement, options); + } + + internal static MachineAssessmentV2SummaryListResult DeserializeMachineAssessmentV2SummaryListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MachineAssessmentV2SummaryData.DeserializeMachineAssessmentV2SummaryData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineAssessmentV2SummaryListResult(value, nextLink, 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(MachineAssessmentV2SummaryListResult)} does not support writing '{options.Format}' format."); + } + } + + MachineAssessmentV2SummaryListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineAssessmentV2SummaryListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineAssessmentV2SummaryListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.cs new file mode 100644 index 000000000000..9de91c88b0f2 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineAssessmentV2SummaryListResult.cs @@ -0,0 +1,80 @@ +// 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.Migrate.Models +{ + /// The response of a MachineAssessmentV2Summary list operation. + internal partial class MachineAssessmentV2SummaryListResult + { + /// + /// 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 MachineAssessmentV2Summary items on this page. + /// is null. + internal MachineAssessmentV2SummaryListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The MachineAssessmentV2Summary items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal MachineAssessmentV2SummaryListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MachineAssessmentV2SummaryListResult() + { + } + + /// The MachineAssessmentV2Summary items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineBootType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineBootType.cs new file mode 100644 index 000000000000..9847f1d14b72 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineBootType.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.Migrate.Models +{ + /// Machine Boot Type. + public readonly partial struct MachineBootType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MachineBootType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string EFIValue = "EFI"; + private const string BiosValue = "BIOS"; + private const string NotSpecifiedValue = "NotSpecified"; + + /// Unknown - Machine Boot Type. + public static MachineBootType Unknown { get; } = new MachineBootType(UnknownValue); + /// EFI - Machine Boot Type. + public static MachineBootType EFI { get; } = new MachineBootType(EFIValue); + /// BIOS - Machine Boot Type. + public static MachineBootType Bios { get; } = new MachineBootType(BiosValue); + /// NotSpecified - Machine Boot Type. + public static MachineBootType NotSpecified { get; } = new MachineBootType(NotSpecifiedValue); + /// Determines if two values are the same. + public static bool operator ==(MachineBootType left, MachineBootType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MachineBootType left, MachineBootType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MachineBootType(string value) => new MachineBootType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MachineBootType other && Equals(other); + /// + public bool Equals(MachineBootType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.Serialization.cs new file mode 100644 index 000000000000..f5180df0ad3f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.Serialization.cs @@ -0,0 +1,151 @@ +// 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.Migrate.Models +{ + internal partial class MachineGraphAssessmentOptionsListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionsListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineGraphAssessmentOptionsListResult 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(MachineGraphAssessmentOptionsListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement, options); + } + + internal static MachineGraphAssessmentOptionsListResult DeserializeMachineGraphAssessmentOptionsListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + Uri nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MachineGraphAssessmentOptionData.DeserializeMachineGraphAssessmentOptionData(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + nextLink = new Uri(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineGraphAssessmentOptionsListResult(value, nextLink, 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(MachineGraphAssessmentOptionsListResult)} does not support writing '{options.Format}' format."); + } + } + + MachineGraphAssessmentOptionsListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionsListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.cs new file mode 100644 index 000000000000..73331039f2b2 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsListResult.cs @@ -0,0 +1,80 @@ +// 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.Migrate.Models +{ + /// The response of a MachineGraphAssessmentOptions list operation. + internal partial class MachineGraphAssessmentOptionsListResult + { + /// + /// 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 MachineGraphAssessmentOptions items on this page. + /// is null. + internal MachineGraphAssessmentOptionsListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The MachineGraphAssessmentOptions items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal MachineGraphAssessmentOptionsListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MachineGraphAssessmentOptionsListResult() + { + } + + /// The MachineGraphAssessmentOptions items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.Serialization.cs new file mode 100644 index 000000000000..3de148fb5705 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.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.Migrate.Models +{ + internal partial class MachineGraphAssessmentOptionsProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionsProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("edges"u8); + writer.WriteStartObject(); + foreach (var item in Edges) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MachineGraphAssessmentOptionsProperties 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(MachineGraphAssessmentOptionsProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMachineGraphAssessmentOptionsProperties(document.RootElement, options); + } + + internal static MachineGraphAssessmentOptionsProperties DeserializeMachineGraphAssessmentOptionsProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary edges = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("edges"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, MachineAssessmentOptionsOutboundEdgeGroup.DeserializeMachineAssessmentOptionsOutboundEdgeGroup(property0.Value, options)); + } + edges = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MachineGraphAssessmentOptionsProperties(edges, 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(MachineGraphAssessmentOptionsProperties)} does not support writing '{options.Format}' format."); + } + } + + MachineGraphAssessmentOptionsProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMachineGraphAssessmentOptionsProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MachineGraphAssessmentOptionsProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.cs new file mode 100644 index 000000000000..b26149278c8d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MachineGraphAssessmentOptionsProperties.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The properties of the assessment options. + internal partial class MachineGraphAssessmentOptionsProperties + { + /// + /// 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 . + /// Gets or sets the edges. + /// is null. + internal MachineGraphAssessmentOptionsProperties(IReadOnlyDictionary edges) + { + Argument.AssertNotNull(edges, nameof(edges)); + + Edges = edges; + } + + /// Initializes a new instance of . + /// Gets or sets the edges. + /// Keeps track of any properties unknown to the library. + internal MachineGraphAssessmentOptionsProperties(IReadOnlyDictionary edges, IDictionary serializedAdditionalRawData) + { + Edges = edges; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MachineGraphAssessmentOptionsProperties() + { + } + + /// Gets or sets the edges. + public IReadOnlyDictionary Edges { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.Serialization.cs new file mode 100644 index 000000000000..64bcfe75e83e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Migrate.Models +{ + public partial class ManagementDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagementDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ReadinessSummary)) + { + writer.WritePropertyName("readinessSummary"u8); + writer.WriteStartArray(); + foreach (var item in ReadinessSummary) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ManagementDetails 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(ManagementDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagementDetails(document.RootElement, options); + } + + internal static ManagementDetails DeserializeManagementDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureManagementOfferingType? name = default; + IReadOnlyList readinessSummary = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = new AzureManagementOfferingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("readinessSummary"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePairCloudSuitabilityCommon.DeserializeNameValuePairCloudSuitabilityCommon(item, options)); + } + readinessSummary = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagementDetails(name, readinessSummary ?? 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(ManagementDetails)} does not support writing '{options.Format}' format."); + } + } + + ManagementDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeManagementDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagementDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.cs new file mode 100644 index 000000000000..9bc65418c800 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ManagementDetails.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Management details. + public partial class ManagementDetails + { + /// + /// 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 ManagementDetails() + { + ReadinessSummary = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The management summary name. + /// The management suitability summary. + /// Keeps track of any properties unknown to the library. + internal ManagementDetails(AzureManagementOfferingType? name, IReadOnlyList readinessSummary, IDictionary serializedAdditionalRawData) + { + Name = name; + ReadinessSummary = readinessSummary; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The management summary name. + public AzureManagementOfferingType? Name { get; } + /// The management suitability summary. + public IReadOnlyList ReadinessSummary { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrateWorkloadType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrateWorkloadType.cs new file mode 100644 index 000000000000..641ca43c6a0f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrateWorkloadType.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.Migrate.Models +{ + /// Migration Workload type. + public readonly partial struct MigrateWorkloadType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MigrateWorkloadType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string MachineValue = "Machine"; + private const string ServerValue = "Server"; + private const string InstanceValue = "Instance"; + private const string WebServerValue = "WebServer"; + private const string WebApplicationValue = "WebApplication"; + private const string DatabaseValue = "Database"; + private const string HostValue = "Host"; + private const string ManagementServerValue = "ManagementServer"; + + /// Unknown - Migration Workload type. + public static MigrateWorkloadType Unknown { get; } = new MigrateWorkloadType(UnknownValue); + /// Machine - Migration Workload type. + public static MigrateWorkloadType Machine { get; } = new MigrateWorkloadType(MachineValue); + /// Server - Migration Workload type. + public static MigrateWorkloadType Server { get; } = new MigrateWorkloadType(ServerValue); + /// Instance - Migration Workload type. + public static MigrateWorkloadType Instance { get; } = new MigrateWorkloadType(InstanceValue); + /// WebServer - Migration Workload type. + public static MigrateWorkloadType WebServer { get; } = new MigrateWorkloadType(WebServerValue); + /// WebApplication - Migration Workload type. + public static MigrateWorkloadType WebApplication { get; } = new MigrateWorkloadType(WebApplicationValue); + /// Database - Migration Workload type. + public static MigrateWorkloadType Database { get; } = new MigrateWorkloadType(DatabaseValue); + /// Host - Migration Workload type. + public static MigrateWorkloadType Host { get; } = new MigrateWorkloadType(HostValue); + /// ManagementServer - Migration Workload type. + public static MigrateWorkloadType ManagementServer { get; } = new MigrateWorkloadType(ManagementServerValue); + /// Determines if two values are the same. + public static bool operator ==(MigrateWorkloadType left, MigrateWorkloadType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MigrateWorkloadType left, MigrateWorkloadType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MigrateWorkloadType(string value) => new MigrateWorkloadType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MigrateWorkloadType other && Equals(other); + /// + public bool Equals(MigrateWorkloadType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.Serialization.cs new file mode 100644 index 000000000000..3833a2532a1b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Migrate.Models +{ + public partial class MigrationDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MigrationDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(ReadinessSummary)) + { + writer.WritePropertyName("readinessSummary"u8); + writer.WriteStartArray(); + foreach (var item in ReadinessSummary) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(MigrationType)) + { + writer.WritePropertyName("migrationType"u8); + writer.WriteStringValue(MigrationType.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MigrationDetails 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(MigrationDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMigrationDetails(document.RootElement, options); + } + + internal static MigrationDetails DeserializeMigrationDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList readinessSummary = default; + MigrationType? migrationType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("readinessSummary"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePairCloudSuitabilityCommon.DeserializeNameValuePairCloudSuitabilityCommon(item, options)); + } + readinessSummary = array; + continue; + } + if (property.NameEquals("migrationType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + migrationType = new MigrationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MigrationDetails(readinessSummary ?? new ChangeTrackingList(), migrationType, 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(MigrationDetails)} does not support writing '{options.Format}' format."); + } + } + + MigrationDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMigrationDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MigrationDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.cs new file mode 100644 index 000000000000..e7d8527d8404 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationDetails.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Migration details. + public partial class MigrationDetails + { + /// + /// 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 MigrationDetails() + { + ReadinessSummary = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The readiness summary. + /// The migration type. + /// Keeps track of any properties unknown to the library. + internal MigrationDetails(IReadOnlyList readinessSummary, MigrationType? migrationType, IDictionary serializedAdditionalRawData) + { + ReadinessSummary = readinessSummary; + MigrationType = migrationType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The readiness summary. + public IReadOnlyList ReadinessSummary { get; } + /// The migration type. + public MigrationType? MigrationType { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.Serialization.cs new file mode 100644 index 000000000000..8f53042a8589 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.Serialization.cs @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + public partial class MigrationIssues : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MigrationIssues)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(IssueCode)) + { + writer.WritePropertyName("issueCode"u8); + writer.WriteStringValue(IssueCode); + } + if (options.Format != "W" && Optional.IsDefined(IssueCategory)) + { + writer.WritePropertyName("issueCategory"u8); + writer.WriteStringValue(IssueCategory.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(IssueDescription)) + { + writer.WritePropertyName("issueDescription"u8); + writer.WriteStringValue(IssueDescription); + } + if (options.Format != "W" && Optional.IsDefined(PossibleCause)) + { + writer.WritePropertyName("possibleCause"u8); + writer.WriteStringValue(PossibleCause); + } + if (options.Format != "W" && Optional.IsCollectionDefined(RecommendedActions)) + { + writer.WritePropertyName("recommendedActions"u8); + writer.WriteStartArray(); + foreach (var item in RecommendedActions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(MoreInformation)) + { + writer.WritePropertyName("moreInformation"u8); + writer.WriteStartArray(); + foreach (var item in MoreInformation) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MigrationIssues 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(MigrationIssues)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMigrationIssues(document.RootElement, options); + } + + internal static MigrationIssues DeserializeMigrationIssues(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string issueCode = default; + MigrationIssuesCategory? issueCategory = default; + string issueDescription = default; + string possibleCause = default; + IReadOnlyList recommendedActions = default; + IReadOnlyList moreInformation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("issueCode"u8)) + { + issueCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("issueCategory"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + issueCategory = new MigrationIssuesCategory(property.Value.GetString()); + continue; + } + if (property.NameEquals("issueDescription"u8)) + { + issueDescription = property.Value.GetString(); + continue; + } + if (property.NameEquals("possibleCause"u8)) + { + possibleCause = property.Value.GetString(); + continue; + } + if (property.NameEquals("recommendedActions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + recommendedActions = array; + continue; + } + if (property.NameEquals("moreInformation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.MoreInformation.DeserializeMoreInformation(item, options)); + } + moreInformation = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MigrationIssues( + issueCode, + issueCategory, + issueDescription, + possibleCause, + recommendedActions ?? new ChangeTrackingList(), + moreInformation ?? 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(MigrationIssues)} does not support writing '{options.Format}' format."); + } + } + + MigrationIssues IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMigrationIssues(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MigrationIssues)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.cs new file mode 100644 index 000000000000..f7656dc96a50 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssues.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.Migrate.Models +{ + /// Migration issues. + public partial class MigrationIssues + { + /// + /// 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 MigrationIssues() + { + RecommendedActions = new ChangeTrackingList(); + MoreInformation = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The issue id. + /// The issue category. + /// The issue description. + /// The possible causes. + /// The recommended action. + /// The more information list. + /// Keeps track of any properties unknown to the library. + internal MigrationIssues(string issueCode, MigrationIssuesCategory? issueCategory, string issueDescription, string possibleCause, IReadOnlyList recommendedActions, IReadOnlyList moreInformation, IDictionary serializedAdditionalRawData) + { + IssueCode = issueCode; + IssueCategory = issueCategory; + IssueDescription = issueDescription; + PossibleCause = possibleCause; + RecommendedActions = recommendedActions; + MoreInformation = moreInformation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The issue id. + public string IssueCode { get; } + /// The issue category. + public MigrationIssuesCategory? IssueCategory { get; } + /// The issue description. + public string IssueDescription { get; } + /// The possible causes. + public string PossibleCause { get; } + /// The recommended action. + public IReadOnlyList RecommendedActions { get; } + /// The more information list. + public IReadOnlyList MoreInformation { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssuesCategory.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssuesCategory.cs new file mode 100644 index 000000000000..786b1fb8621a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationIssuesCategory.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.Migrate.Models +{ + /// Migration Issues Category. + public readonly partial struct MigrationIssuesCategory : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MigrationIssuesCategory(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string IssueValue = "Issue"; + private const string WarningValue = "Warning"; + private const string InternalValue = "Internal"; + + /// Issue - Migration Issues Category. + public static MigrationIssuesCategory Issue { get; } = new MigrationIssuesCategory(IssueValue); + /// Warning - Migration Issues Category. + public static MigrationIssuesCategory Warning { get; } = new MigrationIssuesCategory(WarningValue); + /// Internal - Migration Issues Category. + public static MigrationIssuesCategory Internal { get; } = new MigrationIssuesCategory(InternalValue); + /// Determines if two values are the same. + public static bool operator ==(MigrationIssuesCategory left, MigrationIssuesCategory right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MigrationIssuesCategory left, MigrationIssuesCategory right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MigrationIssuesCategory(string value) => new MigrationIssuesCategory(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MigrationIssuesCategory other && Equals(other); + /// + public bool Equals(MigrationIssuesCategory 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationPlatform.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationPlatform.cs new file mode 100644 index 000000000000..23c1c59296d0 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationPlatform.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.Migrate.Models +{ + /// Migration Platform. + public readonly partial struct MigrationPlatform : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MigrationPlatform(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string PaaSValue = "PaaS"; + private const string IaaSValue = "IaaS"; + private const string SaaSValue = "SaaS"; + + /// Unknown - Migration Platform. + public static MigrationPlatform Unknown { get; } = new MigrationPlatform(UnknownValue); + /// PaaS - Migration Platform. + public static MigrationPlatform PaaS { get; } = new MigrationPlatform(PaaSValue); + /// IaaS - Migration Platform. + public static MigrationPlatform IaaS { get; } = new MigrationPlatform(IaaSValue); + /// SaaS - Migration Platform. + public static MigrationPlatform SaaS { get; } = new MigrationPlatform(SaaSValue); + /// Determines if two values are the same. + public static bool operator ==(MigrationPlatform left, MigrationPlatform right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MigrationPlatform left, MigrationPlatform right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MigrationPlatform(string value) => new MigrationPlatform(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MigrationPlatform other && Equals(other); + /// + public bool Equals(MigrationPlatform 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.Serialization.cs new file mode 100644 index 000000000000..fef518df74ee --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + internal partial class MigrationSuitability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MigrationSuitability)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Readiness)) + { + writer.WritePropertyName("readiness"u8); + writer.WriteStringValue(Readiness.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MigrationSuitability 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(MigrationSuitability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMigrationSuitability(document.RootElement, options); + } + + internal static MigrationSuitability DeserializeMigrationSuitability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CloudSuitabilityCommon? readiness = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("readiness"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + readiness = new CloudSuitabilityCommon(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MigrationSuitability(readiness, 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(MigrationSuitability)} does not support writing '{options.Format}' format."); + } + } + + MigrationSuitability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMigrationSuitability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MigrationSuitability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.cs new file mode 100644 index 000000000000..a7fc3c10055f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationSuitability.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The migration suitability. + internal partial class MigrationSuitability + { + /// + /// 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 MigrationSuitability() + { + } + + /// Initializes a new instance of . + /// The migration suitability. + /// Keeps track of any properties unknown to the library. + internal MigrationSuitability(CloudSuitabilityCommon? readiness, IDictionary serializedAdditionalRawData) + { + Readiness = readiness; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The migration suitability. + public CloudSuitabilityCommon? Readiness { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationType.cs new file mode 100644 index 000000000000..29cc281ea563 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MigrationType.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Migration Type. + public readonly partial struct MigrationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MigrationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string ReplatformValue = "Replatform"; + private const string RehostValue = "Rehost"; + private const string RetainValue = "Retain"; + private const string RearchitectValue = "Rearchitect"; + + /// Unknown - Migration Type. + public static MigrationType Unknown { get; } = new MigrationType(UnknownValue); + /// Replatform - Migration Type. + public static MigrationType Replatform { get; } = new MigrationType(ReplatformValue); + /// Rehost - Migration Type. + public static MigrationType Rehost { get; } = new MigrationType(RehostValue); + /// Retain - Migration Type. + public static MigrationType Retain { get; } = new MigrationType(RetainValue); + /// Rearchitect - Migration Type. + public static MigrationType Rearchitect { get; } = new MigrationType(RearchitectValue); + /// Determines if two values are the same. + public static bool operator ==(MigrationType left, MigrationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MigrationType left, MigrationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator MigrationType(string value) => new MigrationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MigrationType other && Equals(other); + /// + public bool Equals(MigrationType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.Serialization.cs new file mode 100644 index 000000000000..1a5812e8aff9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.Serialization.cs @@ -0,0 +1,140 @@ +// 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.Migrate.Models +{ + public partial class MoreInformation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MoreInformation)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W") + { + writer.WritePropertyName("url"u8); + writer.WriteStringValue(Uri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + MoreInformation 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(MoreInformation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMoreInformation(document.RootElement, options); + } + + internal static MoreInformation DeserializeMoreInformation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string title = default; + string url = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("title"u8)) + { + title = property.Value.GetString(); + continue; + } + if (property.NameEquals("url"u8)) + { + url = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MoreInformation(title, url, 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(MoreInformation)} does not support writing '{options.Format}' format."); + } + } + + MoreInformation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMoreInformation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MoreInformation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.cs new file mode 100644 index 000000000000..4c74eb762d74 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/MoreInformation.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// More information details. + public partial class MoreInformation + { + /// + /// 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 title of the information. + /// The URL of the information. + internal MoreInformation(string title, string uri) + { + Title = title; + Uri = uri; + } + + /// Initializes a new instance of . + /// The title of the information. + /// The URL of the information. + /// Keeps track of any properties unknown to the library. + internal MoreInformation(string title, string uri, IDictionary serializedAdditionalRawData) + { + Title = title; + Uri = uri; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MoreInformation() + { + } + + /// The title of the information. + public string Title { get; } + /// The URL of the information. + public string Uri { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.Serialization.cs new file mode 100644 index 000000000000..44d54ee0aaa3 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.Serialization.cs @@ -0,0 +1,140 @@ +// 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.Migrate.Models +{ + public partial class NameValuePair : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameValuePair)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameValuePair 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(NameValuePair)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameValuePair(document.RootElement, options); + } + + internal static NameValuePair DeserializeNameValuePair(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameValuePair(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameValuePair)} does not support writing '{options.Format}' format."); + } + } + + NameValuePair IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameValuePair(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameValuePair)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.cs new file mode 100644 index 000000000000..8c46de20bc59 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePair.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.Migrate.Models +{ + /// The generic name value pair. + public partial class NameValuePair + { + /// + /// 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 NameValuePair() + { + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// Keeps track of any properties unknown to the library. + internal NameValuePair(string name, string value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name. + public string Name { get; } + /// The value. + public string Value { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.Serialization.cs new file mode 100644 index 000000000000..be6ac047c213 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class NameValuePairCloudSuitabilityCommon : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameValuePairCloudSuitabilityCommon)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameValuePairCloudSuitabilityCommon 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(NameValuePairCloudSuitabilityCommon)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameValuePairCloudSuitabilityCommon(document.RootElement, options); + } + + internal static NameValuePairCloudSuitabilityCommon DeserializeNameValuePairCloudSuitabilityCommon(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CloudSuitabilityCommon? name = default; + int? value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = new CloudSuitabilityCommon(property.Value.GetString()); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameValuePairCloudSuitabilityCommon(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameValuePairCloudSuitabilityCommon)} does not support writing '{options.Format}' format."); + } + } + + NameValuePairCloudSuitabilityCommon IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameValuePairCloudSuitabilityCommon(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameValuePairCloudSuitabilityCommon)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.cs new file mode 100644 index 000000000000..f784ba115d0c --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCloudSuitabilityCommon.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.Migrate.Models +{ + /// The generic name value pair. + public partial class NameValuePairCloudSuitabilityCommon + { + /// + /// 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 NameValuePairCloudSuitabilityCommon() + { + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// Keeps track of any properties unknown to the library. + internal NameValuePairCloudSuitabilityCommon(CloudSuitabilityCommon? name, int? value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name. + public CloudSuitabilityCommon? Name { get; } + /// The value. + public int? Value { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.Serialization.cs new file mode 100644 index 000000000000..52cb3d12a2a4 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class NameValuePairCostType : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameValuePairCostType)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameValuePairCostType 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(NameValuePairCostType)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameValuePairCostType(document.RootElement, options); + } + + internal static NameValuePairCostType DeserializeNameValuePairCostType(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CostType? name = default; + float? value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = new CostType(property.Value.GetString()); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameValuePairCostType(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameValuePairCostType)} does not support writing '{options.Format}' format."); + } + } + + NameValuePairCostType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameValuePairCostType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameValuePairCostType)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.cs new file mode 100644 index 000000000000..7bd605067c22 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairCostType.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.Migrate.Models +{ + /// The generic name value pair. + public partial class NameValuePairCostType + { + /// + /// 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 NameValuePairCostType() + { + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// Keeps track of any properties unknown to the library. + internal NameValuePairCostType(CostType? name, float? value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name. + public CostType? Name { get; } + /// The value. + public float? Value { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.Serialization.cs new file mode 100644 index 000000000000..bdc3cab36011 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class NameValuePairSavingsType : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(NameValuePairSavingsType)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteNumberValue(Value.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + NameValuePairSavingsType 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(NameValuePairSavingsType)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeNameValuePairSavingsType(document.RootElement, options); + } + + internal static NameValuePairSavingsType DeserializeNameValuePairSavingsType(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SavingsType? name = default; + float? value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = new SavingsType(property.Value.GetString()); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + value = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new NameValuePairSavingsType(name, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(NameValuePairSavingsType)} does not support writing '{options.Format}' format."); + } + } + + NameValuePairSavingsType IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeNameValuePairSavingsType(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(NameValuePairSavingsType)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.cs new file mode 100644 index 000000000000..44fc6408906f --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/NameValuePairSavingsType.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.Migrate.Models +{ + /// The generic name value pair. + public partial class NameValuePairSavingsType + { + /// + /// 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 NameValuePairSavingsType() + { + } + + /// Initializes a new instance of . + /// The name. + /// The value. + /// Keeps track of any properties unknown to the library. + internal NameValuePairSavingsType(SavingsType? name, float? value, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name. + public SavingsType? Name { get; } + /// The value. + public float? Value { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Percentile.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Percentile.cs new file mode 100644 index 000000000000..fe33a9250fc8 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Percentile.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Percentile for Performance Data. + public readonly partial struct Percentile : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Percentile(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string Percentile50Value = "Percentile50"; + private const string Percentile90Value = "Percentile90"; + private const string Percentile95Value = "Percentile95"; + private const string Percentile99Value = "Percentile99"; + private const string PercentileUnknownValue = "PercentileUnknown"; + + /// Percentile 50. + public static Percentile Percentile50 { get; } = new Percentile(Percentile50Value); + /// Percentile 90. + public static Percentile Percentile90 { get; } = new Percentile(Percentile90Value); + /// Percentile 95. + public static Percentile Percentile95 { get; } = new Percentile(Percentile95Value); + /// Percentile 99. + public static Percentile Percentile99 { get; } = new Percentile(Percentile99Value); + /// Percentile unknown. + public static Percentile PercentileUnknown { get; } = new Percentile(PercentileUnknownValue); + /// Determines if two values are the same. + public static bool operator ==(Percentile left, Percentile right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Percentile left, Percentile right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator Percentile(string value) => new Percentile(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Percentile other && Equals(other); + /// + public bool Equals(Percentile 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.Serialization.cs new file mode 100644 index 000000000000..7241f189f5a9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.Serialization.cs @@ -0,0 +1,178 @@ +// 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.Migrate.Models +{ + public partial class PerformanceData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PerformanceData)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Percentile)) + { + writer.WritePropertyName("percentile"u8); + writer.WriteStringValue(Percentile.Value.ToString()); + } + if (Optional.IsDefined(TimeRange)) + { + writer.WritePropertyName("timeRange"u8); + writer.WriteStringValue(TimeRange.Value.ToString()); + } + if (Optional.IsDefined(PerfDataStartOn)) + { + writer.WritePropertyName("perfDataStartTime"u8); + writer.WriteStringValue(PerfDataStartOn.Value, "O"); + } + if (Optional.IsDefined(PerfDataEndOn)) + { + writer.WritePropertyName("perfDataEndTime"u8); + writer.WriteStringValue(PerfDataEndOn.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + PerformanceData 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(PerformanceData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePerformanceData(document.RootElement, options); + } + + internal static PerformanceData DeserializePerformanceData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Percentile? percentile = default; + TimeRange? timeRange = default; + DateTimeOffset? perfDataStartTime = default; + DateTimeOffset? perfDataEndTime = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("percentile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + percentile = new Percentile(property.Value.GetString()); + continue; + } + if (property.NameEquals("timeRange"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeRange = new TimeRange(property.Value.GetString()); + continue; + } + if (property.NameEquals("perfDataStartTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + perfDataStartTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("perfDataEndTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + perfDataEndTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PerformanceData(percentile, timeRange, perfDataStartTime, perfDataEndTime, 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(PerformanceData)} does not support writing '{options.Format}' format."); + } + } + + PerformanceData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePerformanceData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PerformanceData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.cs new file mode 100644 index 000000000000..81295aa73618 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PerformanceData.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Performance data class. + public partial class PerformanceData + { + /// + /// 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 PerformanceData() + { + } + + /// Initializes a new instance of . + /// + /// Percentile of the utilization data values to be considered while assessing + /// machines. + /// + /// + /// Time Range for which the historic utilization data should be considered for + /// assessment. + /// + /// Gets or sets the start time to consider performance data for assessment. + /// Gets or sets the end time to consider performance data for assessment. + /// Keeps track of any properties unknown to the library. + internal PerformanceData(Percentile? percentile, TimeRange? timeRange, DateTimeOffset? perfDataStartOn, DateTimeOffset? perfDataEndOn, IDictionary serializedAdditionalRawData) + { + Percentile = percentile; + TimeRange = timeRange; + PerfDataStartOn = perfDataStartOn; + PerfDataEndOn = perfDataEndOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Percentile of the utilization data values to be considered while assessing + /// machines. + /// + public Percentile? Percentile { get; set; } + /// + /// Time Range for which the historic utilization data should be considered for + /// assessment. + /// + public TimeRange? TimeRange { get; set; } + /// Gets or sets the start time to consider performance data for assessment. + public DateTimeOffset? PerfDataStartOn { get; set; } + /// Gets or sets the end time to consider performance data for assessment. + public DateTimeOffset? PerfDataEndOn { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PremiumDiskSupport.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PremiumDiskSupport.cs new file mode 100644 index 000000000000..4fb3b5346c17 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/PremiumDiskSupport.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Premium Disk Support. + public readonly partial struct PremiumDiskSupport : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PremiumDiskSupport(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PremiumDiskSupportedValue = "PremiumDiskSupported"; + private const string PremiumDiskNotSupportedValue = "PremiumDiskNotSupported"; + + /// Premium Disk Supported. + public static PremiumDiskSupport PremiumDiskSupported { get; } = new PremiumDiskSupport(PremiumDiskSupportedValue); + /// Premium Disk Not Supported. + public static PremiumDiskSupport PremiumDiskNotSupported { get; } = new PremiumDiskSupport(PremiumDiskNotSupportedValue); + /// Determines if two values are the same. + public static bool operator ==(PremiumDiskSupport left, PremiumDiskSupport right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PremiumDiskSupport left, PremiumDiskSupport right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator PremiumDiskSupport(string value) => new PremiumDiskSupport(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PremiumDiskSupport other && Equals(other); + /// + public bool Equals(PremiumDiskSupport 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.Serialization.cs new file mode 100644 index 000000000000..318b4d7b6674 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + public partial class ProcessorInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProcessorInfo)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(NumberOfSockets)) + { + writer.WritePropertyName("numberOfSockets"u8); + writer.WriteNumberValue(NumberOfSockets.Value); + } + if (Optional.IsDefined(NumberOfCoresPerSocket)) + { + writer.WritePropertyName("numberOfCoresPerSocket"u8); + writer.WriteNumberValue(NumberOfCoresPerSocket.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ProcessorInfo 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(ProcessorInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProcessorInfo(document.RootElement, options); + } + + internal static ProcessorInfo DeserializeProcessorInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + int? numberOfSockets = default; + int? numberOfCoresPerSocket = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("numberOfSockets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfSockets = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("numberOfCoresPerSocket"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + numberOfCoresPerSocket = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProcessorInfo(name, numberOfSockets, numberOfCoresPerSocket, 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(ProcessorInfo)} does not support writing '{options.Format}' format."); + } + } + + ProcessorInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProcessorInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProcessorInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.cs new file mode 100644 index 000000000000..39516c1b4405 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProcessorInfo.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Represents a information \ details of a processor. + public partial class ProcessorInfo + { + /// + /// 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 ProcessorInfo() + { + } + + /// Initializes a new instance of . + /// Gets or sets the name \ model of a processor. + /// Gets or sets the number of sockets. + /// Gets or sets the number of cores in a socket. + /// Keeps track of any properties unknown to the library. + internal ProcessorInfo(string name, int? numberOfSockets, int? numberOfCoresPerSocket, IDictionary serializedAdditionalRawData) + { + Name = name; + NumberOfSockets = numberOfSockets; + NumberOfCoresPerSocket = numberOfCoresPerSocket; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the name \ model of a processor. + public string Name { get; } + /// Gets or sets the number of sockets. + public int? NumberOfSockets { get; } + /// Gets or sets the number of cores in a socket. + public int? NumberOfCoresPerSocket { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.Serialization.cs new file mode 100644 index 000000000000..9c099713391b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.Serialization.cs @@ -0,0 +1,275 @@ +// 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.Migrate.Models +{ + public partial class ProductSupportStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProductSupportStatus)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(CurrentVersion)) + { + writer.WritePropertyName("currentVersion"u8); + writer.WriteStringValue(CurrentVersion); + } + if (options.Format != "W" && Optional.IsDefined(ServicePackStatus)) + { + writer.WritePropertyName("servicePackStatus"u8); + writer.WriteStringValue(ServicePackStatus); + } + if (options.Format != "W" && Optional.IsDefined(EsuStatus)) + { + writer.WritePropertyName("esuStatus"u8); + writer.WriteStringValue(EsuStatus); + } + if (options.Format != "W" && Optional.IsDefined(SupportStatus)) + { + writer.WritePropertyName("supportStatus"u8); + writer.WriteStringValue(SupportStatus); + } + if (options.Format != "W" && Optional.IsDefined(Eta)) + { + writer.WritePropertyName("eta"u8); + writer.WriteNumberValue(Eta.Value); + } + if (options.Format != "W" && Optional.IsDefined(CurrentEsuYear)) + { + writer.WritePropertyName("currentEsuYear"u8); + writer.WriteStringValue(CurrentEsuYear); + } + if (options.Format != "W" && Optional.IsDefined(MainstreamEndOn)) + { + writer.WritePropertyName("mainstreamEndDate"u8); + writer.WriteStringValue(MainstreamEndOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExtendedSupportEndOn)) + { + writer.WritePropertyName("extendedSupportEndDate"u8); + writer.WriteStringValue(ExtendedSupportEndOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExtendedSecurityUpdateYear1EndOn)) + { + writer.WritePropertyName("extendedSecurityUpdateYear1EndDate"u8); + writer.WriteStringValue(ExtendedSecurityUpdateYear1EndOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExtendedSecurityUpdateYear2EndOn)) + { + writer.WritePropertyName("extendedSecurityUpdateYear2EndDate"u8); + writer.WriteStringValue(ExtendedSecurityUpdateYear2EndOn.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ExtendedSecurityUpdateYear3EndOn)) + { + writer.WritePropertyName("extendedSecurityUpdateYear3EndDate"u8); + writer.WriteStringValue(ExtendedSecurityUpdateYear3EndOn.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ProductSupportStatus 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(ProductSupportStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProductSupportStatus(document.RootElement, options); + } + + internal static ProductSupportStatus DeserializeProductSupportStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string currentVersion = default; + string servicePackStatus = default; + string esuStatus = default; + string supportStatus = default; + int? eta = default; + string currentEsuYear = default; + DateTimeOffset? mainstreamEndDate = default; + DateTimeOffset? extendedSupportEndDate = default; + DateTimeOffset? extendedSecurityUpdateYear1EndDate = default; + DateTimeOffset? extendedSecurityUpdateYear2EndDate = default; + DateTimeOffset? extendedSecurityUpdateYear3EndDate = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("currentVersion"u8)) + { + currentVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("servicePackStatus"u8)) + { + servicePackStatus = property.Value.GetString(); + continue; + } + if (property.NameEquals("esuStatus"u8)) + { + esuStatus = property.Value.GetString(); + continue; + } + if (property.NameEquals("supportStatus"u8)) + { + supportStatus = property.Value.GetString(); + continue; + } + if (property.NameEquals("eta"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + eta = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("currentEsuYear"u8)) + { + currentEsuYear = property.Value.GetString(); + continue; + } + if (property.NameEquals("mainstreamEndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mainstreamEndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("extendedSupportEndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extendedSupportEndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("extendedSecurityUpdateYear1EndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extendedSecurityUpdateYear1EndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("extendedSecurityUpdateYear2EndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extendedSecurityUpdateYear2EndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("extendedSecurityUpdateYear3EndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extendedSecurityUpdateYear3EndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProductSupportStatus( + currentVersion, + servicePackStatus, + esuStatus, + supportStatus, + eta, + currentEsuYear, + mainstreamEndDate, + extendedSupportEndDate, + extendedSecurityUpdateYear1EndDate, + extendedSecurityUpdateYear2EndDate, + extendedSecurityUpdateYear3EndDate, + 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(ProductSupportStatus)} does not support writing '{options.Format}' format."); + } + } + + ProductSupportStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeProductSupportStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProductSupportStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.cs new file mode 100644 index 000000000000..00840f10a72d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProductSupportStatus.cs @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Class to represent the Product Support Status. + public partial class ProductSupportStatus + { + /// + /// 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 ProductSupportStatus() + { + } + + /// Initializes a new instance of . + /// Gets or sets current version of ServicePack. + /// Gets or sets ServicePack of the product. + /// Gets or sets the Extended Security Update ESU status. + /// Gets or sets the support status of the product. + /// Gets or sets the ETA. + /// Gets or sets the current ESU support year. + /// Gets or sets the main stream end date of the product. + /// Gets or sets the extended support end date of the product. + /// Gets or sets the extended security update year 1 end date of the product. + /// Gets or sets the extended security update year 2 end date of the product. + /// Gets or sets the extended security update year 3 end date of the product. + /// Keeps track of any properties unknown to the library. + internal ProductSupportStatus(string currentVersion, string servicePackStatus, string esuStatus, string supportStatus, int? eta, string currentEsuYear, DateTimeOffset? mainstreamEndOn, DateTimeOffset? extendedSupportEndOn, DateTimeOffset? extendedSecurityUpdateYear1EndOn, DateTimeOffset? extendedSecurityUpdateYear2EndOn, DateTimeOffset? extendedSecurityUpdateYear3EndOn, IDictionary serializedAdditionalRawData) + { + CurrentVersion = currentVersion; + ServicePackStatus = servicePackStatus; + EsuStatus = esuStatus; + SupportStatus = supportStatus; + Eta = eta; + CurrentEsuYear = currentEsuYear; + MainstreamEndOn = mainstreamEndOn; + ExtendedSupportEndOn = extendedSupportEndOn; + ExtendedSecurityUpdateYear1EndOn = extendedSecurityUpdateYear1EndOn; + ExtendedSecurityUpdateYear2EndOn = extendedSecurityUpdateYear2EndOn; + ExtendedSecurityUpdateYear3EndOn = extendedSecurityUpdateYear3EndOn; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets current version of ServicePack. + public string CurrentVersion { get; } + /// Gets or sets ServicePack of the product. + public string ServicePackStatus { get; } + /// Gets or sets the Extended Security Update ESU status. + public string EsuStatus { get; } + /// Gets or sets the support status of the product. + public string SupportStatus { get; } + /// Gets or sets the ETA. + public int? Eta { get; } + /// Gets or sets the current ESU support year. + public string CurrentEsuYear { get; } + /// Gets or sets the main stream end date of the product. + public DateTimeOffset? MainstreamEndOn { get; } + /// Gets or sets the extended support end date of the product. + public DateTimeOffset? ExtendedSupportEndOn { get; } + /// Gets or sets the extended security update year 1 end date of the product. + public DateTimeOffset? ExtendedSecurityUpdateYear1EndOn { get; } + /// Gets or sets the extended security update year 2 end date of the product. + public DateTimeOffset? ExtendedSecurityUpdateYear2EndOn { get; } + /// Gets or sets the extended security update year 3 end date of the product. + public DateTimeOffset? ExtendedSecurityUpdateYear3EndOn { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProvisioningState.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..d0511295ed34 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ProvisioningState.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The status of the current operation. + public readonly partial struct ProvisioningState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProvisioningState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SucceededValue = "Succeeded"; + private const string FailedValue = "Failed"; + private const string CanceledValue = "Canceled"; + private const string ProvisioningValue = "Provisioning"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string AcceptedValue = "Accepted"; + + /// Resource provisioning Successful. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Resource provisioning Failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Resource provisioning Canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Resource is being Provisioned. + public static ProvisioningState Provisioning { get; } = new ProvisioningState(ProvisioningValue); + /// Resource is being Updated. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + /// Resource is being Deleted. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Resource is being Accepted. + public static ProvisioningState Accepted { get; } = new ProvisioningState(AcceptedValue); + /// Determines if two values are the same. + public static bool operator ==(ProvisioningState left, ProvisioningState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProvisioningState left, ProvisioningState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ProvisioningState(string value) => new ProvisioningState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProvisioningState other && Equals(other); + /// + public bool Equals(ProvisioningState 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.Serialization.cs new file mode 100644 index 000000000000..692dc1d9e3df --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.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.Migrate.Models +{ + internal partial class RecommendedFor : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RecommendedFor)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsCollectionDefined(Strategies)) + { + writer.WritePropertyName("strategies"u8); + writer.WriteStartArray(); + foreach (var item in Strategies) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + RecommendedFor 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(RecommendedFor)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRecommendedFor(document.RootElement, options); + } + + internal static RecommendedFor DeserializeRecommendedFor(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList strategies = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("strategies"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new StrategyType(item.GetString())); + } + strategies = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RecommendedFor(strategies ?? 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(RecommendedFor)} does not support writing '{options.Format}' format."); + } + } + + RecommendedFor IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeRecommendedFor(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RecommendedFor)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.cs new file mode 100644 index 000000000000..ca7904632dc0 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/RecommendedFor.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The recommended details. + internal partial class RecommendedFor + { + /// + /// 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 RecommendedFor() + { + Strategies = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The list of strategy type. + /// Keeps track of any properties unknown to the library. + internal RecommendedFor(IReadOnlyList strategies, IDictionary serializedAdditionalRawData) + { + Strategies = strategies; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The list of strategy type. + public IReadOnlyList Strategies { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.Serialization.cs new file mode 100644 index 000000000000..7e1f080240c7 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.Serialization.cs @@ -0,0 +1,158 @@ +// 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.Migrate.Models +{ + public partial class SavingsDetailsCommon : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsDetailsCommon)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SavingOptions)) + { + writer.WritePropertyName("savingOptions"u8); + writer.WriteStringValue(SavingOptions.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(SavingsDetail)) + { + writer.WritePropertyName("savingsDetail"u8); + writer.WriteStartArray(); + foreach (var item in SavingsDetail) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SavingsDetailsCommon 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(SavingsDetailsCommon)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsDetailsCommon(document.RootElement, options); + } + + internal static SavingsDetailsCommon DeserializeSavingsDetailsCommon(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SavingsOption? savingOptions = default; + IReadOnlyList savingsDetail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("savingOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + savingOptions = new SavingsOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("savingsDetail"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePairSavingsType.DeserializeNameValuePairSavingsType(item, options)); + } + savingsDetail = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SavingsDetailsCommon(savingOptions, savingsDetail ?? 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(SavingsDetailsCommon)} does not support writing '{options.Format}' format."); + } + } + + SavingsDetailsCommon IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSavingsDetailsCommon(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsDetailsCommon)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.cs new file mode 100644 index 000000000000..ae06d672509a --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsDetailsCommon.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The savings details. + public partial class SavingsDetailsCommon + { + /// + /// 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 SavingsDetailsCommon() + { + SavingsDetail = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The savings options. + /// The sku cost details per azure offer type. + /// Keeps track of any properties unknown to the library. + internal SavingsDetailsCommon(SavingsOption? savingOptions, IReadOnlyList savingsDetail, IDictionary serializedAdditionalRawData) + { + SavingOptions = savingOptions; + SavingsDetail = savingsDetail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The savings options. + public SavingsOption? SavingOptions { get; } + /// The sku cost details per azure offer type. + public IReadOnlyList SavingsDetail { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsOption.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsOption.cs new file mode 100644 index 000000000000..1e590848ca6d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsOption.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The savings options. + public readonly partial struct SavingsOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SavingsOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string RI1YearValue = "RI1Year"; + private const string RI3YearValue = "RI3Year"; + private const string SavingsPlan1YearValue = "SavingsPlan1Year"; + private const string SavingsPlan3YearValue = "SavingsPlan3Year"; + private const string CustomAzureOfferCodeValue = "CustomAzureOfferCode"; + + /// No savings options. + public static SavingsOption None { get; } = new SavingsOption(NoneValue); + /// Reserved Instance for 1 year. + public static SavingsOption RI1Year { get; } = new SavingsOption(RI1YearValue); + /// Reserved Instance for 3 years. + public static SavingsOption RI3Year { get; } = new SavingsOption(RI3YearValue); + /// The savings plan for 1 year. + public static SavingsOption SavingsPlan1Year { get; } = new SavingsOption(SavingsPlan1YearValue); + /// The savings plan for 3 years. + public static SavingsOption SavingsPlan3Year { get; } = new SavingsOption(SavingsPlan3YearValue); + /// Custom azure offer code. + public static SavingsOption CustomAzureOfferCode { get; } = new SavingsOption(CustomAzureOfferCodeValue); + /// Determines if two values are the same. + public static bool operator ==(SavingsOption left, SavingsOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SavingsOption left, SavingsOption right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SavingsOption(string value) => new SavingsOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SavingsOption other && Equals(other); + /// + public bool Equals(SavingsOption 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.Serialization.cs new file mode 100644 index 000000000000..a55601128326 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class SavingsSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SavingsSettings)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(SavingsOptions)) + { + writer.WritePropertyName("savingsOptions"u8); + writer.WriteStringValue(SavingsOptions.Value.ToString()); + } + if (Optional.IsDefined(AzureOfferCode)) + { + writer.WritePropertyName("azureOfferCode"u8); + writer.WriteStringValue(AzureOfferCode.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SavingsSettings 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(SavingsSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSavingsSettings(document.RootElement, options); + } + + internal static SavingsSettings DeserializeSavingsSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SavingsOption? savingsOptions = default; + AzureOffer? azureOfferCode = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("savingsOptions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + savingsOptions = new SavingsOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("azureOfferCode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + azureOfferCode = new AzureOffer(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SavingsSettings(savingsOptions, azureOfferCode, 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(SavingsSettings)} does not support writing '{options.Format}' format."); + } + } + + SavingsSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSavingsSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SavingsSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.cs new file mode 100644 index 000000000000..00f773ed7630 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsSettings.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.Migrate.Models +{ + /// Savings settings class. + public partial class SavingsSettings + { + /// + /// 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 SavingsSettings() + { + } + + /// Initializes a new instance of . + /// Gets or sets the savings options. + /// Gets or sets the Azure offer code. + /// Keeps track of any properties unknown to the library. + internal SavingsSettings(SavingsOption? savingsOptions, AzureOffer? azureOfferCode, IDictionary serializedAdditionalRawData) + { + SavingsOptions = savingsOptions; + AzureOfferCode = azureOfferCode; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Gets or sets the savings options. + public SavingsOption? SavingsOptions { get; set; } + /// Gets or sets the Azure offer code. + public AzureOffer? AzureOfferCode { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsType.cs new file mode 100644 index 000000000000..87aa1949e515 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SavingsType.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.Migrate.Models +{ + /// Savings type. + public readonly partial struct SavingsType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SavingsType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MonthlyAzureHybridCostSavingsValue = "MonthlyAzureHybridCostSavings"; + private const string MonthlyLinuxAzureHybridCostSavingsValue = "MonthlyLinuxAzureHybridCostSavings"; + private const string MonthlyAhubSqlCostSavingsValue = "MonthlyAhubSqlCostSavings"; + private const string MonthlyVcfByolCostDifferenceValue = "MonthlyVcfByolCostDifference"; + + /// MonthlyAzureHybridCostSavings - Savings type. + public static SavingsType MonthlyAzureHybridCostSavings { get; } = new SavingsType(MonthlyAzureHybridCostSavingsValue); + /// MonthlyLinuxAzureHybridCostSavings - Savings type. + public static SavingsType MonthlyLinuxAzureHybridCostSavings { get; } = new SavingsType(MonthlyLinuxAzureHybridCostSavingsValue); + /// MonthlyAhubSqlCostSavings - Savings type. + public static SavingsType MonthlyAhubSqlCostSavings { get; } = new SavingsType(MonthlyAhubSqlCostSavingsValue); + /// MonthlyVcfByolCostDifference - Savings type. + public static SavingsType MonthlyVcfByolCostDifference { get; } = new SavingsType(MonthlyVcfByolCostDifferenceValue); + /// Determines if two values are the same. + public static bool operator ==(SavingsType left, SavingsType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SavingsType left, SavingsType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SavingsType(string value) => new SavingsType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SavingsType other && Equals(other); + /// + public bool Equals(SavingsType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.Serialization.cs new file mode 100644 index 000000000000..7a2236830aa9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.Serialization.cs @@ -0,0 +1,155 @@ +// 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.Migrate.Models +{ + public partial class Scope : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Scope)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(ScopeType)) + { + writer.WritePropertyName("scopeType"u8); + writer.WriteStringValue(ScopeType.Value.ToString()); + } + if (Optional.IsDefined(ServerGroupId)) + { + writer.WritePropertyName("serverGroupId"u8); + writer.WriteStringValue(ServerGroupId); + } + if (Optional.IsDefined(AzureResourceGraphQuery)) + { + writer.WritePropertyName("azureResourceGraphQuery"u8); + writer.WriteStringValue(AzureResourceGraphQuery); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Scope 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(Scope)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScope(document.RootElement, options); + } + + internal static Scope DeserializeScope(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ScopeType? scopeType = default; + string serverGroupId = default; + string azureResourceGraphQuery = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("scopeType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scopeType = new ScopeType(property.Value.GetString()); + continue; + } + if (property.NameEquals("serverGroupId"u8)) + { + serverGroupId = property.Value.GetString(); + continue; + } + if (property.NameEquals("azureResourceGraphQuery"u8)) + { + azureResourceGraphQuery = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Scope(scopeType, serverGroupId, azureResourceGraphQuery, 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(Scope)} does not support writing '{options.Format}' format."); + } + } + + Scope IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeScope(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Scope)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.cs new file mode 100644 index 000000000000..ac23effc2e03 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/Scope.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Scope of the assessment. + public partial class Scope + { + /// + /// 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 Scope() + { + } + + /// Initializes a new instance of . + /// The scope type. + /// The server group arm id. + /// The ARG query. + /// Keeps track of any properties unknown to the library. + internal Scope(ScopeType? scopeType, string serverGroupId, string azureResourceGraphQuery, IDictionary serializedAdditionalRawData) + { + ScopeType = scopeType; + ServerGroupId = serverGroupId; + AzureResourceGraphQuery = azureResourceGraphQuery; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The scope type. + public ScopeType? ScopeType { get; set; } + /// The server group arm id. + public string ServerGroupId { get; set; } + /// The ARG query. + public string AzureResourceGraphQuery { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ScopeType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ScopeType.cs new file mode 100644 index 000000000000..0cf30939619e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/ScopeType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Scope type. + public readonly partial struct ScopeType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ScopeType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ServerGroupIdValue = "ServerGroupId"; + private const string AzureResourceGraphQueryValue = "AzureResourceGraphQuery"; + + /// ServerGroupId - Scope type. + public static ScopeType ServerGroupId { get; } = new ScopeType(ServerGroupIdValue); + /// AzureResourceGraphQuery - Scope type. + public static ScopeType AzureResourceGraphQuery { get; } = new ScopeType(AzureResourceGraphQueryValue); + /// Determines if two values are the same. + public static bool operator ==(ScopeType left, ScopeType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ScopeType left, ScopeType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ScopeType(string value) => new ScopeType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ScopeType other && Equals(other); + /// + public bool Equals(ScopeType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.Serialization.cs new file mode 100644 index 000000000000..7f6c447ad980 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.Serialization.cs @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + internal partial class SecuritySuitability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SecuritySuitability)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Readiness)) + { + writer.WritePropertyName("readiness"u8); + writer.WriteStringValue(Readiness.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SecuritySuitability 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(SecuritySuitability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSecuritySuitability(document.RootElement, options); + } + + internal static SecuritySuitability DeserializeSecuritySuitability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CloudSuitabilityCommon? readiness = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("readiness"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + readiness = new CloudSuitabilityCommon(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SecuritySuitability(readiness, 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(SecuritySuitability)} does not support writing '{options.Format}' format."); + } + } + + SecuritySuitability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSecuritySuitability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SecuritySuitability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.cs new file mode 100644 index 000000000000..6f8b0bb3f1e5 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SecuritySuitability.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// The security suitability. + internal partial class SecuritySuitability + { + /// + /// 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 SecuritySuitability() + { + } + + /// Initializes a new instance of . + /// The security suitability. + /// Keeps track of any properties unknown to the library. + internal SecuritySuitability(CloudSuitabilityCommon? readiness, IDictionary serializedAdditionalRawData) + { + Readiness = readiness; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The security suitability. + public CloudSuitabilityCommon? Readiness { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.Serialization.cs new file mode 100644 index 000000000000..1c41af55a250 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.Serialization.cs @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Migrate.Models +{ + public partial class SkuDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SkuDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SkuType)) + { + writer.WritePropertyName("skuType"u8); + writer.WriteStringValue(SkuType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SkuName)) + { + writer.WritePropertyName("skuName"u8); + writer.WriteStringValue(SkuName); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Capabilities)) + { + writer.WritePropertyName("capabilities"u8); + writer.WriteStartArray(); + foreach (var item in Capabilities) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TotalCost)) + { + writer.WritePropertyName("totalCost"u8); + writer.WriteStartArray(); + foreach (var item in TotalCost) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TotalSavings)) + { + writer.WritePropertyName("totalSavings"u8); + writer.WriteStartArray(); + foreach (var item in TotalSavings) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SkuDetails 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(SkuDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSkuDetails(document.RootElement, options); + } + + internal static SkuDetails DeserializeSkuDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SkuType? skuType = default; + string skuName = default; + IReadOnlyList capabilities = default; + IReadOnlyList totalCost = default; + IReadOnlyList totalSavings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("skuType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + skuType = new SkuType(property.Value.GetString()); + continue; + } + if (property.NameEquals("skuName"u8)) + { + skuName = property.Value.GetString(); + continue; + } + if (property.NameEquals("capabilities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(NameValuePair.DeserializeNameValuePair(item, options)); + } + capabilities = array; + continue; + } + if (property.NameEquals("totalCost"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CostDetailsCommon.DeserializeCostDetailsCommon(item, options)); + } + totalCost = array; + continue; + } + if (property.NameEquals("totalSavings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SavingsDetailsCommon.DeserializeSavingsDetailsCommon(item, options)); + } + totalSavings = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SkuDetails( + skuType, + skuName, + capabilities ?? new ChangeTrackingList(), + totalCost ?? new ChangeTrackingList(), + totalSavings ?? 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(SkuDetails)} does not support writing '{options.Format}' format."); + } + } + + SkuDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSkuDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SkuDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.cs new file mode 100644 index 000000000000..5901ec8389f9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuDetails.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Sku details. + public partial class SkuDetails + { + /// + /// 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 SkuDetails() + { + Capabilities = new ChangeTrackingList(); + TotalCost = new ChangeTrackingList(); + TotalSavings = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The sku type. + /// The sku name. + /// The capabilities. + /// The sku cost details. + /// The sku savings details. + /// Keeps track of any properties unknown to the library. + internal SkuDetails(SkuType? skuType, string skuName, IReadOnlyList capabilities, IReadOnlyList totalCost, IReadOnlyList totalSavings, IDictionary serializedAdditionalRawData) + { + SkuType = skuType; + SkuName = skuName; + Capabilities = capabilities; + TotalCost = totalCost; + TotalSavings = totalSavings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The sku type. + public SkuType? SkuType { get; } + /// The sku name. + public string SkuName { get; } + /// The capabilities. + public IReadOnlyList Capabilities { get; } + /// The sku cost details. + public IReadOnlyList TotalCost { get; } + /// The sku savings details. + public IReadOnlyList TotalSavings { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuKind.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuKind.cs new file mode 100644 index 000000000000..f416fa3ab707 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuKind.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Sku Kind. + public readonly partial struct SkuKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SkuKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EndpointValue = "Endpoint"; + private const string DetailsValue = "Details"; + + /// Endpoint - Sku Kind. + public static SkuKind Endpoint { get; } = new SkuKind(EndpointValue); + /// Details - Sku Kind. + public static SkuKind Details { get; } = new SkuKind(DetailsValue); + /// Determines if two values are the same. + public static bool operator ==(SkuKind left, SkuKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SkuKind left, SkuKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SkuKind(string value) => new SkuKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SkuKind other && Equals(other); + /// + public bool Equals(SkuKind 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuType.cs new file mode 100644 index 000000000000..9145d6b04a6e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkuType.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Sku type. + public readonly partial struct SkuType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SkuType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string ComputeValue = "Compute"; + private const string StorageValue = "Storage"; + private const string NetworkValue = "Network"; + private const string AppServicePlanValue = "AppServicePlan"; + private const string AzureSpringAppsValue = "AzureSpringApps"; + + /// Unknown - Sku type. + public static SkuType Unknown { get; } = new SkuType(UnknownValue); + /// Compute - Sku type. + public static SkuType Compute { get; } = new SkuType(ComputeValue); + /// Storage - Sku type. + public static SkuType Storage { get; } = new SkuType(StorageValue); + /// Network - Sku type. + public static SkuType Network { get; } = new SkuType(NetworkValue); + /// AppServicePlan - Sku type. + public static SkuType AppServicePlan { get; } = new SkuType(AppServicePlanValue); + /// AzureSpringApps - Sku type. + public static SkuType AzureSpringApps { get; } = new SkuType(AzureSpringAppsValue); + /// Determines if two values are the same. + public static bool operator ==(SkuType left, SkuType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SkuType left, SkuType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SkuType(string value) => new SkuType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SkuType other && Equals(other); + /// + public bool Equals(SkuType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.Serialization.cs new file mode 100644 index 000000000000..169c09e0a30e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.Serialization.cs @@ -0,0 +1,229 @@ +// 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.Migrate.Models +{ + public partial class SkusMigrationSuitability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SkusMigrationSuitability)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Kind)) + { + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(ResourceUri)) + { + writer.WritePropertyName("resourceUri"u8); + writer.WriteStringValue(ResourceUri); + } + if (options.Format != "W" && Optional.IsDefined(DisplayName)) + { + writer.WritePropertyName("displayName"u8); + writer.WriteStringValue(DisplayName); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Sources)) + { + writer.WritePropertyName("sources"u8); + writer.WriteStartArray(); + foreach (var item in Sources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteObjectValue(Details, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SkusMigrationSuitability 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(SkusMigrationSuitability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSkusMigrationSuitability(document.RootElement, options); + } + + internal static SkusMigrationSuitability DeserializeSkusMigrationSuitability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SkuKind? kind = default; + string resourceUri = default; + string displayName = default; + string id = default; + SkuType? type = default; + IReadOnlyList sources = default; + SkuDetails details = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + kind = new SkuKind(property.Value.GetString()); + continue; + } + if (property.NameEquals("resourceUri"u8)) + { + resourceUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("displayName"u8)) + { + displayName = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new SkuType(property.Value.GetString()); + continue; + } + if (property.NameEquals("sources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SourceRecommendationMigrationSuitability.DeserializeSourceRecommendationMigrationSuitability(item, options)); + } + sources = array; + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + details = SkuDetails.DeserializeSkuDetails(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SkusMigrationSuitability( + kind, + resourceUri, + displayName, + id, + type, + sources ?? new ChangeTrackingList(), + details, + 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(SkusMigrationSuitability)} does not support writing '{options.Format}' format."); + } + } + + SkusMigrationSuitability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSkusMigrationSuitability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SkusMigrationSuitability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.cs new file mode 100644 index 000000000000..afb1244f824b --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SkusMigrationSuitability.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.Migrate.Models +{ + /// Skus details. + public partial class SkusMigrationSuitability + { + /// + /// 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 SkusMigrationSuitability() + { + Sources = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The Sku kind. + /// The resource uri. + /// The sku name. + /// The sku id. + /// The sku type. + /// The source name. + /// The sku details. + /// Keeps track of any properties unknown to the library. + internal SkusMigrationSuitability(SkuKind? kind, string resourceUri, string displayName, string id, SkuType? type, IReadOnlyList sources, SkuDetails details, IDictionary serializedAdditionalRawData) + { + Kind = kind; + ResourceUri = resourceUri; + DisplayName = displayName; + Id = id; + Type = type; + Sources = sources; + Details = details; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The Sku kind. + public SkuKind? Kind { get; } + /// The resource uri. + public string ResourceUri { get; } + /// The sku name. + public string DisplayName { get; } + /// The sku id. + public string Id { get; } + /// The sku type. + public SkuType? Type { get; } + /// The source name. + public IReadOnlyList Sources { get; } + /// The sku details. + public SkuDetails Details { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.Serialization.cs new file mode 100644 index 000000000000..a7825e38c300 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.Serialization.cs @@ -0,0 +1,178 @@ +// 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.Migrate.Models +{ + public partial class SourceDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SourceName)) + { + writer.WritePropertyName("sourceName"u8); + writer.WriteStringValue(SourceName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SourceType)) + { + writer.WritePropertyName("sourceType"u8); + writer.WriteStringValue(SourceType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Platform)) + { + writer.WritePropertyName("platform"u8); + writer.WriteStringValue(Platform.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SourceDetails 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(SourceDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceDetails(document.RootElement, options); + } + + internal static SourceDetails DeserializeSourceDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AssessmentSource? sourceName = default; + MigrateWorkloadType? sourceType = default; + MigrationPlatform? platform = default; + int? count = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sourceName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceName = new AssessmentSource(property.Value.GetString()); + continue; + } + if (property.NameEquals("sourceType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceType = new MigrateWorkloadType(property.Value.GetString()); + continue; + } + if (property.NameEquals("platform"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platform = new MigrationPlatform(property.Value.GetString()); + continue; + } + if (property.NameEquals("count"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SourceDetails(sourceName, sourceType, platform, count, 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(SourceDetails)} does not support writing '{options.Format}' format."); + } + } + + SourceDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSourceDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.cs new file mode 100644 index 000000000000..26f61c43f6e9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceDetails.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Source details. + public partial class SourceDetails + { + /// + /// 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 SourceDetails() + { + } + + /// Initializes a new instance of . + /// The source name. + /// The source type. + /// The migration platform. + /// The count of a type of source. + /// Keeps track of any properties unknown to the library. + internal SourceDetails(AssessmentSource? sourceName, MigrateWorkloadType? sourceType, MigrationPlatform? platform, int? count, IDictionary serializedAdditionalRawData) + { + SourceName = sourceName; + SourceType = sourceType; + Platform = platform; + Count = count; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The source name. + public AssessmentSource? SourceName { get; } + /// The source type. + public MigrateWorkloadType? SourceType { get; } + /// The migration platform. + public MigrationPlatform? Platform { get; } + /// The count of a type of source. + public int? Count { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.Serialization.cs new file mode 100644 index 000000000000..f0017c5ee537 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.Serialization.cs @@ -0,0 +1,144 @@ +// 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.Migrate.Models +{ + public partial class SourceRecommendationMigrationSuitability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SourceRecommendationMigrationSuitability)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(MigrationSuitability)) + { + writer.WritePropertyName("migrationSuitability"u8); + writer.WriteObjectValue(MigrationSuitability, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SourceRecommendationMigrationSuitability 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(SourceRecommendationMigrationSuitability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSourceRecommendationMigrationSuitability(document.RootElement, options); + } + + internal static SourceRecommendationMigrationSuitability DeserializeSourceRecommendationMigrationSuitability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + MigrationSuitability migrationSuitability = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("migrationSuitability"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + migrationSuitability = MigrationSuitability.DeserializeMigrationSuitability(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SourceRecommendationMigrationSuitability(name, migrationSuitability, 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(SourceRecommendationMigrationSuitability)} does not support writing '{options.Format}' format."); + } + } + + SourceRecommendationMigrationSuitability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSourceRecommendationMigrationSuitability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SourceRecommendationMigrationSuitability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.cs new file mode 100644 index 000000000000..b13a4f1a5f81 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SourceRecommendationMigrationSuitability.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Source recommendation details. + public partial class SourceRecommendationMigrationSuitability + { + /// + /// 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 SourceRecommendationMigrationSuitability() + { + } + + /// Initializes a new instance of . + /// The sku name. + /// The sku type. + /// Keeps track of any properties unknown to the library. + internal SourceRecommendationMigrationSuitability(string name, MigrationSuitability migrationSuitability, IDictionary serializedAdditionalRawData) + { + Name = name; + MigrationSuitability = migrationSuitability; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The sku name. + public string Name { get; } + /// The sku type. + internal MigrationSuitability MigrationSuitability { get; } + /// The migration suitability. + public CloudSuitabilityCommon? MigrationSuitabilityReadiness + { + get => MigrationSuitability?.Readiness; + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/StrategyType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/StrategyType.cs new file mode 100644 index 000000000000..aa4bbb809e99 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/StrategyType.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.Migrate.Models +{ + /// Strategy type. + public readonly partial struct StrategyType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StrategyType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PaaSPreferredValue = "PaaSPreferred"; + private const string CostOptimizedValue = "CostOptimized"; + private const string EffortOptimizedValue = "EffortOptimized"; + + /// PaaSPreferred - Strategy type. + public static StrategyType PaaSPreferred { get; } = new StrategyType(PaaSPreferredValue); + /// CostOptimized - Strategy type. + public static StrategyType CostOptimized { get; } = new StrategyType(CostOptimizedValue); + /// EffortOptimized - Strategy type. + public static StrategyType EffortOptimized { get; } = new StrategyType(EffortOptimizedValue); + /// Determines if two values are the same. + public static bool operator ==(StrategyType left, StrategyType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StrategyType left, StrategyType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator StrategyType(string value) => new StrategyType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StrategyType other && Equals(other); + /// + public bool Equals(StrategyType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.Serialization.cs new file mode 100644 index 000000000000..38ac8079e2ce --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.Serialization.cs @@ -0,0 +1,277 @@ +// 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.Migrate.Models +{ + public partial class SummaryProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SummaryProperties)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SummaryType)) + { + writer.WritePropertyName("summaryType"u8); + writer.WriteStringValue(SummaryType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SummaryName)) + { + writer.WritePropertyName("summaryName"u8); + writer.WriteStringValue(SummaryName); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Sources)) + { + writer.WritePropertyName("sources"u8); + writer.WriteStartArray(); + foreach (var item in Sources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(Targets)) + { + writer.WritePropertyName("targets"u8); + writer.WriteStartArray(); + foreach (var item in Targets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(TargetSourceMapping)) + { + writer.WritePropertyName("targetSourceMapping"u8); + writer.WriteStartArray(); + foreach (var item in TargetSourceMapping) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(CostComponents)) + { + writer.WritePropertyName("costComponents"u8); + writer.WriteStartArray(); + foreach (var item in CostComponents) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(SavingsComponents)) + { + writer.WritePropertyName("savingsComponents"u8); + writer.WriteStartArray(); + foreach (var item in SavingsComponents) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SummaryProperties 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(SummaryProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSummaryProperties(document.RootElement, options); + } + + internal static SummaryProperties DeserializeSummaryProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SummaryType? summaryType = default; + string summaryName = default; + IReadOnlyList sources = default; + IReadOnlyList targets = default; + IReadOnlyList targetSourceMapping = default; + IReadOnlyList costComponents = default; + IReadOnlyList savingsComponents = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("summaryType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + summaryType = new SummaryType(property.Value.GetString()); + continue; + } + if (property.NameEquals("summaryName"u8)) + { + summaryName = property.Value.GetString(); + continue; + } + if (property.NameEquals("sources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SourceDetails.DeserializeSourceDetails(item, options)); + } + sources = array; + continue; + } + if (property.NameEquals("targets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TargetDetails.DeserializeTargetDetails(item, options)); + } + targets = array; + continue; + } + if (property.NameEquals("targetSourceMapping"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(TargetSourcePair.DeserializeTargetSourcePair(item, options)); + } + targetSourceMapping = array; + continue; + } + if (property.NameEquals("costComponents"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CostDetailsCommon.DeserializeCostDetailsCommon(item, options)); + } + costComponents = array; + continue; + } + if (property.NameEquals("savingsComponents"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SavingsDetailsCommon.DeserializeSavingsDetailsCommon(item, options)); + } + savingsComponents = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SummaryProperties( + summaryType, + summaryName, + sources ?? new ChangeTrackingList(), + targets ?? new ChangeTrackingList(), + targetSourceMapping ?? new ChangeTrackingList(), + costComponents ?? new ChangeTrackingList(), + savingsComponents ?? 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(SummaryProperties)} does not support writing '{options.Format}' format."); + } + } + + SummaryProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSummaryProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SummaryProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.cs new file mode 100644 index 000000000000..8dedba7efe9e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryProperties.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.Migrate.Models +{ + /// Summary properties class. + public partial class SummaryProperties + { + /// + /// 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 SummaryProperties() + { + Sources = new ChangeTrackingList(); + Targets = new ChangeTrackingList(); + TargetSourceMapping = new ChangeTrackingList(); + CostComponents = new ChangeTrackingList(); + SavingsComponents = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The summary type. + /// The summary name. + /// The source details list. + /// The target details list. + /// The target source mapping. + /// The cost components. + /// The cost components. + /// Keeps track of any properties unknown to the library. + internal SummaryProperties(SummaryType? summaryType, string summaryName, IReadOnlyList sources, IReadOnlyList targets, IReadOnlyList targetSourceMapping, IReadOnlyList costComponents, IReadOnlyList savingsComponents, IDictionary serializedAdditionalRawData) + { + SummaryType = summaryType; + SummaryName = summaryName; + Sources = sources; + Targets = targets; + TargetSourceMapping = targetSourceMapping; + CostComponents = costComponents; + SavingsComponents = savingsComponents; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The summary type. + public SummaryType? SummaryType { get; } + /// The summary name. + public string SummaryName { get; } + /// The source details list. + public IReadOnlyList Sources { get; } + /// The target details list. + public IReadOnlyList Targets { get; } + /// The target source mapping. + public IReadOnlyList TargetSourceMapping { get; } + /// The cost components. + public IReadOnlyList CostComponents { get; } + /// The cost components. + public IReadOnlyList SavingsComponents { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryType.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryType.cs new file mode 100644 index 000000000000..e166c682086e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/SummaryType.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.Migrate.Models +{ + /// Summary Type. + public readonly partial struct SummaryType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SummaryType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string StrategyValue = "Strategy"; + private const string TargetValue = "Target"; + + /// Unknown - Summary Type. + public static SummaryType Unknown { get; } = new SummaryType(UnknownValue); + /// Strategy - Summary Type. + public static SummaryType Strategy { get; } = new SummaryType(StrategyValue); + /// Target - Summary Type. + public static SummaryType Target { get; } = new SummaryType(TargetValue); + /// Determines if two values are the same. + public static bool operator ==(SummaryType left, SummaryType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SummaryType left, SummaryType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator SummaryType(string value) => new SummaryType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SummaryType other && Equals(other); + /// + public bool Equals(SummaryType 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.Serialization.cs new file mode 100644 index 000000000000..3bf097404317 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.Serialization.cs @@ -0,0 +1,178 @@ +// 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.Migrate.Models +{ + public partial class TargetDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetDetails)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(TargetName)) + { + writer.WritePropertyName("targetName"u8); + writer.WriteStringValue(TargetName.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(TargetType)) + { + writer.WritePropertyName("targetType"u8); + writer.WriteStringValue(TargetType.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Platform)) + { + writer.WritePropertyName("platform"u8); + writer.WriteStringValue(Platform.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Count)) + { + writer.WritePropertyName("count"u8); + writer.WriteNumberValue(Count.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TargetDetails 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(TargetDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetDetails(document.RootElement, options); + } + + internal static TargetDetails DeserializeTargetDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureTarget? targetName = default; + MigrateWorkloadType? targetType = default; + MigrationPlatform? platform = default; + int? count = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("targetName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetName = new AzureTarget(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetType = new MigrateWorkloadType(property.Value.GetString()); + continue; + } + if (property.NameEquals("platform"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platform = new MigrationPlatform(property.Value.GetString()); + continue; + } + if (property.NameEquals("count"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TargetDetails(targetName, targetType, platform, count, 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(TargetDetails)} does not support writing '{options.Format}' format."); + } + } + + TargetDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTargetDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.cs new file mode 100644 index 000000000000..5d18623d77c5 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetDetails.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Target details. + public partial class TargetDetails + { + /// + /// 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 TargetDetails() + { + } + + /// Initializes a new instance of . + /// The target name. + /// The target type. + /// The migration platform. + /// The count of a type of source. + /// Keeps track of any properties unknown to the library. + internal TargetDetails(AzureTarget? targetName, MigrateWorkloadType? targetType, MigrationPlatform? platform, int? count, IDictionary serializedAdditionalRawData) + { + TargetName = targetName; + TargetType = targetType; + Platform = platform; + Count = count; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The target name. + public AzureTarget? TargetName { get; } + /// The target type. + public MigrateWorkloadType? TargetType { get; } + /// The migration platform. + public MigrationPlatform? Platform { get; } + /// The count of a type of source. + public int? Count { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.Serialization.cs new file mode 100644 index 000000000000..a7ee215dc5cb --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.Serialization.cs @@ -0,0 +1,293 @@ +// 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.Migrate.Models +{ + public partial class TargetSourcePair : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TargetSourcePair)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(SourceRef)) + { + writer.WritePropertyName("sourceRef"u8); + writer.WriteStringValue(SourceRef.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(TargetRef)) + { + writer.WritePropertyName("targetRef"u8); + writer.WriteStringValue(TargetRef.Value.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(SourceCount)) + { + writer.WritePropertyName("sourceCount"u8); + writer.WriteNumberValue(SourceCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(TargetCount)) + { + writer.WritePropertyName("targetCount"u8); + writer.WriteNumberValue(TargetCount.Value); + } + if (options.Format != "W" && Optional.IsDefined(MigrationDetails)) + { + writer.WritePropertyName("migrationDetails"u8); + writer.WriteObjectValue(MigrationDetails, options); + } + if (options.Format != "W" && Optional.IsCollectionDefined(ManagementDetails)) + { + writer.WritePropertyName("managementDetails"u8); + writer.WriteStartArray(); + foreach (var item in ManagementDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(CostDetails)) + { + writer.WritePropertyName("costDetails"u8); + writer.WriteStartArray(); + foreach (var item in CostDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(SavingsDetails)) + { + writer.WritePropertyName("savingsDetails"u8); + writer.WriteStartArray(); + foreach (var item in SavingsDetails) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ConfidenceScore)) + { + writer.WritePropertyName("confidenceScore"u8); + writer.WriteNumberValue(ConfidenceScore.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + TargetSourcePair 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(TargetSourcePair)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTargetSourcePair(document.RootElement, options); + } + + internal static TargetSourcePair DeserializeTargetSourcePair(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AssessmentSource? sourceRef = default; + AzureTarget? targetRef = default; + int? sourceCount = default; + int? targetCount = default; + MigrationDetails migrationDetails = default; + IReadOnlyList managementDetails = default; + IReadOnlyList costDetails = default; + IReadOnlyList savingsDetails = default; + double? confidenceScore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sourceRef"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceRef = new AssessmentSource(property.Value.GetString()); + continue; + } + if (property.NameEquals("targetRef"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetRef = new AzureTarget(property.Value.GetString()); + continue; + } + if (property.NameEquals("sourceCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("targetCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + targetCount = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("migrationDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + migrationDetails = MigrationDetails.DeserializeMigrationDetails(property.Value, options); + continue; + } + if (property.NameEquals("managementDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.ManagementDetails.DeserializeManagementDetails(item, options)); + } + managementDetails = array; + continue; + } + if (property.NameEquals("costDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CostDetailsCommon.DeserializeCostDetailsCommon(item, options)); + } + costDetails = array; + continue; + } + if (property.NameEquals("savingsDetails"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SavingsDetailsCommon.DeserializeSavingsDetailsCommon(item, options)); + } + savingsDetails = array; + continue; + } + if (property.NameEquals("confidenceScore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + confidenceScore = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TargetSourcePair( + sourceRef, + targetRef, + sourceCount, + targetCount, + migrationDetails, + managementDetails ?? new ChangeTrackingList(), + costDetails ?? new ChangeTrackingList(), + savingsDetails ?? new ChangeTrackingList(), + confidenceScore, + 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(TargetSourcePair)} does not support writing '{options.Format}' format."); + } + } + + TargetSourcePair IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeTargetSourcePair(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TargetSourcePair)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.cs new file mode 100644 index 000000000000..55fd8e305a01 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TargetSourcePair.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Target source pair. + public partial class TargetSourcePair + { + /// + /// 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 TargetSourcePair() + { + ManagementDetails = new ChangeTrackingList(); + CostDetails = new ChangeTrackingList(); + SavingsDetails = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The source name. + /// The target name. + /// The count of a type of source. + /// The count of a type of target. + /// The migration details. + /// The management details. + /// The cost details. + /// The savings details. + /// The confidence score. + /// Keeps track of any properties unknown to the library. + internal TargetSourcePair(AssessmentSource? sourceRef, AzureTarget? targetRef, int? sourceCount, int? targetCount, MigrationDetails migrationDetails, IReadOnlyList managementDetails, IReadOnlyList costDetails, IReadOnlyList savingsDetails, double? confidenceScore, IDictionary serializedAdditionalRawData) + { + SourceRef = sourceRef; + TargetRef = targetRef; + SourceCount = sourceCount; + TargetCount = targetCount; + MigrationDetails = migrationDetails; + ManagementDetails = managementDetails; + CostDetails = costDetails; + SavingsDetails = savingsDetails; + ConfidenceScore = confidenceScore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The source name. + public AssessmentSource? SourceRef { get; } + /// The target name. + public AzureTarget? TargetRef { get; } + /// The count of a type of source. + public int? SourceCount { get; } + /// The count of a type of target. + public int? TargetCount { get; } + /// The migration details. + public MigrationDetails MigrationDetails { get; } + /// The management details. + public IReadOnlyList ManagementDetails { get; } + /// The cost details. + public IReadOnlyList CostDetails { get; } + /// The savings details. + public IReadOnlyList SavingsDetails { get; } + /// The confidence score. + public double? ConfidenceScore { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TimeRange.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TimeRange.cs new file mode 100644 index 000000000000..6e2d9b762da1 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/TimeRange.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.Migrate.Models +{ + /// Time Range for Performance Data. + public readonly partial struct TimeRange : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TimeRange(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DayValue = "Day"; + private const string WeekValue = "Week"; + private const string MonthValue = "Month"; + private const string CustomValue = "Custom"; + + /// Daily. + public static TimeRange Day { get; } = new TimeRange(DayValue); + /// Weekly. + public static TimeRange Week { get; } = new TimeRange(WeekValue); + /// Monthly. + public static TimeRange Month { get; } = new TimeRange(MonthValue); + /// Custom Time Range. + public static TimeRange Custom { get; } = new TimeRange(CustomValue); + /// Determines if two values are the same. + public static bool operator ==(TimeRange left, TimeRange right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TimeRange left, TimeRange right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator TimeRange(string value) => new TimeRange(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TimeRange other && Equals(other); + /// + public bool Equals(TimeRange 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/UltraDiskSupport.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/UltraDiskSupport.cs new file mode 100644 index 000000000000..d5bcd89685f9 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/UltraDiskSupport.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Ultra Disk Support. + public readonly partial struct UltraDiskSupport : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public UltraDiskSupport(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UltraDiskSupportedValue = "UltraDiskSupported"; + private const string UltraDiskNotSupportedValue = "UltraDiskNotSupported"; + + /// Ultra Disk Supported. + public static UltraDiskSupport UltraDiskSupported { get; } = new UltraDiskSupport(UltraDiskSupportedValue); + /// Ultra Disk Not Supported. + public static UltraDiskSupport UltraDiskNotSupported { get; } = new UltraDiskSupport(UltraDiskNotSupportedValue); + /// Determines if two values are the same. + public static bool operator ==(UltraDiskSupport left, UltraDiskSupport right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(UltraDiskSupport left, UltraDiskSupport right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator UltraDiskSupport(string value) => new UltraDiskSupport(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is UltraDiskSupport other && Equals(other); + /// + public bool Equals(UltraDiskSupport 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmFamilyCategoryItem.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmFamilyCategoryItem.cs new file mode 100644 index 000000000000..28d079954e01 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmFamilyCategoryItem.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// Vm Family Category Item. + public readonly partial struct VmFamilyCategoryItem : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VmFamilyCategoryItem(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string GeneralPurposeValue = "GeneralPurpose"; + private const string ComputeOptimizedValue = "ComputeOptimized"; + private const string MemoryOptimizedValue = "MemoryOptimized"; + private const string StorageOptimizedValue = "StorageOptimized"; + private const string GpuOptimizedValue = "GpuOptimized"; + private const string HighPerformanceComputeValue = "HighPerformanceCompute"; + private const string SupportsPremiumStorageValue = "SupportsPremiumStorage"; + private const string ConfidentialValue = "Confidential"; + private const string SupportsUltraDiskStorageValue = "SupportsUltraDiskStorage"; + + /// Unknown - Vm Family Category Item. + public static VmFamilyCategoryItem Unknown { get; } = new VmFamilyCategoryItem(UnknownValue); + /// GeneralPurpose Vm Family Category Item. + public static VmFamilyCategoryItem GeneralPurpose { get; } = new VmFamilyCategoryItem(GeneralPurposeValue); + /// ComputeOptimized Vm Family Category Item. + public static VmFamilyCategoryItem ComputeOptimized { get; } = new VmFamilyCategoryItem(ComputeOptimizedValue); + /// MemoryOptimized Vm Family Category Item. + public static VmFamilyCategoryItem MemoryOptimized { get; } = new VmFamilyCategoryItem(MemoryOptimizedValue); + /// StorageOptimized Vm Family Category Item. + public static VmFamilyCategoryItem StorageOptimized { get; } = new VmFamilyCategoryItem(StorageOptimizedValue); + /// GpuOptimized Vm Family Category Item. + public static VmFamilyCategoryItem GpuOptimized { get; } = new VmFamilyCategoryItem(GpuOptimizedValue); + /// HighPerformanceCompute Vm Family Category Item. + public static VmFamilyCategoryItem HighPerformanceCompute { get; } = new VmFamilyCategoryItem(HighPerformanceComputeValue); + /// SupportsPremiumStorage Vm Family Category Item. + public static VmFamilyCategoryItem SupportsPremiumStorage { get; } = new VmFamilyCategoryItem(SupportsPremiumStorageValue); + /// Confidential Vm Family Category Item. + public static VmFamilyCategoryItem Confidential { get; } = new VmFamilyCategoryItem(ConfidentialValue); + /// SupportsUltraDiskStorage Vm Family Category Item. + public static VmFamilyCategoryItem SupportsUltraDiskStorage { get; } = new VmFamilyCategoryItem(SupportsUltraDiskStorageValue); + /// Determines if two values are the same. + public static bool operator ==(VmFamilyCategoryItem left, VmFamilyCategoryItem right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VmFamilyCategoryItem left, VmFamilyCategoryItem right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VmFamilyCategoryItem(string value) => new VmFamilyCategoryItem(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VmFamilyCategoryItem other && Equals(other); + /// + public bool Equals(VmFamilyCategoryItem 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/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.Serialization.cs new file mode 100644 index 000000000000..480d64c6cf27 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.Serialization.cs @@ -0,0 +1,161 @@ +// 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.Migrate.Models +{ + public partial class VmSecuritySuitability : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmSecuritySuitability)} does not support writing '{format}' format."); + } + + if (options.Format != "W") + { + writer.WritePropertyName("vmSecurityType"u8); + writer.WriteStringValue(VmSecurityType.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("securitySuitability"u8); + writer.WriteStringValue(SecuritySuitability.ToString()); + } + if (options.Format != "W") + { + writer.WritePropertyName("securitySuitabilityDetails"u8); + writer.WriteStartArray(); + foreach (var item in SecuritySuitabilityDetails) + { + writer.WriteStringValue(item.ToString()); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VmSecuritySuitability 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(VmSecuritySuitability)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmSecuritySuitability(document.RootElement, options); + } + + internal static VmSecuritySuitability DeserializeVmSecuritySuitability(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AzureVmSecurityType vmSecurityType = default; + CloudSuitabilityCommon securitySuitability = default; + IReadOnlyList securitySuitabilityDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vmSecurityType"u8)) + { + vmSecurityType = new AzureVmSecurityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("securitySuitability"u8)) + { + securitySuitability = new CloudSuitabilityCommon(property.Value.GetString()); + continue; + } + if (property.NameEquals("securitySuitabilityDetails"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(new AzureVmSecuritySuitabilityDetail(item.GetString())); + } + securitySuitabilityDetails = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmSecuritySuitability(vmSecurityType, securitySuitability, securitySuitabilityDetails, 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(VmSecuritySuitability)} does not support writing '{options.Format}' format."); + } + } + + VmSecuritySuitability IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVmSecuritySuitability(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmSecuritySuitability)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.cs new file mode 100644 index 000000000000..fa166b27201e --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmSecuritySuitability.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Migrate.Models +{ + /// VM Security Suitability. + public partial class VmSecuritySuitability + { + /// + /// 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 . + /// Gets and sets the security type for this secure VM. + /// Gets the suitability for this secure VM. + /// Gets the security suitability details for this VM. + internal VmSecuritySuitability(AzureVmSecurityType vmSecurityType, CloudSuitabilityCommon securitySuitability, IEnumerable securitySuitabilityDetails) + { + VmSecurityType = vmSecurityType; + SecuritySuitability = securitySuitability; + SecuritySuitabilityDetails = securitySuitabilityDetails.ToList(); + } + + /// Initializes a new instance of . + /// Gets and sets the security type for this secure VM. + /// Gets the suitability for this secure VM. + /// Gets the security suitability details for this VM. + /// Keeps track of any properties unknown to the library. + internal VmSecuritySuitability(AzureVmSecurityType vmSecurityType, CloudSuitabilityCommon securitySuitability, IReadOnlyList securitySuitabilityDetails, IDictionary serializedAdditionalRawData) + { + VmSecurityType = vmSecurityType; + SecuritySuitability = securitySuitability; + SecuritySuitabilityDetails = securitySuitabilityDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VmSecuritySuitability() + { + } + + /// Gets and sets the security type for this secure VM. + public AzureVmSecurityType VmSecurityType { get; } + /// Gets the suitability for this secure VM. + public CloudSuitabilityCommon SecuritySuitability { get; } + /// Gets the security suitability details for this VM. + public IReadOnlyList SecuritySuitabilityDetails { get; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.Serialization.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.Serialization.cs new file mode 100644 index 000000000000..dd72b9893fbd --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.Serialization.cs @@ -0,0 +1,148 @@ +// 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.Migrate.Models +{ + public partial class VmUptime : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmUptime)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DaysPerMonth)) + { + writer.WritePropertyName("daysPerMonth"u8); + writer.WriteNumberValue(DaysPerMonth.Value); + } + if (Optional.IsDefined(HoursPerDay)) + { + writer.WritePropertyName("hoursPerDay"u8); + writer.WriteNumberValue(HoursPerDay.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VmUptime 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(VmUptime)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmUptime(document.RootElement, options); + } + + internal static VmUptime DeserializeVmUptime(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? daysPerMonth = default; + int? hoursPerDay = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("daysPerMonth"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + daysPerMonth = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("hoursPerDay"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hoursPerDay = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmUptime(daysPerMonth, hoursPerDay, 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(VmUptime)} does not support writing '{options.Format}' format."); + } + } + + VmUptime IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVmUptime(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmUptime)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.cs new file mode 100644 index 000000000000..e520b76de8d5 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/Models/VmUptime.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.Migrate.Models +{ + /// Details on the total up-time for the VM. + public partial class VmUptime + { + /// + /// 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 VmUptime() + { + } + + /// Initializes a new instance of . + /// Number of days in a month for VM uptime. + /// Number of hours per day for VM uptime. + /// Keeps track of any properties unknown to the library. + internal VmUptime(int? daysPerMonth, int? hoursPerDay, IDictionary serializedAdditionalRawData) + { + DaysPerMonth = daysPerMonth; + HoursPerDay = hoursPerDay; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Number of days in a month for VM uptime. + public int? DaysPerMonth { get; set; } + /// Number of hours per day for VM uptime. + public int? HoursPerDay { get; set; } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/ProviderConstants.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..276ea5df2712 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/AssessedMachinesV2RestOperations.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/AssessedMachinesV2RestOperations.cs new file mode 100644 index 000000000000..ae4207cc6945 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/AssessedMachinesV2RestOperations.cs @@ -0,0 +1,389 @@ +// 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.Migrate.Models; + +namespace Azure.ResourceManager.Migrate +{ + internal partial class AssessedMachinesV2RestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of AssessedMachinesV2RestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public AssessedMachinesV2RestOperations(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-03-03-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string assessedMachineName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/assessedMachines/", false); + uri.AppendPath(assessedMachineName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string assessedMachineName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/assessedMachines/", false); + uri.AppendPath(assessedMachineName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a AssessedMachineV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName, assessedMachineName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2Data value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = AssessedMachineV2Data.DeserializeAssessedMachineV2Data(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((AssessedMachineV2Data)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a AssessedMachineV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Machine assessment V2 Assessed Machine ARM name. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string assessedMachineName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNullOrEmpty(assessedMachineName, nameof(assessedMachineName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName, assessedMachineName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2Data value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = AssessedMachineV2Data.DeserializeAssessedMachineV2Data(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((AssessedMachineV2Data)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter, int? pageSize, string continuationToken, int? totalRecordCount) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/assessedMachines", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (pageSize != null) + { + uri.AppendQuery("pageSize", pageSize.Value, true); + } + if (continuationToken != null) + { + uri.AppendQuery("continuationToken", continuationToken, true); + } + if (totalRecordCount != null) + { + uri.AppendQuery("totalRecordCount", totalRecordCount.Value, true); + } + return uri; + } + + internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter, int? pageSize, string continuationToken, int? totalRecordCount) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/assessedMachines", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (filter != null) + { + uri.AppendQuery("$filter", filter, true); + } + if (pageSize != null) + { + uri.AppendQuery("pageSize", pageSize.Value, true); + } + if (continuationToken != null) + { + uri.AppendQuery("continuationToken", continuationToken, true); + } + if (totalRecordCount != null) + { + uri.AppendQuery("totalRecordCount", totalRecordCount.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List AssessedMachineV2 resources by MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName, assessmentName, filter, pageSize, continuationToken, totalRecordCount); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2ListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = AssessedMachineV2ListResult.DeserializeAssessedMachineV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List AssessedMachineV2 resources by MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByParent(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName, assessmentName, filter, pageSize, continuationToken, totalRecordCount); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2ListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = AssessedMachineV2ListResult.DeserializeAssessedMachineV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter, int? pageSize, string continuationToken, int? totalRecordCount) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter, int? pageSize, string continuationToken, int? totalRecordCount) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List AssessedMachineV2 resources by MachineAssessmentV2. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName, assessmentName, filter, pageSize, continuationToken, totalRecordCount); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2ListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = AssessedMachineV2ListResult.DeserializeAssessedMachineV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List AssessedMachineV2 resources by MachineAssessmentV2. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Filter query. + /// Optional parameter for page size. + /// Optional parameter for continuation token. + /// Total record count. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string filter = null, int? pageSize = null, string continuationToken = null, int? totalRecordCount = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName, assessmentName, filter, pageSize, continuationToken, totalRecordCount); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + AssessedMachineV2ListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = AssessedMachineV2ListResult.DeserializeAssessedMachineV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentV2SummaryRestOperations.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentV2SummaryRestOperations.cs new file mode 100644 index 000000000000..1cb073ff3337 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentV2SummaryRestOperations.cs @@ -0,0 +1,341 @@ +// 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.Migrate.Models; + +namespace Azure.ResourceManager.Migrate +{ + internal partial class MachineAssessmentV2SummaryRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of MachineAssessmentV2SummaryRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public MachineAssessmentV2SummaryRestOperations(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-03-03-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string summaryName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/summaries/", false); + uri.AppendPath(summaryName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string summaryName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/summaries/", false); + uri.AppendPath(summaryName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a MachineAssessmentV2Summary. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName, summaryName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2SummaryData.DeserializeMachineAssessmentV2SummaryData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineAssessmentV2SummaryData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a MachineAssessmentV2Summary. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Gets the Name of the Machine Summary. + /// The cancellation token to use. + /// , , , or is null. + /// , , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, string summaryName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNullOrEmpty(summaryName, nameof(summaryName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName, summaryName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2SummaryData.DeserializeMachineAssessmentV2SummaryData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineAssessmentV2SummaryData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/summaries", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/summaries", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2SummaryListResult.DeserializeMachineAssessmentV2SummaryListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByParent(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2SummaryListResult.DeserializeMachineAssessmentV2SummaryListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName, assessmentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2SummaryListResult.DeserializeMachineAssessmentV2SummaryListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineAssessmentV2Summary resources by MachineAssessmentV2. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName, assessmentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2SummaryListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2SummaryListResult.DeserializeMachineAssessmentV2SummaryListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentsV2RestOperations.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentsV2RestOperations.cs new file mode 100644 index 000000000000..38d9e971126d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineAssessmentsV2RestOperations.cs @@ -0,0 +1,615 @@ +// 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.Migrate.Models; + +namespace Azure.ResourceManager.Migrate +{ + internal partial class MachineAssessmentsV2RestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of MachineAssessmentsV2RestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public MachineAssessmentsV2RestOperations(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-03-03-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2Data value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2Data.DeserializeMachineAssessmentV2Data(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineAssessmentV2Data)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2Data value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2Data.DeserializeMachineAssessmentV2Data(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineAssessmentV2Data)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string projectName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string projectName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineAssessmentV2 resources by AssessmentProject. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2ListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2ListResult.DeserializeMachineAssessmentV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineAssessmentV2 resources by AssessmentProject. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByParent(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2ListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2ListResult.DeserializeMachineAssessmentV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, MachineAssessmentV2Data data) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, MachineAssessmentV2Data data) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Put; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Create a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task CreateAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, projectName, assessmentName, data); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Create a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// Resource create parameters. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Create(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, MachineAssessmentV2Data data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateRequest(subscriptionId, resourceGroupName, projectName, assessmentName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a MachineAssessmentV2. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The cancellation token to use. + /// , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response Delete(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, projectName, assessmentName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDownloadUrlRequestUri(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, DownloadUrlContent content) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/downloadUrl", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDownloadUrlRequest(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, DownloadUrlContent 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("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessments/", false); + uri.AppendPath(assessmentName, true); + uri.AppendPath("/downloadUrl", 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; + } + + /// Get the URL for downloading the assessment in a report format. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public async Task DownloadUrlAsync(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, DownloadUrlContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateDownloadUrlRequest(subscriptionId, resourceGroupName, projectName, assessmentName, content); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get the URL for downloading the assessment in a report format. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// Machine Assessment V2 ARM name. + /// The content of the action request. + /// The cancellation token to use. + /// , , , or is null. + /// , , or is an empty string, and was expected to be non-empty. + public Response DownloadUrl(string subscriptionId, string resourceGroupName, string projectName, string assessmentName, DownloadUrlContent content, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + Argument.AssertNotNullOrEmpty(assessmentName, nameof(assessmentName)); + Argument.AssertNotNull(content, nameof(content)); + + using var message = CreateDownloadUrlRequest(subscriptionId, resourceGroupName, projectName, assessmentName, content); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 200: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string projectName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string projectName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineAssessmentV2 resources by AssessmentProject. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2ListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineAssessmentV2ListResult.DeserializeMachineAssessmentV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineAssessmentV2 resources by AssessmentProject. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineAssessmentV2ListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineAssessmentV2ListResult.DeserializeMachineAssessmentV2ListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineGraphAssessmentOptionsRestOperations.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineGraphAssessmentOptionsRestOperations.cs new file mode 100644 index 000000000000..f4d2b4225e50 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/src/Generated/RestOperations/MachineGraphAssessmentOptionsRestOperations.cs @@ -0,0 +1,315 @@ +// 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.Migrate.Models; + +namespace Azure.ResourceManager.Migrate +{ + internal partial class MachineGraphAssessmentOptionsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of MachineGraphAssessmentOptionsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Service host. + /// The API version to use for this operation. + /// or is null. + public MachineGraphAssessmentOptionsRestOperations(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-03-03-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string projectName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessmentOptions/default", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string projectName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessmentOptions/default", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a MachineGraphAssessmentOptions. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> GetAsync(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineGraphAssessmentOptionData.DeserializeMachineGraphAssessmentOptionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineGraphAssessmentOptionData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a MachineGraphAssessmentOptions. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Get(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, projectName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineGraphAssessmentOptionData.DeserializeMachineGraphAssessmentOptionData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((MachineGraphAssessmentOptionData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentRequestUri(string subscriptionId, string resourceGroupName, string projectName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessmentOptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByParentRequest(string subscriptionId, string resourceGroupName, string projectName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/resourceGroups/", false); + uri.AppendPath(resourceGroupName, true); + uri.AppendPath("/providers/Microsoft.Migrate/assessmentProjects/", false); + uri.AppendPath(projectName, true); + uri.AppendPath("/assessmentOptions", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineGraphAssessmentOptions resources by AssessmentProject. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentAsync(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineGraphAssessmentOptionsListResult.DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineGraphAssessmentOptions resources by AssessmentProject. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByParent(string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentRequest(subscriptionId, resourceGroupName, projectName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineGraphAssessmentOptionsListResult.DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByParentNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string projectName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByParentNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string projectName) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List MachineGraphAssessmentOptions resources by AssessmentProject. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListByParentNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionsListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = MachineGraphAssessmentOptionsListResult.DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List MachineGraphAssessmentOptions resources by AssessmentProject. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// Assessment Project Name. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListByParentNextPage(string nextLink, string subscriptionId, string resourceGroupName, string projectName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(projectName, nameof(projectName)); + + using var message = CreateListByParentNextPageRequest(nextLink, subscriptionId, resourceGroupName, projectName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MachineGraphAssessmentOptionsListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = MachineGraphAssessmentOptionsListResult.DeserializeMachineGraphAssessmentOptionsListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/src/Properties/AssemblyInfo.cs b/sdk/migrate/Azure.ResourceManager.Migrate/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..8c9a14318269 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/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.Migrate.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("Migrate")] diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/tests/Azure.ResourceManager.Migrate.Tests.csproj b/sdk/migrate/Azure.ResourceManager.Migrate/tests/Azure.ResourceManager.Migrate.Tests.csproj new file mode 100644 index 000000000000..21d451125a20 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/tests/Azure.ResourceManager.Migrate.Tests.csproj @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestBase.cs b/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestBase.cs new file mode 100644 index 000000000000..e3e8cef00b7d --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestBase.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure; +using Azure.Core; +using Azure.Core.TestFramework; +using Azure.ResourceManager; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TestFramework; +using NUnit.Framework; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Migrate.Tests +{ + public class MigrateManagementTestBase : ManagementRecordedTestBase + { + protected ArmClient Client { get; private set; } + protected SubscriptionResource DefaultSubscription { get; private set; } + + protected MigrateManagementTestBase(bool isAsync, RecordedTestMode mode) + : base(isAsync, mode) + { + } + + protected MigrateManagementTestBase(bool isAsync) + : base(isAsync) + { + } + + [SetUp] + public async Task CreateCommonClient() + { + Client = GetArmClient(); + DefaultSubscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); + } + + protected async Task CreateResourceGroup(SubscriptionResource subscription, string rgNamePrefix, AzureLocation location) + { + string rgName = Recording.GenerateAssetName(rgNamePrefix); + ResourceGroupData input = new ResourceGroupData(location); + var lro = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, input); + return lro.Value; + } + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestEnvironment.cs b/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestEnvironment.cs new file mode 100644 index 000000000000..251feeecd081 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/tests/MigrateManagementTestEnvironment.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core.TestFramework; + +namespace Azure.ResourceManager.Migrate.Tests +{ + public class MigrateManagementTestEnvironment : TestEnvironment + { + } +} diff --git a/sdk/migrate/Azure.ResourceManager.Migrate/tsp-location.yaml b/sdk/migrate/Azure.ResourceManager.Migrate/tsp-location.yaml new file mode 100644 index 000000000000..a6cb9a218029 --- /dev/null +++ b/sdk/migrate/Azure.ResourceManager.Migrate/tsp-location.yaml @@ -0,0 +1,5 @@ +directory: specification/migrate/AssessmentProjects.Management/MachineAssessments.Management +commit: 09d9fd97a0477ab6301b1447dc2ae26b98f15414 +repo: Azure/azure-rest-api-specs +additionalDirectories: +- specification/migrate/AssessmentProjects.Management/Common diff --git a/sdk/migrate/ci.mgmt.yml b/sdk/migrate/ci.mgmt.yml new file mode 100644 index 000000000000..2984f984e1ac --- /dev/null +++ b/sdk/migrate/ci.mgmt.yml @@ -0,0 +1,26 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: none + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/migrate /ci.mgmt.yml + - sdk/migrate /Azure.ResourceManager.Migrate / + + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: migrate + ArtifactName: packages + LimitForPullRequest: true + Artifacts: + - name: Azure.ResourceManager.Migrate + safeName: AzureResourceManagerMigrate diff --git a/sdk/resourcemanager/ci.mgmt.yml b/sdk/resourcemanager/ci.mgmt.yml index 4e3c032f60a4..3e50e62f5517 100644 --- a/sdk/resourcemanager/ci.mgmt.yml +++ b/sdk/resourcemanager/ci.mgmt.yml @@ -128,6 +128,7 @@ trigger: - sdk/marketplace/Azure.ResourceManager.Marketplace - sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering - sdk/mediaservices/Azure.ResourceManager.Media + - sdk/migrate/Azure.ResourceManager.Migrate - sdk/migrationassessment/Azure.ResourceManager.Migration.Assessment - sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap - sdk/mixedreality/Azure.ResourceManager.MixedReality @@ -337,6 +338,7 @@ pr: - sdk/marketplace/Azure.ResourceManager.Marketplace - sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering - sdk/mediaservices/Azure.ResourceManager.Media + - sdk/migrate/Azure.ResourceManager.Migrate - sdk/migrationassessment/Azure.ResourceManager.Migration.Assessment - sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap - sdk/mixedreality/Azure.ResourceManager.MixedReality diff --git a/sdk/storage/ci.yml b/sdk/storage/ci.yml index 2ca0501b60bd..4e749e6b85b1 100644 --- a/sdk/storage/ci.yml +++ b/sdk/storage/ci.yml @@ -12,6 +12,8 @@ trigger: - sdk/storage/Azure.Storage.DataMovement/ - sdk/storage/Azure.Storage.DataMovement.Blobs/ - sdk/storage/Azure.Storage.DataMovement.Files/ + exclude: + - sdk/storage/Azure.ResourceManager.Storage/ - sdk/storage/Azure.Storage.DataMovement.Blobs.Files.Shares/ exclude: - sdk/storage/Azure.ResourceManager.Storage/