diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Azure.ResourceManager.ComputeFleet.sln b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Azure.ResourceManager.ComputeFleet.sln new file mode 100644 index 000000000000..c5dc18f0662c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Azure.ResourceManager.ComputeFleet.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ComputeFleet", "src\Azure.ResourceManager.ComputeFleet.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.ResourceManager.ComputeFleet.Tests", "tests\Azure.ResourceManager.ComputeFleet.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/CHANGELOG.md b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Directory.Build.props b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/README.md b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/README.md new file mode 100644 index 000000000000..db5b7d21f435 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/README.md @@ -0,0 +1,86 @@ +# Azure.ResourceManager.ComputeFleet client library for .NET + +Azure.ResourceManager.ComputeFleet is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.ResourceManager.ComputeFleet --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/computefleet/Azure.ResourceManager.ComputeFleet/README.png) diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Azure.ResourceManager.ComputeFleet.csproj b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Azure.ResourceManager.ComputeFleet.csproj new file mode 100644 index 000000000000..281b606b1560 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Azure.ResourceManager.ComputeFleet.csproj @@ -0,0 +1,21 @@ + + + This is the Azure.ResourceManager.ComputeFleet client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.ResourceManager.ComputeFleet for Azure Data Plane + 1.0.0-beta.1 + Azure.ResourceManager.ComputeFleet + $(RequiredTargetFrameworks) + true + true + + + + + + + + + + + + diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/ArmComputeFleetModelFactory.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/ArmComputeFleetModelFactory.cs new file mode 100644 index 000000000000..61792af23bb0 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/ArmComputeFleetModelFactory.cs @@ -0,0 +1,373 @@ +// 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.ComputeFleet.Models +{ + /// Model factory for models. + public static partial class ArmComputeFleetModelFactory + { + /// Initializes a new instance of . + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + /// Localized display information for this particular operation. + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + /// A new instance for mocking. + public static Operation Operation(string name = null, bool? isDataAction = null, OperationDisplay display = null, Origin? origin = null, ActionType? actionType = null) + { + return new Operation( + name, + isDataAction, + display, + origin, + actionType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// A new instance for mocking. + public static OperationDisplay OperationDisplay(string provider = null, string resource = null, string operation = null, string description = null) + { + return new OperationDisplay(provider, resource, operation, description, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Zones in which the Compute Fleet is available. + /// The managed service identities assigned to this resource. + /// Details of the resource plan. + /// A new instance for mocking. + public static FleetData FleetData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, FleetProperties properties = null, IEnumerable zones = null, ManagedServiceIdentity identity = null, ArmPlan plan = null) + { + tags ??= new Dictionary(); + zones ??= new List(); + + return new FleetData( + id, + name, + resourceType, + systemData, + tags, + location, + properties, + zones?.ToList(), + identity, + plan, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Configuration Options for Spot instances in Compute Fleet. + /// Configuration Options for Regular instances in Compute Fleet. + /// List of VM sizes supported for Compute Fleet. + /// Compute Profile to use for running user's workloads. + /// Specifies the time at which the Compute Fleet is created. + /// Specifies the ID which uniquely identifies a Compute Fleet. + /// A new instance for mocking. + public static FleetProperties FleetProperties(ProvisioningState? provisioningState = null, SpotPriorityProfile spotPriorityProfile = null, RegularPriorityProfile regularPriorityProfile = null, IEnumerable vmSizesProfile = null, ComputeProfile computeProfile = null, DateTimeOffset? timeCreated = null, string uniqueId = null) + { + vmSizesProfile ??= new List(); + + return new FleetProperties( + provisioningState, + spotPriorityProfile, + regularPriorityProfile, + vmSizesProfile?.ToList(), + computeProfile, + timeCreated, + uniqueId, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// Specifies the operating system settings for the virtual machines in the scale + /// set. + /// + /// Specifies the storage settings for the virtual machine disks. + /// + /// Specifies properties of the network interfaces of the virtual machines in the + /// scale set. + /// + /// + /// Specifies the Security related profile settings for the virtual machines in the + /// scale set. + /// + /// Specifies the boot diagnostic settings state. + /// + /// Specifies a collection of settings for extensions installed on virtual machines + /// in the scale set. + /// + /// + /// Specifies that the image or disk that is being used was licensed on-premises. + /// <br><br> Possible values for Windows Server operating system are: <br><br> + /// Windows_Client <br><br> Windows_Server <br><br> Possible values for Linux + /// Server operating system are: <br><br> RHEL_BYOS (for RHEL) <br><br> SLES_BYOS + /// (for SUSE) <br><br> For more information, see [Azure Hybrid Use Benefit for + /// Windows + /// Server](https://docs.microsoft.com/azure/virtual-machines/windows/hybrid-use-benefit-licensing) + /// <br><br> [Azure Hybrid Use Benefit for Linux + /// Server](https://docs.microsoft.com/azure/virtual-machines/linux/azure-hybrid-benefit-linux) + /// <br><br> Minimum api-version: 2015-06-15 + /// + /// Specifies Scheduled Event related configurations. + /// + /// UserData for the virtual machines in the scale set, which must be base-64 + /// encoded. Customer should not pass any secrets in here. Minimum api-version: + /// 2021-03-01. + /// + /// + /// Specifies the capacity reservation related details of a scale set. Minimum + /// api-version: 2021-04-01. + /// + /// Specifies the gallery applications that should be made available to the VM/VMSS. + /// + /// Specifies the hardware profile related details of a scale set. Minimum + /// api-version: 2021-11-01. + /// + /// + /// Specifies the service artifact reference id used to set same image version for + /// all virtual machines in the scale set when using 'latest' image version. + /// Minimum api-version: 2022-11-01 + /// + /// + /// Specifies the security posture to be used for all virtual machines in the scale + /// set. Minimum api-version: 2023-03-01 + /// + /// + /// Specifies the time in which this VM profile for the Virtual Machine Scale Set + /// was created. Minimum API version for this property is 2023-09-01. This value + /// will be added to VMSS Flex VM tags when creating/updating the VMSS VM Profile + /// with minimum api-version 2023-09-01. Examples: "2024-07-01T00:00:01.1234567+00:00" + /// + /// A new instance for mocking. + public static BaseVirtualMachineProfile BaseVirtualMachineProfile(VirtualMachineScaleSetOSProfile osProfile = null, VirtualMachineScaleSetStorageProfile storageProfile = null, VirtualMachineScaleSetNetworkProfile networkProfile = null, SecurityProfile securityProfile = null, BootDiagnostics bootDiagnostics = null, VirtualMachineScaleSetExtensionProfile extensionProfile = null, string licenseType = null, ScheduledEventsProfile scheduledEventsProfile = null, string userData = null, ResourceIdentifier capacityReservationGroupId = null, IEnumerable galleryApplications = null, VmSizeProperties hardwareVmSizeProperties = null, ResourceIdentifier serviceArtifactReferenceId = null, SecurityPostureReference securityPostureReference = null, DateTimeOffset? timeCreated = null) + { + galleryApplications ??= new List(); + + return new BaseVirtualMachineProfile( + osProfile, + storageProfile, + networkProfile, + securityProfile, + bootDiagnostics != null ? new DiagnosticsProfile(bootDiagnostics, serializedAdditionalRawData: null) : null, + extensionProfile, + licenseType, + scheduledEventsProfile, + userData, + capacityReservationGroupId != null ? new CapacityReservationProfile(ResourceManagerModelFactory.WritableSubResource(capacityReservationGroupId), serializedAdditionalRawData: null) : null, + galleryApplications != null ? new ApplicationProfile(galleryApplications?.ToList(), serializedAdditionalRawData: null) : null, + hardwareVmSizeProperties != null ? new VirtualMachineScaleSetHardwareProfile(hardwareVmSizeProperties, serializedAdditionalRawData: null) : null, + serviceArtifactReferenceId != null ? ResourceManagerModelFactory.WritableSubResource(serviceArtifactReferenceId) : null, + securityPostureReference, + timeCreated, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource Id. + /// The image publisher. + /// + /// Specifies the offer of the platform image or marketplace image used to create + /// the virtual machine. + /// + /// The image SKU. + /// + /// Specifies the version of the platform image or marketplace image used to create + /// the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. + /// Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest + /// version of an image available at deploy time. Even if you use 'latest', the VM + /// image will not automatically update after deploy time even if a new version + /// becomes available. Please do not use field 'version' for gallery image + /// deployment, gallery image should always use 'id' field for deployment, to use 'latest' + /// version of gallery image, just set + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' + /// in the 'id' field without version input. + /// + /// + /// Specifies in decimal numbers, the version of platform image or marketplace + /// image used to create the virtual machine. This readonly field differs from 'version', + /// only if the value specified in 'version' field is 'latest'. + /// + /// + /// Specified the shared gallery image unique id for vm deployment. This can be + /// fetched from shared gallery image GET call. + /// + /// + /// Specified the community gallery image unique id for vm deployment. This can be + /// fetched from community gallery image GET call. + /// + /// A new instance for mocking. + public static ImageReference ImageReference(ResourceIdentifier id = null, string publisher = null, string offer = null, string sku = null, string version = null, string exactVersion = null, string sharedGalleryImageId = null, string communityGalleryImageId = null) + { + return new ImageReference( + id, + publisher, + offer, + sku, + version, + exactVersion, + sharedGalleryImageId, + communityGalleryImageId, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Resource Id. + /// The name of the extension. + /// Resource type. + /// Describes the properties of a Virtual Machine Scale Set Extension. + /// A new instance for mocking. + public static VirtualMachineScaleSetExtension VirtualMachineScaleSetExtension(ResourceIdentifier id = null, string name = null, string type = null, VirtualMachineScaleSetExtensionProperties properties = null) + { + return new VirtualMachineScaleSetExtension(id, name, type, properties, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// If a value is provided and is different from the previous value, the extension + /// handler will be forced to update even if the extension configuration has not + /// changed. + /// + /// The name of the extension handler publisher. + /// Specifies the type of the extension; an example is "CustomScriptExtension". + /// Specifies the version of the script handler. + /// + /// Indicates whether the extension should use a newer minor version if one is + /// available at deployment time. Once deployed, however, the extension will not + /// upgrade minor versions unless redeployed, even with this property set to true. + /// + /// + /// Indicates whether the extension should be automatically upgraded by the + /// platform if there is a newer version of the extension available. + /// + /// Json formatted public settings for the extension. + /// + /// The extension can contain either protectedSettings or + /// protectedSettingsFromKeyVault or no protected settings at all. + /// + /// The provisioning state, which only appears in the response. + /// + /// Collection of extension names after which this extension needs to be + /// provisioned. + /// + /// + /// Indicates whether failures stemming from the extension will be suppressed + /// (Operational failures such as not connecting to the VM will not be suppressed + /// regardless of this value). The default is false. + /// + /// + /// The extensions protected settings that are passed by reference, and consumed + /// from key vault + /// + /// A new instance for mocking. + public static VirtualMachineScaleSetExtensionProperties VirtualMachineScaleSetExtensionProperties(string forceUpdateTag = null, string publisher = null, string type = null, string typeHandlerVersion = null, bool? autoUpgradeMinorVersion = null, bool? enableAutomaticUpgrade = null, IDictionary settings = null, IDictionary protectedSettings = null, string provisioningState = null, IEnumerable provisionAfterExtensions = null, bool? suppressFailures = null, KeyVaultSecretReference protectedSettingsFromKeyVault = null) + { + settings ??= new Dictionary(); + protectedSettings ??= new Dictionary(); + provisionAfterExtensions ??= new List(); + + return new VirtualMachineScaleSetExtensionProperties( + forceUpdateTag, + publisher, + type, + typeHandlerVersion, + autoUpgradeMinorVersion, + enableAutomaticUpgrade, + settings, + protectedSettings, + provisioningState, + provisionAfterExtensions?.ToList(), + suppressFailures, + protectedSettingsFromKeyVault, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The type of managed identity assigned to this resource. + /// The identities assigned to this resource by the user. + /// A new instance for mocking. + public static ManagedServiceIdentity ManagedServiceIdentity(Guid? principalId = null, Guid? tenantId = null, ManagedServiceIdentityType type = default, IDictionary userAssignedIdentities = null) + { + userAssignedIdentities ??= new Dictionary(); + + return new ManagedServiceIdentity(principalId, tenantId, type, userAssignedIdentities, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The compute RP resource id of the virtualMachineScaleSet + /// "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}" + /// + /// Type of the virtualMachineScaleSet. + /// This represents the operationStatus of the VMSS in response to the last operation that was performed on it by Azure Fleet resource. + /// Error Information when `operationStatus` is `Failed`. + /// A new instance for mocking. + public static VirtualMachineScaleSet VirtualMachineScaleSet(string id = null, string type = null, ProvisioningState operationStatus = default, ApiError error = null) + { + return new VirtualMachineScaleSet(id, type, operationStatus, error, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The error code. + /// The target of the particular error. + /// The error message. + /// The API error details. + /// The API inner error. + /// A new instance for mocking. + public static ApiError ApiError(string code = null, string target = null, string message = null, IEnumerable details = null, InnerError innererror = null) + { + details ??= new List(); + + return new ApiError( + code, + target, + message, + details?.ToList(), + innererror, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The error code. + /// The target of the particular error. + /// The error message. + /// A new instance for mocking. + public static ApiErrorBase ApiErrorBase(string code = null, string target = null, string message = null) + { + return new ApiErrorBase(code, target, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The exception type. + /// The internal error message or exception dump. + /// A new instance for mocking. + public static InnerError InnerError(string exceptionType = null, string errorDetail = null) + { + return new InnerError(exceptionType, errorDetail, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/ComputeFleetExtensions.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/ComputeFleetExtensions.cs new file mode 100644 index 000000000000..e01913aa6c86 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/ComputeFleetExtensions.cs @@ -0,0 +1,289 @@ +// 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.ComputeFleet.Mocking; +using Azure.ResourceManager.ComputeFleet.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ComputeFleet +{ + /// A class to add extension methods to Azure.ResourceManager.ComputeFleet. + public static partial class ComputeFleetExtensions + { + private static MockableComputeFleetArmClient GetMockableComputeFleetArmClient(ArmClient client) + { + return client.GetCachedClient(client0 => new MockableComputeFleetArmClient(client0)); + } + + private static MockableComputeFleetResourceGroupResource GetMockableComputeFleetResourceGroupResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableComputeFleetResourceGroupResource(client, resource.Id)); + } + + private static MockableComputeFleetSubscriptionResource GetMockableComputeFleetSubscriptionResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableComputeFleetSubscriptionResource(client, resource.Id)); + } + + private static MockableComputeFleetTenantResource GetMockableComputeFleetTenantResource(ArmResource resource) + { + return resource.GetCachedClient(client => new MockableComputeFleetTenantResource(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 FleetResource GetFleetResource(this ArmClient client, ResourceIdentifier id) + { + Argument.AssertNotNull(client, nameof(client)); + + return GetMockableComputeFleetArmClient(client).GetFleetResource(id); + } + + /// + /// Gets a collection of FleetResources in the ResourceGroupResource. + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// is null. + /// An object representing collection of FleetResources and their operations over a FleetResource. + public static FleetCollection GetFleets(this ResourceGroupResource resourceGroupResource) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableComputeFleetResourceGroupResource(resourceGroupResource).GetFleets(); + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static async Task> GetFleetAsync(this ResourceGroupResource resourceGroupResource, string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return await GetMockableComputeFleetResourceGroupResource(resourceGroupResource).GetFleetAsync(fleetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public static Response GetFleet(this ResourceGroupResource resourceGroupResource, string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); + + return GetMockableComputeFleetResourceGroupResource(resourceGroupResource).GetFleet(fleetName, cancellationToken); + } + + /// + /// List Fleet resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetFleetsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeFleetSubscriptionResource(subscriptionResource).GetFleetsAsync(cancellationToken); + } + + /// + /// List Fleet resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetFleets(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); + + return GetMockableComputeFleetSubscriptionResource(subscriptionResource).GetFleets(cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.AzureFleet/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// An async collection of that may take multiple service requests to iterate over. + public static AsyncPageable GetOperationsAsync(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableComputeFleetTenantResource(tenantResource).GetOperationsAsync(cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.AzureFleet/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// + /// Mocking + /// To mock this method, please mock instead. + /// + /// + /// The instance the method will execute against. + /// The cancellation token to use. + /// is null. + /// A collection of that may take multiple service requests to iterate over. + public static Pageable GetOperations(this TenantResource tenantResource, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tenantResource, nameof(tenantResource)); + + return GetMockableComputeFleetTenantResource(tenantResource).GetOperations(cancellationToken); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetArmClient.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetArmClient.cs new file mode 100644 index 000000000000..1c776a0d20d4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetArmClient.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Mocking +{ + /// A class to add extension methods to ArmClient. + public partial class MockableComputeFleetArmClient : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableComputeFleetArmClient() + { + } + + /// 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 MockableComputeFleetArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + internal MockableComputeFleetArmClient(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 FleetResource GetFleetResource(ResourceIdentifier id) + { + FleetResource.ValidateResourceId(id); + return new FleetResource(Client, id); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetResourceGroupResource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetResourceGroupResource.cs new file mode 100644 index 000000000000..fe7041973b60 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetResourceGroupResource.cs @@ -0,0 +1,105 @@ +// 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.ComputeFleet.Mocking +{ + /// A class to add extension methods to ResourceGroupResource. + public partial class MockableComputeFleetResourceGroupResource : ArmResource + { + /// Initializes a new instance of the class for mocking. + protected MockableComputeFleetResourceGroupResource() + { + } + + /// 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 MockableComputeFleetResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// Gets a collection of FleetResources in the ResourceGroupResource. + /// An object representing collection of FleetResources and their operations over a FleetResource. + public virtual FleetCollection GetFleets() + { + return GetCachedClient(client => new FleetCollection(client, Id)); + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual async Task> GetFleetAsync(string fleetName, CancellationToken cancellationToken = default) + { + return await GetFleets().GetAsync(fleetName, cancellationToken).ConfigureAwait(false); + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + [ForwardsClientCalls] + public virtual Response GetFleet(string fleetName, CancellationToken cancellationToken = default) + { + return GetFleets().Get(fleetName, cancellationToken); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetSubscriptionResource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetSubscriptionResource.cs new file mode 100644 index 000000000000..f8f646ff27ff --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetSubscriptionResource.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.ComputeFleet.Mocking +{ + /// A class to add extension methods to SubscriptionResource. + public partial class MockableComputeFleetSubscriptionResource : ArmResource + { + private ClientDiagnostics _fleetClientDiagnostics; + private FleetsRestOperations _fleetRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableComputeFleetSubscriptionResource() + { + } + + /// 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 MockableComputeFleetSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics FleetClientDiagnostics => _fleetClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ComputeFleet", FleetResource.ResourceType.Namespace, Diagnostics); + private FleetsRestOperations FleetRestClient => _fleetRestClient ??= new FleetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(FleetResource.ResourceType)); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List Fleet resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetFleetsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => FleetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FleetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FleetResource(Client, FleetData.DeserializeFleetData(e)), FleetClientDiagnostics, Pipeline, "MockableComputeFleetSubscriptionResource.GetFleets", "value", "nextLink", cancellationToken); + } + + /// + /// List Fleet resources by subscription ID + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListBySubscription + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetFleets(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => FleetRestClient.CreateListBySubscriptionRequest(Id.SubscriptionId); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => FleetRestClient.CreateListBySubscriptionNextPageRequest(nextLink, Id.SubscriptionId); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FleetResource(Client, FleetData.DeserializeFleetData(e)), FleetClientDiagnostics, Pipeline, "MockableComputeFleetSubscriptionResource.GetFleets", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetTenantResource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetTenantResource.cs new file mode 100644 index 000000000000..22cae0520e95 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Extensions/MockableComputeFleetTenantResource.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.ComputeFleet.Models; + +namespace Azure.ResourceManager.ComputeFleet.Mocking +{ + /// A class to add extension methods to TenantResource. + public partial class MockableComputeFleetTenantResource : ArmResource + { + private ClientDiagnostics _operationsClientDiagnostics; + private OperationsRestOperations _operationsRestClient; + + /// Initializes a new instance of the class for mocking. + protected MockableComputeFleetTenantResource() + { + } + + /// 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 MockableComputeFleetTenantResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + } + + private ClientDiagnostics OperationsClientDiagnostics => _operationsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.ComputeFleet", ProviderConstants.DefaultProviderNamespace, Diagnostics); + private OperationsRestOperations OperationsRestClient => _operationsRestClient ??= new OperationsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); + + private string GetApiVersionOrNull(ResourceType resourceType) + { + TryGetApiVersion(resourceType, out string apiVersion); + return apiVersion; + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.AzureFleet/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetOperationsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Models.Operation.DeserializeOperation(e), OperationsClientDiagnostics, Pipeline, "MockableComputeFleetTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + + /// + /// List the operations for the provider + /// + /// + /// Request Path + /// /providers/Microsoft.AzureFleet/operations + /// + /// + /// Operation Id + /// Operations_List + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetOperations(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => OperationsRestClient.CreateListRequest(); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => OperationsRestClient.CreateListNextPageRequest(nextLink); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Models.Operation.DeserializeOperation(e), OperationsClientDiagnostics, Pipeline, "MockableComputeFleetTenantResource.GetOperations", "value", "nextLink", cancellationToken); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetCollection.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetCollection.cs new file mode 100644 index 000000000000..43ecac9036d4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetCollection.cs @@ -0,0 +1,494 @@ +// 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.ComputeFleet +{ + /// + /// 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 GetFleets method from an instance of . + /// + public partial class FleetCollection : ArmCollection, IEnumerable, IAsyncEnumerable + { + private readonly ClientDiagnostics _fleetClientDiagnostics; + private readonly FleetsRestOperations _fleetRestClient; + + /// Initializes a new instance of the class for mocking. + protected FleetCollection() + { + } + + /// 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 FleetCollection(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _fleetClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ComputeFleet", FleetResource.ResourceType.Namespace, Diagnostics); + TryGetApiVersion(FleetResource.ResourceType, out string fleetApiVersion); + _fleetRestClient = new FleetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, fleetApiVersion); +#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 Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-05-01-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 name of the Compute Fleet. + /// 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 fleetName, FleetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = await _fleetRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, fleetName, data, cancellationToken).ConfigureAwait(false); + var operation = new ComputeFleetArmOperation(new FleetOperationSource(Client), _fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, fleetName, 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 Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_CreateOrUpdate + /// + /// + /// Default Api Version + /// 2024-05-01-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 name of the Compute Fleet. + /// 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 fleetName, FleetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.CreateOrUpdate"); + scope.Start(); + try + { + var response = _fleetRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, fleetName, data, cancellationToken); + var operation = new ComputeFleetArmOperation(new FleetOperationSource(Client), _fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, fleetName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetAsync(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.Get"); + scope.Start(); + try + { + var response = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, fleetName, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new FleetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Get(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.Get"); + scope.Start(); + try + { + var response = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, fleetName, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new FleetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List Fleet resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-05-01-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) => _fleetRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _fleetRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new FleetResource(Client, FleetData.DeserializeFleetData(e)), _fleetClientDiagnostics, Pipeline, "FleetCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// List Fleet resources by resource group + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets + /// + /// + /// Operation Id + /// Fleet_ListByResourceGroup + /// + /// + /// Default Api Version + /// 2024-05-01-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) => _fleetRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _fleetRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new FleetResource(Client, FleetData.DeserializeFleetData(e)), _fleetClientDiagnostics, Pipeline, "FleetCollection.GetAll", "value", "nextLink", cancellationToken); + } + + /// + /// Checks to see if the resource exists in azure. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> ExistsAsync(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.Exists"); + scope.Start(); + try + { + var response = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, fleetName, 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.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual Response Exists(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.Exists"); + scope.Start(); + try + { + var response = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, fleetName, 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.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual async Task> GetIfExistsAsync(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.GetIfExists"); + scope.Start(); + try + { + var response = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, fleetName, cancellationToken: cancellationToken).ConfigureAwait(false); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new FleetResource(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.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The name of the Compute Fleet. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// is null. + public virtual NullableResponse GetIfExists(string fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetCollection.GetIfExists"); + scope.Start(); + try + { + var response = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, fleetName, cancellationToken: cancellationToken); + if (response.Value == null) + return new NoValueResponse(response.GetRawResponse()); + return Response.FromValue(new FleetResource(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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.Serialization.cs new file mode 100644 index 000000000000..3759b2a587a8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.Serialization.cs @@ -0,0 +1,276 @@ +// 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.ComputeFleet.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ComputeFleet +{ + public partial class FleetData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FleetData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsCollectionDefined(Zones)) + { + writer.WritePropertyName("zones"u8); + writer.WriteStartArray(); + foreach (var item in Zones) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsDefined(Plan)) + { + writer.WritePropertyName("plan"u8); + JsonSerializer.Serialize(writer, Plan); + } + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("location"u8); + writer.WriteStringValue(Location); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W") + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W") + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(ResourceType); + } + if (options.Format != "W" && Optional.IsDefined(SystemData)) + { + writer.WritePropertyName("systemData"u8); + JsonSerializer.Serialize(writer, SystemData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FleetData 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(FleetData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFleetData(document.RootElement, options); + } + + internal static FleetData DeserializeFleetData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FleetProperties properties = default; + IList zones = default; + Models.ManagedServiceIdentity identity = default; + ArmPlan plan = default; + IDictionary tags = default; + AzureLocation location = 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 = FleetProperties.DeserializeFleetProperties(property.Value, options); + continue; + } + if (property.NameEquals("zones"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + zones = array; + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = Models.ManagedServiceIdentity.DeserializeManagedServiceIdentity(property.Value, options); + continue; + } + if (property.NameEquals("plan"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + plan = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("location"u8)) + { + location = new AzureLocation(property.Value.GetString()); + 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 FleetData( + id, + name, + type, + systemData, + tags ?? new ChangeTrackingDictionary(), + location, + properties, + zones ?? new ChangeTrackingList(), + identity, + plan, + 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(FleetData)} does not support writing '{options.Format}' format."); + } + } + + FleetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFleetData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FleetData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.cs new file mode 100644 index 000000000000..9d243a949720 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetData.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.ComputeFleet.Models; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ComputeFleet +{ + /// + /// A class representing the Fleet data model. + /// An Compute Fleet resource + /// + public partial class FleetData : TrackedResourceData + { + /// + /// 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 location. + public FleetData(AzureLocation location) : base(location) + { + Zones = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// The tags. + /// The location. + /// The resource-specific properties for this resource. + /// Zones in which the Compute Fleet is available. + /// The managed service identities assigned to this resource. + /// Details of the resource plan. + /// Keeps track of any properties unknown to the library. + internal FleetData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, FleetProperties properties, IList zones, Models.ManagedServiceIdentity identity, ArmPlan plan, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + { + Properties = properties; + Zones = zones; + Identity = identity; + Plan = plan; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FleetData() + { + } + + /// The resource-specific properties for this resource. + public FleetProperties Properties { get; set; } + /// Zones in which the Compute Fleet is available. + public IList Zones { get; } + /// The managed service identities assigned to this resource. + public Models.ManagedServiceIdentity Identity { get; set; } + /// Details of the resource plan. + public ArmPlan Plan { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.Serialization.cs new file mode 100644 index 000000000000..cea9381c3c7c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.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.ComputeFleet +{ + public partial class FleetResource : IJsonModel + { + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); + + FleetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)Data).Create(ref reader, options); + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options); + + FleetData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options); + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)Data).GetFormatFromOptions(options); + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.cs new file mode 100644 index 000000000000..627ed783ea04 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/FleetResource.cs @@ -0,0 +1,768 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +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.ComputeFleet.Models; +using Azure.ResourceManager.Resources; + +namespace Azure.ResourceManager.ComputeFleet +{ + /// + /// A Class representing a Fleet 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 GetFleetResource method. + /// Otherwise you can get one from its parent resource using the GetFleet method. + /// + public partial class FleetResource : ArmResource + { + /// Generate the resource identifier of a instance. + /// The subscriptionId. + /// The resourceGroupName. + /// The fleetName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string fleetName) + { + var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName}"; + return new ResourceIdentifier(resourceId); + } + + private readonly ClientDiagnostics _fleetClientDiagnostics; + private readonly FleetsRestOperations _fleetRestClient; + private readonly FleetData _data; + + /// Gets the resource type for the operations. + public static readonly ResourceType ResourceType = "Microsoft.AzureFleet/fleets"; + + /// Initializes a new instance of the class for mocking. + protected FleetResource() + { + } + + /// Initializes a new instance of the class. + /// The client parameters to use in these operations. + /// The resource that is the target of operations. + internal FleetResource(ArmClient client, FleetData 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 FleetResource(ArmClient client, ResourceIdentifier id) : base(client, id) + { + _fleetClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.ComputeFleet", ResourceType.Namespace, Diagnostics); + TryGetApiVersion(ResourceType, out string fleetApiVersion); + _fleetRestClient = new FleetsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, fleetApiVersion); +#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 FleetData 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 Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual async Task> GetAsync(CancellationToken cancellationToken = default) + { + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.Get"); + scope.Start(); + try + { + var response = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new FleetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Get a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + public virtual Response Get(CancellationToken cancellationToken = default) + { + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.Get"); + scope.Start(); + try + { + var response = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + if (response.Value == null) + throw new RequestFailedException(response.GetRawResponse()); + return Response.FromValue(new FleetResource(Client, response.Value), response.GetRawResponse()); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Delete + /// + /// + /// Default Api Version + /// 2024-05-01-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 = _fleetClientDiagnostics.CreateScope("FleetResource.Delete"); + scope.Start(); + try + { + var response = await _fleetRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + var operation = new ComputeFleetArmOperation(_fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Delete a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Delete + /// + /// + /// Default Api Version + /// 2024-05-01-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 = _fleetClientDiagnostics.CreateScope("FleetResource.Delete"); + scope.Start(); + try + { + var response = _fleetRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + var operation = new ComputeFleetArmOperation(_fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletionResponse(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Update + /// + /// + /// Default Api Version + /// 2024-05-01-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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, FleetPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.Update"); + scope.Start(); + try + { + var response = await _fleetRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); + var operation = new ComputeFleetArmOperation(new FleetOperationSource(Client), _fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Update a Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Update + /// + /// + /// Default Api Version + /// 2024-05-01-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 resource properties to be updated. + /// The cancellation token to use. + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, FleetPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(patch, nameof(patch)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.Update"); + scope.Start(); + try + { + var response = _fleetRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); + var operation = new ComputeFleetArmOperation(new FleetOperationSource(Client), _fleetClientDiagnostics, Pipeline, _fleetRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + if (waitUntil == WaitUntil.Completed) + operation.WaitForCompletion(cancellationToken); + return operation; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// List VirtualMachineScaleSet resources by Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{name}/virtualMachineScaleSets + /// + /// + /// Operation Id + /// VirtualMachineScaleSet_ListVirtualMachineScaleSets + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetVirtualMachineScaleSetsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _fleetRestClient.CreateListVirtualMachineScaleSetsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _fleetRestClient.CreateListVirtualMachineScaleSetsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => VirtualMachineScaleSet.DeserializeVirtualMachineScaleSet(e), _fleetClientDiagnostics, Pipeline, "FleetResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + } + + /// + /// List VirtualMachineScaleSet resources by Fleet + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{name}/virtualMachineScaleSets + /// + /// + /// Operation Id + /// VirtualMachineScaleSet_ListVirtualMachineScaleSets + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetVirtualMachineScaleSets(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _fleetRestClient.CreateListVirtualMachineScaleSetsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _fleetRestClient.CreateListVirtualMachineScaleSetsNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => VirtualMachineScaleSet.DeserializeVirtualMachineScaleSet(e), _fleetClientDiagnostics, Pipeline, "FleetResource.GetVirtualMachineScaleSets", "value", "nextLink", cancellationToken); + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual async Task> AddTagAsync(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.AddTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues[key] = value; + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new FleetPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Add a tag to the current resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The value for the tag. + /// The cancellation token to use. + /// or is null. + public virtual Response AddTag(string key, string value, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.AddTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues[key] = value; + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new FleetPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags[key] = value; + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.SetTags"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new FleetPatch(); + patch.Tags.ReplaceWith(tags); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Replace the tags on the resource with the given set. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The set of tags to use as replacement. + /// The cancellation token to use. + /// is null. + public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(tags, nameof(tags)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.SetTags"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.ReplaceWith(tags); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new FleetPatch(); + patch.Tags.ReplaceWith(tags); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual async Task> RemoveTagAsync(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.RemoveTag"); + scope.Start(); + try + { + if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + { + var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + originalTags.Value.Data.TagValues.Remove(key); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); + var originalResponse = await _fleetRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + var patch = new FleetPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Removes a tag by key from the resource. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureFleet/fleets/{fleetName} + /// + /// + /// Operation Id + /// Fleets_Get + /// + /// + /// Default Api Version + /// 2024-05-01-preview + /// + /// + /// Resource + /// + /// + /// + /// + /// The key for the tag. + /// The cancellation token to use. + /// is null. + public virtual Response RemoveTag(string key, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(key, nameof(key)); + + using var scope = _fleetClientDiagnostics.CreateScope("FleetResource.RemoveTag"); + scope.Start(); + try + { + if (CanUseTagResource(cancellationToken: cancellationToken)) + { + var originalTags = GetTagResource().Get(cancellationToken); + originalTags.Value.Data.TagValues.Remove(key); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); + var originalResponse = _fleetRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + return Response.FromValue(new FleetResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + } + else + { + var current = Get(cancellationToken: cancellationToken).Value.Data; + var patch = new FleetPatch(); + foreach (var tag in current.Tags) + { + patch.Tags.Add(tag); + } + patch.Tags.Remove(key); + var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + return Response.FromValue(result.Value, result.GetRawResponse()); + } + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Argument.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..a0a6cf71885f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..aa7e5ec8f7e0 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ChangeTrackingList.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..95357b568c62 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..2c90832af748 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Optional.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..857b37b3e1ce --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..34875b3d7f79 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperation.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperation.cs new file mode 100644 index 000000000000..7762c42a9062 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperation.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.ComputeFleet +{ +#pragma warning disable SA1649 // File name should match first type name + internal class ComputeFleetArmOperation : 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 ComputeFleetArmOperation for mocking. + protected ComputeFleetArmOperation() + { + } + + internal ComputeFleetArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal ComputeFleetArmOperation(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, "ComputeFleetArmOperation", 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperationOfT.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperationOfT.cs new file mode 100644 index 000000000000..1c033561536e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/ComputeFleetArmOperationOfT.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.ComputeFleet +{ +#pragma warning disable SA1649 // File name should match first type name + internal class ComputeFleetArmOperation : 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 ComputeFleetArmOperation for mocking. + protected ComputeFleetArmOperation() + { + } + + internal ComputeFleetArmOperation(Response response, RehydrationToken? rehydrationToken = null) + { + _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); + _completeRehydrationToken = rehydrationToken; + _operationId = GetOperationId(rehydrationToken); + } + + internal ComputeFleetArmOperation(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, "ComputeFleetArmOperation", 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/FleetOperationSource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/FleetOperationSource.cs new file mode 100644 index 000000000000..703840fd4c46 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/LongRunningOperation/FleetOperationSource.cs @@ -0,0 +1,38 @@ +// 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; + +namespace Azure.ResourceManager.ComputeFleet +{ + internal class FleetOperationSource : IOperationSource + { + private readonly ArmClient _client; + + internal FleetOperationSource(ArmClient client) + { + _client = client; + } + + FleetResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) + { + using var document = JsonDocument.Parse(response.ContentStream); + var data = FleetData.DeserializeFleetData(document.RootElement); + return new FleetResource(_client, data); + } + + async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) + { + using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + var data = FleetData.DeserializeFleetData(document.RootElement); + return new FleetResource(_client, data); + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ActionType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ActionType.cs new file mode 100644 index 000000000000..967f84628193 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ActionType.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + public readonly partial struct ActionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ActionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InternalValue = "Internal"; + + /// Actions are for internal-only APIs. + public static ActionType Internal { get; } = new ActionType(InternalValue); + /// Determines if two values are the same. + public static bool operator ==(ActionType left, ActionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ActionType left, ActionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ActionType(string value) => new ActionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ActionType other && Equals(other); + /// + public bool Equals(ActionType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.Serialization.cs new file mode 100644 index 000000000000..b9a9a8c9ed08 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class AdditionalUnattendContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AdditionalUnattendContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PassName)) + { + writer.WritePropertyName("passName"u8); + writer.WriteStringValue(PassName.Value.ToString()); + } + if (Optional.IsDefined(ComponentName)) + { + writer.WritePropertyName("componentName"u8); + writer.WriteStringValue(ComponentName.Value.ToString()); + } + if (Optional.IsDefined(SettingName)) + { + writer.WritePropertyName("settingName"u8); + writer.WriteStringValue(SettingName.Value.ToString()); + } + if (Optional.IsDefined(Content)) + { + writer.WritePropertyName("content"u8); + writer.WriteStringValue(Content); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AdditionalUnattendContent 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(AdditionalUnattendContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAdditionalUnattendContent(document.RootElement, options); + } + + internal static AdditionalUnattendContent DeserializeAdditionalUnattendContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AdditionalUnattendContentPassName? passName = default; + AdditionalUnattendContentComponentName? componentName = default; + SettingName? settingName = default; + string content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("passName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + passName = new AdditionalUnattendContentPassName(property.Value.GetString()); + continue; + } + if (property.NameEquals("componentName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + componentName = new AdditionalUnattendContentComponentName(property.Value.GetString()); + continue; + } + if (property.NameEquals("settingName"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + settingName = new SettingName(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + content = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AdditionalUnattendContent(passName, componentName, settingName, content, 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(AdditionalUnattendContent)} does not support writing '{options.Format}' format."); + } + } + + AdditionalUnattendContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAdditionalUnattendContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AdditionalUnattendContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.cs new file mode 100644 index 000000000000..eb6eb9825a19 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContent.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies additional XML formatted information that can be included in the + /// Unattend.xml file, which is used by Windows Setup. Contents are defined by + /// setting name, component name, and the pass in which the content is applied. + /// + public partial class AdditionalUnattendContent + { + /// + /// 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 AdditionalUnattendContent() + { + } + + /// Initializes a new instance of . + /// The pass name. Currently, the only allowable value is OobeSystem. + /// + /// The component name. Currently, the only allowable value is + /// Microsoft-Windows-Shell-Setup. + /// + /// + /// Specifies the name of the setting to which the content applies. Possible values + /// are: FirstLogonCommands and AutoLogon. + /// + /// + /// Specifies the XML formatted content that is added to the unattend.xml file for + /// the specified path and component. The XML must be less than 4KB and must + /// include the root element for the setting or feature that is being inserted. + /// + /// Keeps track of any properties unknown to the library. + internal AdditionalUnattendContent(AdditionalUnattendContentPassName? passName, AdditionalUnattendContentComponentName? componentName, SettingName? settingName, string content, IDictionary serializedAdditionalRawData) + { + PassName = passName; + ComponentName = componentName; + SettingName = settingName; + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The pass name. Currently, the only allowable value is OobeSystem. + public AdditionalUnattendContentPassName? PassName { get; set; } + /// + /// The component name. Currently, the only allowable value is + /// Microsoft-Windows-Shell-Setup. + /// + public AdditionalUnattendContentComponentName? ComponentName { get; set; } + /// + /// Specifies the name of the setting to which the content applies. Possible values + /// are: FirstLogonCommands and AutoLogon. + /// + public SettingName? SettingName { get; set; } + /// + /// Specifies the XML formatted content that is added to the unattend.xml file for + /// the specified path and component. The XML must be less than 4KB and must + /// include the root element for the setting or feature that is being inserted. + /// + public string Content { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentComponentName.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentComponentName.cs new file mode 100644 index 000000000000..02e50f678132 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentComponentName.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// The AdditionalUnattendContent_componentName. + public readonly partial struct AdditionalUnattendContentComponentName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AdditionalUnattendContentComponentName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MicrosoftWindowsShellSetupValue = "Microsoft-Windows-Shell-Setup"; + + /// Microsoft-Windows-Shell-Setup. + public static AdditionalUnattendContentComponentName MicrosoftWindowsShellSetup { get; } = new AdditionalUnattendContentComponentName(MicrosoftWindowsShellSetupValue); + /// Determines if two values are the same. + public static bool operator ==(AdditionalUnattendContentComponentName left, AdditionalUnattendContentComponentName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AdditionalUnattendContentComponentName left, AdditionalUnattendContentComponentName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AdditionalUnattendContentComponentName(string value) => new AdditionalUnattendContentComponentName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AdditionalUnattendContentComponentName other && Equals(other); + /// + public bool Equals(AdditionalUnattendContentComponentName 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentPassName.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentPassName.cs new file mode 100644 index 000000000000..ed38cf0961c8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/AdditionalUnattendContentPassName.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// The AdditionalUnattendContent_passName. + public readonly partial struct AdditionalUnattendContentPassName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AdditionalUnattendContentPassName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OobeSystemValue = "OobeSystem"; + + /// OobeSystem. + public static AdditionalUnattendContentPassName OobeSystem { get; } = new AdditionalUnattendContentPassName(OobeSystemValue); + /// Determines if two values are the same. + public static bool operator ==(AdditionalUnattendContentPassName left, AdditionalUnattendContentPassName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AdditionalUnattendContentPassName left, AdditionalUnattendContentPassName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AdditionalUnattendContentPassName(string value) => new AdditionalUnattendContentPassName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AdditionalUnattendContentPassName other && Equals(other); + /// + public bool Equals(AdditionalUnattendContentPassName 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.Serialization.cs new file mode 100644 index 000000000000..0ef67640f58d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.Serialization.cs @@ -0,0 +1,190 @@ +// 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.ComputeFleet.Models +{ + public partial class ApiError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApiError)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (Optional.IsCollectionDefined(Details)) + { + writer.WritePropertyName("details"u8); + writer.WriteStartArray(); + foreach (var item in Details) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Innererror)) + { + writer.WritePropertyName("innererror"u8); + writer.WriteObjectValue(Innererror, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ApiError 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(ApiError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiError(document.RootElement, options); + } + + internal static ApiError DeserializeApiError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string target = default; + string message = default; + IReadOnlyList details = default; + InnerError innererror = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ApiErrorBase.DeserializeApiErrorBase(item, options)); + } + details = array; + continue; + } + if (property.NameEquals("innererror"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + innererror = InnerError.DeserializeInnerError(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApiError( + code, + target, + message, + details ?? new ChangeTrackingList(), + innererror, + 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(ApiError)} does not support writing '{options.Format}' format."); + } + } + + ApiError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeApiError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.cs new file mode 100644 index 000000000000..628c2472dacc --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiError.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// ApiError for Fleet. + public partial class ApiError + { + /// + /// 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 ApiError() + { + Details = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The error code. + /// The target of the particular error. + /// The error message. + /// The API error details. + /// The API inner error. + /// Keeps track of any properties unknown to the library. + internal ApiError(string code, string target, string message, IReadOnlyList details, InnerError innererror, IDictionary serializedAdditionalRawData) + { + Code = code; + Target = target; + Message = message; + Details = details; + Innererror = innererror; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The error code. + public string Code { get; } + /// The target of the particular error. + public string Target { get; } + /// The error message. + public string Message { get; } + /// The API error details. + public IReadOnlyList Details { get; } + /// The API inner error. + public InnerError Innererror { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.Serialization.cs new file mode 100644 index 000000000000..2dd5973df6c4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.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.ComputeFleet.Models +{ + public partial class ApiErrorBase : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApiErrorBase)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code); + } + if (Optional.IsDefined(Target)) + { + writer.WritePropertyName("target"u8); + writer.WriteStringValue(Target); + } + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ApiErrorBase 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(ApiErrorBase)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiErrorBase(document.RootElement, options); + } + + internal static ApiErrorBase DeserializeApiErrorBase(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string code = default; + string target = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("target"u8)) + { + target = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApiErrorBase(code, target, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ApiErrorBase)} does not support writing '{options.Format}' format."); + } + } + + ApiErrorBase IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeApiErrorBase(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiErrorBase)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.cs new file mode 100644 index 000000000000..d44a4945e7e8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApiErrorBase.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.ComputeFleet.Models +{ + /// API error base. + public partial class ApiErrorBase + { + /// + /// 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 ApiErrorBase() + { + } + + /// Initializes a new instance of . + /// The error code. + /// The target of the particular error. + /// The error message. + /// Keeps track of any properties unknown to the library. + internal ApiErrorBase(string code, string target, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Target = target; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The error code. + public string Code { get; } + /// The target of the particular error. + public string Target { get; } + /// The error message. + public string Message { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.Serialization.cs new file mode 100644 index 000000000000..2df8b8035139 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.Serialization.cs @@ -0,0 +1,136 @@ +// 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.ComputeFleet.Models +{ + internal partial class ApplicationProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApplicationProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(GalleryApplications)) + { + writer.WritePropertyName("galleryApplications"u8); + writer.WriteStartArray(); + foreach (var item in GalleryApplications) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ApplicationProfile 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(ApplicationProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApplicationProfile(document.RootElement, options); + } + + internal static ApplicationProfile DeserializeApplicationProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList galleryApplications = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("galleryApplications"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VmGalleryApplication.DeserializeVmGalleryApplication(item, options)); + } + galleryApplications = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApplicationProfile(galleryApplications ?? 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(ApplicationProfile)} does not support writing '{options.Format}' format."); + } + } + + ApplicationProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeApplicationProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApplicationProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.cs new file mode 100644 index 000000000000..0cb96166f1b8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ApplicationProfile.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.ComputeFleet.Models +{ + /// + /// Contains the list of gallery applications that should be made available to the + /// VM/VMSS + /// + internal partial class ApplicationProfile + { + /// + /// 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 ApplicationProfile() + { + GalleryApplications = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Specifies the gallery applications that should be made available to the VM/VMSS. + /// Keeps track of any properties unknown to the library. + internal ApplicationProfile(IList galleryApplications, IDictionary serializedAdditionalRawData) + { + GalleryApplications = galleryApplications; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the gallery applications that should be made available to the VM/VMSS. + public IList GalleryApplications { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.Serialization.cs new file mode 100644 index 000000000000..c4dd0e879865 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.Serialization.cs @@ -0,0 +1,345 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class BaseVirtualMachineProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BaseVirtualMachineProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(OSProfile)) + { + writer.WritePropertyName("osProfile"u8); + writer.WriteObjectValue(OSProfile, options); + } + if (Optional.IsDefined(StorageProfile)) + { + writer.WritePropertyName("storageProfile"u8); + writer.WriteObjectValue(StorageProfile, options); + } + if (Optional.IsDefined(NetworkProfile)) + { + writer.WritePropertyName("networkProfile"u8); + writer.WriteObjectValue(NetworkProfile, options); + } + if (Optional.IsDefined(SecurityProfile)) + { + writer.WritePropertyName("securityProfile"u8); + writer.WriteObjectValue(SecurityProfile, options); + } + if (Optional.IsDefined(DiagnosticsProfile)) + { + writer.WritePropertyName("diagnosticsProfile"u8); + writer.WriteObjectValue(DiagnosticsProfile, options); + } + if (Optional.IsDefined(ExtensionProfile)) + { + writer.WritePropertyName("extensionProfile"u8); + writer.WriteObjectValue(ExtensionProfile, options); + } + if (Optional.IsDefined(LicenseType)) + { + writer.WritePropertyName("licenseType"u8); + writer.WriteStringValue(LicenseType); + } + if (Optional.IsDefined(ScheduledEventsProfile)) + { + writer.WritePropertyName("scheduledEventsProfile"u8); + writer.WriteObjectValue(ScheduledEventsProfile, options); + } + if (Optional.IsDefined(UserData)) + { + writer.WritePropertyName("userData"u8); + writer.WriteStringValue(UserData); + } + if (Optional.IsDefined(CapacityReservation)) + { + writer.WritePropertyName("capacityReservation"u8); + writer.WriteObjectValue(CapacityReservation, options); + } + if (Optional.IsDefined(ApplicationProfile)) + { + writer.WritePropertyName("applicationProfile"u8); + writer.WriteObjectValue(ApplicationProfile, options); + } + if (Optional.IsDefined(HardwareProfile)) + { + writer.WritePropertyName("hardwareProfile"u8); + writer.WriteObjectValue(HardwareProfile, options); + } + if (Optional.IsDefined(ServiceArtifactReference)) + { + writer.WritePropertyName("serviceArtifactReference"u8); + JsonSerializer.Serialize(writer, ServiceArtifactReference); + } + if (Optional.IsDefined(SecurityPostureReference)) + { + writer.WritePropertyName("securityPostureReference"u8); + writer.WriteObjectValue(SecurityPostureReference, options); + } + if (options.Format != "W" && Optional.IsDefined(TimeCreated)) + { + writer.WritePropertyName("timeCreated"u8); + writer.WriteStringValue(TimeCreated.Value, "O"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BaseVirtualMachineProfile 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(BaseVirtualMachineProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBaseVirtualMachineProfile(document.RootElement, options); + } + + internal static BaseVirtualMachineProfile DeserializeBaseVirtualMachineProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VirtualMachineScaleSetOSProfile osProfile = default; + VirtualMachineScaleSetStorageProfile storageProfile = default; + VirtualMachineScaleSetNetworkProfile networkProfile = default; + SecurityProfile securityProfile = default; + DiagnosticsProfile diagnosticsProfile = default; + VirtualMachineScaleSetExtensionProfile extensionProfile = default; + string licenseType = default; + ScheduledEventsProfile scheduledEventsProfile = default; + string userData = default; + CapacityReservationProfile capacityReservation = default; + ApplicationProfile applicationProfile = default; + VirtualMachineScaleSetHardwareProfile hardwareProfile = default; + WritableSubResource serviceArtifactReference = default; + SecurityPostureReference securityPostureReference = default; + DateTimeOffset? timeCreated = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("osProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + osProfile = VirtualMachineScaleSetOSProfile.DeserializeVirtualMachineScaleSetOSProfile(property.Value, options); + continue; + } + if (property.NameEquals("storageProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + storageProfile = VirtualMachineScaleSetStorageProfile.DeserializeVirtualMachineScaleSetStorageProfile(property.Value, options); + continue; + } + if (property.NameEquals("networkProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkProfile = VirtualMachineScaleSetNetworkProfile.DeserializeVirtualMachineScaleSetNetworkProfile(property.Value, options); + continue; + } + if (property.NameEquals("securityProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityProfile = SecurityProfile.DeserializeSecurityProfile(property.Value, options); + continue; + } + if (property.NameEquals("diagnosticsProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diagnosticsProfile = DiagnosticsProfile.DeserializeDiagnosticsProfile(property.Value, options); + continue; + } + if (property.NameEquals("extensionProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + extensionProfile = VirtualMachineScaleSetExtensionProfile.DeserializeVirtualMachineScaleSetExtensionProfile(property.Value, options); + continue; + } + if (property.NameEquals("licenseType"u8)) + { + licenseType = property.Value.GetString(); + continue; + } + if (property.NameEquals("scheduledEventsProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + scheduledEventsProfile = ScheduledEventsProfile.DeserializeScheduledEventsProfile(property.Value, options); + continue; + } + if (property.NameEquals("userData"u8)) + { + userData = property.Value.GetString(); + continue; + } + if (property.NameEquals("capacityReservation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacityReservation = CapacityReservationProfile.DeserializeCapacityReservationProfile(property.Value, options); + continue; + } + if (property.NameEquals("applicationProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + applicationProfile = ApplicationProfile.DeserializeApplicationProfile(property.Value, options); + continue; + } + if (property.NameEquals("hardwareProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + hardwareProfile = VirtualMachineScaleSetHardwareProfile.DeserializeVirtualMachineScaleSetHardwareProfile(property.Value, options); + continue; + } + if (property.NameEquals("serviceArtifactReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + serviceArtifactReference = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("securityPostureReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityPostureReference = SecurityPostureReference.DeserializeSecurityPostureReference(property.Value, options); + continue; + } + if (property.NameEquals("timeCreated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeCreated = property.Value.GetDateTimeOffset("O"); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BaseVirtualMachineProfile( + osProfile, + storageProfile, + networkProfile, + securityProfile, + diagnosticsProfile, + extensionProfile, + licenseType, + scheduledEventsProfile, + userData, + capacityReservation, + applicationProfile, + hardwareProfile, + serviceArtifactReference, + securityPostureReference, + timeCreated, + 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(BaseVirtualMachineProfile)} does not support writing '{options.Format}' format."); + } + } + + BaseVirtualMachineProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBaseVirtualMachineProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BaseVirtualMachineProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.cs new file mode 100644 index 000000000000..222f0f096db2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BaseVirtualMachineProfile.cs @@ -0,0 +1,282 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes the base virtual machine profile for fleet. + public partial class BaseVirtualMachineProfile + { + /// + /// 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 BaseVirtualMachineProfile() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the operating system settings for the virtual machines in the scale + /// set. + /// + /// Specifies the storage settings for the virtual machine disks. + /// + /// Specifies properties of the network interfaces of the virtual machines in the + /// scale set. + /// + /// + /// Specifies the Security related profile settings for the virtual machines in the + /// scale set. + /// + /// Specifies the boot diagnostic settings state. + /// + /// Specifies a collection of settings for extensions installed on virtual machines + /// in the scale set. + /// + /// + /// Specifies that the image or disk that is being used was licensed on-premises. + /// <br><br> Possible values for Windows Server operating system are: <br><br> + /// Windows_Client <br><br> Windows_Server <br><br> Possible values for Linux + /// Server operating system are: <br><br> RHEL_BYOS (for RHEL) <br><br> SLES_BYOS + /// (for SUSE) <br><br> For more information, see [Azure Hybrid Use Benefit for + /// Windows + /// Server](https://docs.microsoft.com/azure/virtual-machines/windows/hybrid-use-benefit-licensing) + /// <br><br> [Azure Hybrid Use Benefit for Linux + /// Server](https://docs.microsoft.com/azure/virtual-machines/linux/azure-hybrid-benefit-linux) + /// <br><br> Minimum api-version: 2015-06-15 + /// + /// Specifies Scheduled Event related configurations. + /// + /// UserData for the virtual machines in the scale set, which must be base-64 + /// encoded. Customer should not pass any secrets in here. Minimum api-version: + /// 2021-03-01. + /// + /// + /// Specifies the capacity reservation related details of a scale set. Minimum + /// api-version: 2021-04-01. + /// + /// Specifies the gallery applications that should be made available to the VM/VMSS. + /// + /// Specifies the hardware profile related details of a scale set. Minimum + /// api-version: 2021-11-01. + /// + /// + /// Specifies the service artifact reference id used to set same image version for + /// all virtual machines in the scale set when using 'latest' image version. + /// Minimum api-version: 2022-11-01 + /// + /// + /// Specifies the security posture to be used for all virtual machines in the scale + /// set. Minimum api-version: 2023-03-01 + /// + /// + /// Specifies the time in which this VM profile for the Virtual Machine Scale Set + /// was created. Minimum API version for this property is 2023-09-01. This value + /// will be added to VMSS Flex VM tags when creating/updating the VMSS VM Profile + /// with minimum api-version 2023-09-01. Examples: "2024-07-01T00:00:01.1234567+00:00" + /// + /// Keeps track of any properties unknown to the library. + internal BaseVirtualMachineProfile(VirtualMachineScaleSetOSProfile osProfile, VirtualMachineScaleSetStorageProfile storageProfile, VirtualMachineScaleSetNetworkProfile networkProfile, SecurityProfile securityProfile, DiagnosticsProfile diagnosticsProfile, VirtualMachineScaleSetExtensionProfile extensionProfile, string licenseType, ScheduledEventsProfile scheduledEventsProfile, string userData, CapacityReservationProfile capacityReservation, ApplicationProfile applicationProfile, VirtualMachineScaleSetHardwareProfile hardwareProfile, WritableSubResource serviceArtifactReference, SecurityPostureReference securityPostureReference, DateTimeOffset? timeCreated, IDictionary serializedAdditionalRawData) + { + OSProfile = osProfile; + StorageProfile = storageProfile; + NetworkProfile = networkProfile; + SecurityProfile = securityProfile; + DiagnosticsProfile = diagnosticsProfile; + ExtensionProfile = extensionProfile; + LicenseType = licenseType; + ScheduledEventsProfile = scheduledEventsProfile; + UserData = userData; + CapacityReservation = capacityReservation; + ApplicationProfile = applicationProfile; + HardwareProfile = hardwareProfile; + ServiceArtifactReference = serviceArtifactReference; + SecurityPostureReference = securityPostureReference; + TimeCreated = timeCreated; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the operating system settings for the virtual machines in the scale + /// set. + /// + public VirtualMachineScaleSetOSProfile OSProfile { get; set; } + /// Specifies the storage settings for the virtual machine disks. + public VirtualMachineScaleSetStorageProfile StorageProfile { get; set; } + /// + /// Specifies properties of the network interfaces of the virtual machines in the + /// scale set. + /// + public VirtualMachineScaleSetNetworkProfile NetworkProfile { get; set; } + /// + /// Specifies the Security related profile settings for the virtual machines in the + /// scale set. + /// + public SecurityProfile SecurityProfile { get; set; } + /// Specifies the boot diagnostic settings state. + internal DiagnosticsProfile DiagnosticsProfile { get; set; } + /// + /// Boot Diagnostics is a debugging feature which allows you to view Console Output + /// and Screenshot to diagnose VM status. **NOTE**: If storageUri is being + /// specified then ensure that the storage account is in the same region and + /// subscription as the VM. You can easily view the output of your console log. + /// Azure also enables you to see a screenshot of the VM from the hypervisor. + /// + public BootDiagnostics BootDiagnostics + { + get => DiagnosticsProfile is null ? default : DiagnosticsProfile.BootDiagnostics; + set + { + if (DiagnosticsProfile is null) + DiagnosticsProfile = new DiagnosticsProfile(); + DiagnosticsProfile.BootDiagnostics = value; + } + } + + /// + /// Specifies a collection of settings for extensions installed on virtual machines + /// in the scale set. + /// + public VirtualMachineScaleSetExtensionProfile ExtensionProfile { get; set; } + /// + /// Specifies that the image or disk that is being used was licensed on-premises. + /// <br><br> Possible values for Windows Server operating system are: <br><br> + /// Windows_Client <br><br> Windows_Server <br><br> Possible values for Linux + /// Server operating system are: <br><br> RHEL_BYOS (for RHEL) <br><br> SLES_BYOS + /// (for SUSE) <br><br> For more information, see [Azure Hybrid Use Benefit for + /// Windows + /// Server](https://docs.microsoft.com/azure/virtual-machines/windows/hybrid-use-benefit-licensing) + /// <br><br> [Azure Hybrid Use Benefit for Linux + /// Server](https://docs.microsoft.com/azure/virtual-machines/linux/azure-hybrid-benefit-linux) + /// <br><br> Minimum api-version: 2015-06-15 + /// + public string LicenseType { get; set; } + /// Specifies Scheduled Event related configurations. + public ScheduledEventsProfile ScheduledEventsProfile { get; set; } + /// + /// UserData for the virtual machines in the scale set, which must be base-64 + /// encoded. Customer should not pass any secrets in here. Minimum api-version: + /// 2021-03-01. + /// + public string UserData { get; set; } + /// + /// Specifies the capacity reservation related details of a scale set. Minimum + /// api-version: 2021-04-01. + /// + internal CapacityReservationProfile CapacityReservation { get; set; } + /// Gets or sets Id. + public ResourceIdentifier CapacityReservationGroupId + { + get => CapacityReservation is null ? default : CapacityReservation.CapacityReservationGroupId; + set + { + if (CapacityReservation is null) + CapacityReservation = new CapacityReservationProfile(); + CapacityReservation.CapacityReservationGroupId = value; + } + } + + /// Specifies the gallery applications that should be made available to the VM/VMSS. + internal ApplicationProfile ApplicationProfile { get; set; } + /// Specifies the gallery applications that should be made available to the VM/VMSS. + public IList GalleryApplications + { + get + { + if (ApplicationProfile is null) + ApplicationProfile = new ApplicationProfile(); + return ApplicationProfile.GalleryApplications; + } + } + + /// + /// Specifies the hardware profile related details of a scale set. Minimum + /// api-version: 2021-11-01. + /// + internal VirtualMachineScaleSetHardwareProfile HardwareProfile { get; set; } + /// + /// Specifies the properties for customizing the size of the virtual machine. + /// Minimum api-version: 2021-11-01. Please follow the instructions in [VM + /// Customization](https://aka.ms/vmcustomization) for more details. + /// + public VmSizeProperties HardwareVmSizeProperties + { + get => HardwareProfile is null ? default : HardwareProfile.VmSizeProperties; + set + { + if (HardwareProfile is null) + HardwareProfile = new VirtualMachineScaleSetHardwareProfile(); + HardwareProfile.VmSizeProperties = value; + } + } + + /// + /// Specifies the service artifact reference id used to set same image version for + /// all virtual machines in the scale set when using 'latest' image version. + /// Minimum api-version: 2022-11-01 + /// + internal WritableSubResource ServiceArtifactReference { get; set; } + /// Gets or sets Id. + public ResourceIdentifier ServiceArtifactReferenceId + { + get => ServiceArtifactReference is null ? default : ServiceArtifactReference.Id; + set + { + if (ServiceArtifactReference is null) + ServiceArtifactReference = new WritableSubResource(); + ServiceArtifactReference.Id = value; + } + } + + /// + /// Specifies the security posture to be used for all virtual machines in the scale + /// set. Minimum api-version: 2023-03-01 + /// + public SecurityPostureReference SecurityPostureReference { get; set; } + /// + /// Specifies the time in which this VM profile for the Virtual Machine Scale Set + /// was created. Minimum API version for this property is 2023-09-01. This value + /// will be added to VMSS Flex VM tags when creating/updating the VMSS VM Profile + /// with minimum api-version 2023-09-01. Examples: "2024-07-01T00:00:01.1234567+00:00" + /// + public DateTimeOffset? TimeCreated { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.Serialization.cs new file mode 100644 index 000000000000..1c0a319461a6 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.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.ComputeFleet.Models +{ + public partial class BootDiagnostics : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(BootDiagnostics)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(StorageUri)) + { + writer.WritePropertyName("storageUri"u8); + writer.WriteStringValue(StorageUri); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + BootDiagnostics 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(BootDiagnostics)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeBootDiagnostics(document.RootElement, options); + } + + internal static BootDiagnostics DeserializeBootDiagnostics(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? enabled = default; + string storageUri = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("storageUri"u8)) + { + storageUri = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new BootDiagnostics(enabled, storageUri, 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(BootDiagnostics)} does not support writing '{options.Format}' format."); + } + } + + BootDiagnostics IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeBootDiagnostics(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(BootDiagnostics)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.cs new file mode 100644 index 000000000000..97b1ff9bdc61 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/BootDiagnostics.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Boot Diagnostics is a debugging feature which allows you to view Console Output + /// and Screenshot to diagnose VM status. You can easily view the output of your + /// console log. Azure also enables you to see a screenshot of the VM from the + /// hypervisor. + /// + public partial class BootDiagnostics + { + /// + /// 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 BootDiagnostics() + { + } + + /// Initializes a new instance of . + /// Whether boot diagnostics should be enabled on the Virtual Machine. + /// + /// Uri of the storage account to use for placing the console output and + /// screenshot. If storageUri is not specified while enabling boot diagnostics, + /// managed storage will be used. + /// + /// Keeps track of any properties unknown to the library. + internal BootDiagnostics(bool? enabled, string storageUri, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + StorageUri = storageUri; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Whether boot diagnostics should be enabled on the Virtual Machine. + public bool? Enabled { get; set; } + /// + /// Uri of the storage account to use for placing the console output and + /// screenshot. If storageUri is not specified while enabling boot diagnostics, + /// managed storage will be used. + /// + public string StorageUri { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CachingType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CachingType.cs new file mode 100644 index 000000000000..686bdf67e357 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CachingType.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.ComputeFleet.Models +{ + /// Specifies the caching requirements. + public readonly partial struct CachingType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CachingType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string ReadOnlyValue = "ReadOnly"; + private const string ReadWriteValue = "ReadWrite"; + + /// 'None' is default for Standard Storage. + public static CachingType None { get; } = new CachingType(NoneValue); + /// 'ReadOnly' is default for Premium Storage. + public static CachingType ReadOnly { get; } = new CachingType(ReadOnlyValue); + /// 'ReadWrite' is default for OS Disk. + public static CachingType ReadWrite { get; } = new CachingType(ReadWriteValue); + /// Determines if two values are the same. + public static bool operator ==(CachingType left, CachingType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CachingType left, CachingType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CachingType(string value) => new CachingType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CachingType other && Equals(other); + /// + public bool Equals(CachingType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.Serialization.cs new file mode 100644 index 000000000000..bea5e59707db --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + internal partial class CapacityReservationProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CapacityReservationProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(CapacityReservationGroup)) + { + writer.WritePropertyName("capacityReservationGroup"u8); + JsonSerializer.Serialize(writer, CapacityReservationGroup); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CapacityReservationProfile 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(CapacityReservationProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCapacityReservationProfile(document.RootElement, options); + } + + internal static CapacityReservationProfile DeserializeCapacityReservationProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WritableSubResource capacityReservationGroup = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("capacityReservationGroup"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacityReservationGroup = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CapacityReservationProfile(capacityReservationGroup, 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(CapacityReservationProfile)} does not support writing '{options.Format}' format."); + } + } + + CapacityReservationProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCapacityReservationProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CapacityReservationProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.cs new file mode 100644 index 000000000000..06dc7c1cedf4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/CapacityReservationProfile.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// The parameters of a capacity reservation Profile. + internal partial class CapacityReservationProfile + { + /// + /// 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 CapacityReservationProfile() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the capacity reservation group resource id that should be used for + /// allocating the virtual machine or scaleset vm instances provided enough + /// capacity has been reserved. Please refer to https://aka.ms/CapacityReservation + /// for more details. + /// + /// Keeps track of any properties unknown to the library. + internal CapacityReservationProfile(WritableSubResource capacityReservationGroup, IDictionary serializedAdditionalRawData) + { + CapacityReservationGroup = capacityReservationGroup; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the capacity reservation group resource id that should be used for + /// allocating the virtual machine or scaleset vm instances provided enough + /// capacity has been reserved. Please refer to https://aka.ms/CapacityReservation + /// for more details. + /// + internal WritableSubResource CapacityReservationGroup { get; set; } + /// Gets or sets Id. + public ResourceIdentifier CapacityReservationGroupId + { + get => CapacityReservationGroup is null ? default : CapacityReservationGroup.Id; + set + { + if (CapacityReservationGroup is null) + CapacityReservationGroup = new WritableSubResource(); + CapacityReservationGroup.Id = value; + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.Serialization.cs new file mode 100644 index 000000000000..d9f930ead3b4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class ComputeProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ComputeProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("baseVirtualMachineProfile"u8); + writer.WriteObjectValue(BaseVirtualMachineProfile, options); + if (Optional.IsDefined(ComputeApiVersion)) + { + writer.WritePropertyName("computeApiVersion"u8); + writer.WriteStringValue(ComputeApiVersion); + } + if (Optional.IsDefined(PlatformFaultDomainCount)) + { + writer.WritePropertyName("platformFaultDomainCount"u8); + writer.WriteNumberValue(PlatformFaultDomainCount.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ComputeProfile 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(ComputeProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeComputeProfile(document.RootElement, options); + } + + internal static ComputeProfile DeserializeComputeProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BaseVirtualMachineProfile baseVirtualMachineProfile = default; + string computeApiVersion = default; + int? platformFaultDomainCount = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("baseVirtualMachineProfile"u8)) + { + baseVirtualMachineProfile = BaseVirtualMachineProfile.DeserializeBaseVirtualMachineProfile(property.Value, options); + continue; + } + if (property.NameEquals("computeApiVersion"u8)) + { + computeApiVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("platformFaultDomainCount"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + platformFaultDomainCount = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ComputeProfile(baseVirtualMachineProfile, computeApiVersion, platformFaultDomainCount, 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(ComputeProfile)} does not support writing '{options.Format}' format."); + } + } + + ComputeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeComputeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ComputeProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.cs new file mode 100644 index 000000000000..6e440bd8e19a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ComputeProfile.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Compute Profile to use for running user's workloads. + public partial class ComputeProfile + { + /// + /// 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 . + /// Base Virtual Machine Profile Properties to be specified according to "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile". + /// is null. + public ComputeProfile(BaseVirtualMachineProfile baseVirtualMachineProfile) + { + Argument.AssertNotNull(baseVirtualMachineProfile, nameof(baseVirtualMachineProfile)); + + BaseVirtualMachineProfile = baseVirtualMachineProfile; + } + + /// Initializes a new instance of . + /// Base Virtual Machine Profile Properties to be specified according to "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile". + /// + /// Specifies the Microsoft.Compute API version to use when creating underlying Virtual Machine scale sets and Virtual Machines. + /// The default value will be the latest supported computeApiVersion by Compute Fleet. + /// + /// + /// Specifies the number of fault domains to use when creating the underlying VMSS. + /// A fault domain is a logical group of hardware within an Azure datacenter. + /// VMs in the same fault domain share a common power source and network switch. + /// If not specified, defaults to 1, which represents "Max Spreading" (using as many fault domains as possible). + /// This property cannot be updated. + /// + /// Keeps track of any properties unknown to the library. + internal ComputeProfile(BaseVirtualMachineProfile baseVirtualMachineProfile, string computeApiVersion, int? platformFaultDomainCount, IDictionary serializedAdditionalRawData) + { + BaseVirtualMachineProfile = baseVirtualMachineProfile; + ComputeApiVersion = computeApiVersion; + PlatformFaultDomainCount = platformFaultDomainCount; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ComputeProfile() + { + } + + /// Base Virtual Machine Profile Properties to be specified according to "specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/{computeApiVersion}/virtualMachineScaleSet.json#/definitions/VirtualMachineScaleSetVMProfile". + public BaseVirtualMachineProfile BaseVirtualMachineProfile { get; set; } + /// + /// Specifies the Microsoft.Compute API version to use when creating underlying Virtual Machine scale sets and Virtual Machines. + /// The default value will be the latest supported computeApiVersion by Compute Fleet. + /// + public string ComputeApiVersion { get; set; } + /// + /// Specifies the number of fault domains to use when creating the underlying VMSS. + /// A fault domain is a logical group of hardware within an Azure datacenter. + /// VMs in the same fault domain share a common power source and network switch. + /// If not specified, defaults to 1, which represents "Max Spreading" (using as many fault domains as possible). + /// This property cannot be updated. + /// + public int? PlatformFaultDomainCount { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DeleteOption.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DeleteOption.cs new file mode 100644 index 000000000000..cd8654db86df --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DeleteOption.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.ComputeFleet.Models +{ + /// Specify what happens to the network interface when the VM is deleted. + public readonly partial struct DeleteOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DeleteOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DeleteValue = "Delete"; + private const string DetachValue = "Detach"; + + /// Delete Option. + public static DeleteOption Delete { get; } = new DeleteOption(DeleteValue); + /// Detach Option. + public static DeleteOption Detach { get; } = new DeleteOption(DetachValue); + /// Determines if two values are the same. + public static bool operator ==(DeleteOption left, DeleteOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DeleteOption left, DeleteOption right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DeleteOption(string value) => new DeleteOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DeleteOption other && Equals(other); + /// + public bool Equals(DeleteOption 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.Serialization.cs new file mode 100644 index 000000000000..1bbb04601e8d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + internal partial class DiagnosticsProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiagnosticsProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(BootDiagnostics)) + { + writer.WritePropertyName("bootDiagnostics"u8); + writer.WriteObjectValue(BootDiagnostics, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DiagnosticsProfile 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(DiagnosticsProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiagnosticsProfile(document.RootElement, options); + } + + internal static DiagnosticsProfile DeserializeDiagnosticsProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + BootDiagnostics bootDiagnostics = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("bootDiagnostics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bootDiagnostics = BootDiagnostics.DeserializeBootDiagnostics(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DiagnosticsProfile(bootDiagnostics, 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(DiagnosticsProfile)} does not support writing '{options.Format}' format."); + } + } + + DiagnosticsProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDiagnosticsProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiagnosticsProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.cs new file mode 100644 index 000000000000..1bfa6124f2cb --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiagnosticsProfile.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.ComputeFleet.Models +{ + /// Specifies the boot diagnostic settings state. Minimum api-version: 2015-06-15. + internal partial class DiagnosticsProfile + { + /// + /// 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 DiagnosticsProfile() + { + } + + /// Initializes a new instance of . + /// + /// Boot Diagnostics is a debugging feature which allows you to view Console Output + /// and Screenshot to diagnose VM status. **NOTE**: If storageUri is being + /// specified then ensure that the storage account is in the same region and + /// subscription as the VM. You can easily view the output of your console log. + /// Azure also enables you to see a screenshot of the VM from the hypervisor. + /// + /// Keeps track of any properties unknown to the library. + internal DiagnosticsProfile(BootDiagnostics bootDiagnostics, IDictionary serializedAdditionalRawData) + { + BootDiagnostics = bootDiagnostics; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Boot Diagnostics is a debugging feature which allows you to view Console Output + /// and Screenshot to diagnose VM status. **NOTE**: If storageUri is being + /// specified then ensure that the storage account is in the same region and + /// subscription as the VM. You can easily view the output of your console log. + /// Azure also enables you to see a screenshot of the VM from the hypervisor. + /// + public BootDiagnostics BootDiagnostics { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskOption.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskOption.cs new file mode 100644 index 000000000000..0af149a3a2ee --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskOption.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies the ephemeral disk option for operating system disk. + public readonly partial struct DiffDiskOption : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiffDiskOption(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LocalValue = "Local"; + + /// Local Option. + public static DiffDiskOption Local { get; } = new DiffDiskOption(LocalValue); + /// Determines if two values are the same. + public static bool operator ==(DiffDiskOption left, DiffDiskOption right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiffDiskOption left, DiffDiskOption right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DiffDiskOption(string value) => new DiffDiskOption(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiffDiskOption other && Equals(other); + /// + public bool Equals(DiffDiskOption 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskPlacement.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskPlacement.cs new file mode 100644 index 000000000000..bdf67c7ec656 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskPlacement.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the ephemeral disk placement for operating system disk. This property + /// can be used by user in the request to choose the location i.e, cache disk or + /// resource disk space for Ephemeral OS disk provisioning. For more information on + /// Ephemeral OS disk size requirements, please refer Ephemeral OS disk size + /// requirements for Windows VM at + /// https://docs.microsoft.com/azure/virtual-machines/windows/ephemeral-os-disks#size-requirements + /// and Linux VM at + /// https://docs.microsoft.com/azure/virtual-machines/linux/ephemeral-os-disks#size-requirements + /// Minimum api-version for NvmeDisk: 2024-03-01. + /// + public readonly partial struct DiffDiskPlacement : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiffDiskPlacement(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CacheDiskValue = "CacheDisk"; + private const string ResourceDiskValue = "ResourceDisk"; + private const string NvmeDiskValue = "NvmeDisk"; + + /// CacheDisk option. + public static DiffDiskPlacement CacheDisk { get; } = new DiffDiskPlacement(CacheDiskValue); + /// Resource Disk option. + public static DiffDiskPlacement ResourceDisk { get; } = new DiffDiskPlacement(ResourceDiskValue); + /// NvmeDisk option. + public static DiffDiskPlacement NvmeDisk { get; } = new DiffDiskPlacement(NvmeDiskValue); + /// Determines if two values are the same. + public static bool operator ==(DiffDiskPlacement left, DiffDiskPlacement right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiffDiskPlacement left, DiffDiskPlacement right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DiffDiskPlacement(string value) => new DiffDiskPlacement(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiffDiskPlacement other && Equals(other); + /// + public bool Equals(DiffDiskPlacement 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.Serialization.cs new file mode 100644 index 000000000000..0c98648aae2d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class DiffDiskSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DiffDiskSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Option)) + { + writer.WritePropertyName("option"u8); + writer.WriteStringValue(Option.Value.ToString()); + } + if (Optional.IsDefined(Placement)) + { + writer.WritePropertyName("placement"u8); + writer.WriteStringValue(Placement.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DiffDiskSettings 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(DiffDiskSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDiffDiskSettings(document.RootElement, options); + } + + internal static DiffDiskSettings DeserializeDiffDiskSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DiffDiskOption? option = default; + DiffDiskPlacement? placement = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("option"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + option = new DiffDiskOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("placement"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + placement = new DiffDiskPlacement(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DiffDiskSettings(option, placement, 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(DiffDiskSettings)} does not support writing '{options.Format}' format."); + } + } + + DiffDiskSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDiffDiskSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DiffDiskSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.cs new file mode 100644 index 000000000000..d16fc88909f3 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiffDiskSettings.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.ComputeFleet.Models +{ + /// + /// Describes the parameters of ephemeral disk settings that can be specified for + /// operating system disk. **Note:** The ephemeral disk settings can only be + /// specified for managed disk. + /// + public partial class DiffDiskSettings + { + /// + /// 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 DiffDiskSettings() + { + } + + /// Initializes a new instance of . + /// Specifies the ephemeral disk settings for operating system disk. + /// + /// Specifies the ephemeral disk placement for operating system disk. Possible + /// values are: **CacheDisk,** **ResourceDisk.** The defaulting behavior is: + /// **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** + /// is used. Refer to the VM size documentation for Windows VM at + /// https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at + /// https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM + /// sizes exposes a cache disk. + /// + /// Keeps track of any properties unknown to the library. + internal DiffDiskSettings(DiffDiskOption? option, DiffDiskPlacement? placement, IDictionary serializedAdditionalRawData) + { + Option = option; + Placement = placement; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the ephemeral disk settings for operating system disk. + public DiffDiskOption? Option { get; set; } + /// + /// Specifies the ephemeral disk placement for operating system disk. Possible + /// values are: **CacheDisk,** **ResourceDisk.** The defaulting behavior is: + /// **CacheDisk** if one is configured for the VM size otherwise **ResourceDisk** + /// is used. Refer to the VM size documentation for Windows VM at + /// https://docs.microsoft.com/azure/virtual-machines/windows/sizes and Linux VM at + /// https://docs.microsoft.com/azure/virtual-machines/linux/sizes to check which VM + /// sizes exposes a cache disk. + /// + public DiffDiskPlacement? Placement { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskControllerType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskControllerType.cs new file mode 100644 index 000000000000..a5ca74d3da85 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskControllerType.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the disk controller type configured for the VM and + /// VirtualMachineScaleSet. This property is only supported for virtual machines + /// whose operating system disk and VM sku supports Generation 2 + /// (https://docs.microsoft.com/en-us/azure/virtual-machines/generation-2), please + /// check the HyperVGenerations capability returned as part of VM sku capabilities + /// in the response of Microsoft.Compute SKUs api for the region contains V2 + /// (https://docs.microsoft.com/rest/api/compute/resourceskus/list). For more + /// information about Disk Controller Types supported please refer to + /// https://aka.ms/azure-diskcontrollertypes. + /// + public readonly partial struct DiskControllerType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiskControllerType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string SCSIValue = "SCSI"; + private const string NVMeValue = "NVMe"; + + /// SCSI disk type. + public static DiskControllerType SCSI { get; } = new DiskControllerType(SCSIValue); + /// NVMe disk type. + public static DiskControllerType NVMe { get; } = new DiskControllerType(NVMeValue); + /// Determines if two values are the same. + public static bool operator ==(DiskControllerType left, DiskControllerType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiskControllerType left, DiskControllerType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DiskControllerType(string value) => new DiskControllerType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiskControllerType other && Equals(other); + /// + public bool Equals(DiskControllerType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskCreateOptionType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskCreateOptionType.cs new file mode 100644 index 000000000000..112abfb24642 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskCreateOptionType.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies how the virtual machine should be created. + public readonly partial struct DiskCreateOptionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiskCreateOptionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FromImageValue = "FromImage"; + private const string EmptyValue = "Empty"; + private const string AttachValue = "Attach"; + private const string CopyValue = "Copy"; + private const string RestoreValue = "Restore"; + + /// + /// This value is used when you are using an image to create the virtual machine. + /// If you are using a platform image, you also use the imageReference element + /// described above. If you are using a marketplace image, you also use the + /// plan element previously described. + /// + public static DiskCreateOptionType FromImage { get; } = new DiskCreateOptionType(FromImageValue); + /// This value is used when creating an empty data disk. + public static DiskCreateOptionType Empty { get; } = new DiskCreateOptionType(EmptyValue); + /// This value is used when you are using a specialized disk to create the virtual machine. + public static DiskCreateOptionType Attach { get; } = new DiskCreateOptionType(AttachValue); + /// This value is used to create a data disk from a snapshot or another disk. + public static DiskCreateOptionType Copy { get; } = new DiskCreateOptionType(CopyValue); + /// This value is used to create a data disk from a disk restore point. + public static DiskCreateOptionType Restore { get; } = new DiskCreateOptionType(RestoreValue); + /// Determines if two values are the same. + public static bool operator ==(DiskCreateOptionType left, DiskCreateOptionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiskCreateOptionType left, DiskCreateOptionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DiskCreateOptionType(string value) => new DiskCreateOptionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiskCreateOptionType other && Equals(other); + /// + public bool Equals(DiskCreateOptionType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskDeleteOptionType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskDeleteOptionType.cs new file mode 100644 index 000000000000..14e229c96700 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DiskDeleteOptionType.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.ComputeFleet.Models +{ + /// + /// Specifies the behavior of the managed disk when the VM gets deleted, for + /// example whether the managed disk is deleted or detached. Supported values are: + /// **Delete.** If this value is used, the managed disk is deleted when VM gets + /// deleted. **Detach.** If this value is used, the managed disk is retained after + /// VM gets deleted. Minimum api-version: 2021-03-01. + /// + public readonly partial struct DiskDeleteOptionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DiskDeleteOptionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DeleteValue = "Delete"; + private const string DetachValue = "Detach"; + + /// If this value is used, the managed disk is deleted when VM gets deleted. + public static DiskDeleteOptionType Delete { get; } = new DiskDeleteOptionType(DeleteValue); + /// If this value is used, the managed disk is retained after VM gets deleted. + public static DiskDeleteOptionType Detach { get; } = new DiskDeleteOptionType(DetachValue); + /// Determines if two values are the same. + public static bool operator ==(DiskDeleteOptionType left, DiskDeleteOptionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DiskDeleteOptionType left, DiskDeleteOptionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DiskDeleteOptionType(string value) => new DiskDeleteOptionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DiskDeleteOptionType other && Equals(other); + /// + public bool Equals(DiskDeleteOptionType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DomainNameLabelScopeType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DomainNameLabelScopeType.cs new file mode 100644 index 000000000000..9d9724682b7d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/DomainNameLabelScopeType.cs @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// The Domain name label scope.The concatenation of the hashed domain name label + /// that generated according to the policy from domain name label scope and vm + /// index will be the domain name labels of the PublicIPAddress resources that will + /// be created + /// + public readonly partial struct DomainNameLabelScopeType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DomainNameLabelScopeType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TenantReuseValue = "TenantReuse"; + private const string SubscriptionReuseValue = "SubscriptionReuse"; + private const string ResourceGroupReuseValue = "ResourceGroupReuse"; + private const string NoReuseValue = "NoReuse"; + + /// TenantReuse type. + public static DomainNameLabelScopeType TenantReuse { get; } = new DomainNameLabelScopeType(TenantReuseValue); + /// SubscriptionReuse type. + public static DomainNameLabelScopeType SubscriptionReuse { get; } = new DomainNameLabelScopeType(SubscriptionReuseValue); + /// ResourceGroupReuse type. + public static DomainNameLabelScopeType ResourceGroupReuse { get; } = new DomainNameLabelScopeType(ResourceGroupReuseValue); + /// NoReuse type. + public static DomainNameLabelScopeType NoReuse { get; } = new DomainNameLabelScopeType(NoReuseValue); + /// Determines if two values are the same. + public static bool operator ==(DomainNameLabelScopeType left, DomainNameLabelScopeType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DomainNameLabelScopeType left, DomainNameLabelScopeType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DomainNameLabelScopeType(string value) => new DomainNameLabelScopeType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DomainNameLabelScopeType other && Equals(other); + /// + public bool Equals(DomainNameLabelScopeType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.Serialization.cs new file mode 100644 index 000000000000..c327308014ef --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + internal partial class EncryptionIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(EncryptionIdentity)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(UserAssignedIdentityResourceId)) + { + writer.WritePropertyName("userAssignedIdentityResourceId"u8); + writer.WriteStringValue(UserAssignedIdentityResourceId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + EncryptionIdentity 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(EncryptionIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEncryptionIdentity(document.RootElement, options); + } + + internal static EncryptionIdentity DeserializeEncryptionIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier userAssignedIdentityResourceId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("userAssignedIdentityResourceId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + userAssignedIdentityResourceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new EncryptionIdentity(userAssignedIdentityResourceId, 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(EncryptionIdentity)} does not support writing '{options.Format}' format."); + } + } + + EncryptionIdentity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEncryptionIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(EncryptionIdentity)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.cs new file mode 100644 index 000000000000..33c12d17ced7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EncryptionIdentity.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; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the Managed Identity used by ADE to get access token for keyvault + /// operations. + /// + internal partial class EncryptionIdentity + { + /// + /// 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 EncryptionIdentity() + { + } + + /// Initializes a new instance of . + /// Specifies ARM Resource ID of one of the user identities associated with the VM. + /// Keeps track of any properties unknown to the library. + internal EncryptionIdentity(ResourceIdentifier userAssignedIdentityResourceId, IDictionary serializedAdditionalRawData) + { + UserAssignedIdentityResourceId = userAssignedIdentityResourceId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies ARM Resource ID of one of the user identities associated with the VM. + public ResourceIdentifier UserAssignedIdentityResourceId { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EvictionPolicy.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EvictionPolicy.cs new file mode 100644 index 000000000000..8f638180bf24 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/EvictionPolicy.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.ComputeFleet.Models +{ + /// Different kind of eviction policies. + public readonly partial struct EvictionPolicy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public EvictionPolicy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DeleteValue = "Delete"; + private const string DeallocateValue = "Deallocate"; + + /// When evicted, the Spot VM will be deleted and the corresponding capacity will be updated to reflect this. + public static EvictionPolicy Delete { get; } = new EvictionPolicy(DeleteValue); + /// When evicted, the Spot VM will be deallocated/stopped. + public static EvictionPolicy Deallocate { get; } = new EvictionPolicy(DeallocateValue); + /// Determines if two values are the same. + public static bool operator ==(EvictionPolicy left, EvictionPolicy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(EvictionPolicy left, EvictionPolicy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator EvictionPolicy(string value) => new EvictionPolicy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is EvictionPolicy other && Equals(other); + /// + public bool Equals(EvictionPolicy 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.Serialization.cs new file mode 100644 index 000000000000..ff4eb9880764 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.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.ComputeFleet.Models +{ + internal partial class FleetListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FleetListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FleetListResult 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(FleetListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFleetListResult(document.RootElement, options); + } + + internal static FleetListResult DeserializeFleetListResult(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(FleetData.DeserializeFleetData(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 FleetListResult(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(FleetListResult)} does not support writing '{options.Format}' format."); + } + } + + FleetListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFleetListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FleetListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.cs new file mode 100644 index 000000000000..42abe90d3ec5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetListResult.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.ComputeFleet.Models +{ + /// The response of a Fleet list operation. + internal partial class FleetListResult + { + /// + /// 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 Fleet items on this page. + /// is null. + internal FleetListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Fleet items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal FleetListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FleetListResult() + { + } + + /// The Fleet items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.Serialization.cs new file mode 100644 index 000000000000..bfa7cacbb3e5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.Serialization.cs @@ -0,0 +1,183 @@ +// 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.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class FleetPatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FleetPatch)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStartObject(); + foreach (var item in Tags) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(Identity)) + { + writer.WritePropertyName("identity"u8); + writer.WriteObjectValue(Identity, options); + } + if (Optional.IsDefined(Plan)) + { + writer.WritePropertyName("plan"u8); + JsonSerializer.Serialize(writer, Plan); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FleetPatch 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(FleetPatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFleetPatch(document.RootElement, options); + } + + internal static FleetPatch DeserializeFleetPatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IDictionary tags = default; + ManagedServiceIdentityUpdate identity = default; + ArmPlan plan = default; + FleetProperties properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + tags = dictionary; + continue; + } + if (property.NameEquals("identity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + identity = ManagedServiceIdentityUpdate.DeserializeManagedServiceIdentityUpdate(property.Value, options); + continue; + } + if (property.NameEquals("plan"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + plan = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = FleetProperties.DeserializeFleetProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FleetPatch(tags ?? new ChangeTrackingDictionary(), identity, plan, 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(FleetPatch)} does not support writing '{options.Format}' format."); + } + } + + FleetPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFleetPatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FleetPatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.cs new file mode 100644 index 000000000000..990bdc9c24e2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetPatch.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Fleet Update Model. + public partial class FleetPatch + { + /// + /// 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 FleetPatch() + { + Tags = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Resource tags. + /// Updatable managed service identity. + /// Updatable resource plan. + /// RP-specific updatable properties. + /// Keeps track of any properties unknown to the library. + internal FleetPatch(IDictionary tags, ManagedServiceIdentityUpdate identity, ArmPlan plan, FleetProperties properties, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Identity = identity; + Plan = plan; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource tags. + public IDictionary Tags { get; } + /// Updatable managed service identity. + public ManagedServiceIdentityUpdate Identity { get; set; } + /// Updatable resource plan. + public ArmPlan Plan { get; set; } + /// RP-specific updatable properties. + public FleetProperties Properties { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.Serialization.cs new file mode 100644 index 000000000000..87130bc3d34a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class FleetProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FleetProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState.Value.ToString()); + } + if (Optional.IsDefined(SpotPriorityProfile)) + { + writer.WritePropertyName("spotPriorityProfile"u8); + writer.WriteObjectValue(SpotPriorityProfile, options); + } + if (Optional.IsDefined(RegularPriorityProfile)) + { + writer.WritePropertyName("regularPriorityProfile"u8); + writer.WriteObjectValue(RegularPriorityProfile, options); + } + writer.WritePropertyName("vmSizesProfile"u8); + writer.WriteStartArray(); + foreach (var item in VmSizesProfile) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("computeProfile"u8); + writer.WriteObjectValue(ComputeProfile, options); + if (options.Format != "W" && Optional.IsDefined(TimeCreated)) + { + writer.WritePropertyName("timeCreated"u8); + writer.WriteStringValue(TimeCreated.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(UniqueId)) + { + writer.WritePropertyName("uniqueId"u8); + writer.WriteStringValue(UniqueId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FleetProperties 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(FleetProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFleetProperties(document.RootElement, options); + } + + internal static FleetProperties DeserializeFleetProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProvisioningState? provisioningState = default; + SpotPriorityProfile spotPriorityProfile = default; + RegularPriorityProfile regularPriorityProfile = default; + IList vmSizesProfile = default; + ComputeProfile computeProfile = default; + DateTimeOffset? timeCreated = default; + string uniqueId = 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("spotPriorityProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + spotPriorityProfile = SpotPriorityProfile.DeserializeSpotPriorityProfile(property.Value, options); + continue; + } + if (property.NameEquals("regularPriorityProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + regularPriorityProfile = RegularPriorityProfile.DeserializeRegularPriorityProfile(property.Value, options); + continue; + } + if (property.NameEquals("vmSizesProfile"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VmSizeProfile.DeserializeVmSizeProfile(item, options)); + } + vmSizesProfile = array; + continue; + } + if (property.NameEquals("computeProfile"u8)) + { + computeProfile = ComputeProfile.DeserializeComputeProfile(property.Value, options); + continue; + } + if (property.NameEquals("timeCreated"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timeCreated = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("uniqueId"u8)) + { + uniqueId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FleetProperties( + provisioningState, + spotPriorityProfile, + regularPriorityProfile, + vmSizesProfile, + computeProfile, + timeCreated, + uniqueId, + 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(FleetProperties)} does not support writing '{options.Format}' format."); + } + } + + FleetProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFleetProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FleetProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.cs new file mode 100644 index 000000000000..235b0db123f7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/FleetProperties.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Details of the Compute Fleet. + public partial class FleetProperties + { + /// + /// 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 . + /// List of VM sizes supported for Compute Fleet. + /// Compute Profile to use for running user's workloads. + /// or is null. + public FleetProperties(IEnumerable vmSizesProfile, ComputeProfile computeProfile) + { + Argument.AssertNotNull(vmSizesProfile, nameof(vmSizesProfile)); + Argument.AssertNotNull(computeProfile, nameof(computeProfile)); + + VmSizesProfile = vmSizesProfile.ToList(); + ComputeProfile = computeProfile; + } + + /// Initializes a new instance of . + /// The status of the last operation. + /// Configuration Options for Spot instances in Compute Fleet. + /// Configuration Options for Regular instances in Compute Fleet. + /// List of VM sizes supported for Compute Fleet. + /// Compute Profile to use for running user's workloads. + /// Specifies the time at which the Compute Fleet is created. + /// Specifies the ID which uniquely identifies a Compute Fleet. + /// Keeps track of any properties unknown to the library. + internal FleetProperties(ProvisioningState? provisioningState, SpotPriorityProfile spotPriorityProfile, RegularPriorityProfile regularPriorityProfile, IList vmSizesProfile, ComputeProfile computeProfile, DateTimeOffset? timeCreated, string uniqueId, IDictionary serializedAdditionalRawData) + { + ProvisioningState = provisioningState; + SpotPriorityProfile = spotPriorityProfile; + RegularPriorityProfile = regularPriorityProfile; + VmSizesProfile = vmSizesProfile; + ComputeProfile = computeProfile; + TimeCreated = timeCreated; + UniqueId = uniqueId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FleetProperties() + { + } + + /// The status of the last operation. + public ProvisioningState? ProvisioningState { get; } + /// Configuration Options for Spot instances in Compute Fleet. + public SpotPriorityProfile SpotPriorityProfile { get; set; } + /// Configuration Options for Regular instances in Compute Fleet. + public RegularPriorityProfile RegularPriorityProfile { get; set; } + /// List of VM sizes supported for Compute Fleet. + public IList VmSizesProfile { get; } + /// Compute Profile to use for running user's workloads. + public ComputeProfile ComputeProfile { get; set; } + /// Specifies the time at which the Compute Fleet is created. + public DateTimeOffset? TimeCreated { get; } + /// Specifies the ID which uniquely identifies a Compute Fleet. + public string UniqueId { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/IPVersion.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/IPVersion.cs new file mode 100644 index 000000000000..393f0f5143b2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/IPVersion.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Available from Api-Version 2017-03-30 onwards, it represents whether the + /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible + /// values are: 'IPv4' and 'IPv6'. + /// + public readonly partial struct IPVersion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IPVersion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string IPv4Value = "IPv4"; + private const string IPv6Value = "IPv6"; + + /// IPv4 version. + public static IPVersion IPv4 { get; } = new IPVersion(IPv4Value); + /// IPv6 version. + public static IPVersion IPv6 { get; } = new IPVersion(IPv6Value); + /// Determines if two values are the same. + public static bool operator ==(IPVersion left, IPVersion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IPVersion left, IPVersion right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator IPVersion(string value) => new IPVersion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IPVersion other && Equals(other); + /// + public bool Equals(IPVersion 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.Serialization.cs new file mode 100644 index 000000000000..f10613c864dd --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.Serialization.cs @@ -0,0 +1,212 @@ +// 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.ComputeFleet.Models +{ + public partial class ImageReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageReference)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Publisher)) + { + writer.WritePropertyName("publisher"u8); + writer.WriteStringValue(Publisher); + } + if (Optional.IsDefined(Offer)) + { + writer.WritePropertyName("offer"u8); + writer.WriteStringValue(Offer); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteStringValue(Sku); + } + if (Optional.IsDefined(Version)) + { + writer.WritePropertyName("version"u8); + writer.WriteStringValue(Version); + } + if (options.Format != "W" && Optional.IsDefined(ExactVersion)) + { + writer.WritePropertyName("exactVersion"u8); + writer.WriteStringValue(ExactVersion); + } + if (Optional.IsDefined(SharedGalleryImageId)) + { + writer.WritePropertyName("sharedGalleryImageId"u8); + writer.WriteStringValue(SharedGalleryImageId); + } + if (Optional.IsDefined(CommunityGalleryImageId)) + { + writer.WritePropertyName("communityGalleryImageId"u8); + writer.WriteStringValue(CommunityGalleryImageId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ImageReference 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(ImageReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageReference(document.RootElement, options); + } + + internal static ImageReference DeserializeImageReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string publisher = default; + string offer = default; + string sku = default; + string version = default; + string exactVersion = default; + string sharedGalleryImageId = default; + string communityGalleryImageId = 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 = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("publisher"u8)) + { + publisher = property.Value.GetString(); + continue; + } + if (property.NameEquals("offer"u8)) + { + offer = property.Value.GetString(); + continue; + } + if (property.NameEquals("sku"u8)) + { + sku = property.Value.GetString(); + continue; + } + if (property.NameEquals("version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("exactVersion"u8)) + { + exactVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("sharedGalleryImageId"u8)) + { + sharedGalleryImageId = property.Value.GetString(); + continue; + } + if (property.NameEquals("communityGalleryImageId"u8)) + { + communityGalleryImageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ImageReference( + id, + publisher, + offer, + sku, + version, + exactVersion, + sharedGalleryImageId, + communityGalleryImageId, + 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(ImageReference)} does not support writing '{options.Format}' format."); + } + } + + ImageReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeImageReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.cs new file mode 100644 index 000000000000..708e70212104 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ImageReference.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies information about the image to use. You can specify information about + /// platform images, marketplace images, or virtual machine images. This element is + /// required when you want to use a platform image, marketplace image, or virtual + /// machine image, but is not used in other creation operations. NOTE: Image + /// reference publisher and offer can only be set when you create the scale set. + /// + public partial class ImageReference + { + /// + /// 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 ImageReference() + { + } + + /// Initializes a new instance of . + /// Resource Id. + /// The image publisher. + /// + /// Specifies the offer of the platform image or marketplace image used to create + /// the virtual machine. + /// + /// The image SKU. + /// + /// Specifies the version of the platform image or marketplace image used to create + /// the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. + /// Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest + /// version of an image available at deploy time. Even if you use 'latest', the VM + /// image will not automatically update after deploy time even if a new version + /// becomes available. Please do not use field 'version' for gallery image + /// deployment, gallery image should always use 'id' field for deployment, to use 'latest' + /// version of gallery image, just set + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' + /// in the 'id' field without version input. + /// + /// + /// Specifies in decimal numbers, the version of platform image or marketplace + /// image used to create the virtual machine. This readonly field differs from 'version', + /// only if the value specified in 'version' field is 'latest'. + /// + /// + /// Specified the shared gallery image unique id for vm deployment. This can be + /// fetched from shared gallery image GET call. + /// + /// + /// Specified the community gallery image unique id for vm deployment. This can be + /// fetched from community gallery image GET call. + /// + /// Keeps track of any properties unknown to the library. + internal ImageReference(ResourceIdentifier id, string publisher, string offer, string sku, string version, string exactVersion, string sharedGalleryImageId, string communityGalleryImageId, IDictionary serializedAdditionalRawData) + { + Id = id; + Publisher = publisher; + Offer = offer; + Sku = sku; + Version = version; + ExactVersion = exactVersion; + SharedGalleryImageId = sharedGalleryImageId; + CommunityGalleryImageId = communityGalleryImageId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Id. + public ResourceIdentifier Id { get; set; } + /// The image publisher. + public string Publisher { get; set; } + /// + /// Specifies the offer of the platform image or marketplace image used to create + /// the virtual machine. + /// + public string Offer { get; set; } + /// The image SKU. + public string Sku { get; set; } + /// + /// Specifies the version of the platform image or marketplace image used to create + /// the virtual machine. The allowed formats are Major.Minor.Build or 'latest'. + /// Major, Minor, and Build are decimal numbers. Specify 'latest' to use the latest + /// version of an image available at deploy time. Even if you use 'latest', the VM + /// image will not automatically update after deploy time even if a new version + /// becomes available. Please do not use field 'version' for gallery image + /// deployment, gallery image should always use 'id' field for deployment, to use 'latest' + /// version of gallery image, just set + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}' + /// in the 'id' field without version input. + /// + public string Version { get; set; } + /// + /// Specifies in decimal numbers, the version of platform image or marketplace + /// image used to create the virtual machine. This readonly field differs from 'version', + /// only if the value specified in 'version' field is 'latest'. + /// + public string ExactVersion { get; } + /// + /// Specified the shared gallery image unique id for vm deployment. This can be + /// fetched from shared gallery image GET call. + /// + public string SharedGalleryImageId { get; set; } + /// + /// Specified the community gallery image unique id for vm deployment. This can be + /// fetched from community gallery image GET call. + /// + public string CommunityGalleryImageId { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.Serialization.cs new file mode 100644 index 000000000000..e7d2f96d0145 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.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.ComputeFleet.Models +{ + public partial class InnerError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(InnerError)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ExceptionType)) + { + writer.WritePropertyName("exceptionType"u8); + writer.WriteStringValue(ExceptionType); + } + if (Optional.IsDefined(ErrorDetail)) + { + writer.WritePropertyName("errorDetail"u8); + writer.WriteStringValue(ErrorDetail); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + InnerError 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(InnerError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeInnerError(document.RootElement, options); + } + + internal static InnerError DeserializeInnerError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string exceptionType = default; + string errorDetail = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("exceptionType"u8)) + { + exceptionType = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorDetail"u8)) + { + errorDetail = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new InnerError(exceptionType, errorDetail, 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(InnerError)} does not support writing '{options.Format}' format."); + } + } + + InnerError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeInnerError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(InnerError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.cs new file mode 100644 index 000000000000..46708237ef1c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/InnerError.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.ComputeFleet.Models +{ + /// Inner error details. + public partial class InnerError + { + /// + /// 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 InnerError() + { + } + + /// Initializes a new instance of . + /// The exception type. + /// The internal error message or exception dump. + /// Keeps track of any properties unknown to the library. + internal InnerError(string exceptionType, string errorDetail, IDictionary serializedAdditionalRawData) + { + ExceptionType = exceptionType; + ErrorDetail = errorDetail; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The exception type. + public string ExceptionType { get; } + /// The internal error message or exception dump. + public string ErrorDetail { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.Serialization.cs new file mode 100644 index 000000000000..28aa4b6e21fa --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.Serialization.cs @@ -0,0 +1,128 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class KeyVaultSecretReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyVaultSecretReference)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("secretUrl"u8); + writer.WriteStringValue(KeyVaultSecretReferenci); + writer.WritePropertyName("sourceVault"u8); + JsonSerializer.Serialize(writer, SourceVault); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyVaultSecretReference 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(KeyVaultSecretReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyVaultSecretReference(document.RootElement, options); + } + + internal static KeyVaultSecretReference DeserializeKeyVaultSecretReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string secretUrl = default; + WritableSubResource sourceVault = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("secretUrl"u8)) + { + secretUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("sourceVault"u8)) + { + sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyVaultSecretReference(secretUrl, sourceVault, 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(KeyVaultSecretReference)} does not support writing '{options.Format}' format."); + } + } + + KeyVaultSecretReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyVaultSecretReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyVaultSecretReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.cs new file mode 100644 index 000000000000..2e0a358579bd --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/KeyVaultSecretReference.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a reference to Key Vault Secret. + public partial class KeyVaultSecretReference + { + /// + /// 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 URL referencing a secret in a Key Vault. + /// The relative URL of the Key Vault containing the secret. + /// or is null. + public KeyVaultSecretReference(string keyVaultSecretReferenci, WritableSubResource sourceVault) + { + Argument.AssertNotNull(keyVaultSecretReferenci, nameof(keyVaultSecretReferenci)); + Argument.AssertNotNull(sourceVault, nameof(sourceVault)); + + KeyVaultSecretReferenci = keyVaultSecretReferenci; + SourceVault = sourceVault; + } + + /// Initializes a new instance of . + /// The URL referencing a secret in a Key Vault. + /// The relative URL of the Key Vault containing the secret. + /// Keeps track of any properties unknown to the library. + internal KeyVaultSecretReference(string keyVaultSecretReferenci, WritableSubResource sourceVault, IDictionary serializedAdditionalRawData) + { + KeyVaultSecretReferenci = keyVaultSecretReferenci; + SourceVault = sourceVault; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KeyVaultSecretReference() + { + } + + /// The URL referencing a secret in a Key Vault. + public string KeyVaultSecretReferenci { get; set; } + /// The relative URL of the Key Vault containing the secret. + internal WritableSubResource SourceVault { get; set; } + /// Gets or sets Id. + public ResourceIdentifier SourceVaultId + { + get => SourceVault is null ? default : SourceVault.Id; + set + { + if (SourceVault is null) + SourceVault = new WritableSubResource(); + SourceVault.Id = value; + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.Serialization.cs new file mode 100644 index 000000000000..d39f4db0f4b8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.Serialization.cs @@ -0,0 +1,192 @@ +// 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.ComputeFleet.Models +{ + public partial class LinuxConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LinuxConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(DisablePasswordAuthentication)) + { + writer.WritePropertyName("disablePasswordAuthentication"u8); + writer.WriteBooleanValue(DisablePasswordAuthentication.Value); + } + if (Optional.IsDefined(Ssh)) + { + writer.WritePropertyName("ssh"u8); + writer.WriteObjectValue(Ssh, options); + } + if (Optional.IsDefined(ProvisionVmAgent)) + { + writer.WritePropertyName("provisionVMAgent"u8); + writer.WriteBooleanValue(ProvisionVmAgent.Value); + } + if (Optional.IsDefined(PatchSettings)) + { + writer.WritePropertyName("patchSettings"u8); + writer.WriteObjectValue(PatchSettings, options); + } + if (Optional.IsDefined(EnableVmAgentPlatformUpdates)) + { + writer.WritePropertyName("enableVMAgentPlatformUpdates"u8); + writer.WriteBooleanValue(EnableVmAgentPlatformUpdates.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LinuxConfiguration 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(LinuxConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLinuxConfiguration(document.RootElement, options); + } + + internal static LinuxConfiguration DeserializeLinuxConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? disablePasswordAuthentication = default; + SshConfiguration ssh = default; + bool? provisionVmAgent = default; + LinuxPatchSettings patchSettings = default; + bool? enableVmAgentPlatformUpdates = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("disablePasswordAuthentication"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + disablePasswordAuthentication = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("ssh"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + ssh = SshConfiguration.DeserializeSshConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("provisionVMAgent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisionVmAgent = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("patchSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + patchSettings = LinuxPatchSettings.DeserializeLinuxPatchSettings(property.Value, options); + continue; + } + if (property.NameEquals("enableVMAgentPlatformUpdates"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableVmAgentPlatformUpdates = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LinuxConfiguration( + disablePasswordAuthentication, + ssh, + provisionVmAgent, + patchSettings, + enableVmAgentPlatformUpdates, + 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(LinuxConfiguration)} does not support writing '{options.Format}' format."); + } + } + + LinuxConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLinuxConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LinuxConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.cs new file mode 100644 index 000000000000..2161f5b10fe2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxConfiguration.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the Linux operating system settings on the virtual machine. For a + /// list of supported Linux distributions, see [Linux on Azure-Endorsed + /// Distributions](https://docs.microsoft.com/azure/virtual-machines/linux/endorsed-distros). + /// + public partial class LinuxConfiguration + { + /// + /// 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 LinuxConfiguration() + { + } + + /// Initializes a new instance of . + /// Specifies whether password authentication should be disabled. + /// Specifies the ssh key configuration for a Linux OS. + /// + /// Indicates whether virtual machine agent should be provisioned on the virtual + /// machine. When this property is not specified in the request body, default + /// behavior is to set it to true. This will ensure that VM Agent is installed on + /// the VM so that extensions can be added to the VM later. + /// + /// [Preview Feature] Specifies settings related to VM Guest Patching on Linux. + /// + /// Indicates whether VMAgent Platform Updates is enabled for the Linux virtual + /// machine. Default value is false. + /// + /// Keeps track of any properties unknown to the library. + internal LinuxConfiguration(bool? disablePasswordAuthentication, SshConfiguration ssh, bool? provisionVmAgent, LinuxPatchSettings patchSettings, bool? enableVmAgentPlatformUpdates, IDictionary serializedAdditionalRawData) + { + DisablePasswordAuthentication = disablePasswordAuthentication; + Ssh = ssh; + ProvisionVmAgent = provisionVmAgent; + PatchSettings = patchSettings; + EnableVmAgentPlatformUpdates = enableVmAgentPlatformUpdates; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies whether password authentication should be disabled. + public bool? DisablePasswordAuthentication { get; set; } + /// Specifies the ssh key configuration for a Linux OS. + internal SshConfiguration Ssh { get; set; } + /// The list of SSH public keys used to authenticate with linux based VMs. + public IList SshPublicKeys + { + get + { + if (Ssh is null) + Ssh = new SshConfiguration(); + return Ssh.PublicKeys; + } + } + + /// + /// Indicates whether virtual machine agent should be provisioned on the virtual + /// machine. When this property is not specified in the request body, default + /// behavior is to set it to true. This will ensure that VM Agent is installed on + /// the VM so that extensions can be added to the VM later. + /// + public bool? ProvisionVmAgent { get; set; } + /// [Preview Feature] Specifies settings related to VM Guest Patching on Linux. + public LinuxPatchSettings PatchSettings { get; set; } + /// + /// Indicates whether VMAgent Platform Updates is enabled for the Linux virtual + /// machine. Default value is false. + /// + public bool? EnableVmAgentPlatformUpdates { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchAssessmentMode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchAssessmentMode.cs new file mode 100644 index 000000000000..72c3b1f91fb7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchAssessmentMode.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.ComputeFleet.Models +{ + /// + /// Specifies the mode of VM Guest Patch Assessment for the IaaS virtual + /// machine.

Possible values are:

**ImageDefault** - You + /// control the timing of patch assessments on a virtual machine.

+ /// **AutomaticByPlatform** - The platform will trigger periodic patch assessments. + /// The property provisionVMAgent must be true. + ///
+ public readonly partial struct LinuxPatchAssessmentMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LinuxPatchAssessmentMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImageDefaultValue = "ImageDefault"; + private const string AutomaticByPlatformValue = "AutomaticByPlatform"; + + /// You control the timing of patch assessments on a virtual machine. + public static LinuxPatchAssessmentMode ImageDefault { get; } = new LinuxPatchAssessmentMode(ImageDefaultValue); + /// The platform will trigger periodic patch assessments.The property provisionVMAgent must be true. + public static LinuxPatchAssessmentMode AutomaticByPlatform { get; } = new LinuxPatchAssessmentMode(AutomaticByPlatformValue); + /// Determines if two values are the same. + public static bool operator ==(LinuxPatchAssessmentMode left, LinuxPatchAssessmentMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LinuxPatchAssessmentMode left, LinuxPatchAssessmentMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator LinuxPatchAssessmentMode(string value) => new LinuxPatchAssessmentMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LinuxPatchAssessmentMode other && Equals(other); + /// + public bool Equals(LinuxPatchAssessmentMode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.Serialization.cs new file mode 100644 index 000000000000..ea5c2c9ceff2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class LinuxPatchSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LinuxPatchSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PatchMode)) + { + writer.WritePropertyName("patchMode"u8); + writer.WriteStringValue(PatchMode.Value.ToString()); + } + if (Optional.IsDefined(AssessmentMode)) + { + writer.WritePropertyName("assessmentMode"u8); + writer.WriteStringValue(AssessmentMode.Value.ToString()); + } + if (Optional.IsDefined(AutomaticByPlatformSettings)) + { + writer.WritePropertyName("automaticByPlatformSettings"u8); + writer.WriteObjectValue(AutomaticByPlatformSettings, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LinuxPatchSettings 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(LinuxPatchSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLinuxPatchSettings(document.RootElement, options); + } + + internal static LinuxPatchSettings DeserializeLinuxPatchSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LinuxVmGuestPatchMode? patchMode = default; + LinuxPatchAssessmentMode? assessmentMode = default; + LinuxVmGuestPatchAutomaticByPlatformSettings automaticByPlatformSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("patchMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + patchMode = new LinuxVmGuestPatchMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("assessmentMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + assessmentMode = new LinuxPatchAssessmentMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("automaticByPlatformSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + automaticByPlatformSettings = LinuxVmGuestPatchAutomaticByPlatformSettings.DeserializeLinuxVmGuestPatchAutomaticByPlatformSettings(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LinuxPatchSettings(patchMode, assessmentMode, automaticByPlatformSettings, 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(LinuxPatchSettings)} does not support writing '{options.Format}' format."); + } + } + + LinuxPatchSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLinuxPatchSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LinuxPatchSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.cs new file mode 100644 index 000000000000..f46770baa270 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxPatchSettings.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.ComputeFleet.Models +{ + /// Specifies settings related to VM Guest Patching on Linux. + public partial class LinuxPatchSettings + { + /// + /// 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 LinuxPatchSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - The + /// virtual machine's default patching configuration is used. <br /><br /> + /// **AutomaticByPlatform** - The virtual machine will be automatically updated by + /// the platform. The property provisionVMAgent must be true + /// + /// + /// Specifies the mode of VM Guest Patch Assessment for the IaaS virtual + /// machine.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - You + /// control the timing of patch assessments on a virtual machine. <br /><br /> + /// **AutomaticByPlatform** - The platform will trigger periodic patch assessments. + /// The property provisionVMAgent must be true. + /// + /// + /// Specifies additional settings for patch mode AutomaticByPlatform in VM Guest + /// Patching on Linux. + /// + /// Keeps track of any properties unknown to the library. + internal LinuxPatchSettings(LinuxVmGuestPatchMode? patchMode, LinuxPatchAssessmentMode? assessmentMode, LinuxVmGuestPatchAutomaticByPlatformSettings automaticByPlatformSettings, IDictionary serializedAdditionalRawData) + { + PatchMode = patchMode; + AssessmentMode = assessmentMode; + AutomaticByPlatformSettings = automaticByPlatformSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - The + /// virtual machine's default patching configuration is used. <br /><br /> + /// **AutomaticByPlatform** - The virtual machine will be automatically updated by + /// the platform. The property provisionVMAgent must be true + /// + public LinuxVmGuestPatchMode? PatchMode { get; set; } + /// + /// Specifies the mode of VM Guest Patch Assessment for the IaaS virtual + /// machine.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - You + /// control the timing of patch assessments on a virtual machine. <br /><br /> + /// **AutomaticByPlatform** - The platform will trigger periodic patch assessments. + /// The property provisionVMAgent must be true. + /// + public LinuxPatchAssessmentMode? AssessmentMode { get; set; } + /// + /// Specifies additional settings for patch mode AutomaticByPlatform in VM Guest + /// Patching on Linux. + /// + public LinuxVmGuestPatchAutomaticByPlatformSettings AutomaticByPlatformSettings { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformRebootSetting.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformRebootSetting.cs new file mode 100644 index 000000000000..dedbc674ead4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformRebootSetting.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.ComputeFleet.Models +{ + /// + /// Specifies the reboot setting for all AutomaticByPlatform patch installation + /// operations. + /// + public readonly partial struct LinuxVmGuestPatchAutomaticByPlatformRebootSetting : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LinuxVmGuestPatchAutomaticByPlatformRebootSetting(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string IfRequiredValue = "IfRequired"; + private const string NeverValue = "Never"; + private const string AlwaysValue = "Always"; + + /// Unknown Reboot setting. + public static LinuxVmGuestPatchAutomaticByPlatformRebootSetting Unknown { get; } = new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(UnknownValue); + /// IfRequired Reboot setting. + public static LinuxVmGuestPatchAutomaticByPlatformRebootSetting IfRequired { get; } = new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(IfRequiredValue); + /// Never Reboot setting. + public static LinuxVmGuestPatchAutomaticByPlatformRebootSetting Never { get; } = new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(NeverValue); + /// Always Reboot setting. + public static LinuxVmGuestPatchAutomaticByPlatformRebootSetting Always { get; } = new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(AlwaysValue); + /// Determines if two values are the same. + public static bool operator ==(LinuxVmGuestPatchAutomaticByPlatformRebootSetting left, LinuxVmGuestPatchAutomaticByPlatformRebootSetting right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LinuxVmGuestPatchAutomaticByPlatformRebootSetting left, LinuxVmGuestPatchAutomaticByPlatformRebootSetting right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator LinuxVmGuestPatchAutomaticByPlatformRebootSetting(string value) => new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LinuxVmGuestPatchAutomaticByPlatformRebootSetting other && Equals(other); + /// + public bool Equals(LinuxVmGuestPatchAutomaticByPlatformRebootSetting 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.Serialization.cs new file mode 100644 index 000000000000..5e9bf73dc10f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class LinuxVmGuestPatchAutomaticByPlatformSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LinuxVmGuestPatchAutomaticByPlatformSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(RebootSetting)) + { + writer.WritePropertyName("rebootSetting"u8); + writer.WriteStringValue(RebootSetting.Value.ToString()); + } + if (Optional.IsDefined(BypassPlatformSafetyChecksOnUserSchedule)) + { + writer.WritePropertyName("bypassPlatformSafetyChecksOnUserSchedule"u8); + writer.WriteBooleanValue(BypassPlatformSafetyChecksOnUserSchedule.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + LinuxVmGuestPatchAutomaticByPlatformSettings 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(LinuxVmGuestPatchAutomaticByPlatformSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLinuxVmGuestPatchAutomaticByPlatformSettings(document.RootElement, options); + } + + internal static LinuxVmGuestPatchAutomaticByPlatformSettings DeserializeLinuxVmGuestPatchAutomaticByPlatformSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + LinuxVmGuestPatchAutomaticByPlatformRebootSetting? rebootSetting = default; + bool? bypassPlatformSafetyChecksOnUserSchedule = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rebootSetting"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rebootSetting = new LinuxVmGuestPatchAutomaticByPlatformRebootSetting(property.Value.GetString()); + continue; + } + if (property.NameEquals("bypassPlatformSafetyChecksOnUserSchedule"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bypassPlatformSafetyChecksOnUserSchedule = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LinuxVmGuestPatchAutomaticByPlatformSettings(rebootSetting, bypassPlatformSafetyChecksOnUserSchedule, 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(LinuxVmGuestPatchAutomaticByPlatformSettings)} does not support writing '{options.Format}' format."); + } + } + + LinuxVmGuestPatchAutomaticByPlatformSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeLinuxVmGuestPatchAutomaticByPlatformSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LinuxVmGuestPatchAutomaticByPlatformSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.cs new file mode 100644 index 000000000000..6fc3de401996 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchAutomaticByPlatformSettings.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.ComputeFleet.Models +{ + /// + /// Specifies additional settings to be applied when patch mode AutomaticByPlatform + /// is selected in Linux patch settings. + /// + public partial class LinuxVmGuestPatchAutomaticByPlatformSettings + { + /// + /// 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 LinuxVmGuestPatchAutomaticByPlatformSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the reboot setting for all AutomaticByPlatform patch installation + /// operations. + /// + /// Enables customer to schedule patching without accidental upgrades. + /// Keeps track of any properties unknown to the library. + internal LinuxVmGuestPatchAutomaticByPlatformSettings(LinuxVmGuestPatchAutomaticByPlatformRebootSetting? rebootSetting, bool? bypassPlatformSafetyChecksOnUserSchedule, IDictionary serializedAdditionalRawData) + { + RebootSetting = rebootSetting; + BypassPlatformSafetyChecksOnUserSchedule = bypassPlatformSafetyChecksOnUserSchedule; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the reboot setting for all AutomaticByPlatform patch installation + /// operations. + /// + public LinuxVmGuestPatchAutomaticByPlatformRebootSetting? RebootSetting { get; set; } + /// Enables customer to schedule patching without accidental upgrades. + public bool? BypassPlatformSafetyChecksOnUserSchedule { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchMode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchMode.cs new file mode 100644 index 000000000000..f96d7beab67b --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/LinuxVmGuestPatchMode.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible. + /// + public readonly partial struct LinuxVmGuestPatchMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LinuxVmGuestPatchMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImageDefaultValue = "ImageDefault"; + private const string AutomaticByPlatformValue = "AutomaticByPlatform"; + + /// The virtual machine's default patching configuration is used. + public static LinuxVmGuestPatchMode ImageDefault { get; } = new LinuxVmGuestPatchMode(ImageDefaultValue); + /// The virtual machine will be automatically updated by the platform. The property provisionVMAgent must be true. + public static LinuxVmGuestPatchMode AutomaticByPlatform { get; } = new LinuxVmGuestPatchMode(AutomaticByPlatformValue); + /// Determines if two values are the same. + public static bool operator ==(LinuxVmGuestPatchMode left, LinuxVmGuestPatchMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LinuxVmGuestPatchMode left, LinuxVmGuestPatchMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator LinuxVmGuestPatchMode(string value) => new LinuxVmGuestPatchMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LinuxVmGuestPatchMode other && Equals(other); + /// + public bool Equals(LinuxVmGuestPatchMode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.Serialization.cs new file mode 100644 index 000000000000..5fdee0d579ad --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.Serialization.cs @@ -0,0 +1,176 @@ +// 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.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class ManagedServiceIdentity : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedServiceIdentity)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(PrincipalId)) + { + writer.WritePropertyName("principalId"u8); + writer.WriteStringValue(PrincipalId.Value); + } + if (options.Format != "W" && Optional.IsDefined(TenantId)) + { + writer.WritePropertyName("tenantId"u8); + writer.WriteStringValue(TenantId.Value); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"u8); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + JsonSerializer.Serialize(writer, item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedServiceIdentity 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(ManagedServiceIdentity)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedServiceIdentity(document.RootElement, options); + } + + internal static ManagedServiceIdentity DeserializeManagedServiceIdentity(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Guid? principalId = default; + Guid? tenantId = default; + ManagedServiceIdentityType type = default; + IDictionary userAssignedIdentities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("principalId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + principalId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("tenantId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tenantId = property.Value.GetGuid(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new ManagedServiceIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("userAssignedIdentities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + } + userAssignedIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedServiceIdentity(principalId, tenantId, type, userAssignedIdentities ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentity)} does not support writing '{options.Format}' format."); + } + } + + ManagedServiceIdentity IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedServiceIdentity(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentity)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.cs new file mode 100644 index 000000000000..2dd040739822 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentity.cs @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Managed service identity (system assigned and/or user assigned identities). + public partial class ManagedServiceIdentity + { + /// + /// 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 type of managed identity assigned to this resource. + public ManagedServiceIdentity(ManagedServiceIdentityType type) + { + Type = type; + UserAssignedIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + /// The type of managed identity assigned to this resource. + /// The identities assigned to this resource by the user. + /// Keeps track of any properties unknown to the library. + internal ManagedServiceIdentity(Guid? principalId, Guid? tenantId, ManagedServiceIdentityType type, IDictionary userAssignedIdentities, IDictionary serializedAdditionalRawData) + { + PrincipalId = principalId; + TenantId = tenantId; + Type = type; + UserAssignedIdentities = userAssignedIdentities; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ManagedServiceIdentity() + { + } + + /// The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. + public Guid? PrincipalId { get; } + /// The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + public Guid? TenantId { get; } + /// The type of managed identity assigned to this resource. + public ManagedServiceIdentityType Type { get; set; } + /// The identities assigned to this resource by the user. + public IDictionary UserAssignedIdentities { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityType.cs new file mode 100644 index 000000000000..18b8518d7087 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityType.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.ComputeFleet.Models +{ + /// Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + public readonly partial struct ManagedServiceIdentityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ManagedServiceIdentityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string SystemAssignedValue = "SystemAssigned"; + private const string UserAssignedValue = "UserAssigned"; + private const string SystemAndUserAssignedValue = "SystemAssigned,UserAssigned"; + + /// No managed identity. + public static ManagedServiceIdentityType None { get; } = new ManagedServiceIdentityType(NoneValue); + /// System assigned managed identity. + public static ManagedServiceIdentityType SystemAssigned { get; } = new ManagedServiceIdentityType(SystemAssignedValue); + /// User assigned managed identity. + public static ManagedServiceIdentityType UserAssigned { get; } = new ManagedServiceIdentityType(UserAssignedValue); + /// System and user assigned managed identity. + public static ManagedServiceIdentityType SystemAndUserAssigned { get; } = new ManagedServiceIdentityType(SystemAndUserAssignedValue); + /// Determines if two values are the same. + public static bool operator ==(ManagedServiceIdentityType left, ManagedServiceIdentityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ManagedServiceIdentityType left, ManagedServiceIdentityType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ManagedServiceIdentityType(string value) => new ManagedServiceIdentityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ManagedServiceIdentityType other && Equals(other); + /// + public bool Equals(ManagedServiceIdentityType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.Serialization.cs new file mode 100644 index 000000000000..9c36f9d4dda3 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.Serialization.cs @@ -0,0 +1,153 @@ +// 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.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class ManagedServiceIdentityUpdate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ManagedServiceIdentityUpdate)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsCollectionDefined(UserAssignedIdentities)) + { + writer.WritePropertyName("userAssignedIdentities"u8); + writer.WriteStartObject(); + foreach (var item in UserAssignedIdentities) + { + writer.WritePropertyName(item.Key); + JsonSerializer.Serialize(writer, item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ManagedServiceIdentityUpdate 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(ManagedServiceIdentityUpdate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeManagedServiceIdentityUpdate(document.RootElement, options); + } + + internal static ManagedServiceIdentityUpdate DeserializeManagedServiceIdentityUpdate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ManagedServiceIdentityType? type = default; + IDictionary userAssignedIdentities = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ManagedServiceIdentityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("userAssignedIdentities"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + } + userAssignedIdentities = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ManagedServiceIdentityUpdate(type, userAssignedIdentities ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentityUpdate)} does not support writing '{options.Format}' format."); + } + } + + ManagedServiceIdentityUpdate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeManagedServiceIdentityUpdate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ManagedServiceIdentityUpdate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.cs new file mode 100644 index 000000000000..edbb8b34dad4 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ManagedServiceIdentityUpdate.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// The template for adding optional properties. + public partial class ManagedServiceIdentityUpdate + { + /// + /// 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 ManagedServiceIdentityUpdate() + { + UserAssignedIdentities = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The type of managed identity assigned to this resource. + /// The identities assigned to this resource by the user. + /// Keeps track of any properties unknown to the library. + internal ManagedServiceIdentityUpdate(ManagedServiceIdentityType? type, IDictionary userAssignedIdentities, IDictionary serializedAdditionalRawData) + { + Type = type; + UserAssignedIdentities = userAssignedIdentities; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The type of managed identity assigned to this resource. + public ManagedServiceIdentityType? Type { get; set; } + /// The identities assigned to this resource by the user. + public IDictionary UserAssignedIdentities { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Mode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Mode.cs new file mode 100644 index 000000000000..c910e8b91c38 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Mode.cs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the mode that ProxyAgent will execute on if the feature is enabled. + /// ProxyAgent will start to audit or monitor but not enforce access control over + /// requests to host endpoints in Audit mode, while in Enforce mode it will enforce + /// access control. The default value is Enforce mode. + /// + public readonly partial struct Mode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Mode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AuditValue = "Audit"; + private const string EnforceValue = "Enforce"; + + /// Audit Mode. + public static Mode Audit { get; } = new Mode(AuditValue); + /// Enforce Mode. + public static Mode Enforce { get; } = new Mode(EnforceValue); + /// Determines if two values are the same. + public static bool operator ==(Mode left, Mode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Mode left, Mode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Mode(string value) => new Mode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Mode other && Equals(other); + /// + public bool Equals(Mode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkApiVersion.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkApiVersion.cs new file mode 100644 index 000000000000..70c5277c62ac --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkApiVersion.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// specifies the Microsoft.Network API version used when creating networking + /// resources in the Network Interface Configurations for Virtual Machine Scale Set + /// with orchestration mode 'Flexible' + /// + public readonly partial struct NetworkApiVersion : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NetworkApiVersion(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string _20201101Value = "2020-11-01"; + + /// Initial version supported. Later versions are supported as well. + public static NetworkApiVersion _20201101 { get; } = new NetworkApiVersion(_20201101Value); + /// Determines if two values are the same. + public static bool operator ==(NetworkApiVersion left, NetworkApiVersion right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NetworkApiVersion left, NetworkApiVersion right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator NetworkApiVersion(string value) => new NetworkApiVersion(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NetworkApiVersion other && Equals(other); + /// + public bool Equals(NetworkApiVersion 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliaryMode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliaryMode.cs new file mode 100644 index 000000000000..9a53d5589683 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliaryMode.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.ComputeFleet.Models +{ + /// + /// Specifies whether the Auxiliary mode is enabled for the Network Interface + /// resource. + /// + public readonly partial struct NetworkInterfaceAuxiliaryMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NetworkInterfaceAuxiliaryMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string AcceleratedConnectionsValue = "AcceleratedConnections"; + private const string FloatingValue = "Floating"; + + /// None Mode. + public static NetworkInterfaceAuxiliaryMode None { get; } = new NetworkInterfaceAuxiliaryMode(NoneValue); + /// AcceleratedConnections Mode. + public static NetworkInterfaceAuxiliaryMode AcceleratedConnections { get; } = new NetworkInterfaceAuxiliaryMode(AcceleratedConnectionsValue); + /// Floating Mode. + public static NetworkInterfaceAuxiliaryMode Floating { get; } = new NetworkInterfaceAuxiliaryMode(FloatingValue); + /// Determines if two values are the same. + public static bool operator ==(NetworkInterfaceAuxiliaryMode left, NetworkInterfaceAuxiliaryMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NetworkInterfaceAuxiliaryMode left, NetworkInterfaceAuxiliaryMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator NetworkInterfaceAuxiliaryMode(string value) => new NetworkInterfaceAuxiliaryMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NetworkInterfaceAuxiliaryMode other && Equals(other); + /// + public bool Equals(NetworkInterfaceAuxiliaryMode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliarySku.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliarySku.cs new file mode 100644 index 000000000000..187328038e05 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/NetworkInterfaceAuxiliarySku.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.ComputeFleet.Models +{ + /// + /// Specifies whether the Auxiliary sku is enabled for the Network Interface + /// resource. + /// + public readonly partial struct NetworkInterfaceAuxiliarySku : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public NetworkInterfaceAuxiliarySku(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "None"; + private const string A1Value = "A1"; + private const string A2Value = "A2"; + private const string A4Value = "A4"; + private const string A8Value = "A8"; + + /// no sku. + public static NetworkInterfaceAuxiliarySku None { get; } = new NetworkInterfaceAuxiliarySku(NoneValue); + /// A1 sku. + public static NetworkInterfaceAuxiliarySku A1 { get; } = new NetworkInterfaceAuxiliarySku(A1Value); + /// A2 sku. + public static NetworkInterfaceAuxiliarySku A2 { get; } = new NetworkInterfaceAuxiliarySku(A2Value); + /// A4 sku. + public static NetworkInterfaceAuxiliarySku A4 { get; } = new NetworkInterfaceAuxiliarySku(A4Value); + /// A8 sku. + public static NetworkInterfaceAuxiliarySku A8 { get; } = new NetworkInterfaceAuxiliarySku(A8Value); + /// Determines if two values are the same. + public static bool operator ==(NetworkInterfaceAuxiliarySku left, NetworkInterfaceAuxiliarySku right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(NetworkInterfaceAuxiliarySku left, NetworkInterfaceAuxiliarySku right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator NetworkInterfaceAuxiliarySku(string value) => new NetworkInterfaceAuxiliarySku(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is NetworkInterfaceAuxiliarySku other && Equals(other); + /// + public bool Equals(NetworkInterfaceAuxiliarySku 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.Serialization.cs new file mode 100644 index 000000000000..4c580e734118 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.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.ComputeFleet.Models +{ + public partial class OSImageNotificationProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OSImageNotificationProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NotBeforeTimeout)) + { + writer.WritePropertyName("notBeforeTimeout"u8); + writer.WriteStringValue(NotBeforeTimeout); + } + if (Optional.IsDefined(Enable)) + { + writer.WritePropertyName("enable"u8); + writer.WriteBooleanValue(Enable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OSImageNotificationProfile 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(OSImageNotificationProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOSImageNotificationProfile(document.RootElement, options); + } + + internal static OSImageNotificationProfile DeserializeOSImageNotificationProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string notBeforeTimeout = default; + bool? enable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("notBeforeTimeout"u8)) + { + notBeforeTimeout = property.Value.GetString(); + continue; + } + if (property.NameEquals("enable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OSImageNotificationProfile(notBeforeTimeout, enable, 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(OSImageNotificationProfile)} does not support writing '{options.Format}' format."); + } + } + + OSImageNotificationProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOSImageNotificationProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OSImageNotificationProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.cs new file mode 100644 index 000000000000..13f0eb2e6924 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OSImageNotificationProfile.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies OS Image Scheduled Event related configurations. + public partial class OSImageNotificationProfile + { + /// + /// 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 OSImageNotificationProfile() + { + } + + /// Initializes a new instance of . + /// + /// Length of time a Virtual Machine being reimaged or having its OS upgraded will + /// have to potentially approve the OS Image Scheduled Event before the event is + /// auto approved (timed out). The configuration is specified in ISO 8601 format, + /// and the value must not exceed 15 minutes (PT15M) + /// + /// Specifies whether the OS Image Scheduled event is enabled or disabled. + /// Keeps track of any properties unknown to the library. + internal OSImageNotificationProfile(string notBeforeTimeout, bool? enable, IDictionary serializedAdditionalRawData) + { + NotBeforeTimeout = notBeforeTimeout; + Enable = enable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Length of time a Virtual Machine being reimaged or having its OS upgraded will + /// have to potentially approve the OS Image Scheduled Event before the event is + /// auto approved (timed out). The configuration is specified in ISO 8601 format, + /// and the value must not exceed 15 minutes (PT15M) + /// + public string NotBeforeTimeout { get; set; } + /// Specifies whether the OS Image Scheduled event is enabled or disabled. + public bool? Enable { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperatingSystemType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperatingSystemType.cs new file mode 100644 index 000000000000..fc13a7e6fbcf --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperatingSystemType.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// This property allows you to specify the type of the OS that is included in the + /// disk if creating a VM from user-image or a specialized VHD. Possible values + /// are: **Windows,** **Linux.** + /// + public readonly partial struct OperatingSystemType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OperatingSystemType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string WindowsValue = "Windows"; + private const string LinuxValue = "Linux"; + + /// Windows OS type. + public static OperatingSystemType Windows { get; } = new OperatingSystemType(WindowsValue); + /// Linux OS type. + public static OperatingSystemType Linux { get; } = new OperatingSystemType(LinuxValue); + /// Determines if two values are the same. + public static bool operator ==(OperatingSystemType left, OperatingSystemType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OperatingSystemType left, OperatingSystemType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OperatingSystemType(string value) => new OperatingSystemType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OperatingSystemType other && Equals(other); + /// + public bool Equals(OperatingSystemType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.Serialization.cs new file mode 100644 index 000000000000..16f39acf6c39 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.Serialization.cs @@ -0,0 +1,188 @@ +// 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.ComputeFleet.Models +{ + public partial class Operation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Operation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(IsDataAction)) + { + writer.WritePropertyName("isDataAction"u8); + writer.WriteBooleanValue(IsDataAction.Value); + } + if (options.Format != "W" && Optional.IsDefined(Display)) + { + writer.WritePropertyName("display"u8); + writer.WriteObjectValue(Display, options); + } + if (options.Format != "W" && Optional.IsDefined(Origin)) + { + writer.WritePropertyName("origin"u8); + writer.WriteStringValue(Origin.Value.ToString()); + } + if (Optional.IsDefined(ActionType)) + { + writer.WritePropertyName("actionType"u8); + writer.WriteStringValue(ActionType.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Operation 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(Operation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperation(document.RootElement, options); + } + + internal static Operation DeserializeOperation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + bool? isDataAction = default; + OperationDisplay display = default; + Origin? origin = default; + ActionType? actionType = 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("isDataAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isDataAction = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("display"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + display = OperationDisplay.DeserializeOperationDisplay(property.Value, options); + continue; + } + if (property.NameEquals("origin"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + origin = new Origin(property.Value.GetString()); + continue; + } + if (property.NameEquals("actionType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actionType = new ActionType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Operation( + name, + isDataAction, + display, + origin, + actionType, + 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(Operation)} does not support writing '{options.Format}' format."); + } + } + + Operation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOperation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Operation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..f109f6f1917b --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Operation.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.ComputeFleet.Models +{ + /// Details of a REST API operation, returned from the Resource Provider Operations API. + public partial class Operation + { + /// + /// 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 Operation() + { + } + + /// Initializes a new instance of . + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + /// Localized display information for this particular operation. + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + /// Keeps track of any properties unknown to the library. + internal Operation(string name, bool? isDataAction, OperationDisplay display, Origin? origin, ActionType? actionType, IDictionary serializedAdditionalRawData) + { + Name = name; + IsDataAction = isDataAction; + Display = display; + Origin = origin; + ActionType = actionType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + public string Name { get; } + /// Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure Resource Manager/control-plane operations. + public bool? IsDataAction { get; } + /// Localized display information for this particular operation. + public OperationDisplay Display { get; } + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + public Origin? Origin { get; } + /// Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + public ActionType? ActionType { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.Serialization.cs new file mode 100644 index 000000000000..c479e75cf723 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.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.ComputeFleet.Models +{ + public partial class OperationDisplay : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationDisplay)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + if (options.Format != "W" && Optional.IsDefined(Resource)) + { + writer.WritePropertyName("resource"u8); + writer.WriteStringValue(Resource); + } + if (options.Format != "W" && Optional.IsDefined(Operation)) + { + writer.WritePropertyName("operation"u8); + writer.WriteStringValue(Operation); + } + if (options.Format != "W" && Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationDisplay 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(OperationDisplay)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationDisplay(document.RootElement, options); + } + + internal static OperationDisplay DeserializeOperationDisplay(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string provider = default; + string resource = default; + string operation = default; + string description = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("resource"u8)) + { + resource = property.Value.GetString(); + continue; + } + if (property.NameEquals("operation"u8)) + { + operation = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OperationDisplay(provider, resource, operation, description, 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(OperationDisplay)} does not support writing '{options.Format}' format."); + } + } + + OperationDisplay IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOperationDisplay(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationDisplay)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..4a58aa77fb97 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationDisplay.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.ComputeFleet.Models +{ + /// Localized display information for and operation. + public partial class OperationDisplay + { + /// + /// 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 OperationDisplay() + { + } + + /// Initializes a new instance of . + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + /// Keeps track of any properties unknown to the library. + internal OperationDisplay(string provider, string resource, string operation, string description, IDictionary serializedAdditionalRawData) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + public string Provider { get; } + /// The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + public string Resource { get; } + /// The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + public string Operation { get; } + /// The short, localized friendly description of the operation; suitable for tool tips and detailed views. + public string Description { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.Serialization.cs new file mode 100644 index 000000000000..5bb155d6cdaa --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.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.ComputeFleet.Models +{ + internal partial class OperationListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OperationListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + OperationListResult 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(OperationListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOperationListResult(document.RootElement, options); + } + + internal static OperationListResult DeserializeOperationListResult(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(Operation.DeserializeOperation(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 OperationListResult(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(OperationListResult)} does not support writing '{options.Format}' format."); + } + } + + OperationListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeOperationListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OperationListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.cs new file mode 100644 index 000000000000..73beee51a305 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/OperationListResult.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.ComputeFleet.Models +{ + /// A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + internal partial class OperationListResult + { + /// + /// 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 Operation items on this page. + /// is null. + internal OperationListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The Operation items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal OperationListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal OperationListResult() + { + } + + /// The Operation items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Origin.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Origin.cs new file mode 100644 index 000000000000..16fd792a3d62 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/Origin.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.ComputeFleet.Models +{ + /// The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system". + public readonly partial struct Origin : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public Origin(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UserValue = "user"; + private const string SystemValue = "system"; + private const string UserSystemValue = "user,system"; + + /// Indicates the operation is initiated by a user. + public static Origin User { get; } = new Origin(UserValue); + /// Indicates the operation is initiated by a system. + public static Origin System { get; } = new Origin(SystemValue); + /// Indicates the operation is initiated by a user or system. + public static Origin UserSystem { get; } = new Origin(UserSystemValue); + /// Determines if two values are the same. + public static bool operator ==(Origin left, Origin right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(Origin left, Origin right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator Origin(string value) => new Origin(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is Origin other && Equals(other); + /// + public bool Equals(Origin 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.Serialization.cs new file mode 100644 index 000000000000..b4eea7c97066 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class PatchSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PatchSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(PatchMode)) + { + writer.WritePropertyName("patchMode"u8); + writer.WriteStringValue(PatchMode.Value.ToString()); + } + if (Optional.IsDefined(EnableHotpatching)) + { + writer.WritePropertyName("enableHotpatching"u8); + writer.WriteBooleanValue(EnableHotpatching.Value); + } + if (Optional.IsDefined(AssessmentMode)) + { + writer.WritePropertyName("assessmentMode"u8); + writer.WriteStringValue(AssessmentMode.Value.ToString()); + } + if (Optional.IsDefined(AutomaticByPlatformSettings)) + { + writer.WritePropertyName("automaticByPlatformSettings"u8); + writer.WriteObjectValue(AutomaticByPlatformSettings, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PatchSettings 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(PatchSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePatchSettings(document.RootElement, options); + } + + internal static PatchSettings DeserializePatchSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WindowsVmGuestPatchMode? patchMode = default; + bool? enableHotpatching = default; + WindowsPatchAssessmentMode? assessmentMode = default; + WindowsVmGuestPatchAutomaticByPlatformSettings automaticByPlatformSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("patchMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + patchMode = new WindowsVmGuestPatchMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("enableHotpatching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableHotpatching = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("assessmentMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + assessmentMode = new WindowsPatchAssessmentMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("automaticByPlatformSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + automaticByPlatformSettings = WindowsVmGuestPatchAutomaticByPlatformSettings.DeserializeWindowsVmGuestPatchAutomaticByPlatformSettings(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PatchSettings(patchMode, enableHotpatching, assessmentMode, automaticByPlatformSettings, 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(PatchSettings)} does not support writing '{options.Format}' format."); + } + } + + PatchSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePatchSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PatchSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.cs new file mode 100644 index 000000000000..8e2aa9804321 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PatchSettings.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies settings related to VM Guest Patching on Windows. + public partial class PatchSettings + { + /// + /// 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 PatchSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible.<br /><br /> Possible values are:<br /><br /> **Manual** - You + /// control the application of patches to a virtual machine. You do this by + /// applying patches manually inside the VM. In this mode, automatic updates are + /// disabled; the property WindowsConfiguration.enableAutomaticUpdates must be + /// false<br /><br /> **AutomaticByOS** - The virtual machine will automatically be + /// updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates + /// must be true. <br /><br /> **AutomaticByPlatform** - the virtual machine will + /// automatically updated by the platform. The properties provisionVMAgent and + /// WindowsConfiguration.enableAutomaticUpdates must be true + /// + /// + /// Enables customers to patch their Azure VMs without requiring a reboot. For + /// enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' + /// must be set to 'AutomaticByPlatform'. + /// + /// + /// Specifies the mode of VM Guest patch assessment for the IaaS virtual + /// machine.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - You + /// control the timing of patch assessments on a virtual machine.<br /><br /> + /// **AutomaticByPlatform** - The platform will trigger periodic patch assessments. + /// The property provisionVMAgent must be true. + /// + /// + /// Specifies additional settings for patch mode AutomaticByPlatform in VM Guest + /// Patching on Windows. + /// + /// Keeps track of any properties unknown to the library. + internal PatchSettings(WindowsVmGuestPatchMode? patchMode, bool? enableHotpatching, WindowsPatchAssessmentMode? assessmentMode, WindowsVmGuestPatchAutomaticByPlatformSettings automaticByPlatformSettings, IDictionary serializedAdditionalRawData) + { + PatchMode = patchMode; + EnableHotpatching = enableHotpatching; + AssessmentMode = assessmentMode; + AutomaticByPlatformSettings = automaticByPlatformSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible.<br /><br /> Possible values are:<br /><br /> **Manual** - You + /// control the application of patches to a virtual machine. You do this by + /// applying patches manually inside the VM. In this mode, automatic updates are + /// disabled; the property WindowsConfiguration.enableAutomaticUpdates must be + /// false<br /><br /> **AutomaticByOS** - The virtual machine will automatically be + /// updated by the OS. The property WindowsConfiguration.enableAutomaticUpdates + /// must be true. <br /><br /> **AutomaticByPlatform** - the virtual machine will + /// automatically updated by the platform. The properties provisionVMAgent and + /// WindowsConfiguration.enableAutomaticUpdates must be true + /// + public WindowsVmGuestPatchMode? PatchMode { get; set; } + /// + /// Enables customers to patch their Azure VMs without requiring a reboot. For + /// enableHotpatching, the 'provisionVMAgent' must be set to true and 'patchMode' + /// must be set to 'AutomaticByPlatform'. + /// + public bool? EnableHotpatching { get; set; } + /// + /// Specifies the mode of VM Guest patch assessment for the IaaS virtual + /// machine.<br /><br /> Possible values are:<br /><br /> **ImageDefault** - You + /// control the timing of patch assessments on a virtual machine.<br /><br /> + /// **AutomaticByPlatform** - The platform will trigger periodic patch assessments. + /// The property provisionVMAgent must be true. + /// + public WindowsPatchAssessmentMode? AssessmentMode { get; set; } + /// + /// Specifies additional settings for patch mode AutomaticByPlatform in VM Guest + /// Patching on Windows. + /// + public WindowsVmGuestPatchAutomaticByPlatformSettings AutomaticByPlatformSettings { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProtocolType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProtocolType.cs new file mode 100644 index 000000000000..87d1ee33fe26 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProtocolType.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.ComputeFleet.Models +{ + /// + /// Specifies the protocol of WinRM listener. Possible values are: **http,** + /// **https.** + /// + public readonly partial struct ProtocolType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ProtocolType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string HttpValue = "Http"; + private const string HttpsValue = "Https"; + + /// Http protocol. + public static ProtocolType Http { get; } = new ProtocolType(HttpValue); + /// Https protocol. + public static ProtocolType Https { get; } = new ProtocolType(HttpsValue); + /// Determines if two values are the same. + public static bool operator ==(ProtocolType left, ProtocolType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ProtocolType left, ProtocolType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ProtocolType(string value) => new ProtocolType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ProtocolType other && Equals(other); + /// + public bool Equals(ProtocolType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProvisioningState.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..42975a9fe337 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet.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 CreatingValue = "Creating"; + private const string UpdatingValue = "Updating"; + private const string DeletingValue = "Deleting"; + private const string MigratingValue = "Migrating"; + + /// Resource has been created. + public static ProvisioningState Succeeded { get; } = new ProvisioningState(SucceededValue); + /// Resource creation failed. + public static ProvisioningState Failed { get; } = new ProvisioningState(FailedValue); + /// Resource creation was canceled. + public static ProvisioningState Canceled { get; } = new ProvisioningState(CanceledValue); + /// Initial creation in progress. + public static ProvisioningState Creating { get; } = new ProvisioningState(CreatingValue); + /// Update in progress. + public static ProvisioningState Updating { get; } = new ProvisioningState(UpdatingValue); + /// Deletion in progress. + public static ProvisioningState Deleting { get; } = new ProvisioningState(DeletingValue); + /// Resource is being migrated from one subscription or resource group to another. + public static ProvisioningState Migrating { get; } = new ProvisioningState(MigratingValue); + /// 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 string 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.Serialization.cs new file mode 100644 index 000000000000..144385882132 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class ProxyAgentSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProxyAgentSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Enabled)) + { + writer.WritePropertyName("enabled"u8); + writer.WriteBooleanValue(Enabled.Value); + } + if (Optional.IsDefined(Mode)) + { + writer.WritePropertyName("mode"u8); + writer.WriteStringValue(Mode.Value.ToString()); + } + if (Optional.IsDefined(KeyIncarnationId)) + { + writer.WritePropertyName("keyIncarnationId"u8); + writer.WriteNumberValue(KeyIncarnationId.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProxyAgentSettings 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(ProxyAgentSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProxyAgentSettings(document.RootElement, options); + } + + internal static ProxyAgentSettings DeserializeProxyAgentSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? enabled = default; + Mode? mode = default; + int? keyIncarnationId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("enabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("mode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + mode = new Mode(property.Value.GetString()); + continue; + } + if (property.NameEquals("keyIncarnationId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + keyIncarnationId = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProxyAgentSettings(enabled, mode, keyIncarnationId, 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(ProxyAgentSettings)} does not support writing '{options.Format}' format."); + } + } + + ProxyAgentSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeProxyAgentSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProxyAgentSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.cs new file mode 100644 index 000000000000..aea955635718 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ProxyAgentSettings.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies ProxyAgent settings while creating the virtual machine. Minimum + /// api-version: 2023-09-01. + /// + public partial class ProxyAgentSettings + { + /// + /// 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 ProxyAgentSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies whether ProxyAgent feature should be enabled on the virtual machine + /// or virtual machine scale set. + /// + /// + /// Specifies the mode that ProxyAgent will execute on if the feature is enabled. + /// ProxyAgent will start to audit or monitor but not enforce access control over + /// requests to host endpoints in Audit mode, while in Enforce mode it will enforce + /// access control. The default value is Enforce mode. + /// + /// + /// Increase the value of this property allows user to reset the key used for + /// securing communication channel between guest and host. + /// + /// Keeps track of any properties unknown to the library. + internal ProxyAgentSettings(bool? enabled, Mode? mode, int? keyIncarnationId, IDictionary serializedAdditionalRawData) + { + Enabled = enabled; + Mode = mode; + KeyIncarnationId = keyIncarnationId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies whether ProxyAgent feature should be enabled on the virtual machine + /// or virtual machine scale set. + /// + public bool? Enabled { get; set; } + /// + /// Specifies the mode that ProxyAgent will execute on if the feature is enabled. + /// ProxyAgent will start to audit or monitor but not enforce access control over + /// requests to host endpoints in Audit mode, while in Enforce mode it will enforce + /// access control. The default value is Enforce mode. + /// + public Mode? Mode { get; set; } + /// + /// Increase the value of this property allows user to reset the key used for + /// securing communication channel between guest and host. + /// + public int? KeyIncarnationId { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.Serialization.cs new file mode 100644 index 000000000000..e442c49a511f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class PublicIPAddressSku : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(PublicIPAddressSku)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name.Value.ToString()); + } + if (Optional.IsDefined(Tier)) + { + writer.WritePropertyName("tier"u8); + writer.WriteStringValue(Tier.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + PublicIPAddressSku 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(PublicIPAddressSku)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePublicIPAddressSku(document.RootElement, options); + } + + internal static PublicIPAddressSku DeserializePublicIPAddressSku(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + PublicIPAddressSkuName? name = default; + PublicIPAddressSkuTier? tier = 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 PublicIPAddressSkuName(property.Value.GetString()); + continue; + } + if (property.NameEquals("tier"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + tier = new PublicIPAddressSkuTier(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new PublicIPAddressSku(name, tier, 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(PublicIPAddressSku)} does not support writing '{options.Format}' format."); + } + } + + PublicIPAddressSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializePublicIPAddressSku(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(PublicIPAddressSku)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.cs new file mode 100644 index 000000000000..fa67667d6c8e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSku.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Describes the public IP Sku. It can only be set with OrchestrationMode as + /// Flexible. + /// + public partial class PublicIPAddressSku + { + /// + /// 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 PublicIPAddressSku() + { + } + + /// Initializes a new instance of . + /// Specify public IP sku name. + /// Specify public IP sku tier. + /// Keeps track of any properties unknown to the library. + internal PublicIPAddressSku(PublicIPAddressSkuName? name, PublicIPAddressSkuTier? tier, IDictionary serializedAdditionalRawData) + { + Name = name; + Tier = tier; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specify public IP sku name. + public PublicIPAddressSkuName? Name { get; set; } + /// Specify public IP sku tier. + public PublicIPAddressSkuTier? Tier { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuName.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuName.cs new file mode 100644 index 000000000000..c654400d0700 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuName.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.ComputeFleet.Models +{ + /// Specify public IP sku name. + public readonly partial struct PublicIPAddressSkuName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PublicIPAddressSkuName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string BasicValue = "Basic"; + private const string StandardValue = "Standard"; + + /// Basic sku name. + public static PublicIPAddressSkuName Basic { get; } = new PublicIPAddressSkuName(BasicValue); + /// Standard sku name. + public static PublicIPAddressSkuName Standard { get; } = new PublicIPAddressSkuName(StandardValue); + /// Determines if two values are the same. + public static bool operator ==(PublicIPAddressSkuName left, PublicIPAddressSkuName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PublicIPAddressSkuName left, PublicIPAddressSkuName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PublicIPAddressSkuName(string value) => new PublicIPAddressSkuName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicIPAddressSkuName other && Equals(other); + /// + public bool Equals(PublicIPAddressSkuName 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuTier.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuTier.cs new file mode 100644 index 000000000000..0b8c3673bec6 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/PublicIPAddressSkuTier.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.ComputeFleet.Models +{ + /// Specify public IP sku tier. + public readonly partial struct PublicIPAddressSkuTier : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PublicIPAddressSkuTier(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RegionalValue = "Regional"; + private const string GlobalValue = "Global"; + + /// Regional sku tier. + public static PublicIPAddressSkuTier Regional { get; } = new PublicIPAddressSkuTier(RegionalValue); + /// Global sku tier. + public static PublicIPAddressSkuTier Global { get; } = new PublicIPAddressSkuTier(GlobalValue); + /// Determines if two values are the same. + public static bool operator ==(PublicIPAddressSkuTier left, PublicIPAddressSkuTier right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PublicIPAddressSkuTier left, PublicIPAddressSkuTier right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PublicIPAddressSkuTier(string value) => new PublicIPAddressSkuTier(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PublicIPAddressSkuTier other && Equals(other); + /// + public bool Equals(PublicIPAddressSkuTier 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityAllocationStrategy.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityAllocationStrategy.cs new file mode 100644 index 000000000000..49694b9d5760 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityAllocationStrategy.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.ComputeFleet.Models +{ + /// Regular VM Allocation strategy types for Compute Fleet. + public readonly partial struct RegularPriorityAllocationStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RegularPriorityAllocationStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LowestPriceValue = "LowestPrice"; + private const string PrioritizedValue = "Prioritized"; + + /// Default. VM sizes distribution will be determined to optimize for price. + public static RegularPriorityAllocationStrategy LowestPrice { get; } = new RegularPriorityAllocationStrategy(LowestPriceValue); + /// VM sizes distribution will be determined to optimize for the 'priority' as specified for each vm size. + public static RegularPriorityAllocationStrategy Prioritized { get; } = new RegularPriorityAllocationStrategy(PrioritizedValue); + /// Determines if two values are the same. + public static bool operator ==(RegularPriorityAllocationStrategy left, RegularPriorityAllocationStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RegularPriorityAllocationStrategy left, RegularPriorityAllocationStrategy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RegularPriorityAllocationStrategy(string value) => new RegularPriorityAllocationStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RegularPriorityAllocationStrategy other && Equals(other); + /// + public bool Equals(RegularPriorityAllocationStrategy 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.Serialization.cs new file mode 100644 index 000000000000..2db980f8d3f7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class RegularPriorityProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RegularPriorityProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity.Value); + } + if (Optional.IsDefined(MinCapacity)) + { + writer.WritePropertyName("minCapacity"u8); + writer.WriteNumberValue(MinCapacity.Value); + } + if (Optional.IsDefined(AllocationStrategy)) + { + writer.WritePropertyName("allocationStrategy"u8); + writer.WriteStringValue(AllocationStrategy.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RegularPriorityProfile 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(RegularPriorityProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRegularPriorityProfile(document.RootElement, options); + } + + internal static RegularPriorityProfile DeserializeRegularPriorityProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? capacity = default; + int? minCapacity = default; + RegularPriorityAllocationStrategy? allocationStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("capacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("minCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minCapacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("allocationStrategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allocationStrategy = new RegularPriorityAllocationStrategy(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RegularPriorityProfile(capacity, minCapacity, allocationStrategy, 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(RegularPriorityProfile)} does not support writing '{options.Format}' format."); + } + } + + RegularPriorityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRegularPriorityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RegularPriorityProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.cs new file mode 100644 index 000000000000..a910113c1fe1 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/RegularPriorityProfile.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.ComputeFleet.Models +{ + /// Configuration Options for Regular instances in Compute Fleet. + public partial class RegularPriorityProfile + { + /// + /// 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 RegularPriorityProfile() + { + } + + /// Initializes a new instance of . + /// Total capacity to achieve. It is currently in terms of number of VMs. + /// Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we will reject the request in the sync path itself. + /// Allocation strategy to follow when determining the VM sizes distribution for Regular VMs. + /// Keeps track of any properties unknown to the library. + internal RegularPriorityProfile(int? capacity, int? minCapacity, RegularPriorityAllocationStrategy? allocationStrategy, IDictionary serializedAdditionalRawData) + { + Capacity = capacity; + MinCapacity = minCapacity; + AllocationStrategy = allocationStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Total capacity to achieve. It is currently in terms of number of VMs. + public int? Capacity { get; set; } + /// Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we will reject the request in the sync path itself. + public int? MinCapacity { get; set; } + /// Allocation strategy to follow when determining the VM sizes distribution for Regular VMs. + public RegularPriorityAllocationStrategy? AllocationStrategy { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.Serialization.cs new file mode 100644 index 000000000000..d5df758b8f66 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class ScheduledEventsProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ScheduledEventsProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(TerminateNotificationProfile)) + { + writer.WritePropertyName("terminateNotificationProfile"u8); + writer.WriteObjectValue(TerminateNotificationProfile, options); + } + if (Optional.IsDefined(OSImageNotificationProfile)) + { + writer.WritePropertyName("osImageNotificationProfile"u8); + writer.WriteObjectValue(OSImageNotificationProfile, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ScheduledEventsProfile 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(ScheduledEventsProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeScheduledEventsProfile(document.RootElement, options); + } + + internal static ScheduledEventsProfile DeserializeScheduledEventsProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TerminateNotificationProfile terminateNotificationProfile = default; + OSImageNotificationProfile osImageNotificationProfile = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("terminateNotificationProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + terminateNotificationProfile = TerminateNotificationProfile.DeserializeTerminateNotificationProfile(property.Value, options); + continue; + } + if (property.NameEquals("osImageNotificationProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + osImageNotificationProfile = OSImageNotificationProfile.DeserializeOSImageNotificationProfile(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ScheduledEventsProfile(terminateNotificationProfile, osImageNotificationProfile, 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(ScheduledEventsProfile)} does not support writing '{options.Format}' format."); + } + } + + ScheduledEventsProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeScheduledEventsProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ScheduledEventsProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.cs new file mode 100644 index 000000000000..b3c88dcf185e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/ScheduledEventsProfile.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.ComputeFleet.Models +{ + /// Specifies Scheduled Event related configurations. + public partial class ScheduledEventsProfile + { + /// + /// 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 ScheduledEventsProfile() + { + } + + /// Initializes a new instance of . + /// Specifies Terminate Scheduled Event related configurations. + /// Specifies OS Image Scheduled Event related configurations. + /// Keeps track of any properties unknown to the library. + internal ScheduledEventsProfile(TerminateNotificationProfile terminateNotificationProfile, OSImageNotificationProfile osImageNotificationProfile, IDictionary serializedAdditionalRawData) + { + TerminateNotificationProfile = terminateNotificationProfile; + OSImageNotificationProfile = osImageNotificationProfile; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies Terminate Scheduled Event related configurations. + public TerminateNotificationProfile TerminateNotificationProfile { get; set; } + /// Specifies OS Image Scheduled Event related configurations. + public OSImageNotificationProfile OSImageNotificationProfile { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityEncryptionType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityEncryptionType.cs new file mode 100644 index 000000000000..ed070b2c10c3 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityEncryptionType.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.ComputeFleet.Models +{ + /// + /// Specifies the EncryptionType of the managed disk. + /// **Note:** It can be set for only Confidential VMs. + /// + public readonly partial struct SecurityEncryptionType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SecurityEncryptionType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VmGuestStateOnlyValue = "VMGuestStateOnly"; + private const string DiskWithVmGuestStateValue = "DiskWithVMGuestState"; + private const string NonPersistedTPMValue = "NonPersistedTPM"; + + /// + /// EncryptionType of the managed disk is set to VMGuestStateOnly for encryption + /// of just the VMGuestState blob. + /// + public static SecurityEncryptionType VmGuestStateOnly { get; } = new SecurityEncryptionType(VmGuestStateOnlyValue); + /// + /// EncryptionType of the managed disk is set to DiskWithVMGuestState for encryption + /// of the managed disk along with VMGuestState blob. + /// + public static SecurityEncryptionType DiskWithVmGuestState { get; } = new SecurityEncryptionType(DiskWithVmGuestStateValue); + /// + /// EncryptionType of the managed disk is set to NonPersistedTPM for not persisting + /// firmware state in the VMGuestState blob. + /// + public static SecurityEncryptionType NonPersistedTPM { get; } = new SecurityEncryptionType(NonPersistedTPMValue); + /// Determines if two values are the same. + public static bool operator ==(SecurityEncryptionType left, SecurityEncryptionType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SecurityEncryptionType left, SecurityEncryptionType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SecurityEncryptionType(string value) => new SecurityEncryptionType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SecurityEncryptionType other && Equals(other); + /// + public bool Equals(SecurityEncryptionType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.Serialization.cs new file mode 100644 index 000000000000..b38c31c76a0c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.Serialization.cs @@ -0,0 +1,162 @@ +// 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.ComputeFleet.Models +{ + public partial class SecurityPostureReference : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SecurityPostureReference)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsCollectionDefined(ExcludeExtensions)) + { + writer.WritePropertyName("excludeExtensions"u8); + writer.WriteStartArray(); + foreach (var item in ExcludeExtensions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IsOverridable)) + { + writer.WritePropertyName("isOverridable"u8); + writer.WriteBooleanValue(IsOverridable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SecurityPostureReference 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(SecurityPostureReference)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSecurityPostureReference(document.RootElement, options); + } + + internal static SecurityPostureReference DeserializeSecurityPostureReference(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IList excludeExtensions = default; + bool? isOverridable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("excludeExtensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + excludeExtensions = array; + continue; + } + if (property.NameEquals("isOverridable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + isOverridable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SecurityPostureReference(id, excludeExtensions ?? new ChangeTrackingList(), isOverridable, 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(SecurityPostureReference)} does not support writing '{options.Format}' format."); + } + } + + SecurityPostureReference IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSecurityPostureReference(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SecurityPostureReference)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.cs new file mode 100644 index 000000000000..3bd487ff507c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityPostureReference.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.ComputeFleet.Models +{ + /// + /// Specifies the security posture to be used for all virtual machines in the scale + /// set. Minimum api-version: 2023-03-01 + /// + public partial class SecurityPostureReference + { + /// + /// 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 SecurityPostureReference() + { + ExcludeExtensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The security posture reference id in the form of + /// /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest + /// + /// + /// List of virtual machine extension names to exclude when applying the security + /// posture. + /// + /// Whether the security posture can be overridden by the user. + /// Keeps track of any properties unknown to the library. + internal SecurityPostureReference(string id, IList excludeExtensions, bool? isOverridable, IDictionary serializedAdditionalRawData) + { + Id = id; + ExcludeExtensions = excludeExtensions; + IsOverridable = isOverridable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The security posture reference id in the form of + /// /CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest + /// + public string Id { get; set; } + /// + /// List of virtual machine extension names to exclude when applying the security + /// posture. + /// + public IList ExcludeExtensions { get; } + /// Whether the security posture can be overridden by the user. + public bool? IsOverridable { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.Serialization.cs new file mode 100644 index 000000000000..244910641680 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.Serialization.cs @@ -0,0 +1,192 @@ +// 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.ComputeFleet.Models +{ + public partial class SecurityProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SecurityProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(UefiSettings)) + { + writer.WritePropertyName("uefiSettings"u8); + writer.WriteObjectValue(UefiSettings, options); + } + if (Optional.IsDefined(EncryptionAtHost)) + { + writer.WritePropertyName("encryptionAtHost"u8); + writer.WriteBooleanValue(EncryptionAtHost.Value); + } + if (Optional.IsDefined(SecurityType)) + { + writer.WritePropertyName("securityType"u8); + writer.WriteStringValue(SecurityType.Value.ToString()); + } + if (Optional.IsDefined(EncryptionIdentity)) + { + writer.WritePropertyName("encryptionIdentity"u8); + writer.WriteObjectValue(EncryptionIdentity, options); + } + if (Optional.IsDefined(ProxyAgentSettings)) + { + writer.WritePropertyName("proxyAgentSettings"u8); + writer.WriteObjectValue(ProxyAgentSettings, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SecurityProfile 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(SecurityProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSecurityProfile(document.RootElement, options); + } + + internal static SecurityProfile DeserializeSecurityProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UefiSettings uefiSettings = default; + bool? encryptionAtHost = default; + SecurityType? securityType = default; + EncryptionIdentity encryptionIdentity = default; + ProxyAgentSettings proxyAgentSettings = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("uefiSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + uefiSettings = UefiSettings.DeserializeUefiSettings(property.Value, options); + continue; + } + if (property.NameEquals("encryptionAtHost"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + encryptionAtHost = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("securityType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityType = new SecurityType(property.Value.GetString()); + continue; + } + if (property.NameEquals("encryptionIdentity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + encryptionIdentity = EncryptionIdentity.DeserializeEncryptionIdentity(property.Value, options); + continue; + } + if (property.NameEquals("proxyAgentSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + proxyAgentSettings = ProxyAgentSettings.DeserializeProxyAgentSettings(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SecurityProfile( + uefiSettings, + encryptionAtHost, + securityType, + encryptionIdentity, + proxyAgentSettings, + 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(SecurityProfile)} does not support writing '{options.Format}' format."); + } + } + + SecurityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSecurityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SecurityProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.cs new file mode 100644 index 000000000000..3c54acab74f7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityProfile.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the Security profile settings for the virtual machine or virtual + /// machine scale set. + /// + public partial class SecurityProfile + { + /// + /// 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 SecurityProfile() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the security settings like secure boot and vTPM used while creating + /// the virtual machine. Minimum api-version: 2020-12-01. + /// + /// + /// This property can be used by user in the request to enable or disable the Host + /// Encryption for the virtual machine or virtual machine scale set. This will + /// enable the encryption for all the disks including Resource/Temp disk at host + /// itself. The default behavior is: The Encryption at host will be disabled unless + /// this property is set to true for the resource. + /// + /// + /// Specifies the SecurityType of the virtual machine. It has to be set to any + /// specified value to enable UefiSettings. The default behavior is: UefiSettings + /// will not be enabled unless this property is set. + /// + /// + /// Specifies the Managed Identity used by ADE to get access token for keyvault + /// operations. + /// + /// + /// Specifies ProxyAgent settings while creating the virtual machine. Minimum + /// api-version: 2023-09-01. + /// + /// Keeps track of any properties unknown to the library. + internal SecurityProfile(UefiSettings uefiSettings, bool? encryptionAtHost, SecurityType? securityType, EncryptionIdentity encryptionIdentity, ProxyAgentSettings proxyAgentSettings, IDictionary serializedAdditionalRawData) + { + UefiSettings = uefiSettings; + EncryptionAtHost = encryptionAtHost; + SecurityType = securityType; + EncryptionIdentity = encryptionIdentity; + ProxyAgentSettings = proxyAgentSettings; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the security settings like secure boot and vTPM used while creating + /// the virtual machine. Minimum api-version: 2020-12-01. + /// + public UefiSettings UefiSettings { get; set; } + /// + /// This property can be used by user in the request to enable or disable the Host + /// Encryption for the virtual machine or virtual machine scale set. This will + /// enable the encryption for all the disks including Resource/Temp disk at host + /// itself. The default behavior is: The Encryption at host will be disabled unless + /// this property is set to true for the resource. + /// + public bool? EncryptionAtHost { get; set; } + /// + /// Specifies the SecurityType of the virtual machine. It has to be set to any + /// specified value to enable UefiSettings. The default behavior is: UefiSettings + /// will not be enabled unless this property is set. + /// + public SecurityType? SecurityType { get; set; } + /// + /// Specifies the Managed Identity used by ADE to get access token for keyvault + /// operations. + /// + internal EncryptionIdentity EncryptionIdentity { get; set; } + /// Specifies ARM Resource ID of one of the user identities associated with the VM. + public ResourceIdentifier UserAssignedIdentityResourceId + { + get => EncryptionIdentity is null ? default : EncryptionIdentity.UserAssignedIdentityResourceId; + set + { + if (EncryptionIdentity is null) + EncryptionIdentity = new EncryptionIdentity(); + EncryptionIdentity.UserAssignedIdentityResourceId = value; + } + } + + /// + /// Specifies ProxyAgent settings while creating the virtual machine. Minimum + /// api-version: 2023-09-01. + /// + public ProxyAgentSettings ProxyAgentSettings { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityType.cs new file mode 100644 index 000000000000..0e0799fd93af --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SecurityType.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the SecurityType of the virtual machine. It has to be set to any + /// specified value to enable UefiSettings. The default behavior is: UefiSettings + /// will not be enabled unless this property is set. + /// + public readonly partial struct SecurityType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SecurityType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TrustedLaunchValue = "TrustedLaunch"; + private const string ConfidentialVmValue = "ConfidentialVM"; + + /// TrustedLaunch security type. + public static SecurityType TrustedLaunch { get; } = new SecurityType(TrustedLaunchValue); + /// ConfidentialVM security type. + public static SecurityType ConfidentialVm { get; } = new SecurityType(ConfidentialVmValue); + /// Determines if two values are the same. + public static bool operator ==(SecurityType left, SecurityType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SecurityType left, SecurityType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SecurityType(string value) => new SecurityType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SecurityType other && Equals(other); + /// + public bool Equals(SecurityType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SettingName.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SettingName.cs new file mode 100644 index 000000000000..2087d6bfcea1 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SettingName.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.ComputeFleet.Models +{ + /// + /// Specifies the name of the setting to which the content applies. Possible values + /// are: FirstLogonCommands and AutoLogon. + /// + public readonly partial struct SettingName : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SettingName(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoLogonValue = "AutoLogon"; + private const string FirstLogonCommandsValue = "FirstLogonCommands"; + + /// AutoLogon setting. + public static SettingName AutoLogon { get; } = new SettingName(AutoLogonValue); + /// FirstLogonCommands setting. + public static SettingName FirstLogonCommands { get; } = new SettingName(FirstLogonCommandsValue); + /// Determines if two values are the same. + public static bool operator ==(SettingName left, SettingName right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SettingName left, SettingName right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SettingName(string value) => new SettingName(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SettingName other && Equals(other); + /// + public bool Equals(SettingName 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotAllocationStrategy.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotAllocationStrategy.cs new file mode 100644 index 000000000000..2721fa92c10f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotAllocationStrategy.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.ComputeFleet.Models +{ + /// Spot allocation strategy types for Compute Fleet. + public readonly partial struct SpotAllocationStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public SpotAllocationStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PriceCapacityOptimizedValue = "PriceCapacityOptimized"; + private const string LowestPriceValue = "LowestPrice"; + private const string CapacityOptimizedValue = "CapacityOptimized"; + + /// Default. VM sizes distribution will be determined to optimize for both price and capacity. + public static SpotAllocationStrategy PriceCapacityOptimized { get; } = new SpotAllocationStrategy(PriceCapacityOptimizedValue); + /// VM sizes distribution will be determined to optimize for price. Note: Capacity will still be considered here but will be given much less weight. + public static SpotAllocationStrategy LowestPrice { get; } = new SpotAllocationStrategy(LowestPriceValue); + /// VM sizes distribution will be determined to optimize for capacity. + public static SpotAllocationStrategy CapacityOptimized { get; } = new SpotAllocationStrategy(CapacityOptimizedValue); + /// Determines if two values are the same. + public static bool operator ==(SpotAllocationStrategy left, SpotAllocationStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(SpotAllocationStrategy left, SpotAllocationStrategy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator SpotAllocationStrategy(string value) => new SpotAllocationStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is SpotAllocationStrategy other && Equals(other); + /// + public bool Equals(SpotAllocationStrategy 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.Serialization.cs new file mode 100644 index 000000000000..6995d38d893a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.Serialization.cs @@ -0,0 +1,208 @@ +// 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.ComputeFleet.Models +{ + public partial class SpotPriorityProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SpotPriorityProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Capacity)) + { + writer.WritePropertyName("capacity"u8); + writer.WriteNumberValue(Capacity.Value); + } + if (Optional.IsDefined(MinCapacity)) + { + writer.WritePropertyName("minCapacity"u8); + writer.WriteNumberValue(MinCapacity.Value); + } + if (Optional.IsDefined(MaxPricePerVm)) + { + writer.WritePropertyName("maxPricePerVM"u8); + writer.WriteNumberValue(MaxPricePerVm.Value); + } + if (Optional.IsDefined(EvictionPolicy)) + { + writer.WritePropertyName("evictionPolicy"u8); + writer.WriteStringValue(EvictionPolicy.Value.ToString()); + } + if (Optional.IsDefined(AllocationStrategy)) + { + writer.WritePropertyName("allocationStrategy"u8); + writer.WriteStringValue(AllocationStrategy.Value.ToString()); + } + if (Optional.IsDefined(Maintain)) + { + writer.WritePropertyName("maintain"u8); + writer.WriteBooleanValue(Maintain.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SpotPriorityProfile 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(SpotPriorityProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSpotPriorityProfile(document.RootElement, options); + } + + internal static SpotPriorityProfile DeserializeSpotPriorityProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? capacity = default; + int? minCapacity = default; + float? maxPricePerVm = default; + EvictionPolicy? evictionPolicy = default; + SpotAllocationStrategy? allocationStrategy = default; + bool? maintain = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("capacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + capacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("minCapacity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minCapacity = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("maxPricePerVM"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxPricePerVm = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("evictionPolicy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + evictionPolicy = new EvictionPolicy(property.Value.GetString()); + continue; + } + if (property.NameEquals("allocationStrategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allocationStrategy = new SpotAllocationStrategy(property.Value.GetString()); + continue; + } + if (property.NameEquals("maintain"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maintain = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SpotPriorityProfile( + capacity, + minCapacity, + maxPricePerVm, + evictionPolicy, + allocationStrategy, + maintain, + 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(SpotPriorityProfile)} does not support writing '{options.Format}' format."); + } + } + + SpotPriorityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSpotPriorityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SpotPriorityProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.cs new file mode 100644 index 000000000000..ba312053cbbb --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SpotPriorityProfile.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Configuration Options for Spot instances in Compute Fleet. + public partial class SpotPriorityProfile + { + /// + /// 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 SpotPriorityProfile() + { + } + + /// Initializes a new instance of . + /// Total capacity to achieve. It is currently in terms of number of VMs. + /// Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we will reject the request in the sync path itself. + /// Price per hour of each Spot VM will never exceed this. + /// Eviction Policy to follow when evicting Spot VMs. + /// Allocation strategy to follow when determining the VM sizes distribution for Spot VMs. + /// + /// Flag to enable/disable continuous goal seeking for the desired capacity and restoration of evicted Spot VMs. + /// If maintain is enabled, AzureFleetRP will use all VM sizes in vmSizesProfile to create new VMs (if VMs are evicted deleted) + /// or update existing VMs with new VM sizes (if VMs are evicted deallocated or failed to allocate due to capacity constraint) in order to achieve the desired capacity. + /// Maintain is enabled by default. + /// + /// Keeps track of any properties unknown to the library. + internal SpotPriorityProfile(int? capacity, int? minCapacity, float? maxPricePerVm, EvictionPolicy? evictionPolicy, SpotAllocationStrategy? allocationStrategy, bool? maintain, IDictionary serializedAdditionalRawData) + { + Capacity = capacity; + MinCapacity = minCapacity; + MaxPricePerVm = maxPricePerVm; + EvictionPolicy = evictionPolicy; + AllocationStrategy = allocationStrategy; + Maintain = maintain; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Total capacity to achieve. It is currently in terms of number of VMs. + public int? Capacity { get; set; } + /// Minimum capacity to achieve which cannot be updated. If we will not be able to "guarantee" minimum capacity, we will reject the request in the sync path itself. + public int? MinCapacity { get; set; } + /// Price per hour of each Spot VM will never exceed this. + public float? MaxPricePerVm { get; set; } + /// Eviction Policy to follow when evicting Spot VMs. + public EvictionPolicy? EvictionPolicy { get; set; } + /// Allocation strategy to follow when determining the VM sizes distribution for Spot VMs. + public SpotAllocationStrategy? AllocationStrategy { get; set; } + /// + /// Flag to enable/disable continuous goal seeking for the desired capacity and restoration of evicted Spot VMs. + /// If maintain is enabled, AzureFleetRP will use all VM sizes in vmSizesProfile to create new VMs (if VMs are evicted deleted) + /// or update existing VMs with new VM sizes (if VMs are evicted deallocated or failed to allocate due to capacity constraint) in order to achieve the desired capacity. + /// Maintain is enabled by default. + /// + public bool? Maintain { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.Serialization.cs new file mode 100644 index 000000000000..7c340ab71d9f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.Serialization.cs @@ -0,0 +1,136 @@ +// 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.ComputeFleet.Models +{ + internal partial class SshConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SshConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(PublicKeys)) + { + writer.WritePropertyName("publicKeys"u8); + writer.WriteStartArray(); + foreach (var item in PublicKeys) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SshConfiguration 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(SshConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSshConfiguration(document.RootElement, options); + } + + internal static SshConfiguration DeserializeSshConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList publicKeys = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("publicKeys"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SshPublicKey.DeserializeSshPublicKey(item, options)); + } + publicKeys = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SshConfiguration(publicKeys ?? 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(SshConfiguration)} does not support writing '{options.Format}' format."); + } + } + + SshConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSshConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SshConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.cs new file mode 100644 index 000000000000..c1fc4d9d8056 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshConfiguration.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.ComputeFleet.Models +{ + /// SSH configuration for Linux based VMs running on Azure. + internal partial class SshConfiguration + { + /// + /// 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 SshConfiguration() + { + PublicKeys = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The list of SSH public keys used to authenticate with linux based VMs. + /// Keeps track of any properties unknown to the library. + internal SshConfiguration(IList publicKeys, IDictionary serializedAdditionalRawData) + { + PublicKeys = publicKeys; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The list of SSH public keys used to authenticate with linux based VMs. + public IList PublicKeys { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.Serialization.cs new file mode 100644 index 000000000000..a33238fb0eb8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.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.ComputeFleet.Models +{ + public partial class SshPublicKey : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SshPublicKey)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Path)) + { + writer.WritePropertyName("path"u8); + writer.WriteStringValue(Path); + } + if (Optional.IsDefined(KeyData)) + { + writer.WritePropertyName("keyData"u8); + writer.WriteStringValue(KeyData); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + SshPublicKey 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(SshPublicKey)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSshPublicKey(document.RootElement, options); + } + + internal static SshPublicKey DeserializeSshPublicKey(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string path = default; + string keyData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("path"u8)) + { + path = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyData"u8)) + { + keyData = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SshPublicKey(path, keyData, 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(SshPublicKey)} does not support writing '{options.Format}' format."); + } + } + + SshPublicKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeSshPublicKey(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SshPublicKey)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.cs new file mode 100644 index 000000000000..0773ee36c4de --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/SshPublicKey.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.ComputeFleet.Models +{ + /// + /// Contains information about SSH certificate public key and the path on the Linux + /// VM where the public key is placed. + /// + public partial class SshPublicKey + { + /// + /// 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 SshPublicKey() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the full path on the created VM where ssh public key is stored. If + /// the file already exists, the specified key is appended to the file. Example: + /// /home/user/.ssh/authorized_keys + /// + /// + /// SSH public key certificate used to authenticate with the VM through ssh. The + /// key needs to be at least 2048-bit and in ssh-rsa format. For creating ssh keys, + /// see [Create SSH keys on Linux and Mac for Linux VMs in + /// Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). + /// + /// Keeps track of any properties unknown to the library. + internal SshPublicKey(string path, string keyData, IDictionary serializedAdditionalRawData) + { + Path = path; + KeyData = keyData; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the full path on the created VM where ssh public key is stored. If + /// the file already exists, the specified key is appended to the file. Example: + /// /home/user/.ssh/authorized_keys + /// + public string Path { get; set; } + /// + /// SSH public key certificate used to authenticate with the VM through ssh. The + /// key needs to be at least 2048-bit and in ssh-rsa format. For creating ssh keys, + /// see [Create SSH keys on Linux and Mac for Linux VMs in + /// Azure]https://docs.microsoft.com/azure/virtual-machines/linux/create-ssh-keys-detailed). + /// + public string KeyData { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/StorageAccountType.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/StorageAccountType.cs new file mode 100644 index 000000000000..c3cfe49f5fe8 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/StorageAccountType.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.ComputeFleet.Models +{ + /// + /// Specifies the storage account type for the managed disk. Managed OS disk + /// storage account type can only be set when you create the scale set. NOTE: + /// UltraSSD_LRS can only be used with data disks. It cannot be used with OS Disk. + /// Standard_LRS uses Standard HDD. StandardSSD_LRS uses Standard SSD. Premium_LRS + /// uses Premium SSD. UltraSSD_LRS uses Ultra disk. Premium_ZRS uses Premium SSD + /// zone redundant storage. StandardSSD_ZRS uses Standard SSD zone redundant + /// storage. For more information regarding disks supported for Windows Virtual + /// Machines, refer to + /// https://docs.microsoft.com/azure/virtual-machines/windows/disks-types and, for + /// Linux Virtual Machines, refer to + /// https://docs.microsoft.com/azure/virtual-machines/linux/disks-types + /// + public readonly partial struct StorageAccountType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public StorageAccountType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string StandardLRSValue = "Standard_LRS"; + private const string PremiumLRSValue = "Premium_LRS"; + private const string StandardSSDLRSValue = "StandardSSD_LRS"; + private const string UltraSSDLRSValue = "UltraSSD_LRS"; + private const string PremiumZRSValue = "Premium_ZRS"; + private const string StandardSSDZRSValue = "StandardSSD_ZRS"; + private const string PremiumV2LRSValue = "PremiumV2_LRS"; + + /// Standard_LRS option. + public static StorageAccountType StandardLRS { get; } = new StorageAccountType(StandardLRSValue); + /// Premium_LRS option. + public static StorageAccountType PremiumLRS { get; } = new StorageAccountType(PremiumLRSValue); + /// StandardSSD_LRS option. + public static StorageAccountType StandardSSDLRS { get; } = new StorageAccountType(StandardSSDLRSValue); + /// UltraSSD_LRS option. + public static StorageAccountType UltraSSDLRS { get; } = new StorageAccountType(UltraSSDLRSValue); + /// Premium_ZRS option. + public static StorageAccountType PremiumZRS { get; } = new StorageAccountType(PremiumZRSValue); + /// StandardSSD_ZRS option. + public static StorageAccountType StandardSSDZRS { get; } = new StorageAccountType(StandardSSDZRSValue); + /// PremiumV2_LRS option. + public static StorageAccountType PremiumV2LRS { get; } = new StorageAccountType(PremiumV2LRSValue); + /// Determines if two values are the same. + public static bool operator ==(StorageAccountType left, StorageAccountType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(StorageAccountType left, StorageAccountType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator StorageAccountType(string value) => new StorageAccountType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is StorageAccountType other && Equals(other); + /// + public bool Equals(StorageAccountType 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.Serialization.cs new file mode 100644 index 000000000000..5957e126fc43 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.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.ComputeFleet.Models +{ + public partial class TerminateNotificationProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TerminateNotificationProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(NotBeforeTimeout)) + { + writer.WritePropertyName("notBeforeTimeout"u8); + writer.WriteStringValue(NotBeforeTimeout); + } + if (Optional.IsDefined(Enable)) + { + writer.WritePropertyName("enable"u8); + writer.WriteBooleanValue(Enable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TerminateNotificationProfile 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(TerminateNotificationProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTerminateNotificationProfile(document.RootElement, options); + } + + internal static TerminateNotificationProfile DeserializeTerminateNotificationProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string notBeforeTimeout = default; + bool? enable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("notBeforeTimeout"u8)) + { + notBeforeTimeout = property.Value.GetString(); + continue; + } + if (property.NameEquals("enable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TerminateNotificationProfile(notBeforeTimeout, enable, 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(TerminateNotificationProfile)} does not support writing '{options.Format}' format."); + } + } + + TerminateNotificationProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTerminateNotificationProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TerminateNotificationProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.cs new file mode 100644 index 000000000000..1e2cbe947e87 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/TerminateNotificationProfile.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies Terminate Scheduled Event related configurations. + public partial class TerminateNotificationProfile + { + /// + /// 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 TerminateNotificationProfile() + { + } + + /// Initializes a new instance of . + /// + /// Configurable length of time a Virtual Machine being deleted will have to + /// potentially approve the Terminate Scheduled Event before the event is auto + /// approved (timed out). The configuration must be specified in ISO 8601 format, + /// the default value is 5 minutes (PT5M) + /// + /// Specifies whether the Terminate Scheduled event is enabled or disabled. + /// Keeps track of any properties unknown to the library. + internal TerminateNotificationProfile(string notBeforeTimeout, bool? enable, IDictionary serializedAdditionalRawData) + { + NotBeforeTimeout = notBeforeTimeout; + Enable = enable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Configurable length of time a Virtual Machine being deleted will have to + /// potentially approve the Terminate Scheduled Event before the event is auto + /// approved (timed out). The configuration must be specified in ISO 8601 format, + /// the default value is 5 minutes (PT5M) + /// + public string NotBeforeTimeout { get; set; } + /// Specifies whether the Terminate Scheduled event is enabled or disabled. + public bool? Enable { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.Serialization.cs new file mode 100644 index 000000000000..99bc5d31a9c2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class UefiSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UefiSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(SecureBootEnabled)) + { + writer.WritePropertyName("secureBootEnabled"u8); + writer.WriteBooleanValue(SecureBootEnabled.Value); + } + if (Optional.IsDefined(VTpmEnabled)) + { + writer.WritePropertyName("vTpmEnabled"u8); + writer.WriteBooleanValue(VTpmEnabled.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UefiSettings 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(UefiSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUefiSettings(document.RootElement, options); + } + + internal static UefiSettings DeserializeUefiSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? secureBootEnabled = default; + bool? vTpmEnabled = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("secureBootEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + secureBootEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("vTpmEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vTpmEnabled = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UefiSettings(secureBootEnabled, vTpmEnabled, 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(UefiSettings)} does not support writing '{options.Format}' format."); + } + } + + UefiSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUefiSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UefiSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.cs new file mode 100644 index 000000000000..bdd7490b00ac --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/UefiSettings.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.ComputeFleet.Models +{ + /// + /// Specifies the security settings like secure boot and vTPM used while creating + /// the virtual machine. Minimum api-version: 2020-12-01. + /// + public partial class UefiSettings + { + /// + /// 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 UefiSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies whether secure boot should be enabled on the virtual machine. Minimum + /// api-version: 2020-12-01. + /// + /// + /// Specifies whether vTPM should be enabled on the virtual machine. Minimum + /// api-version: 2020-12-01. + /// + /// Keeps track of any properties unknown to the library. + internal UefiSettings(bool? secureBootEnabled, bool? vTpmEnabled, IDictionary serializedAdditionalRawData) + { + SecureBootEnabled = secureBootEnabled; + VTpmEnabled = vTpmEnabled; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies whether secure boot should be enabled on the virtual machine. Minimum + /// api-version: 2020-12-01. + /// + public bool? SecureBootEnabled { get; set; } + /// + /// Specifies whether vTPM should be enabled on the virtual machine. Minimum + /// api-version: 2020-12-01. + /// + public bool? VTpmEnabled { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.Serialization.cs new file mode 100644 index 000000000000..99ea7d6d3e96 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.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.ComputeFleet.Models +{ + public partial class VaultCertificate : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultCertificate)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(VaultCertificati)) + { + writer.WritePropertyName("certificateUrl"u8); + writer.WriteStringValue(VaultCertificati); + } + if (Optional.IsDefined(CertificateStore)) + { + writer.WritePropertyName("certificateStore"u8); + writer.WriteStringValue(CertificateStore); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VaultCertificate 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(VaultCertificate)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVaultCertificate(document.RootElement, options); + } + + internal static VaultCertificate DeserializeVaultCertificate(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string certificateUrl = default; + string certificateStore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("certificateUrl"u8)) + { + certificateUrl = property.Value.GetString(); + continue; + } + if (property.NameEquals("certificateStore"u8)) + { + certificateStore = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VaultCertificate(certificateUrl, certificateStore, 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(VaultCertificate)} does not support writing '{options.Format}' format."); + } + } + + VaultCertificate IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVaultCertificate(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VaultCertificate)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.cs new file mode 100644 index 000000000000..c4ed873a2c86 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultCertificate.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Describes a single certificate reference in a Key Vault, and where the + /// certificate should reside on the VM. + /// + public partial class VaultCertificate + { + /// + /// 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 VaultCertificate() + { + } + + /// Initializes a new instance of . + /// + /// This is the URL of a certificate that has been uploaded to Key Vault as a + /// secret. For adding a secret to the Key Vault, see [Add a key or secret to the + /// key + /// vault](https://docs.microsoft.com/azure/key-vault/key-vault-get-started/#add). + /// In this case, your certificate needs to be It is the Base64 encoding of the + /// following JSON Object which is encoded in UTF-8: <br><br> {<br> + /// "data":"<Base64-encoded-certificate>",<br> "dataType":"pfx",<br> + /// "password":"<pfx-file-password>"<br>} <br> To install certificates on a virtual + /// machine it is recommended to use the [Azure Key Vault virtual machine extension + /// for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + /// + /// For Windows VMs, specifies the certificate store on the Virtual Machine to + /// which the certificate should be added. The specified certificate store is + /// implicitly in the LocalMachine account. For Linux VMs, the certificate file is + /// placed under the /var/lib/waagent directory, with the file name + /// <UppercaseThumbprint>.crt for the X509 certificate file and + /// <UppercaseThumbprint>.prv for private key. Both of these files are .pem + /// formatted. + /// + /// Keeps track of any properties unknown to the library. + internal VaultCertificate(string vaultCertificati, string certificateStore, IDictionary serializedAdditionalRawData) + { + VaultCertificati = vaultCertificati; + CertificateStore = certificateStore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// This is the URL of a certificate that has been uploaded to Key Vault as a + /// secret. For adding a secret to the Key Vault, see [Add a key or secret to the + /// key + /// vault](https://docs.microsoft.com/azure/key-vault/key-vault-get-started/#add). + /// In this case, your certificate needs to be It is the Base64 encoding of the + /// following JSON Object which is encoded in UTF-8: <br><br> {<br> + /// "data":"<Base64-encoded-certificate>",<br> "dataType":"pfx",<br> + /// "password":"<pfx-file-password>"<br>} <br> To install certificates on a virtual + /// machine it is recommended to use the [Azure Key Vault virtual machine extension + /// for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + public string VaultCertificati { get; set; } + /// + /// For Windows VMs, specifies the certificate store on the Virtual Machine to + /// which the certificate should be added. The specified certificate store is + /// implicitly in the LocalMachine account. For Linux VMs, the certificate file is + /// placed under the /var/lib/waagent directory, with the file name + /// <UppercaseThumbprint>.crt for the X509 certificate file and + /// <UppercaseThumbprint>.prv for private key. Both of these files are .pem + /// formatted. + /// + public string CertificateStore { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.Serialization.cs new file mode 100644 index 000000000000..5042422459f9 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VaultSecretGroup : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VaultSecretGroup)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(SourceVault)) + { + writer.WritePropertyName("sourceVault"u8); + JsonSerializer.Serialize(writer, SourceVault); + } + if (Optional.IsCollectionDefined(VaultCertificates)) + { + writer.WritePropertyName("vaultCertificates"u8); + writer.WriteStartArray(); + foreach (var item in VaultCertificates) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VaultSecretGroup 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(VaultSecretGroup)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVaultSecretGroup(document.RootElement, options); + } + + internal static VaultSecretGroup DeserializeVaultSecretGroup(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WritableSubResource sourceVault = default; + IList vaultCertificates = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("sourceVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("vaultCertificates"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VaultCertificate.DeserializeVaultCertificate(item, options)); + } + vaultCertificates = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VaultSecretGroup(sourceVault, vaultCertificates ?? 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(VaultSecretGroup)} does not support writing '{options.Format}' format."); + } + } + + VaultSecretGroup IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVaultSecretGroup(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VaultSecretGroup)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.cs new file mode 100644 index 000000000000..5301950671d2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VaultSecretGroup.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; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a set of certificates which are all in the same Key Vault. + public partial class VaultSecretGroup + { + /// + /// 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 VaultSecretGroup() + { + VaultCertificates = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The relative URL of the Key Vault containing all of the certificates in + /// VaultCertificates. + /// + /// The list of key vault references in SourceVault which contain certificates. + /// Keeps track of any properties unknown to the library. + internal VaultSecretGroup(WritableSubResource sourceVault, IList vaultCertificates, IDictionary serializedAdditionalRawData) + { + SourceVault = sourceVault; + VaultCertificates = vaultCertificates; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The relative URL of the Key Vault containing all of the certificates in + /// VaultCertificates. + /// + internal WritableSubResource SourceVault { get; set; } + /// Gets or sets Id. + public ResourceIdentifier SourceVaultId + { + get => SourceVault is null ? default : SourceVault.Id; + set + { + if (SourceVault is null) + SourceVault = new WritableSubResource(); + SourceVault.Id = value; + } + } + + /// The list of key vault references in SourceVault which contain certificates. + public IList VaultCertificates { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.Serialization.cs new file mode 100644 index 000000000000..414e9285c791 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.Serialization.cs @@ -0,0 +1,122 @@ +// 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.ComputeFleet.Models +{ + internal partial class VirtualHardDisk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualHardDisk)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Uri)) + { + writer.WritePropertyName("uri"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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualHardDisk 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(VirtualHardDisk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualHardDisk(document.RootElement, options); + } + + internal static VirtualHardDisk DeserializeVirtualHardDisk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string uri = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("uri"u8)) + { + uri = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualHardDisk(uri, 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(VirtualHardDisk)} does not support writing '{options.Format}' format."); + } + } + + VirtualHardDisk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualHardDisk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualHardDisk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.cs new file mode 100644 index 000000000000..28b0bb5f96ce --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualHardDisk.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.ComputeFleet.Models +{ + /// Describes the uri of a disk. + internal partial class VirtualHardDisk + { + /// + /// 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 VirtualHardDisk() + { + } + + /// Initializes a new instance of . + /// Specifies the virtual hard disk's uri. + /// Keeps track of any properties unknown to the library. + internal VirtualHardDisk(string uri, IDictionary serializedAdditionalRawData) + { + Uri = uri; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the virtual hard disk's uri. + public string Uri { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.Serialization.cs new file mode 100644 index 000000000000..90569f878c04 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSet : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSet)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (options.Format != "W") + { + writer.WritePropertyName("operationStatus"u8); + writer.WriteStringValue(OperationStatus.ToString()); + } + if (options.Format != "W" && Optional.IsDefined(Error)) + { + writer.WritePropertyName("error"u8); + writer.WriteObjectValue(Error, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSet 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(VirtualMachineScaleSet)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSet(document.RootElement, options); + } + + internal static VirtualMachineScaleSet DeserializeVirtualMachineScaleSet(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string type = default; + ProvisioningState operationStatus = default; + ApiError error = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("operationStatus"u8)) + { + operationStatus = new ProvisioningState(property.Value.GetString()); + continue; + } + if (property.NameEquals("error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + error = ApiError.DeserializeApiError(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSet(id, type, operationStatus, error, 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(VirtualMachineScaleSet)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSet IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSet(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSet)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.cs new file mode 100644 index 000000000000..281bd4374695 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSet.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// An AzureFleet's virtualMachineScaleSet. + public partial class VirtualMachineScaleSet + { + /// + /// 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 compute RP resource id of the virtualMachineScaleSet + /// "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}" + /// + /// This represents the operationStatus of the VMSS in response to the last operation that was performed on it by Azure Fleet resource. + internal VirtualMachineScaleSet(string id, ProvisioningState operationStatus) + { + Id = id; + OperationStatus = operationStatus; + } + + /// Initializes a new instance of . + /// + /// The compute RP resource id of the virtualMachineScaleSet + /// "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}" + /// + /// Type of the virtualMachineScaleSet. + /// This represents the operationStatus of the VMSS in response to the last operation that was performed on it by Azure Fleet resource. + /// Error Information when `operationStatus` is `Failed`. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSet(string id, string type, ProvisioningState operationStatus, ApiError error, IDictionary serializedAdditionalRawData) + { + Id = id; + Type = type; + OperationStatus = operationStatus; + Error = error; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSet() + { + } + + /// + /// The compute RP resource id of the virtualMachineScaleSet + /// "subscriptions/{subId}/resourceGroups/{rgName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}" + /// + public string Id { get; } + /// Type of the virtualMachineScaleSet. + public string Type { get; } + /// This represents the operationStatus of the VMSS in response to the last operation that was performed on it by Azure Fleet resource. + public ProvisioningState OperationStatus { get; } + /// Error Information when `operationStatus` is `Failed`. + public ApiError Error { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs new file mode 100644 index 000000000000..cbdce8a8d5f2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs @@ -0,0 +1,254 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetDataDisk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetDataDisk)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + writer.WritePropertyName("lun"u8); + writer.WriteNumberValue(Lun); + if (Optional.IsDefined(Caching)) + { + writer.WritePropertyName("caching"u8); + writer.WriteStringValue(Caching.Value.ToString()); + } + if (Optional.IsDefined(WriteAcceleratorEnabled)) + { + writer.WritePropertyName("writeAcceleratorEnabled"u8); + writer.WriteBooleanValue(WriteAcceleratorEnabled.Value); + } + writer.WritePropertyName("createOption"u8); + writer.WriteStringValue(CreateOption.ToString()); + if (Optional.IsDefined(DiskSizeGB)) + { + writer.WritePropertyName("diskSizeGB"u8); + writer.WriteNumberValue(DiskSizeGB.Value); + } + if (Optional.IsDefined(ManagedDisk)) + { + writer.WritePropertyName("managedDisk"u8); + writer.WriteObjectValue(ManagedDisk, options); + } + if (Optional.IsDefined(DiskIOPSReadWrite)) + { + writer.WritePropertyName("diskIOPSReadWrite"u8); + writer.WriteNumberValue(DiskIOPSReadWrite.Value); + } + if (Optional.IsDefined(DiskMBpsReadWrite)) + { + writer.WritePropertyName("diskMBpsReadWrite"u8); + writer.WriteNumberValue(DiskMBpsReadWrite.Value); + } + if (Optional.IsDefined(DeleteOption)) + { + writer.WritePropertyName("deleteOption"u8); + writer.WriteStringValue(DeleteOption.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetDataDisk 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(VirtualMachineScaleSetDataDisk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetDataDisk(document.RootElement, options); + } + + internal static VirtualMachineScaleSetDataDisk DeserializeVirtualMachineScaleSetDataDisk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + int lun = default; + CachingType? caching = default; + bool? writeAcceleratorEnabled = default; + DiskCreateOptionType createOption = default; + int? diskSizeGB = default; + VirtualMachineScaleSetManagedDiskParameters managedDisk = default; + long? diskIOPSReadWrite = default; + long? diskMBpsReadWrite = default; + DiskDeleteOptionType? deleteOption = 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("lun"u8)) + { + lun = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("caching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + caching = new CachingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("writeAcceleratorEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + writeAcceleratorEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("createOption"u8)) + { + createOption = new DiskCreateOptionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("diskSizeGB"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskSizeGB = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("managedDisk"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedDisk = VirtualMachineScaleSetManagedDiskParameters.DeserializeVirtualMachineScaleSetManagedDiskParameters(property.Value, options); + continue; + } + if (property.NameEquals("diskIOPSReadWrite"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskIOPSReadWrite = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("diskMBpsReadWrite"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskMBpsReadWrite = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("deleteOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deleteOption = new DiskDeleteOptionType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetDataDisk( + name, + lun, + caching, + writeAcceleratorEnabled, + createOption, + diskSizeGB, + managedDisk, + diskIOPSReadWrite, + diskMBpsReadWrite, + deleteOption, + 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(VirtualMachineScaleSetDataDisk)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetDataDisk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetDataDisk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetDataDisk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.cs new file mode 100644 index 000000000000..81d3d2119d69 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetDataDisk.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set data disk. + public partial class VirtualMachineScaleSetDataDisk + { + /// + /// 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 . + /// + /// Specifies the logical unit number of the data disk. This value is used to + /// identify data disks within the VM and therefore must be unique for each data + /// disk attached to a VM. + /// + /// The create option. + public VirtualMachineScaleSetDataDisk(int lun, DiskCreateOptionType createOption) + { + Lun = lun; + CreateOption = createOption; + } + + /// Initializes a new instance of . + /// The disk name. + /// + /// Specifies the logical unit number of the data disk. This value is used to + /// identify data disks within the VM and therefore must be unique for each data + /// disk attached to a VM. + /// + /// + /// Specifies the caching requirements. Possible values are: **None,** + /// **ReadOnly,** **ReadWrite.** The default values are: **None for Standard + /// storage. ReadOnly for Premium storage.** + /// + /// Specifies whether writeAccelerator should be enabled or disabled on the disk. + /// The create option. + /// + /// Specifies the size of an empty data disk in gigabytes. This element can be used + /// to overwrite the size of the disk in a virtual machine image. The property + /// diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be + /// larger than 1023. + /// + /// The managed disk parameters. + /// + /// Specifies the Read-Write IOPS for the managed disk. Should be used only when + /// StorageAccountType is UltraSSD_LRS. If not specified, a default value would be + /// assigned based on diskSizeGB. + /// + /// + /// Specifies the bandwidth in MB per second for the managed disk. Should be used + /// only when StorageAccountType is UltraSSD_LRS. If not specified, a default value + /// would be assigned based on diskSizeGB. + /// + /// + /// Specifies whether data disk should be deleted or detached upon VMSS Flex + /// deletion (This feature is available for VMSS with Flexible OrchestrationMode + /// only).<br><br> Possible values: <br><br> **Delete** If this value is used, the + /// data disk is deleted when the VMSS Flex VM is deleted.<br><br> **Detach** If + /// this value is used, the data disk is retained after VMSS Flex VM is + /// deleted.<br><br> The default value is set to **Delete**. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetDataDisk(string name, int lun, CachingType? caching, bool? writeAcceleratorEnabled, DiskCreateOptionType createOption, int? diskSizeGB, VirtualMachineScaleSetManagedDiskParameters managedDisk, long? diskIOPSReadWrite, long? diskMBpsReadWrite, DiskDeleteOptionType? deleteOption, IDictionary serializedAdditionalRawData) + { + Name = name; + Lun = lun; + Caching = caching; + WriteAcceleratorEnabled = writeAcceleratorEnabled; + CreateOption = createOption; + DiskSizeGB = diskSizeGB; + ManagedDisk = managedDisk; + DiskIOPSReadWrite = diskIOPSReadWrite; + DiskMBpsReadWrite = diskMBpsReadWrite; + DeleteOption = deleteOption; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetDataDisk() + { + } + + /// The disk name. + public string Name { get; set; } + /// + /// Specifies the logical unit number of the data disk. This value is used to + /// identify data disks within the VM and therefore must be unique for each data + /// disk attached to a VM. + /// + public int Lun { get; set; } + /// + /// Specifies the caching requirements. Possible values are: **None,** + /// **ReadOnly,** **ReadWrite.** The default values are: **None for Standard + /// storage. ReadOnly for Premium storage.** + /// + public CachingType? Caching { get; set; } + /// Specifies whether writeAccelerator should be enabled or disabled on the disk. + public bool? WriteAcceleratorEnabled { get; set; } + /// The create option. + public DiskCreateOptionType CreateOption { get; set; } + /// + /// Specifies the size of an empty data disk in gigabytes. This element can be used + /// to overwrite the size of the disk in a virtual machine image. The property + /// diskSizeGB is the number of bytes x 1024^3 for the disk and the value cannot be + /// larger than 1023. + /// + public int? DiskSizeGB { get; set; } + /// The managed disk parameters. + public VirtualMachineScaleSetManagedDiskParameters ManagedDisk { get; set; } + /// + /// Specifies the Read-Write IOPS for the managed disk. Should be used only when + /// StorageAccountType is UltraSSD_LRS. If not specified, a default value would be + /// assigned based on diskSizeGB. + /// + public long? DiskIOPSReadWrite { get; set; } + /// + /// Specifies the bandwidth in MB per second for the managed disk. Should be used + /// only when StorageAccountType is UltraSSD_LRS. If not specified, a default value + /// would be assigned based on diskSizeGB. + /// + public long? DiskMBpsReadWrite { get; set; } + /// + /// Specifies whether data disk should be deleted or detached upon VMSS Flex + /// deletion (This feature is available for VMSS with Flexible OrchestrationMode + /// only).<br><br> Possible values: <br><br> **Delete** If this value is used, the + /// data disk is deleted when the VMSS Flex VM is deleted.<br><br> **Detach** If + /// this value is used, the data disk is retained after VMSS Flex VM is + /// deleted.<br><br> The default value is set to **Delete**. + /// + public DiskDeleteOptionType? DeleteOption { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.Serialization.cs new file mode 100644 index 000000000000..6d73b8140c5c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetExtension : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtension)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (options.Format != "W" && Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetExtension 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(VirtualMachineScaleSetExtension)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetExtension(document.RootElement, options); + } + + internal static VirtualMachineScaleSetExtension DeserializeVirtualMachineScaleSetExtension(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + string type = default; + VirtualMachineScaleSetExtensionProperties properties = 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 = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualMachineScaleSetExtensionProperties.DeserializeVirtualMachineScaleSetExtensionProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetExtension(id, name, type, 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(VirtualMachineScaleSetExtension)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetExtension IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetExtension(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtension)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.cs new file mode 100644 index 000000000000..6238939c8a72 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtension.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a Virtual Machine Scale Set Extension. + public partial class VirtualMachineScaleSetExtension + { + /// + /// 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 VirtualMachineScaleSetExtension() + { + } + + /// Initializes a new instance of . + /// Resource Id. + /// The name of the extension. + /// Resource type. + /// Describes the properties of a Virtual Machine Scale Set Extension. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetExtension(ResourceIdentifier id, string name, string type, VirtualMachineScaleSetExtensionProperties properties, IDictionary serializedAdditionalRawData) + { + Id = id; + Name = name; + Type = type; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resource Id. + public ResourceIdentifier Id { get; } + /// The name of the extension. + public string Name { get; set; } + /// Resource type. + public string Type { get; } + /// Describes the properties of a Virtual Machine Scale Set Extension. + public VirtualMachineScaleSetExtensionProperties Properties { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs new file mode 100644 index 000000000000..5562142ec71d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetExtensionProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Extensions)) + { + writer.WritePropertyName("extensions"u8); + writer.WriteStartArray(); + foreach (var item in Extensions) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ExtensionsTimeBudget)) + { + writer.WritePropertyName("extensionsTimeBudget"u8); + writer.WriteStringValue(ExtensionsTimeBudget); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetExtensionProfile 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(VirtualMachineScaleSetExtensionProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetExtensionProfile(document.RootElement, options); + } + + internal static VirtualMachineScaleSetExtensionProfile DeserializeVirtualMachineScaleSetExtensionProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList extensions = default; + string extensionsTimeBudget = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("extensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VirtualMachineScaleSetExtension.DeserializeVirtualMachineScaleSetExtension(item, options)); + } + extensions = array; + continue; + } + if (property.NameEquals("extensionsTimeBudget"u8)) + { + extensionsTimeBudget = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetExtensionProfile(extensions ?? new ChangeTrackingList(), extensionsTimeBudget, 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(VirtualMachineScaleSetExtensionProfile)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetExtensionProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetExtensionProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.cs new file mode 100644 index 000000000000..7188ed387da7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.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; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set extension profile. + public partial class VirtualMachineScaleSetExtensionProfile + { + /// + /// 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 VirtualMachineScaleSetExtensionProfile() + { + Extensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The virtual machine scale set child extension resources. + /// + /// Specifies the time alloted for all extensions to start. The time duration + /// should be between 15 minutes and 120 minutes (inclusive) and should be + /// specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). + /// Minimum api-version: 2020-06-01. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetExtensionProfile(IList extensions, string extensionsTimeBudget, IDictionary serializedAdditionalRawData) + { + Extensions = extensions; + ExtensionsTimeBudget = extensionsTimeBudget; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The virtual machine scale set child extension resources. + public IList Extensions { get; } + /// + /// Specifies the time alloted for all extensions to start. The time duration + /// should be between 15 minutes and 120 minutes (inclusive) and should be + /// specified in ISO 8601 format. The default value is 90 minutes (PT1H30M). + /// Minimum api-version: 2020-06-01. + /// + public string ExtensionsTimeBudget { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.Serialization.cs new file mode 100644 index 000000000000..f2b3deab4926 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.Serialization.cs @@ -0,0 +1,354 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetExtensionProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ForceUpdateTag)) + { + writer.WritePropertyName("forceUpdateTag"u8); + writer.WriteStringValue(ForceUpdateTag); + } + if (Optional.IsDefined(Publisher)) + { + writer.WritePropertyName("publisher"u8); + writer.WriteStringValue(Publisher); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsDefined(TypeHandlerVersion)) + { + writer.WritePropertyName("typeHandlerVersion"u8); + writer.WriteStringValue(TypeHandlerVersion); + } + if (Optional.IsDefined(AutoUpgradeMinorVersion)) + { + writer.WritePropertyName("autoUpgradeMinorVersion"u8); + writer.WriteBooleanValue(AutoUpgradeMinorVersion.Value); + } + if (Optional.IsDefined(EnableAutomaticUpgrade)) + { + writer.WritePropertyName("enableAutomaticUpgrade"u8); + writer.WriteBooleanValue(EnableAutomaticUpgrade.Value); + } + if (Optional.IsCollectionDefined(Settings)) + { + writer.WritePropertyName("settings"u8); + writer.WriteStartObject(); + foreach (var item in Settings) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (Optional.IsCollectionDefined(ProtectedSettings)) + { + writer.WritePropertyName("protectedSettings"u8); + writer.WriteStartObject(); + foreach (var item in ProtectedSettings) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) + { + writer.WritePropertyName("provisioningState"u8); + writer.WriteStringValue(ProvisioningState); + } + if (Optional.IsCollectionDefined(ProvisionAfterExtensions)) + { + writer.WritePropertyName("provisionAfterExtensions"u8); + writer.WriteStartArray(); + foreach (var item in ProvisionAfterExtensions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(SuppressFailures)) + { + writer.WritePropertyName("suppressFailures"u8); + writer.WriteBooleanValue(SuppressFailures.Value); + } + if (Optional.IsDefined(ProtectedSettingsFromKeyVault)) + { + writer.WritePropertyName("protectedSettingsFromKeyVault"u8); + writer.WriteObjectValue(ProtectedSettingsFromKeyVault, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetExtensionProperties 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(VirtualMachineScaleSetExtensionProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetExtensionProperties(document.RootElement, options); + } + + internal static VirtualMachineScaleSetExtensionProperties DeserializeVirtualMachineScaleSetExtensionProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string forceUpdateTag = default; + string publisher = default; + string type = default; + string typeHandlerVersion = default; + bool? autoUpgradeMinorVersion = default; + bool? enableAutomaticUpgrade = default; + IDictionary settings = default; + IDictionary protectedSettings = default; + string provisioningState = default; + IList provisionAfterExtensions = default; + bool? suppressFailures = default; + KeyVaultSecretReference protectedSettingsFromKeyVault = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("forceUpdateTag"u8)) + { + forceUpdateTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("publisher"u8)) + { + publisher = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("typeHandlerVersion"u8)) + { + typeHandlerVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("autoUpgradeMinorVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + autoUpgradeMinorVersion = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enableAutomaticUpgrade"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableAutomaticUpgrade = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("settings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + settings = dictionary; + continue; + } + if (property.NameEquals("protectedSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + protectedSettings = dictionary; + continue; + } + if (property.NameEquals("provisioningState"u8)) + { + provisioningState = property.Value.GetString(); + continue; + } + if (property.NameEquals("provisionAfterExtensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + provisionAfterExtensions = array; + continue; + } + if (property.NameEquals("suppressFailures"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + suppressFailures = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("protectedSettingsFromKeyVault"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + protectedSettingsFromKeyVault = KeyVaultSecretReference.DeserializeKeyVaultSecretReference(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetExtensionProperties( + forceUpdateTag, + publisher, + type, + typeHandlerVersion, + autoUpgradeMinorVersion, + enableAutomaticUpgrade, + settings ?? new ChangeTrackingDictionary(), + protectedSettings ?? new ChangeTrackingDictionary(), + provisioningState, + provisionAfterExtensions ?? new ChangeTrackingList(), + suppressFailures, + protectedSettingsFromKeyVault, + 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(VirtualMachineScaleSetExtensionProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetExtensionProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetExtensionProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.cs new file mode 100644 index 000000000000..7c5c9e1a1452 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetExtensionProperties.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes the properties of a Virtual Machine Scale Set Extension. + public partial class VirtualMachineScaleSetExtensionProperties + { + /// + /// 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 VirtualMachineScaleSetExtensionProperties() + { + Settings = new ChangeTrackingDictionary(); + ProtectedSettings = new ChangeTrackingDictionary(); + ProvisionAfterExtensions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// If a value is provided and is different from the previous value, the extension + /// handler will be forced to update even if the extension configuration has not + /// changed. + /// + /// The name of the extension handler publisher. + /// Specifies the type of the extension; an example is "CustomScriptExtension". + /// Specifies the version of the script handler. + /// + /// Indicates whether the extension should use a newer minor version if one is + /// available at deployment time. Once deployed, however, the extension will not + /// upgrade minor versions unless redeployed, even with this property set to true. + /// + /// + /// Indicates whether the extension should be automatically upgraded by the + /// platform if there is a newer version of the extension available. + /// + /// Json formatted public settings for the extension. + /// + /// The extension can contain either protectedSettings or + /// protectedSettingsFromKeyVault or no protected settings at all. + /// + /// The provisioning state, which only appears in the response. + /// + /// Collection of extension names after which this extension needs to be + /// provisioned. + /// + /// + /// Indicates whether failures stemming from the extension will be suppressed + /// (Operational failures such as not connecting to the VM will not be suppressed + /// regardless of this value). The default is false. + /// + /// + /// The extensions protected settings that are passed by reference, and consumed + /// from key vault + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetExtensionProperties(string forceUpdateTag, string publisher, string type, string typeHandlerVersion, bool? autoUpgradeMinorVersion, bool? enableAutomaticUpgrade, IDictionary settings, IDictionary protectedSettings, string provisioningState, IList provisionAfterExtensions, bool? suppressFailures, KeyVaultSecretReference protectedSettingsFromKeyVault, IDictionary serializedAdditionalRawData) + { + ForceUpdateTag = forceUpdateTag; + Publisher = publisher; + Type = type; + TypeHandlerVersion = typeHandlerVersion; + AutoUpgradeMinorVersion = autoUpgradeMinorVersion; + EnableAutomaticUpgrade = enableAutomaticUpgrade; + Settings = settings; + ProtectedSettings = protectedSettings; + ProvisioningState = provisioningState; + ProvisionAfterExtensions = provisionAfterExtensions; + SuppressFailures = suppressFailures; + ProtectedSettingsFromKeyVault = protectedSettingsFromKeyVault; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// If a value is provided and is different from the previous value, the extension + /// handler will be forced to update even if the extension configuration has not + /// changed. + /// + public string ForceUpdateTag { get; set; } + /// The name of the extension handler publisher. + public string Publisher { get; set; } + /// Specifies the type of the extension; an example is "CustomScriptExtension". + public string Type { get; set; } + /// Specifies the version of the script handler. + public string TypeHandlerVersion { get; set; } + /// + /// Indicates whether the extension should use a newer minor version if one is + /// available at deployment time. Once deployed, however, the extension will not + /// upgrade minor versions unless redeployed, even with this property set to true. + /// + public bool? AutoUpgradeMinorVersion { get; set; } + /// + /// Indicates whether the extension should be automatically upgraded by the + /// platform if there is a newer version of the extension available. + /// + public bool? EnableAutomaticUpgrade { get; set; } + /// + /// Json formatted public settings for the extension. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Settings { get; } + /// + /// The extension can contain either protectedSettings or + /// protectedSettingsFromKeyVault or no protected settings at all. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary ProtectedSettings { get; } + /// The provisioning state, which only appears in the response. + public string ProvisioningState { get; } + /// + /// Collection of extension names after which this extension needs to be + /// provisioned. + /// + public IList ProvisionAfterExtensions { get; } + /// + /// Indicates whether failures stemming from the extension will be suppressed + /// (Operational failures such as not connecting to the VM will not be suppressed + /// regardless of this value). The default is false. + /// + public bool? SuppressFailures { get; set; } + /// + /// The extensions protected settings that are passed by reference, and consumed + /// from key vault + /// + public KeyVaultSecretReference ProtectedSettingsFromKeyVault { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.Serialization.cs new file mode 100644 index 000000000000..93dc613284fb --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + internal partial class VirtualMachineScaleSetHardwareProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetHardwareProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(VmSizeProperties)) + { + writer.WritePropertyName("vmSizeProperties"u8); + writer.WriteObjectValue(VmSizeProperties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetHardwareProfile 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(VirtualMachineScaleSetHardwareProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetHardwareProfile(document.RootElement, options); + } + + internal static VirtualMachineScaleSetHardwareProfile DeserializeVirtualMachineScaleSetHardwareProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VmSizeProperties vmSizeProperties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vmSizeProperties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vmSizeProperties = VmSizeProperties.DeserializeVmSizeProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetHardwareProfile(vmSizeProperties, 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(VirtualMachineScaleSetHardwareProfile)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetHardwareProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetHardwareProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetHardwareProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.cs new file mode 100644 index 000000000000..fa699d7348e2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetHardwareProfile.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.ComputeFleet.Models +{ + /// Specifies the hardware settings for the virtual machine scale set. + internal partial class VirtualMachineScaleSetHardwareProfile + { + /// + /// 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 VirtualMachineScaleSetHardwareProfile() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the properties for customizing the size of the virtual machine. + /// Minimum api-version: 2021-11-01. Please follow the instructions in [VM + /// Customization](https://aka.ms/vmcustomization) for more details. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetHardwareProfile(VmSizeProperties vmSizeProperties, IDictionary serializedAdditionalRawData) + { + VmSizeProperties = vmSizeProperties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the properties for customizing the size of the virtual machine. + /// Minimum api-version: 2021-11-01. Please follow the instructions in [VM + /// Customization](https://aka.ms/vmcustomization) for more details. + /// + public VmSizeProperties VmSizeProperties { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs new file mode 100644 index 000000000000..449618446528 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs @@ -0,0 +1,134 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetIPConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetIPConfiguration 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(VirtualMachineScaleSetIPConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetIPConfiguration(document.RootElement, options); + } + + internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineScaleSetIPConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VirtualMachineScaleSetIPConfigurationProperties properties = 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("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualMachineScaleSetIPConfigurationProperties.DeserializeVirtualMachineScaleSetIPConfigurationProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetIPConfiguration(name, 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(VirtualMachineScaleSetIPConfiguration)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetIPConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetIPConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.cs new file mode 100644 index 000000000000..63e051f7002c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set network profile's IP configuration. + public partial class VirtualMachineScaleSetIPConfiguration + { + /// + /// 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 IP configuration name. + /// is null. + public VirtualMachineScaleSetIPConfiguration(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The IP configuration name. + /// + /// Describes a virtual machine scale set network profile's IP configuration + /// properties. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetIPConfiguration(string name, VirtualMachineScaleSetIPConfigurationProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetIPConfiguration() + { + } + + /// The IP configuration name. + public string Name { get; set; } + /// + /// Describes a virtual machine scale set network profile's IP configuration + /// properties. + /// + public VirtualMachineScaleSetIPConfigurationProperties Properties { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.Serialization.cs new file mode 100644 index 000000000000..3abfad41c400 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.Serialization.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetIPConfigurationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPConfigurationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Subnet)) + { + writer.WritePropertyName("subnet"u8); + JsonSerializer.Serialize(writer, Subnet); + } + if (Optional.IsDefined(Primary)) + { + writer.WritePropertyName("primary"u8); + writer.WriteBooleanValue(Primary.Value); + } + if (Optional.IsDefined(PublicIPAddressConfiguration)) + { + writer.WritePropertyName("publicIPAddressConfiguration"u8); + writer.WriteObjectValue(PublicIPAddressConfiguration, options); + } + if (Optional.IsDefined(PrivateIPAddressVersion)) + { + writer.WritePropertyName("privateIPAddressVersion"u8); + writer.WriteStringValue(PrivateIPAddressVersion.Value.ToString()); + } + if (Optional.IsCollectionDefined(ApplicationGatewayBackendAddressPools)) + { + writer.WritePropertyName("applicationGatewayBackendAddressPools"u8); + writer.WriteStartArray(); + foreach (var item in ApplicationGatewayBackendAddressPools) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ApplicationSecurityGroups)) + { + writer.WritePropertyName("applicationSecurityGroups"u8); + writer.WriteStartArray(); + foreach (var item in ApplicationSecurityGroups) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(LoadBalancerBackendAddressPools)) + { + writer.WritePropertyName("loadBalancerBackendAddressPools"u8); + writer.WriteStartArray(); + foreach (var item in LoadBalancerBackendAddressPools) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(LoadBalancerInboundNatPools)) + { + writer.WritePropertyName("loadBalancerInboundNatPools"u8); + writer.WriteStartArray(); + foreach (var item in LoadBalancerInboundNatPools) + { + JsonSerializer.Serialize(writer, item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetIPConfigurationProperties 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(VirtualMachineScaleSetIPConfigurationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetIPConfigurationProperties(document.RootElement, options); + } + + internal static VirtualMachineScaleSetIPConfigurationProperties DeserializeVirtualMachineScaleSetIPConfigurationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WritableSubResource subnet = default; + bool? primary = default; + VirtualMachineScaleSetPublicIPAddressConfiguration publicIPAddressConfiguration = default; + IPVersion? privateIPAddressVersion = default; + IList applicationGatewayBackendAddressPools = default; + IList applicationSecurityGroups = default; + IList loadBalancerBackendAddressPools = default; + IList loadBalancerInboundNatPools = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("subnet"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + subnet = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("primary"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + primary = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("publicIPAddressConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPAddressConfiguration = VirtualMachineScaleSetPublicIPAddressConfiguration.DeserializeVirtualMachineScaleSetPublicIPAddressConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("privateIPAddressVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + privateIPAddressVersion = new IPVersion(property.Value.GetString()); + continue; + } + if (property.NameEquals("applicationGatewayBackendAddressPools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + applicationGatewayBackendAddressPools = array; + continue; + } + if (property.NameEquals("applicationSecurityGroups"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + applicationSecurityGroups = array; + continue; + } + if (property.NameEquals("loadBalancerBackendAddressPools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + loadBalancerBackendAddressPools = array; + continue; + } + if (property.NameEquals("loadBalancerInboundNatPools"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(JsonSerializer.Deserialize(item.GetRawText())); + } + loadBalancerInboundNatPools = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetIPConfigurationProperties( + subnet, + primary, + publicIPAddressConfiguration, + privateIPAddressVersion, + applicationGatewayBackendAddressPools ?? new ChangeTrackingList(), + applicationSecurityGroups ?? new ChangeTrackingList(), + loadBalancerBackendAddressPools ?? new ChangeTrackingList(), + loadBalancerInboundNatPools ?? 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(VirtualMachineScaleSetIPConfigurationProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetIPConfigurationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetIPConfigurationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPConfigurationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.cs new file mode 100644 index 000000000000..74c4d7f34ee3 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPConfigurationProperties.cs @@ -0,0 +1,154 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Describes a virtual machine scale set network profile's IP configuration + /// properties. + /// + public partial class VirtualMachineScaleSetIPConfigurationProperties + { + /// + /// 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 VirtualMachineScaleSetIPConfigurationProperties() + { + ApplicationGatewayBackendAddressPools = new ChangeTrackingList(); + ApplicationSecurityGroups = new ChangeTrackingList(); + LoadBalancerBackendAddressPools = new ChangeTrackingList(); + LoadBalancerInboundNatPools = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Specifies the identifier of the subnet. + /// + /// Specifies the primary network interface in case the virtual machine has more + /// than 1 network interface. + /// + /// The publicIPAddressConfiguration. + /// + /// Available from Api-Version 2017-03-30 onwards, it represents whether the + /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible + /// values are: 'IPv4' and 'IPv6'. + /// + /// + /// Specifies an array of references to backend address pools of application + /// gateways. A scale set can reference backend address pools of multiple + /// application gateways. Multiple scale sets cannot use the same application + /// gateway. + /// + /// Specifies an array of references to application security group. + /// + /// Specifies an array of references to backend address pools of load balancers. A + /// scale set can reference backend address pools of one public and one internal + /// load balancer. Multiple scale sets cannot use the same basic sku load balancer. + /// + /// + /// Specifies an array of references to inbound Nat pools of the load balancers. A + /// scale set can reference inbound nat pools of one public and one internal load + /// balancer. Multiple scale sets cannot use the same basic sku load balancer. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetIPConfigurationProperties(WritableSubResource subnet, bool? primary, VirtualMachineScaleSetPublicIPAddressConfiguration publicIPAddressConfiguration, IPVersion? privateIPAddressVersion, IList applicationGatewayBackendAddressPools, IList applicationSecurityGroups, IList loadBalancerBackendAddressPools, IList loadBalancerInboundNatPools, IDictionary serializedAdditionalRawData) + { + Subnet = subnet; + Primary = primary; + PublicIPAddressConfiguration = publicIPAddressConfiguration; + PrivateIPAddressVersion = privateIPAddressVersion; + ApplicationGatewayBackendAddressPools = applicationGatewayBackendAddressPools; + ApplicationSecurityGroups = applicationSecurityGroups; + LoadBalancerBackendAddressPools = loadBalancerBackendAddressPools; + LoadBalancerInboundNatPools = loadBalancerInboundNatPools; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the identifier of the subnet. + internal WritableSubResource Subnet { get; set; } + /// Gets or sets Id. + public ResourceIdentifier SubnetId + { + get => Subnet is null ? default : Subnet.Id; + set + { + if (Subnet is null) + Subnet = new WritableSubResource(); + Subnet.Id = value; + } + } + + /// + /// Specifies the primary network interface in case the virtual machine has more + /// than 1 network interface. + /// + public bool? Primary { get; set; } + /// The publicIPAddressConfiguration. + public VirtualMachineScaleSetPublicIPAddressConfiguration PublicIPAddressConfiguration { get; set; } + /// + /// Available from Api-Version 2017-03-30 onwards, it represents whether the + /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible + /// values are: 'IPv4' and 'IPv6'. + /// + public IPVersion? PrivateIPAddressVersion { get; set; } + /// + /// Specifies an array of references to backend address pools of application + /// gateways. A scale set can reference backend address pools of multiple + /// application gateways. Multiple scale sets cannot use the same application + /// gateway. + /// + public IList ApplicationGatewayBackendAddressPools { get; } + /// Specifies an array of references to application security group. + public IList ApplicationSecurityGroups { get; } + /// + /// Specifies an array of references to backend address pools of load balancers. A + /// scale set can reference backend address pools of one public and one internal + /// load balancer. Multiple scale sets cannot use the same basic sku load balancer. + /// + public IList LoadBalancerBackendAddressPools { get; } + /// + /// Specifies an array of references to inbound Nat pools of the load balancers. A + /// scale set can reference inbound nat pools of one public and one internal load + /// balancer. Multiple scale sets cannot use the same basic sku load balancer. + /// + public IList LoadBalancerInboundNatPools { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs new file mode 100644 index 000000000000..f76dca0cec8e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetIPTag : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPTag)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(IPTagType)) + { + writer.WritePropertyName("ipTagType"u8); + writer.WriteStringValue(IPTagType); + } + if (Optional.IsDefined(Tag)) + { + writer.WritePropertyName("tag"u8); + writer.WriteStringValue(Tag); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetIPTag 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(VirtualMachineScaleSetIPTag)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetIPTag(document.RootElement, options); + } + + internal static VirtualMachineScaleSetIPTag DeserializeVirtualMachineScaleSetIPTag(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string ipTagType = default; + string tag = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ipTagType"u8)) + { + ipTagType = property.Value.GetString(); + continue; + } + if (property.NameEquals("tag"u8)) + { + tag = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetIPTag(ipTagType, tag, 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(VirtualMachineScaleSetIPTag)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetIPTag IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetIPTag(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPTag)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.cs new file mode 100644 index 000000000000..68e32263e389 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetIPTag.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.ComputeFleet.Models +{ + /// Contains the IP tag associated with the public IP address. + public partial class VirtualMachineScaleSetIPTag + { + /// + /// 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 VirtualMachineScaleSetIPTag() + { + } + + /// Initializes a new instance of . + /// IP tag type. Example: FirstPartyUsage. + /// IP tag associated with the public IP. Example: SQL, Storage etc. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetIPTag(string ipTagType, string tag, IDictionary serializedAdditionalRawData) + { + IPTagType = ipTagType; + Tag = tag; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// IP tag type. Example: FirstPartyUsage. + public string IPTagType { get; set; } + /// IP tag associated with the public IP. Example: SQL, Storage etc. + public string Tag { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs new file mode 100644 index 000000000000..74bcc9536ce5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.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.ComputeFleet.Models +{ + internal partial class VirtualMachineScaleSetListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetListResult)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + 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)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetListResult 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(VirtualMachineScaleSetListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetListResult(document.RootElement, options); + } + + internal static VirtualMachineScaleSetListResult DeserializeVirtualMachineScaleSetListResult(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(VirtualMachineScaleSet.DeserializeVirtualMachineScaleSet(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 VirtualMachineScaleSetListResult(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(VirtualMachineScaleSetListResult)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.cs new file mode 100644 index 000000000000..7319cea13efb --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetListResult.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.ComputeFleet.Models +{ + /// The response of a VirtualMachineScaleSet list operation. + internal partial class VirtualMachineScaleSetListResult + { + /// + /// 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 VirtualMachineScaleSet items on this page. + /// is null. + internal VirtualMachineScaleSetListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The VirtualMachineScaleSet items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetListResult(IReadOnlyList value, Uri nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetListResult() + { + } + + /// The VirtualMachineScaleSet items on this page. + public IReadOnlyList Value { get; } + /// The link to the next page of items. + public Uri NextLink { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs new file mode 100644 index 000000000000..884d485715b7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetManagedDiskParameters : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetManagedDiskParameters)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(StorageAccountType)) + { + writer.WritePropertyName("storageAccountType"u8); + writer.WriteStringValue(StorageAccountType.Value.ToString()); + } + if (Optional.IsDefined(DiskEncryptionSet)) + { + writer.WritePropertyName("diskEncryptionSet"u8); + JsonSerializer.Serialize(writer, DiskEncryptionSet); + } + if (Optional.IsDefined(SecurityProfile)) + { + writer.WritePropertyName("securityProfile"u8); + writer.WriteObjectValue(SecurityProfile, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetManagedDiskParameters 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(VirtualMachineScaleSetManagedDiskParameters)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetManagedDiskParameters(document.RootElement, options); + } + + internal static VirtualMachineScaleSetManagedDiskParameters DeserializeVirtualMachineScaleSetManagedDiskParameters(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + StorageAccountType? storageAccountType = default; + WritableSubResource diskEncryptionSet = default; + VmDiskSecurityProfile securityProfile = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("storageAccountType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + storageAccountType = new StorageAccountType(property.Value.GetString()); + continue; + } + if (property.NameEquals("diskEncryptionSet"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("securityProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityProfile = VmDiskSecurityProfile.DeserializeVmDiskSecurityProfile(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetManagedDiskParameters(storageAccountType, diskEncryptionSet, securityProfile, 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(VirtualMachineScaleSetManagedDiskParameters)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetManagedDiskParameters IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetManagedDiskParameters(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetManagedDiskParameters)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.cs new file mode 100644 index 000000000000..27c84e4e48fe --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.cs @@ -0,0 +1,99 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes the parameters of a ScaleSet managed disk. + public partial class VirtualMachineScaleSetManagedDiskParameters + { + /// + /// 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 VirtualMachineScaleSetManagedDiskParameters() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can + /// only be used with data disks, it cannot be used with OS Disk. + /// + /// + /// Specifies the customer managed disk encryption set resource id for the managed + /// disk. + /// + /// Specifies the security profile for the managed disk. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetManagedDiskParameters(StorageAccountType? storageAccountType, WritableSubResource diskEncryptionSet, VmDiskSecurityProfile securityProfile, IDictionary serializedAdditionalRawData) + { + StorageAccountType = storageAccountType; + DiskEncryptionSet = diskEncryptionSet; + SecurityProfile = securityProfile; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the storage account type for the managed disk. NOTE: UltraSSD_LRS can + /// only be used with data disks, it cannot be used with OS Disk. + /// + public StorageAccountType? StorageAccountType { get; set; } + /// + /// Specifies the customer managed disk encryption set resource id for the managed + /// disk. + /// + internal WritableSubResource DiskEncryptionSet { get; set; } + /// Gets or sets Id. + public ResourceIdentifier DiskEncryptionSetId + { + get => DiskEncryptionSet is null ? default : DiskEncryptionSet.Id; + set + { + if (DiskEncryptionSet is null) + DiskEncryptionSet = new WritableSubResource(); + DiskEncryptionSet.Id = value; + } + } + + /// Specifies the security profile for the managed disk. + public VmDiskSecurityProfile SecurityProfile { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs new file mode 100644 index 000000000000..d921fed39def --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs @@ -0,0 +1,134 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetNetworkConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetNetworkConfiguration 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(VirtualMachineScaleSetNetworkConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetNetworkConfiguration(document.RootElement, options); + } + + internal static VirtualMachineScaleSetNetworkConfiguration DeserializeVirtualMachineScaleSetNetworkConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VirtualMachineScaleSetNetworkConfigurationProperties properties = 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("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualMachineScaleSetNetworkConfigurationProperties.DeserializeVirtualMachineScaleSetNetworkConfigurationProperties(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetNetworkConfiguration(name, 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(VirtualMachineScaleSetNetworkConfiguration)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetNetworkConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetNetworkConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.cs new file mode 100644 index 000000000000..3bb594c389d5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set network profile's network configurations. + public partial class VirtualMachineScaleSetNetworkConfiguration + { + /// + /// 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 network configuration name. + /// is null. + public VirtualMachineScaleSetNetworkConfiguration(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The network configuration name. + /// Describes a virtual machine scale set network profile's IP configuration. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetNetworkConfiguration(string name, VirtualMachineScaleSetNetworkConfigurationProperties properties, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetNetworkConfiguration() + { + } + + /// The network configuration name. + public string Name { get; set; } + /// Describes a virtual machine scale set network profile's IP configuration. + public VirtualMachineScaleSetNetworkConfigurationProperties Properties { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs new file mode 100644 index 000000000000..53cc6ef7cdfa --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs @@ -0,0 +1,136 @@ +// 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.ComputeFleet.Models +{ + internal partial class VirtualMachineScaleSetNetworkConfigurationDnsSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfigurationDnsSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(DnsServers)) + { + writer.WritePropertyName("dnsServers"u8); + writer.WriteStartArray(); + foreach (var item in DnsServers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetNetworkConfigurationDnsSettings 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(VirtualMachineScaleSetNetworkConfigurationDnsSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetNetworkConfigurationDnsSettings(document.RootElement, options); + } + + internal static VirtualMachineScaleSetNetworkConfigurationDnsSettings DeserializeVirtualMachineScaleSetNetworkConfigurationDnsSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList dnsServers = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dnsServers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dnsServers = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetNetworkConfigurationDnsSettings(dnsServers ?? 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(VirtualMachineScaleSetNetworkConfigurationDnsSettings)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetNetworkConfigurationDnsSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetNetworkConfigurationDnsSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfigurationDnsSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.cs new file mode 100644 index 000000000000..6813f6fa7383 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.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.ComputeFleet.Models +{ + /// Describes a virtual machines scale sets network configuration's DNS settings. + internal partial class VirtualMachineScaleSetNetworkConfigurationDnsSettings + { + /// + /// 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 VirtualMachineScaleSetNetworkConfigurationDnsSettings() + { + DnsServers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of DNS servers IP addresses. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetNetworkConfigurationDnsSettings(IList dnsServers, IDictionary serializedAdditionalRawData) + { + DnsServers = dnsServers; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of DNS servers IP addresses. + public IList DnsServers { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.Serialization.cs new file mode 100644 index 000000000000..98dc01c38810 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.Serialization.cs @@ -0,0 +1,292 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetNetworkConfigurationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfigurationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Primary)) + { + writer.WritePropertyName("primary"u8); + writer.WriteBooleanValue(Primary.Value); + } + if (Optional.IsDefined(EnableAcceleratedNetworking)) + { + writer.WritePropertyName("enableAcceleratedNetworking"u8); + writer.WriteBooleanValue(EnableAcceleratedNetworking.Value); + } + if (Optional.IsDefined(DisableTcpStateTracking)) + { + writer.WritePropertyName("disableTcpStateTracking"u8); + writer.WriteBooleanValue(DisableTcpStateTracking.Value); + } + if (Optional.IsDefined(EnableFpga)) + { + writer.WritePropertyName("enableFpga"u8); + writer.WriteBooleanValue(EnableFpga.Value); + } + if (Optional.IsDefined(NetworkSecurityGroup)) + { + writer.WritePropertyName("networkSecurityGroup"u8); + JsonSerializer.Serialize(writer, NetworkSecurityGroup); + } + if (Optional.IsDefined(DnsSettings)) + { + writer.WritePropertyName("dnsSettings"u8); + writer.WriteObjectValue(DnsSettings, options); + } + writer.WritePropertyName("ipConfigurations"u8); + writer.WriteStartArray(); + foreach (var item in IPConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(EnableIPForwarding)) + { + writer.WritePropertyName("enableIPForwarding"u8); + writer.WriteBooleanValue(EnableIPForwarding.Value); + } + if (Optional.IsDefined(DeleteOption)) + { + writer.WritePropertyName("deleteOption"u8); + writer.WriteStringValue(DeleteOption.Value.ToString()); + } + if (Optional.IsDefined(AuxiliaryMode)) + { + writer.WritePropertyName("auxiliaryMode"u8); + writer.WriteStringValue(AuxiliaryMode.Value.ToString()); + } + if (Optional.IsDefined(AuxiliarySku)) + { + writer.WritePropertyName("auxiliarySku"u8); + writer.WriteStringValue(AuxiliarySku.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetNetworkConfigurationProperties 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(VirtualMachineScaleSetNetworkConfigurationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetNetworkConfigurationProperties(document.RootElement, options); + } + + internal static VirtualMachineScaleSetNetworkConfigurationProperties DeserializeVirtualMachineScaleSetNetworkConfigurationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? primary = default; + bool? enableAcceleratedNetworking = default; + bool? disableTcpStateTracking = default; + bool? enableFpga = default; + WritableSubResource networkSecurityGroup = default; + VirtualMachineScaleSetNetworkConfigurationDnsSettings dnsSettings = default; + IList ipConfigurations = default; + bool? enableIPForwarding = default; + DeleteOption? deleteOption = default; + NetworkInterfaceAuxiliaryMode? auxiliaryMode = default; + NetworkInterfaceAuxiliarySku? auxiliarySku = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("primary"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + primary = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enableAcceleratedNetworking"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableAcceleratedNetworking = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("disableTcpStateTracking"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + disableTcpStateTracking = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enableFpga"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableFpga = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("networkSecurityGroup"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkSecurityGroup = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("dnsSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dnsSettings = VirtualMachineScaleSetNetworkConfigurationDnsSettings.DeserializeVirtualMachineScaleSetNetworkConfigurationDnsSettings(property.Value, options); + continue; + } + if (property.NameEquals("ipConfigurations"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VirtualMachineScaleSetIPConfiguration.DeserializeVirtualMachineScaleSetIPConfiguration(item, options)); + } + ipConfigurations = array; + continue; + } + if (property.NameEquals("enableIPForwarding"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableIPForwarding = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("deleteOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deleteOption = new DeleteOption(property.Value.GetString()); + continue; + } + if (property.NameEquals("auxiliaryMode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + auxiliaryMode = new NetworkInterfaceAuxiliaryMode(property.Value.GetString()); + continue; + } + if (property.NameEquals("auxiliarySku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + auxiliarySku = new NetworkInterfaceAuxiliarySku(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetNetworkConfigurationProperties( + primary, + enableAcceleratedNetworking, + disableTcpStateTracking, + enableFpga, + networkSecurityGroup, + dnsSettings, + ipConfigurations, + enableIPForwarding, + deleteOption, + auxiliaryMode, + auxiliarySku, + 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(VirtualMachineScaleSetNetworkConfigurationProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetNetworkConfigurationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetNetworkConfigurationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfigurationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.cs new file mode 100644 index 000000000000..d227679063c5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationProperties.cs @@ -0,0 +1,159 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set network profile's IP configuration. + public partial class VirtualMachineScaleSetNetworkConfigurationProperties + { + /// + /// 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 . + /// Specifies the IP configurations of the network interface. + /// is null. + public VirtualMachineScaleSetNetworkConfigurationProperties(IEnumerable ipConfigurations) + { + Argument.AssertNotNull(ipConfigurations, nameof(ipConfigurations)); + + IPConfigurations = ipConfigurations.ToList(); + } + + /// Initializes a new instance of . + /// + /// Specifies the primary network interface in case the virtual machine has more + /// than 1 network interface. + /// + /// Specifies whether the network interface is accelerated networking-enabled. + /// Specifies whether the network interface is disabled for tcp state tracking. + /// Specifies whether the network interface is FPGA networking-enabled. + /// The network security group. + /// The dns settings to be applied on the network interfaces. + /// Specifies the IP configurations of the network interface. + /// Whether IP forwarding enabled on this NIC. + /// Specify what happens to the network interface when the VM is deleted. + /// + /// Specifies whether the Auxiliary mode is enabled for the Network Interface + /// resource. + /// + /// + /// Specifies whether the Auxiliary sku is enabled for the Network Interface + /// resource. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetNetworkConfigurationProperties(bool? primary, bool? enableAcceleratedNetworking, bool? disableTcpStateTracking, bool? enableFpga, WritableSubResource networkSecurityGroup, VirtualMachineScaleSetNetworkConfigurationDnsSettings dnsSettings, IList ipConfigurations, bool? enableIPForwarding, DeleteOption? deleteOption, NetworkInterfaceAuxiliaryMode? auxiliaryMode, NetworkInterfaceAuxiliarySku? auxiliarySku, IDictionary serializedAdditionalRawData) + { + Primary = primary; + EnableAcceleratedNetworking = enableAcceleratedNetworking; + DisableTcpStateTracking = disableTcpStateTracking; + EnableFpga = enableFpga; + NetworkSecurityGroup = networkSecurityGroup; + DnsSettings = dnsSettings; + IPConfigurations = ipConfigurations; + EnableIPForwarding = enableIPForwarding; + DeleteOption = deleteOption; + AuxiliaryMode = auxiliaryMode; + AuxiliarySku = auxiliarySku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetNetworkConfigurationProperties() + { + } + + /// + /// Specifies the primary network interface in case the virtual machine has more + /// than 1 network interface. + /// + public bool? Primary { get; set; } + /// Specifies whether the network interface is accelerated networking-enabled. + public bool? EnableAcceleratedNetworking { get; set; } + /// Specifies whether the network interface is disabled for tcp state tracking. + public bool? DisableTcpStateTracking { get; set; } + /// Specifies whether the network interface is FPGA networking-enabled. + public bool? EnableFpga { get; set; } + /// The network security group. + internal WritableSubResource NetworkSecurityGroup { get; set; } + /// Gets or sets Id. + public ResourceIdentifier NetworkSecurityGroupId + { + get => NetworkSecurityGroup is null ? default : NetworkSecurityGroup.Id; + set + { + if (NetworkSecurityGroup is null) + NetworkSecurityGroup = new WritableSubResource(); + NetworkSecurityGroup.Id = value; + } + } + + /// The dns settings to be applied on the network interfaces. + internal VirtualMachineScaleSetNetworkConfigurationDnsSettings DnsSettings { get; set; } + /// List of DNS servers IP addresses. + public IList DnsServers + { + get + { + if (DnsSettings is null) + DnsSettings = new VirtualMachineScaleSetNetworkConfigurationDnsSettings(); + return DnsSettings.DnsServers; + } + } + + /// Specifies the IP configurations of the network interface. + public IList IPConfigurations { get; } + /// Whether IP forwarding enabled on this NIC. + public bool? EnableIPForwarding { get; set; } + /// Specify what happens to the network interface when the VM is deleted. + public DeleteOption? DeleteOption { get; set; } + /// + /// Specifies whether the Auxiliary mode is enabled for the Network Interface + /// resource. + /// + public NetworkInterfaceAuxiliaryMode? AuxiliaryMode { get; set; } + /// + /// Specifies whether the Auxiliary sku is enabled for the Network Interface + /// resource. + /// + public NetworkInterfaceAuxiliarySku? AuxiliarySku { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs new file mode 100644 index 000000000000..dda04c8fce79 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetNetworkProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(HealthProbe)) + { + writer.WritePropertyName("healthProbe"u8); + JsonSerializer.Serialize(writer, HealthProbe); + } + if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) + { + writer.WritePropertyName("networkInterfaceConfigurations"u8); + writer.WriteStartArray(); + foreach (var item in NetworkInterfaceConfigurations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(NetworkApiVersion)) + { + writer.WritePropertyName("networkApiVersion"u8); + writer.WriteStringValue(NetworkApiVersion.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetNetworkProfile 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(VirtualMachineScaleSetNetworkProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetNetworkProfile(document.RootElement, options); + } + + internal static VirtualMachineScaleSetNetworkProfile DeserializeVirtualMachineScaleSetNetworkProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WritableSubResource healthProbe = default; + IList networkInterfaceConfigurations = default; + NetworkApiVersion? networkApiVersion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("healthProbe"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + healthProbe = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("networkInterfaceConfigurations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VirtualMachineScaleSetNetworkConfiguration.DeserializeVirtualMachineScaleSetNetworkConfiguration(item, options)); + } + networkInterfaceConfigurations = array; + continue; + } + if (property.NameEquals("networkApiVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + networkApiVersion = new NetworkApiVersion(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetNetworkProfile(healthProbe, networkInterfaceConfigurations ?? new ChangeTrackingList(), networkApiVersion, 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(VirtualMachineScaleSetNetworkProfile)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetNetworkProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetNetworkProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.cs new file mode 100644 index 000000000000..bf73b459d1c9 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.cs @@ -0,0 +1,104 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set network profile. + public partial class VirtualMachineScaleSetNetworkProfile + { + /// + /// 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 VirtualMachineScaleSetNetworkProfile() + { + NetworkInterfaceConfigurations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// A reference to a load balancer probe used to determine the health of an + /// instance in the virtual machine scale set. The reference will be in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. + /// + /// The list of network configurations. + /// + /// specifies the Microsoft.Network API version used when creating networking + /// resources in the Network Interface Configurations for Virtual Machine Scale Set + /// with orchestration mode 'Flexible' + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetNetworkProfile(WritableSubResource healthProbe, IList networkInterfaceConfigurations, NetworkApiVersion? networkApiVersion, IDictionary serializedAdditionalRawData) + { + HealthProbe = healthProbe; + NetworkInterfaceConfigurations = networkInterfaceConfigurations; + NetworkApiVersion = networkApiVersion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A reference to a load balancer probe used to determine the health of an + /// instance in the virtual machine scale set. The reference will be in the form: + /// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}'. + /// + internal WritableSubResource HealthProbe { get; set; } + /// Gets or sets Id. + public ResourceIdentifier HealthProbeId + { + get => HealthProbe is null ? default : HealthProbe.Id; + set + { + if (HealthProbe is null) + HealthProbe = new WritableSubResource(); + HealthProbe.Id = value; + } + } + + /// The list of network configurations. + public IList NetworkInterfaceConfigurations { get; } + /// + /// specifies the Microsoft.Network API version used when creating networking + /// resources in the Network Interface Configurations for Virtual Machine Scale Set + /// with orchestration mode 'Flexible' + /// + public NetworkApiVersion? NetworkApiVersion { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs new file mode 100644 index 000000000000..2b13933effa5 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs @@ -0,0 +1,287 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetOSDisk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSDisk)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Caching)) + { + writer.WritePropertyName("caching"u8); + writer.WriteStringValue(Caching.Value.ToString()); + } + if (Optional.IsDefined(WriteAcceleratorEnabled)) + { + writer.WritePropertyName("writeAcceleratorEnabled"u8); + writer.WriteBooleanValue(WriteAcceleratorEnabled.Value); + } + writer.WritePropertyName("createOption"u8); + writer.WriteStringValue(CreateOption.ToString()); + if (Optional.IsDefined(DiffDiskSettings)) + { + writer.WritePropertyName("diffDiskSettings"u8); + writer.WriteObjectValue(DiffDiskSettings, options); + } + if (Optional.IsDefined(DiskSizeGB)) + { + writer.WritePropertyName("diskSizeGB"u8); + writer.WriteNumberValue(DiskSizeGB.Value); + } + if (Optional.IsDefined(OSType)) + { + writer.WritePropertyName("osType"u8); + writer.WriteStringValue(OSType.Value.ToString()); + } + if (Optional.IsDefined(Image)) + { + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + if (Optional.IsCollectionDefined(VhdContainers)) + { + writer.WritePropertyName("vhdContainers"u8); + writer.WriteStartArray(); + foreach (var item in VhdContainers) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ManagedDisk)) + { + writer.WritePropertyName("managedDisk"u8); + writer.WriteObjectValue(ManagedDisk, options); + } + if (Optional.IsDefined(DeleteOption)) + { + writer.WritePropertyName("deleteOption"u8); + writer.WriteStringValue(DeleteOption.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetOSDisk 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(VirtualMachineScaleSetOSDisk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetOSDisk(document.RootElement, options); + } + + internal static VirtualMachineScaleSetOSDisk DeserializeVirtualMachineScaleSetOSDisk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + CachingType? caching = default; + bool? writeAcceleratorEnabled = default; + DiskCreateOptionType createOption = default; + DiffDiskSettings diffDiskSettings = default; + int? diskSizeGB = default; + OperatingSystemType? osType = default; + VirtualHardDisk image = default; + IList vhdContainers = default; + VirtualMachineScaleSetManagedDiskParameters managedDisk = default; + DiskDeleteOptionType? deleteOption = 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("caching"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + caching = new CachingType(property.Value.GetString()); + continue; + } + if (property.NameEquals("writeAcceleratorEnabled"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + writeAcceleratorEnabled = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("createOption"u8)) + { + createOption = new DiskCreateOptionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("diffDiskSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diffDiskSettings = DiffDiskSettings.DeserializeDiffDiskSettings(property.Value, options); + continue; + } + if (property.NameEquals("diskSizeGB"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskSizeGB = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("osType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + osType = new OperatingSystemType(property.Value.GetString()); + continue; + } + if (property.NameEquals("image"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + image = VirtualHardDisk.DeserializeVirtualHardDisk(property.Value, options); + continue; + } + if (property.NameEquals("vhdContainers"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vhdContainers = array; + continue; + } + if (property.NameEquals("managedDisk"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + managedDisk = VirtualMachineScaleSetManagedDiskParameters.DeserializeVirtualMachineScaleSetManagedDiskParameters(property.Value, options); + continue; + } + if (property.NameEquals("deleteOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deleteOption = new DiskDeleteOptionType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetOSDisk( + name, + caching, + writeAcceleratorEnabled, + createOption, + diffDiskSettings, + diskSizeGB, + osType, + image, + vhdContainers ?? new ChangeTrackingList(), + managedDisk, + deleteOption, + 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(VirtualMachineScaleSetOSDisk)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetOSDisk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetOSDisk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSDisk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.cs new file mode 100644 index 000000000000..b4e26d1b0ca9 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSDisk.cs @@ -0,0 +1,199 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set operating system disk. + public partial class VirtualMachineScaleSetOSDisk + { + /// + /// 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 . + /// + /// Specifies how the virtual machines in the scale set should be created. The only + /// allowed value is: **FromImage.** This value is used when you are using an image + /// to create the virtual machine. If you are using a platform image, you also use + /// the imageReference element described above. If you are using a marketplace + /// image, you also use the plan element previously described. + /// + public VirtualMachineScaleSetOSDisk(DiskCreateOptionType createOption) + { + CreateOption = createOption; + VhdContainers = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The disk name. + /// + /// Specifies the caching requirements. Possible values are: **None,** + /// **ReadOnly,** **ReadWrite.** The default values are: **None for Standard + /// storage. ReadOnly for Premium storage.** + /// + /// Specifies whether writeAccelerator should be enabled or disabled on the disk. + /// + /// Specifies how the virtual machines in the scale set should be created. The only + /// allowed value is: **FromImage.** This value is used when you are using an image + /// to create the virtual machine. If you are using a platform image, you also use + /// the imageReference element described above. If you are using a marketplace + /// image, you also use the plan element previously described. + /// + /// + /// Specifies the ephemeral disk Settings for the operating system disk used by the + /// virtual machine scale set. + /// + /// + /// Specifies the size of an empty data disk in gigabytes. This element can be used + /// to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' + /// is the number of bytes x 1024^3 for the disk and the value cannot + /// be larger than 1023. + /// + /// + /// This property allows you to specify the type of the OS that is included in the + /// disk if creating a VM from user-image or a specialized VHD. Possible values + /// are: **Windows,** **Linux.** + /// + /// Specifies information about the unmanaged user image to base the scale set on. + /// + /// Specifies the container urls that are used to store operating system disks for + /// the scale set. + /// + /// The managed disk parameters. + /// + /// Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion + /// (This feature is available for VMSS with Flexible OrchestrationMode only). + /// <br><br> Possible values: <br><br> **Delete** If this value is used, the OS + /// disk is deleted when VMSS Flex VM is deleted.<br><br> **Detach** If this value + /// is used, the OS disk is retained after VMSS Flex VM is deleted. <br><br> The + /// default value is set to **Delete**. For an Ephemeral OS Disk, the default value + /// is set to **Delete**. User cannot change the delete option for Ephemeral OS + /// Disk. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetOSDisk(string name, CachingType? caching, bool? writeAcceleratorEnabled, DiskCreateOptionType createOption, DiffDiskSettings diffDiskSettings, int? diskSizeGB, OperatingSystemType? osType, VirtualHardDisk image, IList vhdContainers, VirtualMachineScaleSetManagedDiskParameters managedDisk, DiskDeleteOptionType? deleteOption, IDictionary serializedAdditionalRawData) + { + Name = name; + Caching = caching; + WriteAcceleratorEnabled = writeAcceleratorEnabled; + CreateOption = createOption; + DiffDiskSettings = diffDiskSettings; + DiskSizeGB = diskSizeGB; + OSType = osType; + Image = image; + VhdContainers = vhdContainers; + ManagedDisk = managedDisk; + DeleteOption = deleteOption; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetOSDisk() + { + } + + /// The disk name. + public string Name { get; set; } + /// + /// Specifies the caching requirements. Possible values are: **None,** + /// **ReadOnly,** **ReadWrite.** The default values are: **None for Standard + /// storage. ReadOnly for Premium storage.** + /// + public CachingType? Caching { get; set; } + /// Specifies whether writeAccelerator should be enabled or disabled on the disk. + public bool? WriteAcceleratorEnabled { get; set; } + /// + /// Specifies how the virtual machines in the scale set should be created. The only + /// allowed value is: **FromImage.** This value is used when you are using an image + /// to create the virtual machine. If you are using a platform image, you also use + /// the imageReference element described above. If you are using a marketplace + /// image, you also use the plan element previously described. + /// + public DiskCreateOptionType CreateOption { get; set; } + /// + /// Specifies the ephemeral disk Settings for the operating system disk used by the + /// virtual machine scale set. + /// + public DiffDiskSettings DiffDiskSettings { get; set; } + /// + /// Specifies the size of an empty data disk in gigabytes. This element can be used + /// to overwrite the size of the disk in a virtual machine image. The property 'diskSizeGB' + /// is the number of bytes x 1024^3 for the disk and the value cannot + /// be larger than 1023. + /// + public int? DiskSizeGB { get; set; } + /// + /// This property allows you to specify the type of the OS that is included in the + /// disk if creating a VM from user-image or a specialized VHD. Possible values + /// are: **Windows,** **Linux.** + /// + public OperatingSystemType? OSType { get; set; } + /// Specifies information about the unmanaged user image to base the scale set on. + internal VirtualHardDisk Image { get; set; } + /// Specifies the virtual hard disk's uri. + public string ImageUri + { + get => Image is null ? default : Image.Uri; + set + { + if (Image is null) + Image = new VirtualHardDisk(); + Image.Uri = value; + } + } + + /// + /// Specifies the container urls that are used to store operating system disks for + /// the scale set. + /// + public IList VhdContainers { get; } + /// The managed disk parameters. + public VirtualMachineScaleSetManagedDiskParameters ManagedDisk { get; set; } + /// + /// Specifies whether OS Disk should be deleted or detached upon VMSS Flex deletion + /// (This feature is available for VMSS with Flexible OrchestrationMode only). + /// <br><br> Possible values: <br><br> **Delete** If this value is used, the OS + /// disk is deleted when VMSS Flex VM is deleted.<br><br> **Detach** If this value + /// is used, the OS disk is retained after VMSS Flex VM is deleted. <br><br> The + /// default value is set to **Delete**. For an Ephemeral OS Disk, the default value + /// is set to **Delete**. User cannot change the delete option for Ephemeral OS + /// Disk. + /// + public DiskDeleteOptionType? DeleteOption { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs new file mode 100644 index 000000000000..6e51224c82d6 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs @@ -0,0 +1,250 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetOSProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ComputerNamePrefix)) + { + writer.WritePropertyName("computerNamePrefix"u8); + writer.WriteStringValue(ComputerNamePrefix); + } + if (Optional.IsDefined(AdminUsername)) + { + writer.WritePropertyName("adminUsername"u8); + writer.WriteStringValue(AdminUsername); + } + if (Optional.IsDefined(AdminPassword)) + { + writer.WritePropertyName("adminPassword"u8); + writer.WriteStringValue(AdminPassword); + } + if (Optional.IsDefined(CustomData)) + { + writer.WritePropertyName("customData"u8); + writer.WriteStringValue(CustomData); + } + if (Optional.IsDefined(WindowsConfiguration)) + { + writer.WritePropertyName("windowsConfiguration"u8); + writer.WriteObjectValue(WindowsConfiguration, options); + } + if (Optional.IsDefined(LinuxConfiguration)) + { + writer.WritePropertyName("linuxConfiguration"u8); + writer.WriteObjectValue(LinuxConfiguration, options); + } + if (Optional.IsCollectionDefined(Secrets)) + { + writer.WritePropertyName("secrets"u8); + writer.WriteStartArray(); + foreach (var item in Secrets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(AllowExtensionOperations)) + { + writer.WritePropertyName("allowExtensionOperations"u8); + writer.WriteBooleanValue(AllowExtensionOperations.Value); + } + if (Optional.IsDefined(RequireGuestProvisionSignal)) + { + writer.WritePropertyName("requireGuestProvisionSignal"u8); + writer.WriteBooleanValue(RequireGuestProvisionSignal.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetOSProfile 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(VirtualMachineScaleSetOSProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetOSProfile(document.RootElement, options); + } + + internal static VirtualMachineScaleSetOSProfile DeserializeVirtualMachineScaleSetOSProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string computerNamePrefix = default; + string adminUsername = default; + string adminPassword = default; + string customData = default; + WindowsConfiguration windowsConfiguration = default; + LinuxConfiguration linuxConfiguration = default; + IList secrets = default; + bool? allowExtensionOperations = default; + bool? requireGuestProvisionSignal = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("computerNamePrefix"u8)) + { + computerNamePrefix = property.Value.GetString(); + continue; + } + if (property.NameEquals("adminUsername"u8)) + { + adminUsername = property.Value.GetString(); + continue; + } + if (property.NameEquals("adminPassword"u8)) + { + adminPassword = property.Value.GetString(); + continue; + } + if (property.NameEquals("customData"u8)) + { + customData = property.Value.GetString(); + continue; + } + if (property.NameEquals("windowsConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + windowsConfiguration = WindowsConfiguration.DeserializeWindowsConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("linuxConfiguration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + linuxConfiguration = LinuxConfiguration.DeserializeLinuxConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("secrets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VaultSecretGroup.DeserializeVaultSecretGroup(item, options)); + } + secrets = array; + continue; + } + if (property.NameEquals("allowExtensionOperations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + allowExtensionOperations = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("requireGuestProvisionSignal"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + requireGuestProvisionSignal = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetOSProfile( + computerNamePrefix, + adminUsername, + adminPassword, + customData, + windowsConfiguration, + linuxConfiguration, + secrets ?? new ChangeTrackingList(), + allowExtensionOperations, + requireGuestProvisionSignal, + 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(VirtualMachineScaleSetOSProfile)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetOSProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetOSProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.cs new file mode 100644 index 000000000000..2af67213a0fa --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetOSProfile.cs @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set OS profile. + public partial class VirtualMachineScaleSetOSProfile + { + /// + /// 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 VirtualMachineScaleSetOSProfile() + { + Secrets = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Specifies the computer name prefix for all of the virtual machines in the scale + /// set. Computer name prefixes must be 1 to 15 characters long. + /// + /// + /// Specifies the name of the administrator account. <br><br> **Windows-only + /// restriction:** Cannot end in "." <br><br> **Disallowed values:** + /// "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", + /// "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", + /// "console", "david", "guest", "john", "owner", "root", "server", "sql", + /// "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + /// <br><br> **Minimum-length (Linux):** 1 character <br><br> **Max-length + /// (Linux):** 64 characters <br><br> **Max-length (Windows):** 20 characters + /// + /// + /// Specifies the password of the administrator account. <br><br> **Minimum-length + /// (Windows):** 8 characters <br><br> **Minimum-length (Linux):** 6 characters + /// <br><br> **Max-length (Windows):** 123 characters <br><br> **Max-length + /// (Linux):** 72 characters <br><br> **Complexity requirements:** 3 out of 4 + /// conditions below need to be fulfilled <br> Has lower characters <br>Has upper + /// characters <br> Has a digit <br> Has a special character (Regex match [\W_]) + /// <br><br> **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", + /// "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", + /// "Password22", "iloveyou!" <br><br> For resetting the password, see [How to + /// reset the Remote Desktop service or its login password in a Windows + /// VM](https://docs.microsoft.com/troubleshoot/azure/virtual-machines/reset-rdp) + /// <br><br> For resetting root password, see [Manage users, SSH, and check or + /// repair disks on Azure Linux VMs using the VMAccess + /// Extension](https://docs.microsoft.com/troubleshoot/azure/virtual-machines/troubleshoot-ssh-connection) + /// + /// + /// Specifies a base-64 encoded string of custom data. The base-64 encoded string + /// is decoded to a binary array that is saved as a file on the Virtual Machine. + /// The maximum length of the binary array is 65535 bytes. For using cloud-init for + /// your VM, see [Using cloud-init to customize a Linux VM during + /// creation](https://docs.microsoft.com/azure/virtual-machines/linux/using-cloud-init) + /// + /// Specifies Windows operating system settings on the virtual machine. + /// + /// Specifies the Linux operating system settings on the virtual machine. For a + /// list of supported Linux distributions, see [Linux on Azure-Endorsed + /// Distributions](https://docs.microsoft.com/azure/virtual-machines/linux/endorsed-distros). + /// + /// + /// Specifies set of certificates that should be installed onto the virtual + /// machines in the scale set. To install certificates on a virtual machine it is + /// recommended to use the [Azure Key Vault virtual machine extension for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + /// + /// Specifies whether extension operations should be allowed on the virtual machine + /// scale set. This may only be set to False when no extensions are present on the + /// virtual machine scale set. + /// + /// Optional property which must either be set to True or omitted. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetOSProfile(string computerNamePrefix, string adminUsername, string adminPassword, string customData, WindowsConfiguration windowsConfiguration, LinuxConfiguration linuxConfiguration, IList secrets, bool? allowExtensionOperations, bool? requireGuestProvisionSignal, IDictionary serializedAdditionalRawData) + { + ComputerNamePrefix = computerNamePrefix; + AdminUsername = adminUsername; + AdminPassword = adminPassword; + CustomData = customData; + WindowsConfiguration = windowsConfiguration; + LinuxConfiguration = linuxConfiguration; + Secrets = secrets; + AllowExtensionOperations = allowExtensionOperations; + RequireGuestProvisionSignal = requireGuestProvisionSignal; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the computer name prefix for all of the virtual machines in the scale + /// set. Computer name prefixes must be 1 to 15 characters long. + /// + public string ComputerNamePrefix { get; set; } + /// + /// Specifies the name of the administrator account. <br><br> **Windows-only + /// restriction:** Cannot end in "." <br><br> **Disallowed values:** + /// "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", + /// "admin1", "1", "123", "a", "actuser", "adm", "admin2", "aspnet", "backup", + /// "console", "david", "guest", "john", "owner", "root", "server", "sql", + /// "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + /// <br><br> **Minimum-length (Linux):** 1 character <br><br> **Max-length + /// (Linux):** 64 characters <br><br> **Max-length (Windows):** 20 characters + /// + public string AdminUsername { get; set; } + /// + /// Specifies the password of the administrator account. <br><br> **Minimum-length + /// (Windows):** 8 characters <br><br> **Minimum-length (Linux):** 6 characters + /// <br><br> **Max-length (Windows):** 123 characters <br><br> **Max-length + /// (Linux):** 72 characters <br><br> **Complexity requirements:** 3 out of 4 + /// conditions below need to be fulfilled <br> Has lower characters <br>Has upper + /// characters <br> Has a digit <br> Has a special character (Regex match [\W_]) + /// <br><br> **Disallowed values:** "abc@123", "P@$$w0rd", "P@ssw0rd", + /// "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", + /// "Password22", "iloveyou!" <br><br> For resetting the password, see [How to + /// reset the Remote Desktop service or its login password in a Windows + /// VM](https://docs.microsoft.com/troubleshoot/azure/virtual-machines/reset-rdp) + /// <br><br> For resetting root password, see [Manage users, SSH, and check or + /// repair disks on Azure Linux VMs using the VMAccess + /// Extension](https://docs.microsoft.com/troubleshoot/azure/virtual-machines/troubleshoot-ssh-connection) + /// + public string AdminPassword { get; set; } + /// + /// Specifies a base-64 encoded string of custom data. The base-64 encoded string + /// is decoded to a binary array that is saved as a file on the Virtual Machine. + /// The maximum length of the binary array is 65535 bytes. For using cloud-init for + /// your VM, see [Using cloud-init to customize a Linux VM during + /// creation](https://docs.microsoft.com/azure/virtual-machines/linux/using-cloud-init) + /// + public string CustomData { get; set; } + /// Specifies Windows operating system settings on the virtual machine. + public WindowsConfiguration WindowsConfiguration { get; set; } + /// + /// Specifies the Linux operating system settings on the virtual machine. For a + /// list of supported Linux distributions, see [Linux on Azure-Endorsed + /// Distributions](https://docs.microsoft.com/azure/virtual-machines/linux/endorsed-distros). + /// + public LinuxConfiguration LinuxConfiguration { get; set; } + /// + /// Specifies set of certificates that should be installed onto the virtual + /// machines in the scale set. To install certificates on a virtual machine it is + /// recommended to use the [Azure Key Vault virtual machine extension for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + public IList Secrets { get; } + /// + /// Specifies whether extension operations should be allowed on the virtual machine + /// scale set. This may only be set to False when no extensions are present on the + /// virtual machine scale set. + /// + public bool? AllowExtensionOperations { get; set; } + /// Optional property which must either be set to True or omitted. + public bool? RequireGuestProvisionSignal { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs new file mode 100644 index 000000000000..a24b9fb442b2 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetPublicIPAddressConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } + if (Optional.IsDefined(Sku)) + { + writer.WritePropertyName("sku"u8); + writer.WriteObjectValue(Sku, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetPublicIPAddressConfiguration 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(VirtualMachineScaleSetPublicIPAddressConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfiguration(document.RootElement, options); + } + + internal static VirtualMachineScaleSetPublicIPAddressConfiguration DeserializeVirtualMachineScaleSetPublicIPAddressConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VirtualMachineScaleSetPublicIPAddressConfigurationProperties properties = default; + PublicIPAddressSku sku = 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("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = VirtualMachineScaleSetPublicIPAddressConfigurationProperties.DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationProperties(property.Value, options); + continue; + } + if (property.NameEquals("sku"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + sku = PublicIPAddressSku.DeserializePublicIPAddressSku(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetPublicIPAddressConfiguration(name, properties, sku, 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(VirtualMachineScaleSetPublicIPAddressConfiguration)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetPublicIPAddressConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.cs new file mode 100644 index 000000000000..08a778db6999 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Describes a virtual machines scale set IP Configuration's PublicIPAddress + /// configuration + /// + public partial class VirtualMachineScaleSetPublicIPAddressConfiguration + { + /// + /// 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 publicIP address configuration name. + /// is null. + public VirtualMachineScaleSetPublicIPAddressConfiguration(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The publicIP address configuration name. + /// + /// Describes a virtual machines scale set IP Configuration's PublicIPAddress + /// configuration + /// + /// + /// Describes the public IP Sku. It can only be set with OrchestrationMode as + /// Flexible. + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetPublicIPAddressConfiguration(string name, VirtualMachineScaleSetPublicIPAddressConfigurationProperties properties, PublicIPAddressSku sku, IDictionary serializedAdditionalRawData) + { + Name = name; + Properties = properties; + Sku = sku; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetPublicIPAddressConfiguration() + { + } + + /// The publicIP address configuration name. + public string Name { get; set; } + /// + /// Describes a virtual machines scale set IP Configuration's PublicIPAddress + /// configuration + /// + public VirtualMachineScaleSetPublicIPAddressConfigurationProperties Properties { get; set; } + /// + /// Describes the public IP Sku. It can only be set with OrchestrationMode as + /// Flexible. + /// + public PublicIPAddressSku Sku { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs new file mode 100644 index 000000000000..68151c384886 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs @@ -0,0 +1,134 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("domainNameLabel"u8); + writer.WriteStringValue(DomainNameLabel); + if (Optional.IsDefined(DomainNameLabelScope)) + { + writer.WritePropertyName("domainNameLabelScope"u8); + writer.WriteStringValue(DomainNameLabelScope.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings 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(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(document.RootElement, options); + } + + internal static VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string domainNameLabel = default; + DomainNameLabelScopeType? domainNameLabelScope = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("domainNameLabel"u8)) + { + domainNameLabel = property.Value.GetString(); + continue; + } + if (property.NameEquals("domainNameLabelScope"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + domainNameLabelScope = new DomainNameLabelScopeType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(domainNameLabel, domainNameLabelScope, 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(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.cs new file mode 100644 index 000000000000..68dc6414f938 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machines scale sets network configuration's DNS settings. + public partial class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings + { + /// + /// 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 Domain name label.The concatenation of the domain name label and vm index + /// will be the domain name labels of the PublicIPAddress resources that will be + /// created + /// + /// is null. + public VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(string domainNameLabel) + { + Argument.AssertNotNull(domainNameLabel, nameof(domainNameLabel)); + + DomainNameLabel = domainNameLabel; + } + + /// Initializes a new instance of . + /// + /// The Domain name label.The concatenation of the domain name label and vm index + /// will be the domain name labels of the PublicIPAddress resources that will be + /// created + /// + /// + /// The Domain name label scope.The concatenation of the hashed domain name label + /// that generated according to the policy from domain name label scope and vm + /// index will be the domain name labels of the PublicIPAddress resources that will + /// be created + /// + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(string domainNameLabel, DomainNameLabelScopeType? domainNameLabelScope, IDictionary serializedAdditionalRawData) + { + DomainNameLabel = domainNameLabel; + DomainNameLabelScope = domainNameLabelScope; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings() + { + } + + /// + /// The Domain name label.The concatenation of the domain name label and vm index + /// will be the domain name labels of the PublicIPAddress resources that will be + /// created + /// + public string DomainNameLabel { get; set; } + /// + /// The Domain name label scope.The concatenation of the hashed domain name label + /// that generated according to the policy from domain name label scope and vm + /// index will be the domain name labels of the PublicIPAddress resources that will + /// be created + /// + public DomainNameLabelScopeType? DomainNameLabelScope { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.Serialization.cs new file mode 100644 index 000000000000..ad6573561e1f --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.Serialization.cs @@ -0,0 +1,219 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetPublicIPAddressConfigurationProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfigurationProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(IdleTimeoutInMinutes)) + { + writer.WritePropertyName("idleTimeoutInMinutes"u8); + writer.WriteNumberValue(IdleTimeoutInMinutes.Value); + } + if (Optional.IsDefined(DnsSettings)) + { + writer.WritePropertyName("dnsSettings"u8); + writer.WriteObjectValue(DnsSettings, options); + } + if (Optional.IsCollectionDefined(IPTags)) + { + writer.WritePropertyName("ipTags"u8); + writer.WriteStartArray(); + foreach (var item in IPTags) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PublicIPPrefix)) + { + writer.WritePropertyName("publicIPPrefix"u8); + JsonSerializer.Serialize(writer, PublicIPPrefix); + } + if (Optional.IsDefined(PublicIPAddressVersion)) + { + writer.WritePropertyName("publicIPAddressVersion"u8); + writer.WriteStringValue(PublicIPAddressVersion.Value.ToString()); + } + if (Optional.IsDefined(DeleteOption)) + { + writer.WritePropertyName("deleteOption"u8); + writer.WriteStringValue(DeleteOption.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetPublicIPAddressConfigurationProperties 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(VirtualMachineScaleSetPublicIPAddressConfigurationProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationProperties(document.RootElement, options); + } + + internal static VirtualMachineScaleSetPublicIPAddressConfigurationProperties DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? idleTimeoutInMinutes = default; + VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings dnsSettings = default; + IList ipTags = default; + WritableSubResource publicIPPrefix = default; + IPVersion? publicIPAddressVersion = default; + DeleteOption? deleteOption = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("idleTimeoutInMinutes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + idleTimeoutInMinutes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("dnsSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dnsSettings = VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings(property.Value, options); + continue; + } + if (property.NameEquals("ipTags"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VirtualMachineScaleSetIPTag.DeserializeVirtualMachineScaleSetIPTag(item, options)); + } + ipTags = array; + continue; + } + if (property.NameEquals("publicIPPrefix"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPPrefix = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("publicIPAddressVersion"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + publicIPAddressVersion = new IPVersion(property.Value.GetString()); + continue; + } + if (property.NameEquals("deleteOption"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + deleteOption = new DeleteOption(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetPublicIPAddressConfigurationProperties( + idleTimeoutInMinutes, + dnsSettings, + ipTags ?? new ChangeTrackingList(), + publicIPPrefix, + publicIPAddressVersion, + deleteOption, + 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(VirtualMachineScaleSetPublicIPAddressConfigurationProperties)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetPublicIPAddressConfigurationProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetPublicIPAddressConfigurationProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfigurationProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.cs new file mode 100644 index 000000000000..336212575987 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationProperties.cs @@ -0,0 +1,111 @@ +// 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.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Describes a virtual machines scale set IP Configuration's PublicIPAddress + /// configuration + /// + public partial class VirtualMachineScaleSetPublicIPAddressConfigurationProperties + { + /// + /// 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 VirtualMachineScaleSetPublicIPAddressConfigurationProperties() + { + IPTags = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The idle timeout of the public IP address. + /// The dns settings to be applied on the publicIP addresses . + /// The list of IP tags associated with the public IP address. + /// The PublicIPPrefix from which to allocate publicIP addresses. + /// + /// Available from Api-Version 2019-07-01 onwards, it represents whether the + /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible + /// values are: 'IPv4' and 'IPv6'. + /// + /// Specify what happens to the public IP when the VM is deleted. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetPublicIPAddressConfigurationProperties(int? idleTimeoutInMinutes, VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings dnsSettings, IList ipTags, WritableSubResource publicIPPrefix, IPVersion? publicIPAddressVersion, DeleteOption? deleteOption, IDictionary serializedAdditionalRawData) + { + IdleTimeoutInMinutes = idleTimeoutInMinutes; + DnsSettings = dnsSettings; + IPTags = ipTags; + PublicIPPrefix = publicIPPrefix; + PublicIPAddressVersion = publicIPAddressVersion; + DeleteOption = deleteOption; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The idle timeout of the public IP address. + public int? IdleTimeoutInMinutes { get; set; } + /// The dns settings to be applied on the publicIP addresses . + public VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings DnsSettings { get; set; } + /// The list of IP tags associated with the public IP address. + public IList IPTags { get; } + /// The PublicIPPrefix from which to allocate publicIP addresses. + internal WritableSubResource PublicIPPrefix { get; set; } + /// Gets or sets Id. + public ResourceIdentifier PublicIPPrefixId + { + get => PublicIPPrefix is null ? default : PublicIPPrefix.Id; + set + { + if (PublicIPPrefix is null) + PublicIPPrefix = new WritableSubResource(); + PublicIPPrefix.Id = value; + } + } + + /// + /// Available from Api-Version 2019-07-01 onwards, it represents whether the + /// specific ipconfiguration is IPv4 or IPv6. Default is taken as IPv4. Possible + /// values are: 'IPv4' and 'IPv6'. + /// + public IPVersion? PublicIPAddressVersion { get; set; } + /// Specify what happens to the public IP when the VM is deleted. + public DeleteOption? DeleteOption { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs new file mode 100644 index 000000000000..5c1e451e4d55 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs @@ -0,0 +1,181 @@ +// 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.ComputeFleet.Models +{ + public partial class VirtualMachineScaleSetStorageProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VirtualMachineScaleSetStorageProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ImageReference)) + { + writer.WritePropertyName("imageReference"u8); + writer.WriteObjectValue(ImageReference, options); + } + if (Optional.IsDefined(OSDisk)) + { + writer.WritePropertyName("osDisk"u8); + writer.WriteObjectValue(OSDisk, options); + } + if (Optional.IsCollectionDefined(DataDisks)) + { + writer.WritePropertyName("dataDisks"u8); + writer.WriteStartArray(); + foreach (var item in DataDisks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(DiskControllerType)) + { + writer.WritePropertyName("diskControllerType"u8); + writer.WriteStringValue(DiskControllerType.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VirtualMachineScaleSetStorageProfile 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(VirtualMachineScaleSetStorageProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVirtualMachineScaleSetStorageProfile(document.RootElement, options); + } + + internal static VirtualMachineScaleSetStorageProfile DeserializeVirtualMachineScaleSetStorageProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ImageReference imageReference = default; + VirtualMachineScaleSetOSDisk osDisk = default; + IList dataDisks = default; + DiskControllerType? diskControllerType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("imageReference"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageReference = ImageReference.DeserializeImageReference(property.Value, options); + continue; + } + if (property.NameEquals("osDisk"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + osDisk = VirtualMachineScaleSetOSDisk.DeserializeVirtualMachineScaleSetOSDisk(property.Value, options); + continue; + } + if (property.NameEquals("dataDisks"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(VirtualMachineScaleSetDataDisk.DeserializeVirtualMachineScaleSetDataDisk(item, options)); + } + dataDisks = array; + continue; + } + if (property.NameEquals("diskControllerType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskControllerType = new DiskControllerType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VirtualMachineScaleSetStorageProfile(imageReference, osDisk, dataDisks ?? new ChangeTrackingList(), diskControllerType, 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(VirtualMachineScaleSetStorageProfile)} does not support writing '{options.Format}' format."); + } + } + + VirtualMachineScaleSetStorageProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVirtualMachineScaleSetStorageProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VirtualMachineScaleSetStorageProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.cs new file mode 100644 index 000000000000..e1d551b9d097 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VirtualMachineScaleSetStorageProfile.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes a virtual machine scale set storage profile. + public partial class VirtualMachineScaleSetStorageProfile + { + /// + /// 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 VirtualMachineScaleSetStorageProfile() + { + DataDisks = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Specifies information about the image to use. You can specify information about + /// platform images, marketplace images, or virtual machine images. This element is + /// required when you want to use a platform image, marketplace image, or virtual + /// machine image, but is not used in other creation operations. + /// + /// + /// Specifies information about the operating system disk used by the virtual + /// machines in the scale set. For more information about disks, see [About disks + /// and VHDs for Azure virtual + /// machines](https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview). + /// + /// + /// Specifies the parameters that are used to add data disks to the virtual + /// machines in the scale set. For more information about disks, see [About disks + /// and VHDs for Azure virtual + /// machines](https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview). + /// + /// Specifies the disk controller type configured for the virtual machines in the scale set. Minimum api-version: 2022-08-01. + /// Keeps track of any properties unknown to the library. + internal VirtualMachineScaleSetStorageProfile(ImageReference imageReference, VirtualMachineScaleSetOSDisk osDisk, IList dataDisks, DiskControllerType? diskControllerType, IDictionary serializedAdditionalRawData) + { + ImageReference = imageReference; + OSDisk = osDisk; + DataDisks = dataDisks; + DiskControllerType = diskControllerType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies information about the image to use. You can specify information about + /// platform images, marketplace images, or virtual machine images. This element is + /// required when you want to use a platform image, marketplace image, or virtual + /// machine image, but is not used in other creation operations. + /// + public ImageReference ImageReference { get; set; } + /// + /// Specifies information about the operating system disk used by the virtual + /// machines in the scale set. For more information about disks, see [About disks + /// and VHDs for Azure virtual + /// machines](https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview). + /// + public VirtualMachineScaleSetOSDisk OSDisk { get; set; } + /// + /// Specifies the parameters that are used to add data disks to the virtual + /// machines in the scale set. For more information about disks, see [About disks + /// and VHDs for Azure virtual + /// machines](https://docs.microsoft.com/azure/virtual-machines/managed-disks-overview). + /// + public IList DataDisks { get; } + /// Specifies the disk controller type configured for the virtual machines in the scale set. Minimum api-version: 2022-08-01. + public DiskControllerType? DiskControllerType { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.Serialization.cs new file mode 100644 index 000000000000..cf685e6e544a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VmDiskSecurityProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmDiskSecurityProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(SecurityEncryptionType)) + { + writer.WritePropertyName("securityEncryptionType"u8); + writer.WriteStringValue(SecurityEncryptionType.Value.ToString()); + } + if (Optional.IsDefined(DiskEncryptionSet)) + { + writer.WritePropertyName("diskEncryptionSet"u8); + JsonSerializer.Serialize(writer, DiskEncryptionSet); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VmDiskSecurityProfile 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(VmDiskSecurityProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmDiskSecurityProfile(document.RootElement, options); + } + + internal static VmDiskSecurityProfile DeserializeVmDiskSecurityProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + SecurityEncryptionType? securityEncryptionType = default; + WritableSubResource diskEncryptionSet = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("securityEncryptionType"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + securityEncryptionType = new SecurityEncryptionType(property.Value.GetString()); + continue; + } + if (property.NameEquals("diskEncryptionSet"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmDiskSecurityProfile(securityEncryptionType, diskEncryptionSet, 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(VmDiskSecurityProfile)} does not support writing '{options.Format}' format."); + } + } + + VmDiskSecurityProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVmDiskSecurityProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmDiskSecurityProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.cs new file mode 100644 index 000000000000..ea2bf0cde48e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmDiskSecurityProfile.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; +using Azure.Core; +using Azure.ResourceManager.Resources.Models; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the security profile settings for the managed disk. **Note:** It can + /// only be set for Confidential VMs. + /// + public partial class VmDiskSecurityProfile + { + /// + /// 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 VmDiskSecurityProfile() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the EncryptionType of the managed disk. It is set to + /// DiskWithVMGuestState for encryption of the managed disk along with VMGuestState + /// blob, VMGuestStateOnly for encryption of just the VMGuestState blob, and + /// NonPersistedTPM for not persisting firmware state in the VMGuestState blob.. + /// **Note:** It can be set for only Confidential VMs. + /// + /// + /// Specifies the customer managed disk encryption set resource id for the managed + /// disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and + /// VMGuest blob. + /// + /// Keeps track of any properties unknown to the library. + internal VmDiskSecurityProfile(SecurityEncryptionType? securityEncryptionType, WritableSubResource diskEncryptionSet, IDictionary serializedAdditionalRawData) + { + SecurityEncryptionType = securityEncryptionType; + DiskEncryptionSet = diskEncryptionSet; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the EncryptionType of the managed disk. It is set to + /// DiskWithVMGuestState for encryption of the managed disk along with VMGuestState + /// blob, VMGuestStateOnly for encryption of just the VMGuestState blob, and + /// NonPersistedTPM for not persisting firmware state in the VMGuestState blob.. + /// **Note:** It can be set for only Confidential VMs. + /// + public SecurityEncryptionType? SecurityEncryptionType { get; set; } + /// + /// Specifies the customer managed disk encryption set resource id for the managed + /// disk that is used for Customer Managed Key encrypted ConfidentialVM OS Disk and + /// VMGuest blob. + /// + internal WritableSubResource DiskEncryptionSet { get; set; } + /// Gets or sets Id. + public ResourceIdentifier DiskEncryptionSetId + { + get => DiskEncryptionSet is null ? default : DiskEncryptionSet.Id; + set + { + if (DiskEncryptionSet is null) + DiskEncryptionSet = new WritableSubResource(); + DiskEncryptionSet.Id = value; + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.Serialization.cs new file mode 100644 index 000000000000..b4530e2e3408 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.Serialization.cs @@ -0,0 +1,193 @@ +// 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.ComputeFleet.Models +{ + public partial class VmGalleryApplication : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmGalleryApplication)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Tags)) + { + writer.WritePropertyName("tags"u8); + writer.WriteStringValue(Tags); + } + if (Optional.IsDefined(Order)) + { + writer.WritePropertyName("order"u8); + writer.WriteNumberValue(Order.Value); + } + writer.WritePropertyName("packageReferenceId"u8); + writer.WriteStringValue(PackageReferenceId); + if (Optional.IsDefined(ConfigurationReference)) + { + writer.WritePropertyName("configurationReference"u8); + writer.WriteStringValue(ConfigurationReference); + } + if (Optional.IsDefined(TreatFailureAsDeploymentFailure)) + { + writer.WritePropertyName("treatFailureAsDeploymentFailure"u8); + writer.WriteBooleanValue(TreatFailureAsDeploymentFailure.Value); + } + if (Optional.IsDefined(EnableAutomaticUpgrade)) + { + writer.WritePropertyName("enableAutomaticUpgrade"u8); + writer.WriteBooleanValue(EnableAutomaticUpgrade.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VmGalleryApplication 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(VmGalleryApplication)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmGalleryApplication(document.RootElement, options); + } + + internal static VmGalleryApplication DeserializeVmGalleryApplication(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string tags = default; + int? order = default; + ResourceIdentifier packageReferenceId = default; + string configurationReference = default; + bool? treatFailureAsDeploymentFailure = default; + bool? enableAutomaticUpgrade = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tags"u8)) + { + tags = property.Value.GetString(); + continue; + } + if (property.NameEquals("order"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + order = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("packageReferenceId"u8)) + { + packageReferenceId = new ResourceIdentifier(property.Value.GetString()); + continue; + } + if (property.NameEquals("configurationReference"u8)) + { + configurationReference = property.Value.GetString(); + continue; + } + if (property.NameEquals("treatFailureAsDeploymentFailure"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + treatFailureAsDeploymentFailure = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enableAutomaticUpgrade"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableAutomaticUpgrade = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmGalleryApplication( + tags, + order, + packageReferenceId, + configurationReference, + treatFailureAsDeploymentFailure, + enableAutomaticUpgrade, + 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(VmGalleryApplication)} does not support writing '{options.Format}' format."); + } + } + + VmGalleryApplication IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVmGalleryApplication(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmGalleryApplication)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.cs new file mode 100644 index 000000000000..eb7a3c8d0860 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmGalleryApplication.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the required information to reference a compute gallery application + /// version + /// + public partial class VmGalleryApplication + { + /// + /// 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 . + /// + /// Specifies the GalleryApplicationVersion resource id on the form of + /// /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version} + /// + /// is null. + public VmGalleryApplication(ResourceIdentifier packageReferenceId) + { + Argument.AssertNotNull(packageReferenceId, nameof(packageReferenceId)); + + PackageReferenceId = packageReferenceId; + } + + /// Initializes a new instance of . + /// Optional, Specifies a passthrough value for more generic context. + /// Optional, Specifies the order in which the packages have to be installed. + /// + /// Specifies the GalleryApplicationVersion resource id on the form of + /// /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version} + /// + /// + /// Optional, Specifies the uri to an azure blob that will replace the default + /// configuration for the package if provided + /// + /// + /// Optional, If true, any failure for any operation in the VmApplication will fail + /// the deployment + /// + /// + /// If set to true, when a new Gallery Application version is available in PIR/SIG, + /// it will be automatically updated for the VM/VMSS + /// + /// Keeps track of any properties unknown to the library. + internal VmGalleryApplication(string tags, int? order, ResourceIdentifier packageReferenceId, string configurationReference, bool? treatFailureAsDeploymentFailure, bool? enableAutomaticUpgrade, IDictionary serializedAdditionalRawData) + { + Tags = tags; + Order = order; + PackageReferenceId = packageReferenceId; + ConfigurationReference = configurationReference; + TreatFailureAsDeploymentFailure = treatFailureAsDeploymentFailure; + EnableAutomaticUpgrade = enableAutomaticUpgrade; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VmGalleryApplication() + { + } + + /// Optional, Specifies a passthrough value for more generic context. + public string Tags { get; set; } + /// Optional, Specifies the order in which the packages have to be installed. + public int? Order { get; set; } + /// + /// Specifies the GalleryApplicationVersion resource id on the form of + /// /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{application}/versions/{version} + /// + public ResourceIdentifier PackageReferenceId { get; set; } + /// + /// Optional, Specifies the uri to an azure blob that will replace the default + /// configuration for the package if provided + /// + public string ConfigurationReference { get; set; } + /// + /// Optional, If true, any failure for any operation in the VmApplication will fail + /// the deployment + /// + public bool? TreatFailureAsDeploymentFailure { get; set; } + /// + /// If set to true, when a new Gallery Application version is available in PIR/SIG, + /// it will be automatically updated for the VM/VMSS + /// + public bool? EnableAutomaticUpgrade { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.Serialization.cs new file mode 100644 index 000000000000..1dc52b2f0b6a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.Serialization.cs @@ -0,0 +1,134 @@ +// 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.ComputeFleet.Models +{ + public partial class VmSizeProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmSizeProfile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(Rank)) + { + writer.WritePropertyName("rank"u8); + writer.WriteNumberValue(Rank.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VmSizeProfile 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(VmSizeProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmSizeProfile(document.RootElement, options); + } + + internal static VmSizeProfile DeserializeVmSizeProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + int? rank = 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("rank"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rank = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmSizeProfile(name, rank, 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(VmSizeProfile)} does not support writing '{options.Format}' format."); + } + } + + VmSizeProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVmSizeProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmSizeProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.cs new file mode 100644 index 000000000000..d17cdddd66cb --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProfile.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifications about a VM Size. This will also contain the corresponding rank and weight in future. + public partial class VmSizeProfile + { + /// + /// 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 Sku name (e.g. 'Standard_DS1_v2'). + /// is null. + public VmSizeProfile(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The Sku name (e.g. 'Standard_DS1_v2'). + /// + /// The rank of the VM size. This is used with 'RegularPriorityAllocationStrategy.Prioritized' + /// The lower the number, the higher the priority. Starting with 0. + /// + /// Keeps track of any properties unknown to the library. + internal VmSizeProfile(string name, int? rank, IDictionary serializedAdditionalRawData) + { + Name = name; + Rank = rank; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VmSizeProfile() + { + } + + /// The Sku name (e.g. 'Standard_DS1_v2'). + public string Name { get; set; } + /// + /// The rank of the VM size. This is used with 'RegularPriorityAllocationStrategy.Prioritized' + /// The lower the number, the higher the priority. Starting with 0. + /// + public int? Rank { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.Serialization.cs new file mode 100644 index 000000000000..5e166aebab05 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class VmSizeProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmSizeProperties)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(VCPUsAvailable)) + { + writer.WritePropertyName("vCPUsAvailable"u8); + writer.WriteNumberValue(VCPUsAvailable.Value); + } + if (Optional.IsDefined(VCPUsPerCore)) + { + writer.WritePropertyName("vCPUsPerCore"u8); + writer.WriteNumberValue(VCPUsPerCore.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VmSizeProperties 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(VmSizeProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmSizeProperties(document.RootElement, options); + } + + internal static VmSizeProperties DeserializeVmSizeProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? vcpUsAvailable = default; + int? vcpUsPerCore = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vCPUsAvailable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vcpUsAvailable = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("vCPUsPerCore"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + vcpUsPerCore = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmSizeProperties(vcpUsAvailable, vcpUsPerCore, 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(VmSizeProperties)} does not support writing '{options.Format}' format."); + } + } + + VmSizeProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVmSizeProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmSizeProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.cs new file mode 100644 index 000000000000..8fb9e1bb0306 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/VmSizeProperties.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies VM Size Property settings on the virtual machine. + public partial class VmSizeProperties + { + /// + /// 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 VmSizeProperties() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the number of vCPUs available for the VM. When this property is not + /// specified in the request body the default behavior is to set it to the value of + /// vCPUs available for that VM size exposed in api response of [List all available + /// virtual machine sizes in a + /// region](https://docs.microsoft.com/en-us/rest/api/compute/resource-skus/list). + /// + /// + /// Specifies the vCPU to physical core ratio. When this property is not specified + /// in the request body the default behavior is set to the value of vCPUsPerCore + /// for the VM Size exposed in api response of [List all available virtual machine + /// sizes in a + /// region](https://docs.microsoft.com/en-us/rest/api/compute/resource-skus/list). + /// **Setting this property to 1 also means that hyper-threading is disabled.** + /// + /// Keeps track of any properties unknown to the library. + internal VmSizeProperties(int? vcpUsAvailable, int? vcpUsPerCore, IDictionary serializedAdditionalRawData) + { + VCPUsAvailable = vcpUsAvailable; + VCPUsPerCore = vcpUsPerCore; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the number of vCPUs available for the VM. When this property is not + /// specified in the request body the default behavior is to set it to the value of + /// vCPUs available for that VM size exposed in api response of [List all available + /// virtual machine sizes in a + /// region](https://docs.microsoft.com/en-us/rest/api/compute/resource-skus/list). + /// + public int? VCPUsAvailable { get; set; } + /// + /// Specifies the vCPU to physical core ratio. When this property is not specified + /// in the request body the default behavior is set to the value of vCPUsPerCore + /// for the VM Size exposed in api response of [List all available virtual machine + /// sizes in a + /// region](https://docs.microsoft.com/en-us/rest/api/compute/resource-skus/list). + /// **Setting this property to 1 also means that hyper-threading is disabled.** + /// + public int? VCPUsPerCore { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.Serialization.cs new file mode 100644 index 000000000000..aee9e0cbcb3a --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.Serialization.cs @@ -0,0 +1,136 @@ +// 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.ComputeFleet.Models +{ + internal partial class WinRMConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WinRMConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Listeners)) + { + writer.WritePropertyName("listeners"u8); + writer.WriteStartArray(); + foreach (var item in Listeners) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + WinRMConfiguration 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(WinRMConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWinRMConfiguration(document.RootElement, options); + } + + internal static WinRMConfiguration DeserializeWinRMConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList listeners = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("listeners"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WinRMListener.DeserializeWinRMListener(item, options)); + } + listeners = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WinRMConfiguration(listeners ?? 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(WinRMConfiguration)} does not support writing '{options.Format}' format."); + } + } + + WinRMConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWinRMConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WinRMConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.cs new file mode 100644 index 000000000000..aecbca534895 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMConfiguration.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.ComputeFleet.Models +{ + /// Describes Windows Remote Management configuration of the VM. + internal partial class WinRMConfiguration + { + /// + /// 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 WinRMConfiguration() + { + Listeners = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The list of Windows Remote Management listeners. + /// Keeps track of any properties unknown to the library. + internal WinRMConfiguration(IList listeners, IDictionary serializedAdditionalRawData) + { + Listeners = listeners; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The list of Windows Remote Management listeners. + public IList Listeners { get; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.Serialization.cs new file mode 100644 index 000000000000..7c5142576645 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.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.ComputeFleet.Models +{ + public partial class WinRMListener : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WinRMListener)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Protocol)) + { + writer.WritePropertyName("protocol"u8); + writer.WriteStringValue(Protocol.Value.ToString()); + } + if (Optional.IsDefined(WinRMListenei)) + { + writer.WritePropertyName("certificateUrl"u8); + writer.WriteStringValue(WinRMListenei); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + WinRMListener 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(WinRMListener)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWinRMListener(document.RootElement, options); + } + + internal static WinRMListener DeserializeWinRMListener(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ProtocolType? protocol = default; + string certificateUrl = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("protocol"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + protocol = new ProtocolType(property.Value.GetString()); + continue; + } + if (property.NameEquals("certificateUrl"u8)) + { + certificateUrl = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WinRMListener(protocol, certificateUrl, 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(WinRMListener)} does not support writing '{options.Format}' format."); + } + } + + WinRMListener IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWinRMListener(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WinRMListener)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.cs new file mode 100644 index 000000000000..ac291c9bb66c --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WinRMListener.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Describes Protocol and thumbprint of Windows Remote Management listener. + public partial class WinRMListener + { + /// + /// 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 WinRMListener() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the protocol of WinRM listener. Possible values are: **http,** + /// **https.** + /// + /// + /// This is the URL of a certificate that has been uploaded to Key Vault as a + /// secret. For adding a secret to the Key Vault, see [Add a key or secret to the + /// key + /// vault](https://docs.microsoft.com/azure/key-vault/key-vault-get-started/#add). + /// In this case, your certificate needs to be the Base64 encoding of the following + /// JSON Object which is encoded in UTF-8: <br><br> {<br> + /// "data":"<Base64-encoded-certificate>",<br> "dataType":"pfx",<br> + /// "password":"<pfx-file-password>"<br>} <br> To install certificates on a virtual + /// machine it is recommended to use the [Azure Key Vault virtual machine extension + /// for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + /// Keeps track of any properties unknown to the library. + internal WinRMListener(ProtocolType? protocol, string winRMListenei, IDictionary serializedAdditionalRawData) + { + Protocol = protocol; + WinRMListenei = winRMListenei; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the protocol of WinRM listener. Possible values are: **http,** + /// **https.** + /// + public ProtocolType? Protocol { get; set; } + /// + /// This is the URL of a certificate that has been uploaded to Key Vault as a + /// secret. For adding a secret to the Key Vault, see [Add a key or secret to the + /// key + /// vault](https://docs.microsoft.com/azure/key-vault/key-vault-get-started/#add). + /// In this case, your certificate needs to be the Base64 encoding of the following + /// JSON Object which is encoded in UTF-8: <br><br> {<br> + /// "data":"<Base64-encoded-certificate>",<br> "dataType":"pfx",<br> + /// "password":"<pfx-file-password>"<br>} <br> To install certificates on a virtual + /// machine it is recommended to use the [Azure Key Vault virtual machine extension + /// for + /// Linux](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-linux) + /// or the [Azure Key Vault virtual machine extension for + /// Windows](https://docs.microsoft.com/azure/virtual-machines/extensions/key-vault-windows). + /// + public string WinRMListenei { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.Serialization.cs new file mode 100644 index 000000000000..dddc36533972 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.Serialization.cs @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class WindowsConfiguration : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WindowsConfiguration)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ProvisionVmAgent)) + { + writer.WritePropertyName("provisionVMAgent"u8); + writer.WriteBooleanValue(ProvisionVmAgent.Value); + } + if (Optional.IsDefined(EnableAutomaticUpdates)) + { + writer.WritePropertyName("enableAutomaticUpdates"u8); + writer.WriteBooleanValue(EnableAutomaticUpdates.Value); + } + if (Optional.IsDefined(TimeZone)) + { + writer.WritePropertyName("timeZone"u8); + writer.WriteStringValue(TimeZone); + } + if (Optional.IsCollectionDefined(AdditionalUnattendContent)) + { + writer.WritePropertyName("additionalUnattendContent"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalUnattendContent) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PatchSettings)) + { + writer.WritePropertyName("patchSettings"u8); + writer.WriteObjectValue(PatchSettings, options); + } + if (Optional.IsDefined(WinRM)) + { + writer.WritePropertyName("winRM"u8); + writer.WriteObjectValue(WinRM, options); + } + if (Optional.IsDefined(EnableVmAgentPlatformUpdates)) + { + writer.WritePropertyName("enableVMAgentPlatformUpdates"u8); + writer.WriteBooleanValue(EnableVmAgentPlatformUpdates.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + WindowsConfiguration 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(WindowsConfiguration)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWindowsConfiguration(document.RootElement, options); + } + + internal static WindowsConfiguration DeserializeWindowsConfiguration(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + bool? provisionVmAgent = default; + bool? enableAutomaticUpdates = default; + string timeZone = default; + IList additionalUnattendContent = default; + PatchSettings patchSettings = default; + WinRMConfiguration winRM = default; + bool? enableVmAgentPlatformUpdates = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("provisionVMAgent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + provisionVmAgent = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("enableAutomaticUpdates"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableAutomaticUpdates = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("timeZone"u8)) + { + timeZone = property.Value.GetString(); + continue; + } + if (property.NameEquals("additionalUnattendContent"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Models.AdditionalUnattendContent.DeserializeAdditionalUnattendContent(item, options)); + } + additionalUnattendContent = array; + continue; + } + if (property.NameEquals("patchSettings"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + patchSettings = PatchSettings.DeserializePatchSettings(property.Value, options); + continue; + } + if (property.NameEquals("winRM"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + winRM = WinRMConfiguration.DeserializeWinRMConfiguration(property.Value, options); + continue; + } + if (property.NameEquals("enableVMAgentPlatformUpdates"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + enableVmAgentPlatformUpdates = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WindowsConfiguration( + provisionVmAgent, + enableAutomaticUpdates, + timeZone, + additionalUnattendContent ?? new ChangeTrackingList(), + patchSettings, + winRM, + enableVmAgentPlatformUpdates, + 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(WindowsConfiguration)} does not support writing '{options.Format}' format."); + } + } + + WindowsConfiguration IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWindowsConfiguration(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WindowsConfiguration)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.cs new file mode 100644 index 000000000000..0440fd007dda --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsConfiguration.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// Specifies Windows operating system settings on the virtual machine. + public partial class WindowsConfiguration + { + /// + /// 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 WindowsConfiguration() + { + AdditionalUnattendContent = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// Indicates whether virtual machine agent should be provisioned on the virtual + /// machine. When this property is not specified in the request body, it is set to + /// true by default. This will ensure that VM Agent is installed on the VM so that + /// extensions can be added to the VM later. + /// + /// + /// Indicates whether Automatic Updates is enabled for the Windows virtual machine. + /// Default value is true. For virtual machine scale sets, this property can be + /// updated and updates will take effect on OS reprovisioning. + /// + /// + /// Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". + /// Possible values can be + /// [TimeZoneInfo.Id](https://docs.microsoft.com/dotnet/api/system.timezoneinfo.id?#System_TimeZoneInfo_Id) + /// value from time zones returned by + /// [TimeZoneInfo.GetSystemTimeZones](https://docs.microsoft.com/dotnet/api/system.timezoneinfo.getsystemtimezones). + /// + /// + /// Specifies additional base-64 encoded XML formatted information that can be + /// included in the Unattend.xml file, which is used by Windows Setup. + /// + /// [Preview Feature] Specifies settings related to VM Guest Patching on Windows. + /// + /// Specifies the Windows Remote Management listeners. This enables remote Windows + /// PowerShell. + /// + /// + /// Indicates whether VMAgent Platform Updates is enabled for the Windows virtual + /// machine. Default value is false. + /// + /// Keeps track of any properties unknown to the library. + internal WindowsConfiguration(bool? provisionVmAgent, bool? enableAutomaticUpdates, string timeZone, IList additionalUnattendContent, PatchSettings patchSettings, WinRMConfiguration winRM, bool? enableVmAgentPlatformUpdates, IDictionary serializedAdditionalRawData) + { + ProvisionVmAgent = provisionVmAgent; + EnableAutomaticUpdates = enableAutomaticUpdates; + TimeZone = timeZone; + AdditionalUnattendContent = additionalUnattendContent; + PatchSettings = patchSettings; + WinRM = winRM; + EnableVmAgentPlatformUpdates = enableVmAgentPlatformUpdates; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Indicates whether virtual machine agent should be provisioned on the virtual + /// machine. When this property is not specified in the request body, it is set to + /// true by default. This will ensure that VM Agent is installed on the VM so that + /// extensions can be added to the VM later. + /// + public bool? ProvisionVmAgent { get; set; } + /// + /// Indicates whether Automatic Updates is enabled for the Windows virtual machine. + /// Default value is true. For virtual machine scale sets, this property can be + /// updated and updates will take effect on OS reprovisioning. + /// + public bool? EnableAutomaticUpdates { get; set; } + /// + /// Specifies the time zone of the virtual machine. e.g. "Pacific Standard Time". + /// Possible values can be + /// [TimeZoneInfo.Id](https://docs.microsoft.com/dotnet/api/system.timezoneinfo.id?#System_TimeZoneInfo_Id) + /// value from time zones returned by + /// [TimeZoneInfo.GetSystemTimeZones](https://docs.microsoft.com/dotnet/api/system.timezoneinfo.getsystemtimezones). + /// + public string TimeZone { get; set; } + /// + /// Specifies additional base-64 encoded XML formatted information that can be + /// included in the Unattend.xml file, which is used by Windows Setup. + /// + public IList AdditionalUnattendContent { get; } + /// [Preview Feature] Specifies settings related to VM Guest Patching on Windows. + public PatchSettings PatchSettings { get; set; } + /// + /// Specifies the Windows Remote Management listeners. This enables remote Windows + /// PowerShell. + /// + internal WinRMConfiguration WinRM { get; set; } + /// The list of Windows Remote Management listeners. + public IList WinRMListeners + { + get + { + if (WinRM is null) + WinRM = new WinRMConfiguration(); + return WinRM.Listeners; + } + } + + /// + /// Indicates whether VMAgent Platform Updates is enabled for the Windows virtual + /// machine. Default value is false. + /// + public bool? EnableVmAgentPlatformUpdates { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsPatchAssessmentMode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsPatchAssessmentMode.cs new file mode 100644 index 000000000000..6068f35a851e --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsPatchAssessmentMode.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.ComputeFleet.Models +{ + /// Specifies the mode of VM Guest patch assessment for the IaaS virtual machine. + public readonly partial struct WindowsPatchAssessmentMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public WindowsPatchAssessmentMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImageDefaultValue = "ImageDefault"; + private const string AutomaticByPlatformValue = "AutomaticByPlatform"; + + /// You control the timing of patch assessments on a virtual machine. + public static WindowsPatchAssessmentMode ImageDefault { get; } = new WindowsPatchAssessmentMode(ImageDefaultValue); + /// The platform will trigger periodic patch assessments. The property provisionVMAgent must be true. + public static WindowsPatchAssessmentMode AutomaticByPlatform { get; } = new WindowsPatchAssessmentMode(AutomaticByPlatformValue); + /// Determines if two values are the same. + public static bool operator ==(WindowsPatchAssessmentMode left, WindowsPatchAssessmentMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(WindowsPatchAssessmentMode left, WindowsPatchAssessmentMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator WindowsPatchAssessmentMode(string value) => new WindowsPatchAssessmentMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WindowsPatchAssessmentMode other && Equals(other); + /// + public bool Equals(WindowsPatchAssessmentMode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformRebootSetting.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformRebootSetting.cs new file mode 100644 index 000000000000..56fea1995211 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformRebootSetting.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.ComputeFleet.Models +{ + /// Specifies the reboot setting for all AutomaticByPlatform patch installation operations. + public readonly partial struct WindowsVmGuestPatchAutomaticByPlatformRebootSetting : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public WindowsVmGuestPatchAutomaticByPlatformRebootSetting(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string IfRequiredValue = "IfRequired"; + private const string NeverValue = "Never"; + private const string AlwaysValue = "Always"; + + /// Unknown Reboot setting. + public static WindowsVmGuestPatchAutomaticByPlatformRebootSetting Unknown { get; } = new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(UnknownValue); + /// IfRequired Reboot setting. + public static WindowsVmGuestPatchAutomaticByPlatformRebootSetting IfRequired { get; } = new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(IfRequiredValue); + /// Never Reboot setting. + public static WindowsVmGuestPatchAutomaticByPlatformRebootSetting Never { get; } = new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(NeverValue); + /// Always Reboot setting. + public static WindowsVmGuestPatchAutomaticByPlatformRebootSetting Always { get; } = new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(AlwaysValue); + /// Determines if two values are the same. + public static bool operator ==(WindowsVmGuestPatchAutomaticByPlatformRebootSetting left, WindowsVmGuestPatchAutomaticByPlatformRebootSetting right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(WindowsVmGuestPatchAutomaticByPlatformRebootSetting left, WindowsVmGuestPatchAutomaticByPlatformRebootSetting right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator WindowsVmGuestPatchAutomaticByPlatformRebootSetting(string value) => new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WindowsVmGuestPatchAutomaticByPlatformRebootSetting other && Equals(other); + /// + public bool Equals(WindowsVmGuestPatchAutomaticByPlatformRebootSetting 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.Serialization.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.Serialization.cs new file mode 100644 index 000000000000..77c5dbfdd63d --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.Serialization.cs @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + public partial class WindowsVmGuestPatchAutomaticByPlatformSettings : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WindowsVmGuestPatchAutomaticByPlatformSettings)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(RebootSetting)) + { + writer.WritePropertyName("rebootSetting"u8); + writer.WriteStringValue(RebootSetting.Value.ToString()); + } + if (Optional.IsDefined(BypassPlatformSafetyChecksOnUserSchedule)) + { + writer.WritePropertyName("bypassPlatformSafetyChecksOnUserSchedule"u8); + writer.WriteBooleanValue(BypassPlatformSafetyChecksOnUserSchedule.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + WindowsVmGuestPatchAutomaticByPlatformSettings 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(WindowsVmGuestPatchAutomaticByPlatformSettings)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWindowsVmGuestPatchAutomaticByPlatformSettings(document.RootElement, options); + } + + internal static WindowsVmGuestPatchAutomaticByPlatformSettings DeserializeWindowsVmGuestPatchAutomaticByPlatformSettings(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WindowsVmGuestPatchAutomaticByPlatformRebootSetting? rebootSetting = default; + bool? bypassPlatformSafetyChecksOnUserSchedule = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rebootSetting"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rebootSetting = new WindowsVmGuestPatchAutomaticByPlatformRebootSetting(property.Value.GetString()); + continue; + } + if (property.NameEquals("bypassPlatformSafetyChecksOnUserSchedule"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + bypassPlatformSafetyChecksOnUserSchedule = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WindowsVmGuestPatchAutomaticByPlatformSettings(rebootSetting, bypassPlatformSafetyChecksOnUserSchedule, 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(WindowsVmGuestPatchAutomaticByPlatformSettings)} does not support writing '{options.Format}' format."); + } + } + + WindowsVmGuestPatchAutomaticByPlatformSettings IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeWindowsVmGuestPatchAutomaticByPlatformSettings(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WindowsVmGuestPatchAutomaticByPlatformSettings)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.cs new file mode 100644 index 000000000000..100d013ccecc --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchAutomaticByPlatformSettings.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.ComputeFleet.Models +{ + /// + /// Specifies additional settings to be applied when patch mode AutomaticByPlatform + /// is selected in Windows patch settings. + /// + public partial class WindowsVmGuestPatchAutomaticByPlatformSettings + { + /// + /// 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 WindowsVmGuestPatchAutomaticByPlatformSettings() + { + } + + /// Initializes a new instance of . + /// + /// Specifies the reboot setting for all AutomaticByPlatform patch installation + /// operations. + /// + /// Enables customer to schedule patching without accidental upgrades. + /// Keeps track of any properties unknown to the library. + internal WindowsVmGuestPatchAutomaticByPlatformSettings(WindowsVmGuestPatchAutomaticByPlatformRebootSetting? rebootSetting, bool? bypassPlatformSafetyChecksOnUserSchedule, IDictionary serializedAdditionalRawData) + { + RebootSetting = rebootSetting; + BypassPlatformSafetyChecksOnUserSchedule = bypassPlatformSafetyChecksOnUserSchedule; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Specifies the reboot setting for all AutomaticByPlatform patch installation + /// operations. + /// + public WindowsVmGuestPatchAutomaticByPlatformRebootSetting? RebootSetting { get; set; } + /// Enables customer to schedule patching without accidental upgrades. + public bool? BypassPlatformSafetyChecksOnUserSchedule { get; set; } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchMode.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchMode.cs new file mode 100644 index 000000000000..436c69c730c6 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/Models/WindowsVmGuestPatchMode.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.ComputeFleet.Models +{ + /// + /// Specifies the mode of VM Guest Patching to IaaS virtual machine or virtual + /// machines associated to virtual machine scale set with OrchestrationMode as + /// Flexible. + /// + public readonly partial struct WindowsVmGuestPatchMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public WindowsVmGuestPatchMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ManualValue = "Manual"; + private const string AutomaticByOSValue = "AutomaticByOS"; + private const string AutomaticByPlatformValue = "AutomaticByPlatform"; + + /// + /// You control the application of patches to a virtual machine. + /// You do this by applying patches manually inside the VM. In this mode, + /// automatic updates are disabled; the property WindowsConfiguration.enableAutomaticUpdates + /// must be false + /// + public static WindowsVmGuestPatchMode Manual { get; } = new WindowsVmGuestPatchMode(ManualValue); + /// + /// The virtual machine will automatically be updated by the OS. + /// The property WindowsConfiguration.enableAutomaticUpdates must be true. + /// + public static WindowsVmGuestPatchMode AutomaticByOS { get; } = new WindowsVmGuestPatchMode(AutomaticByOSValue); + /// + /// The virtual machine will automatically updated by the platform. The properties + /// provisionVMAgent and WindowsConfiguration.enableAutomaticUpdates must be true. + /// + public static WindowsVmGuestPatchMode AutomaticByPlatform { get; } = new WindowsVmGuestPatchMode(AutomaticByPlatformValue); + /// Determines if two values are the same. + public static bool operator ==(WindowsVmGuestPatchMode left, WindowsVmGuestPatchMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(WindowsVmGuestPatchMode left, WindowsVmGuestPatchMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator WindowsVmGuestPatchMode(string value) => new WindowsVmGuestPatchMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is WindowsVmGuestPatchMode other && Equals(other); + /// + public bool Equals(WindowsVmGuestPatchMode 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/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/ProviderConstants.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/ProviderConstants.cs new file mode 100644 index 000000000000..89dbf6abd991 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet +{ + internal static class ProviderConstants + { + public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/FleetsRestOperations.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/FleetsRestOperations.cs new file mode 100644 index 000000000000..03282ef05f51 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/FleetsRestOperations.cs @@ -0,0 +1,901 @@ +// 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.ComputeFleet.Models; + +namespace Azure.ResourceManager.ComputeFleet +{ + internal partial class FleetsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of FleetsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Azure Resource Manager url. + /// The API version to use for this operation. + /// or is null. + public FleetsRestOperations(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-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string fleetName) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string fleetName) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Get a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, fleetName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + FleetData value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = FleetData.DeserializeFleetData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((FleetData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + /// Get a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var message = CreateGetRequest(subscriptionId, resourceGroupName, fleetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + FleetData value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = FleetData.DeserializeFleetData(document.RootElement); + return Response.FromValue(value, message.Response); + } + case 404: + return Response.FromValue((FleetData)null, message.Response); + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateCreateOrUpdateRequestUri(string subscriptionId, string resourceGroupName, string fleetName, FleetData 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string fleetName, FleetData 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, 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 Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string fleetName, FleetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, fleetName, 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 Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 CreateOrUpdate(string subscriptionId, string resourceGroupName, string fleetName, FleetData data, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(data, nameof(data)); + + using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, fleetName, data); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 201: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string fleetName, FleetPatch patch) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string fleetName, FleetPatch patch) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Patch; + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, 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(patch, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// Update a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task UpdateAsync(string subscriptionId, string resourceGroupName, string fleetName, FleetPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, fleetName, patch); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Update a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// The resource properties to be updated. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response Update(string subscriptionId, string resourceGroupName, string fleetName, FleetPatch patch, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + Argument.AssertNotNull(patch, nameof(patch)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, fleetName, patch); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + case 202: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string fleetName) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string fleetName) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(fleetName, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Delete a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, fleetName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + /// Delete a Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Compute Fleet. + /// 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 fleetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(fleetName, nameof(fleetName)); + + using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, fleetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 202: + case 204: + return message.Response; + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) + { + 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.AzureFleet/fleets", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) + { + 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.AzureFleet/fleets", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Fleet resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Fleet resources by resource group. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionRequestUri(string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/providers/Microsoft.AzureFleet/fleets", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListBySubscriptionRequest(string subscriptionId) + { + 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("/providers/Microsoft.AzureFleet/fleets", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List Fleet resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionAsync(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Fleet resources by subscription ID. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscription(string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionRequest(subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVirtualMachineScaleSetsRequestUri(string subscriptionId, string resourceGroupName, string name) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/virtualMachineScaleSets", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListVirtualMachineScaleSetsRequest(string subscriptionId, string resourceGroupName, string name) + { + 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.AzureFleet/fleets/", false); + uri.AppendPath(name, true); + uri.AppendPath("/virtualMachineScaleSets", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List VirtualMachineScaleSet resources by Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Fleet. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListVirtualMachineScaleSetsAsync(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListVirtualMachineScaleSetsRequest(subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VirtualMachineScaleSetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List VirtualMachineScaleSet resources by Fleet. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The name of the Fleet. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListVirtualMachineScaleSets(string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListVirtualMachineScaleSetsRequest(subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VirtualMachineScaleSetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) + { + 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 Fleet resources by resource group. + /// 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. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Fleet resources by resource group. + /// 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. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + + using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListBySubscriptionNextPageRequestUri(string nextLink, string subscriptionId) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListBySubscriptionNextPageRequest(string nextLink, string subscriptionId) + { + 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 Fleet resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public async Task> ListBySubscriptionNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List Fleet resources by subscription ID. + /// The URL to the next page of results. + /// The ID of the target subscription. The value must be an UUID. + /// The cancellation token to use. + /// or is null. + /// is an empty string, and was expected to be non-empty. + public Response ListBySubscriptionNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + + using var message = CreateListBySubscriptionNextPageRequest(nextLink, subscriptionId); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + FleetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = FleetListResult.DeserializeFleetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListVirtualMachineScaleSetsNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListVirtualMachineScaleSetsNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string name) + { + 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 VirtualMachineScaleSet resources by Fleet. + /// 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. + /// The name of the Fleet. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListVirtualMachineScaleSetsNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListVirtualMachineScaleSetsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VirtualMachineScaleSetListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List VirtualMachineScaleSet resources by Fleet. + /// 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. + /// The name of the Fleet. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListVirtualMachineScaleSetsNextPage(string nextLink, string subscriptionId, string resourceGroupName, string name, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(name, nameof(name)); + + using var message = CreateListVirtualMachineScaleSetsNextPageRequest(nextLink, subscriptionId, resourceGroupName, name); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VirtualMachineScaleSetListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = VirtualMachineScaleSetListResult.DeserializeVirtualMachineScaleSetListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/OperationsRestOperations.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/OperationsRestOperations.cs new file mode 100644 index 000000000000..7a48aad4e664 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Generated/RestOperations/OperationsRestOperations.cs @@ -0,0 +1,173 @@ +// 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.ComputeFleet.Models; + +namespace Azure.ResourceManager.ComputeFleet +{ + internal partial class OperationsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of OperationsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// Azure Resource Manager url. + /// The API version to use for this operation. + /// or is null. + public OperationsRestOperations(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-05-01-preview"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateListRequestUri() + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.AzureFleet/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest() + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/providers/Microsoft.AzureFleet/operations", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// List the operations for the provider. + /// The cancellation token to use. + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The cancellation token to use. + public Response List(CancellationToken cancellationToken = default) + { + using var message = CreateListRequest(); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink) + { + 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 the operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public async Task> ListNextPageAsync(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// List the operations for the provider. + /// The URL to the next page of results. + /// The cancellation token to use. + /// is null. + public Response ListNextPage(string nextLink, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + + using var message = CreateListNextPageRequest(nextLink); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + OperationListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = OperationListResult.DeserializeOperationListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Properties/AssemblyInfo.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..f6ed0b8917d7 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/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.ComputeFleet.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tests/Azure.ResourceManager.ComputeFleet.Tests.csproj b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tests/Azure.ResourceManager.ComputeFleet.Tests.csproj new file mode 100644 index 000000000000..dfe7590b5b77 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tests/Azure.ResourceManager.ComputeFleet.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml new file mode 100644 index 000000000000..c804076be2d9 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/azurefleet/AzureFleet.Management +commit: 4a2df47bc5a5c3467c8b3625515f41de03d38a06 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/computefleet/ci.yml b/sdk/computefleet/ci.yml new file mode 100644 index 000000000000..e7ab252c0132 --- /dev/null +++ b/sdk/computefleet/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/computefleet + - sdk/computefleet/ci.yml + - sdk/computefleet/Azure.ResourceManager.ComputeFleet + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/computefleet + - sdk/computefleet/ci.yml + - sdk/computefleet/Azure.ResourceManager.ComputeFleet + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: computefleet + ArtifactName: packages + Artifacts: + - name: Azure.ResourceManager.ComputeFleet + safeName: AzureResourceManagerComputeFleet