diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/ArmComputeModelFactory.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/ArmComputeModelFactory.cs index 7db942270bd3..7750a74c2d29 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/ArmComputeModelFactory.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/ArmComputeModelFactory.cs @@ -158,10 +158,12 @@ public static VirtualMachineScaleSetData VirtualMachineScaleSetData(ResourceIden /// Policy for Resiliency. /// Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. /// Specifies the sku profile for the virtual machine scale set. + /// Specifies the lifecycle hooks profile for the virtual machine scale set. /// Additional Properties. /// A new instance for mocking. - public static VirtualMachineScaleSetProperties VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy = null, ScheduledEventsPolicy scheduledEventsPolicy = null, AutomaticRepairsPolicy automaticRepairsPolicy = null, VirtualMachineScaleSetVmProfile virtualMachineProfile = null, string provisioningState = null, bool? overprovision = null, bool? doNotRunExtensionsOnOverprovisionedVms = null, string uniqueId = null, bool? singlePlacementGroup = null, bool? zoneBalance = null, int? platformFaultDomainCount = null, ResourceIdentifier proximityPlacementGroupId = null, ResourceIdentifier hostGroupId = null, AdditionalCapabilities additionalCapabilities = null, ScaleInPolicy scaleInPolicy = null, OrchestrationMode? orchestrationMode = null, SpotRestorePolicy spotRestorePolicy = null, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy = null, DateTimeOffset? timeCreated = null, bool? isMaximumCapacityConstrained = null, ResiliencyPolicy resiliencyPolicy = null, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode = null, ComputeSkuProfile skuProfile = null, IDictionary additionalProperties = null) + public static VirtualMachineScaleSetProperties VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy = null, ScheduledEventsPolicy scheduledEventsPolicy = null, AutomaticRepairsPolicy automaticRepairsPolicy = null, VirtualMachineScaleSetVmProfile virtualMachineProfile = null, string provisioningState = null, bool? overprovision = null, bool? doNotRunExtensionsOnOverprovisionedVms = null, string uniqueId = null, bool? singlePlacementGroup = null, bool? zoneBalance = null, int? platformFaultDomainCount = null, ResourceIdentifier proximityPlacementGroupId = null, ResourceIdentifier hostGroupId = null, AdditionalCapabilities additionalCapabilities = null, ScaleInPolicy scaleInPolicy = null, OrchestrationMode? orchestrationMode = null, SpotRestorePolicy spotRestorePolicy = null, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy = null, DateTimeOffset? timeCreated = null, bool? isMaximumCapacityConstrained = null, ResiliencyPolicy resiliencyPolicy = null, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode = null, ComputeSkuProfile skuProfile = null, IEnumerable lifecycleHooks = null, IDictionary additionalProperties = null) { + lifecycleHooks ??= new List(); additionalProperties ??= new Dictionary(); return new VirtualMachineScaleSetProperties( @@ -188,6 +190,7 @@ public static VirtualMachineScaleSetProperties VirtualMachineScaleSetProperties( resiliencyPolicy, zonalPlatformFaultDomainAlignMode, skuProfile, + lifecycleHooks != null ? new LifecycleHooksProfile(lifecycleHooks?.ToList(), serializedAdditionalRawData: null) : null, additionalProperties); } @@ -951,6 +954,41 @@ public static DataDisksToDetach DataDisksToDetach(string diskId = null, DiskDeta return new DataDisksToDetach(diskId, detachOption, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Defines the type or scenario for sending a lifecycle hook notification to the customer. + /// Specifies the exact UTC timestamp in ISO 8601 format till which the event would remain in the current lifecycle state waiting for an action from the customer. Beyond this timestamp, the platform will apply the DefaultAction for the event. + /// Specifies the exact UTC timestamp in ISO 8601 format till when the customer can delay the lifecycle hook event. The customer will not be allowed to delay the event to a timestamp beyond this time. + /// The UTC timestamp in ISO 8601 format at which the platform creates the VMScaleSet lifecycle hook event entity. + /// Specify the action that will be aplied on the a target resource in the VMScaleSet lifecycle hook event, if the platform does not get a response from the customer for the target resource before waitUntil. + /// List of resources which are getting processed in the lifecycle hook event. + /// Additional key-value pairs set on the lifecycle hook event that gives customer some useful context/data. + /// Specifies the state of the lifecycle hook event. + /// A new instance for mocking. + public static VmScaleSetLifecycleHookEvent VmScaleSetLifecycleHookEvent(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, string typePropertiesType = null, string waitUntil = null, string maxWaitUntil = null, string timeCreated = null, LifecycleHookAction? defaultAction = null, IEnumerable targetResources = null, IDictionary additionalContext = null, VmScaleSetLifecycleHookEventState? state = null) + { + targetResources ??= new List(); + additionalContext ??= new Dictionary(); + + return new VmScaleSetLifecycleHookEvent( + id, + name, + resourceType, + systemData, + typePropertiesType, + waitUntil, + maxWaitUntil, + timeCreated, + defaultAction, + targetResources?.ToList(), + additionalContext, + state, + serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The id. /// The name. @@ -4482,6 +4520,38 @@ public static OSVersionPropertiesBase OSVersionPropertiesBase(string version = n return new OSVersionPropertiesBase(version, label, isDefault, isActive, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// The upgrade policy. + /// The ScheduledEventsPolicy. + /// Policy for automatic repairs. + /// The virtual machine profile. + /// The provisioning state, which only appears in the response. + /// Specifies whether the Virtual Machine Scale Set should be overprovisioned. + /// When Overprovision is enabled, extensions are launched only on the requested number of VMs which are finally kept. This property will hence ensure that the extensions do not run on the extra overprovisioned VMs. + /// Specifies the ID which uniquely identifies a Virtual Machine Scale Set. + /// When true this limits the scale set to a single placement group, of max size 100 virtual machines. NOTE: If singlePlacementGroup is true, it may be modified to false. However, if singlePlacementGroup is false, it may not be modified to true. + /// Whether to force strictly even Virtual Machine distribution cross x-zones in case there is zone outage. zoneBalance property can only be set if the zones property of the scale set contains more than one zone. If there are no zones or only one zone specified, then zoneBalance property should not be set. + /// Fault Domain count for each placement group. + /// Specifies information about the proximity placement group that the virtual machine scale set should be assigned to. Minimum api-version: 2018-04-01. + /// Specifies information about the dedicated host group that the virtual machine scale set resides in. Minimum api-version: 2020-06-01. + /// Specifies additional capabilities enabled or disabled on the Virtual Machines in the Virtual Machine Scale Set. For instance: whether the Virtual Machines have the capability to support attaching managed data disks with UltraSSD_LRS storage account type. + /// Specifies the policies applied when scaling in Virtual Machines in the Virtual Machine Scale Set. + /// Specifies the orchestration mode for the virtual machine scale set. + /// Specifies the Spot Restore properties for the virtual machine scale set. + /// Specifies the desired targets for mixing Spot and Regular priority VMs within the same VMSS Flex instance. + /// Specifies the time at which the Virtual Machine Scale Set resource was created. Minimum api-version: 2021-11-01. + /// Optional property which must either be set to True or omitted. + /// Policy for Resiliency. + /// Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. + /// Specifies the sku profile for the virtual machine scale set. + /// Additional Properties. + /// A new instance for mocking. + [EditorBrowsable(EditorBrowsableState.Never)] + public static VirtualMachineScaleSetProperties VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy, ScheduledEventsPolicy scheduledEventsPolicy, AutomaticRepairsPolicy automaticRepairsPolicy, VirtualMachineScaleSetVmProfile virtualMachineProfile, string provisioningState, bool? overprovision, bool? doNotRunExtensionsOnOverprovisionedVms, string uniqueId, bool? singlePlacementGroup, bool? zoneBalance, int? platformFaultDomainCount, ResourceIdentifier proximityPlacementGroupId, ResourceIdentifier hostGroupId, AdditionalCapabilities additionalCapabilities, ScaleInPolicy scaleInPolicy, OrchestrationMode? orchestrationMode, SpotRestorePolicy spotRestorePolicy, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy, DateTimeOffset? timeCreated, bool? isMaximumCapacityConstrained, ResiliencyPolicy resiliencyPolicy, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode, ComputeSkuProfile skuProfile, IDictionary additionalProperties) + { + return VirtualMachineScaleSetProperties(upgradePolicy: upgradePolicy, scheduledEventsPolicy: scheduledEventsPolicy, automaticRepairsPolicy: automaticRepairsPolicy, virtualMachineProfile: virtualMachineProfile, provisioningState: provisioningState, overprovision: overprovision, doNotRunExtensionsOnOverprovisionedVms: doNotRunExtensionsOnOverprovisionedVms, uniqueId: uniqueId, singlePlacementGroup: singlePlacementGroup, zoneBalance: zoneBalance, platformFaultDomainCount: platformFaultDomainCount, proximityPlacementGroupId: proximityPlacementGroupId, hostGroupId: hostGroupId, additionalCapabilities: additionalCapabilities, scaleInPolicy: scaleInPolicy, orchestrationMode: orchestrationMode, spotRestorePolicy: spotRestorePolicy, priorityMixPolicy: priorityMixPolicy, timeCreated: timeCreated, isMaximumCapacityConstrained: isMaximumCapacityConstrained, resiliencyPolicy: resiliencyPolicy, zonalPlatformFaultDomainAlignMode: zonalPlatformFaultDomainAlignMode, skuProfile: skuProfile, lifecycleHooks: default, additionalProperties: additionalProperties); + } + /// Initializes a new instance of . /// The id. /// The name. diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.Serialization.cs new file mode 100644 index 000000000000..e865f201a392 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.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.Compute.Models +{ + public partial class LifecycleHook : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LifecycleHook)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(LifecycleHookType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(LifecycleHookType); + } + if (Optional.IsDefined(WaitDuration)) + { + writer.WritePropertyName("waitDuration"u8); + writer.WriteStringValue(WaitDuration.Value, "P"); + } + if (Optional.IsDefined(DefaultAction)) + { + writer.WritePropertyName("defaultAction"u8); + writer.WriteStringValue(DefaultAction.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LifecycleHook 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(LifecycleHook)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLifecycleHook(document.RootElement, options); + } + + internal static LifecycleHook DeserializeLifecycleHook(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + TimeSpan? waitDuration = default; + LifecycleHookAction? defaultAction = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("waitDuration"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + waitDuration = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("defaultAction"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultAction = new LifecycleHookAction(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LifecycleHook(type, waitDuration, defaultAction, 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, AzureResourceManagerComputeContext.Default); + default: + throw new FormatException($"The model {nameof(LifecycleHook)} does not support writing '{options.Format}' format."); + } + } + + LifecycleHook IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLifecycleHook(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LifecycleHook)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.cs new file mode 100644 index 000000000000..43d082952317 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHook.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.Compute.Models +{ + /// Describes a lifecycle hook. + public partial class LifecycleHook + { + /// + /// 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 LifecycleHook() + { + } + + /// Initializes a new instance of . + /// Specifies the type of the lifecycle hook. + /// Specifies the time duration an LCH event (that is sent to the customer) waits for a response from the customer. It should be in ISO 8601 format. + /// Specifies the default action for the lifecycle hook. This action will be applied on the the target resources if the customer does not take any action for the target resource before waitUntil. + /// Keeps track of any properties unknown to the library. + internal LifecycleHook(string lifecycleHookType, TimeSpan? waitDuration, LifecycleHookAction? defaultAction, IDictionary serializedAdditionalRawData) + { + LifecycleHookType = lifecycleHookType; + WaitDuration = waitDuration; + DefaultAction = defaultAction; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the type of the lifecycle hook. + public string LifecycleHookType { get; set; } + /// Specifies the time duration an LCH event (that is sent to the customer) waits for a response from the customer. It should be in ISO 8601 format. + public TimeSpan? WaitDuration { get; set; } + /// Specifies the default action for the lifecycle hook. This action will be applied on the the target resources if the customer does not take any action for the target resource before waitUntil. + public LifecycleHookAction? DefaultAction { get; set; } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookAction.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookAction.cs new file mode 100644 index 000000000000..2f9228ef7b68 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookAction.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.Compute.Models +{ + /// The action that will be taken on a target resource in a lifecycle hook event. + public readonly partial struct LifecycleHookAction : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LifecycleHookAction(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApproveValue = "Approve"; + + /// The lifecycle hook of a target resource in a lifecycle hook event will be approved. + public static LifecycleHookAction Approve { get; } = new LifecycleHookAction(ApproveValue); + /// Determines if two values are the same. + public static bool operator ==(LifecycleHookAction left, LifecycleHookAction right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LifecycleHookAction left, LifecycleHookAction right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LifecycleHookAction(string value) => new LifecycleHookAction(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LifecycleHookAction other && Equals(other); + /// + public bool Equals(LifecycleHookAction 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/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookActionState.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookActionState.cs new file mode 100644 index 000000000000..c80caf7d95e8 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHookActionState.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.Compute.Models +{ + /// Approval status of a target resource in a VMScaleSet lifecycle hook event. + public readonly partial struct LifecycleHookActionState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public LifecycleHookActionState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ApprovedValue = "Approved"; + private const string WaitingValue = "Waiting"; + + /// The lifecycle hook for the target resource is approved. + public static LifecycleHookActionState Approved { get; } = new LifecycleHookActionState(ApprovedValue); + /// The lifecycle hook for the target resource is waiting for approval. + public static LifecycleHookActionState Waiting { get; } = new LifecycleHookActionState(WaitingValue); + /// Determines if two values are the same. + public static bool operator ==(LifecycleHookActionState left, LifecycleHookActionState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LifecycleHookActionState left, LifecycleHookActionState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator LifecycleHookActionState(string value) => new LifecycleHookActionState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is LifecycleHookActionState other && Equals(other); + /// + public bool Equals(LifecycleHookActionState 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/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.Serialization.cs new file mode 100644 index 000000000000..3ac848e09620 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.Compute.Models +{ + internal partial class LifecycleHooksProfile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(LifecycleHooksProfile)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(LifecycleHooks)) + { + writer.WritePropertyName("lifecycleHooks"u8); + writer.WriteStartArray(); + foreach (var item in LifecycleHooks) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + LifecycleHooksProfile 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(LifecycleHooksProfile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLifecycleHooksProfile(document.RootElement, options); + } + + internal static LifecycleHooksProfile DeserializeLifecycleHooksProfile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList lifecycleHooks = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("lifecycleHooks"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(LifecycleHook.DeserializeLifecycleHook(item, options)); + } + lifecycleHooks = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new LifecycleHooksProfile(lifecycleHooks ?? 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, AzureResourceManagerComputeContext.Default); + default: + throw new FormatException($"The model {nameof(LifecycleHooksProfile)} does not support writing '{options.Format}' format."); + } + } + + LifecycleHooksProfile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLifecycleHooksProfile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(LifecycleHooksProfile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.cs new file mode 100644 index 000000000000..422eb6c73f83 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/LifecycleHooksProfile.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.Compute.Models +{ + /// Specifies the lifecycle hooks profile for the virtual machine scale set. + internal partial class LifecycleHooksProfile + { + /// + /// 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 LifecycleHooksProfile() + { + LifecycleHooks = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Specifies the lifecycle hooks configured for the virtual machine scale set. + /// Keeps track of any properties unknown to the library. + internal LifecycleHooksProfile(IList lifecycleHooks, IDictionary serializedAdditionalRawData) + { + LifecycleHooks = lifecycleHooks; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the lifecycle hooks configured for the virtual machine scale set. + public IList LifecycleHooks { get; } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.Serialization.cs index a71d901a0b9d..e832d9abf8a4 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.Serialization.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.Serialization.cs @@ -105,6 +105,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("skuProfile"u8); writer.WriteObjectValue(SkuProfile, options); } + if (Optional.IsDefined(LifecycleHooksProfile)) + { + writer.WritePropertyName("lifecycleHooksProfile"u8); + writer.WriteObjectValue(LifecycleHooksProfile, options); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -156,6 +161,7 @@ internal static VirtualMachineScaleSetPatchProperties DeserializeVirtualMachineS ResiliencyPolicy resiliencyPolicy = default; ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode = default; ComputeSkuProfile skuProfile = default; + LifecycleHooksProfile lifecycleHooksProfile = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -286,6 +292,15 @@ internal static VirtualMachineScaleSetPatchProperties DeserializeVirtualMachineS skuProfile = ComputeSkuProfile.DeserializeComputeSkuProfile(property.Value, options); continue; } + if (property.NameEquals("lifecycleHooksProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lifecycleHooksProfile = LifecycleHooksProfile.DeserializeLifecycleHooksProfile(property.Value, options); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -307,6 +322,7 @@ internal static VirtualMachineScaleSetPatchProperties DeserializeVirtualMachineS resiliencyPolicy, zonalPlatformFaultDomainAlignMode, skuProfile, + lifecycleHooksProfile, serializedAdditionalRawData); } diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.cs index 1f3cb453c998..910f97e40532 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetPatchProperties.cs @@ -67,8 +67,9 @@ public VirtualMachineScaleSetPatchProperties() /// Policy for Resiliency. /// Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. /// Specifies the sku profile for the virtual machine scale set. + /// Specifies the lifecycle hooks profile for the virtual machine scale set. /// Keeps track of any properties unknown to the library. - internal VirtualMachineScaleSetPatchProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy, AutomaticRepairsPolicy automaticRepairsPolicy, VirtualMachineScaleSetUpdateVmProfile virtualMachineProfile, bool? overprovision, bool? doNotRunExtensionsOnOverprovisionedVms, bool? singlePlacementGroup, AdditionalCapabilities additionalCapabilities, ScaleInPolicy scaleInPolicy, WritableSubResource proximityPlacementGroup, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy, SpotRestorePolicy spotRestorePolicy, ResiliencyPolicy resiliencyPolicy, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode, ComputeSkuProfile skuProfile, IDictionary serializedAdditionalRawData) + internal VirtualMachineScaleSetPatchProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy, AutomaticRepairsPolicy automaticRepairsPolicy, VirtualMachineScaleSetUpdateVmProfile virtualMachineProfile, bool? overprovision, bool? doNotRunExtensionsOnOverprovisionedVms, bool? singlePlacementGroup, AdditionalCapabilities additionalCapabilities, ScaleInPolicy scaleInPolicy, WritableSubResource proximityPlacementGroup, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy, SpotRestorePolicy spotRestorePolicy, ResiliencyPolicy resiliencyPolicy, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode, ComputeSkuProfile skuProfile, LifecycleHooksProfile lifecycleHooksProfile, IDictionary serializedAdditionalRawData) { UpgradePolicy = upgradePolicy; AutomaticRepairsPolicy = automaticRepairsPolicy; @@ -84,6 +85,7 @@ internal VirtualMachineScaleSetPatchProperties(VirtualMachineScaleSetUpgradePoli ResiliencyPolicy = resiliencyPolicy; ZonalPlatformFaultDomainAlignMode = zonalPlatformFaultDomainAlignMode; SkuProfile = skuProfile; + LifecycleHooksProfile = lifecycleHooksProfile; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -127,5 +129,17 @@ public ResourceIdentifier ProximityPlacementGroupId public ZonalPlatformFaultDomainAlignMode? ZonalPlatformFaultDomainAlignMode { get; set; } /// Specifies the sku profile for the virtual machine scale set. public ComputeSkuProfile SkuProfile { get; set; } + /// Specifies the lifecycle hooks profile for the virtual machine scale set. + internal LifecycleHooksProfile LifecycleHooksProfile { get; set; } + /// Specifies the lifecycle hooks configured for the virtual machine scale set. + public IList LifecycleHooks + { + get + { + if (LifecycleHooksProfile is null) + LifecycleHooksProfile = new LifecycleHooksProfile(); + return LifecycleHooksProfile.LifecycleHooks; + } + } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.Serialization.cs index 843d1959bb8d..0e4c24451926 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.Serialization.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.Serialization.cs @@ -150,6 +150,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("skuProfile"u8); writer.WriteObjectValue(SkuProfile, options); } + if (Optional.IsDefined(LifecycleHooksProfile)) + { + writer.WritePropertyName("lifecycleHooksProfile"u8); + writer.WriteObjectValue(LifecycleHooksProfile, options); + } foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); @@ -207,6 +212,7 @@ internal static VirtualMachineScaleSetProperties DeserializeVirtualMachineScaleS ResiliencyPolicy resiliencyPolicy = default; ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode = default; ComputeSkuProfile skuProfile = default; + LifecycleHooksProfile lifecycleHooksProfile = default; IDictionary additionalProperties = default; Dictionary additionalPropertiesDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -410,6 +416,15 @@ internal static VirtualMachineScaleSetProperties DeserializeVirtualMachineScaleS skuProfile = ComputeSkuProfile.DeserializeComputeSkuProfile(property.Value, options); continue; } + if (property.NameEquals("lifecycleHooksProfile"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lifecycleHooksProfile = LifecycleHooksProfile.DeserializeLifecycleHooksProfile(property.Value, options); + continue; + } additionalPropertiesDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } additionalProperties = additionalPropertiesDictionary; @@ -437,6 +452,7 @@ internal static VirtualMachineScaleSetProperties DeserializeVirtualMachineScaleS resiliencyPolicy, zonalPlatformFaultDomainAlignMode, skuProfile, + lifecycleHooksProfile, additionalProperties); } diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.cs index 768acec935d4..924087bb8e71 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VirtualMachineScaleSetProperties.cs @@ -45,8 +45,9 @@ public VirtualMachineScaleSetProperties() /// Policy for Resiliency. /// Specifies the align mode between Virtual Machine Scale Set compute and storage Fault Domain count. /// Specifies the sku profile for the virtual machine scale set. + /// Specifies the lifecycle hooks profile for the virtual machine scale set. /// Additional Properties. - internal VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy, ScheduledEventsPolicy scheduledEventsPolicy, AutomaticRepairsPolicy automaticRepairsPolicy, VirtualMachineScaleSetVmProfile virtualMachineProfile, string provisioningState, bool? overprovision, bool? doNotRunExtensionsOnOverprovisionedVms, string uniqueId, bool? singlePlacementGroup, bool? zoneBalance, int? platformFaultDomainCount, WritableSubResource proximityPlacementGroup, WritableSubResource hostGroup, AdditionalCapabilities additionalCapabilities, ScaleInPolicy scaleInPolicy, OrchestrationMode? orchestrationMode, SpotRestorePolicy spotRestorePolicy, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy, DateTimeOffset? timeCreated, bool? isMaximumCapacityConstrained, ResiliencyPolicy resiliencyPolicy, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode, ComputeSkuProfile skuProfile, IDictionary additionalProperties) + internal VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy upgradePolicy, ScheduledEventsPolicy scheduledEventsPolicy, AutomaticRepairsPolicy automaticRepairsPolicy, VirtualMachineScaleSetVmProfile virtualMachineProfile, string provisioningState, bool? overprovision, bool? doNotRunExtensionsOnOverprovisionedVms, string uniqueId, bool? singlePlacementGroup, bool? zoneBalance, int? platformFaultDomainCount, WritableSubResource proximityPlacementGroup, WritableSubResource hostGroup, AdditionalCapabilities additionalCapabilities, ScaleInPolicy scaleInPolicy, OrchestrationMode? orchestrationMode, SpotRestorePolicy spotRestorePolicy, VirtualMachineScaleSetPriorityMixPolicy priorityMixPolicy, DateTimeOffset? timeCreated, bool? isMaximumCapacityConstrained, ResiliencyPolicy resiliencyPolicy, ZonalPlatformFaultDomainAlignMode? zonalPlatformFaultDomainAlignMode, ComputeSkuProfile skuProfile, LifecycleHooksProfile lifecycleHooksProfile, IDictionary additionalProperties) { UpgradePolicy = upgradePolicy; ScheduledEventsPolicy = scheduledEventsPolicy; @@ -71,6 +72,7 @@ internal VirtualMachineScaleSetProperties(VirtualMachineScaleSetUpgradePolicy up ResiliencyPolicy = resiliencyPolicy; ZonalPlatformFaultDomainAlignMode = zonalPlatformFaultDomainAlignMode; SkuProfile = skuProfile; + LifecycleHooksProfile = lifecycleHooksProfile; AdditionalProperties = additionalProperties; } @@ -144,6 +146,19 @@ public ResourceIdentifier HostGroupId public ZonalPlatformFaultDomainAlignMode? ZonalPlatformFaultDomainAlignMode { get; set; } /// Specifies the sku profile for the virtual machine scale set. public ComputeSkuProfile SkuProfile { get; set; } + /// Specifies the lifecycle hooks profile for the virtual machine scale set. + internal LifecycleHooksProfile LifecycleHooksProfile { get; set; } + /// Specifies the lifecycle hooks configured for the virtual machine scale set. + public IList LifecycleHooks + { + get + { + if (LifecycleHooksProfile is null) + LifecycleHooksProfile = new LifecycleHooksProfile(); + return LifecycleHooksProfile.LifecycleHooks; + } + } + /// /// Additional Properties /// diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.Serialization.cs new file mode 100644 index 000000000000..64f9f785c3e2 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.Serialization.cs @@ -0,0 +1,286 @@ +// 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.Compute.Models +{ + public partial class VmScaleSetLifecycleHookEvent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEvent)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + if (Optional.IsDefined(TypePropertiesType)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(TypePropertiesType); + } + if (Optional.IsDefined(WaitUntil)) + { + writer.WritePropertyName("waitUntil"u8); + writer.WriteStringValue(WaitUntil); + } + if (Optional.IsDefined(MaxWaitUntil)) + { + writer.WritePropertyName("maxWaitUntil"u8); + writer.WriteStringValue(MaxWaitUntil); + } + if (Optional.IsDefined(TimeCreated)) + { + writer.WritePropertyName("timeCreated"u8); + writer.WriteStringValue(TimeCreated); + } + if (Optional.IsDefined(DefaultAction)) + { + writer.WritePropertyName("defaultAction"u8); + writer.WriteStringValue(DefaultAction.Value.ToString()); + } + if (Optional.IsCollectionDefined(TargetResources)) + { + writer.WritePropertyName("targetResources"u8); + writer.WriteStartArray(); + foreach (var item in TargetResources) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(AdditionalContext)) + { + writer.WritePropertyName("additionalContext"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalContext) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(State)) + { + writer.WritePropertyName("state"u8); + writer.WriteStringValue(State.Value.ToString()); + } + writer.WriteEndObject(); + } + + VmScaleSetLifecycleHookEvent 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(VmScaleSetLifecycleHookEvent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmScaleSetLifecycleHookEvent(document.RootElement, options); + } + + internal static VmScaleSetLifecycleHookEvent DeserializeVmScaleSetLifecycleHookEvent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ResourceIdentifier id = default; + string name = default; + ResourceType type = default; + SystemData systemData = default; + string type0 = default; + string waitUntil = default; + string maxWaitUntil = default; + string timeCreated = default; + LifecycleHookAction? defaultAction = default; + IList targetResources = default; + IDictionary additionalContext = default; + VmScaleSetLifecycleHookEventState? state = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + 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 (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.NameEquals("type"u8)) + { + type0 = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("waitUntil"u8)) + { + waitUntil = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("maxWaitUntil"u8)) + { + maxWaitUntil = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("timeCreated"u8)) + { + timeCreated = property0.Value.GetString(); + continue; + } + if (property0.NameEquals("defaultAction"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + defaultAction = new LifecycleHookAction(property0.Value.GetString()); + continue; + } + if (property0.NameEquals("targetResources"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property0.Value.EnumerateArray()) + { + array.Add(VmScaleSetLifecycleHookEventTargetResource.DeserializeVmScaleSetLifecycleHookEventTargetResource(item, options)); + } + targetResources = array; + continue; + } + if (property0.NameEquals("additionalContext"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property1 in property0.Value.EnumerateObject()) + { + dictionary.Add(property1.Name, property1.Value.GetString()); + } + additionalContext = dictionary; + continue; + } + if (property0.NameEquals("state"u8)) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + state = new VmScaleSetLifecycleHookEventState(property0.Value.GetString()); + continue; + } + } + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmScaleSetLifecycleHookEvent( + id, + name, + type, + systemData, + type0, + waitUntil, + maxWaitUntil, + timeCreated, + defaultAction, + targetResources ?? new ChangeTrackingList(), + additionalContext ?? new ChangeTrackingDictionary(), + state, + 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, AzureResourceManagerComputeContext.Default); + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEvent)} does not support writing '{options.Format}' format."); + } + } + + VmScaleSetLifecycleHookEvent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVmScaleSetLifecycleHookEvent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEvent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.cs new file mode 100644 index 000000000000..784d993f93b0 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEvent.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; +using Azure.Core; +using Azure.ResourceManager.Models; + +namespace Azure.ResourceManager.Compute.Models +{ + /// Defines a VMScaleSet lifecycle hook event. + public partial class VmScaleSetLifecycleHookEvent : ResourceData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public VmScaleSetLifecycleHookEvent() + { + TargetResources = new ChangeTrackingList(); + AdditionalContext = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The id. + /// The name. + /// The resourceType. + /// The systemData. + /// Defines the type or scenario for sending a lifecycle hook notification to the customer. + /// Specifies the exact UTC timestamp in ISO 8601 format till which the event would remain in the current lifecycle state waiting for an action from the customer. Beyond this timestamp, the platform will apply the DefaultAction for the event. + /// Specifies the exact UTC timestamp in ISO 8601 format till when the customer can delay the lifecycle hook event. The customer will not be allowed to delay the event to a timestamp beyond this time. + /// The UTC timestamp in ISO 8601 format at which the platform creates the VMScaleSet lifecycle hook event entity. + /// Specify the action that will be aplied on the a target resource in the VMScaleSet lifecycle hook event, if the platform does not get a response from the customer for the target resource before waitUntil. + /// List of resources which are getting processed in the lifecycle hook event. + /// Additional key-value pairs set on the lifecycle hook event that gives customer some useful context/data. + /// Specifies the state of the lifecycle hook event. + /// Keeps track of any properties unknown to the library. + internal VmScaleSetLifecycleHookEvent(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, string typePropertiesType, string waitUntil, string maxWaitUntil, string timeCreated, LifecycleHookAction? defaultAction, IList targetResources, IDictionary additionalContext, VmScaleSetLifecycleHookEventState? state, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData) + { + TypePropertiesType = typePropertiesType; + WaitUntil = waitUntil; + MaxWaitUntil = maxWaitUntil; + TimeCreated = timeCreated; + DefaultAction = defaultAction; + TargetResources = targetResources; + AdditionalContext = additionalContext; + State = state; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Defines the type or scenario for sending a lifecycle hook notification to the customer. + public string TypePropertiesType { get; set; } + /// Specifies the exact UTC timestamp in ISO 8601 format till which the event would remain in the current lifecycle state waiting for an action from the customer. Beyond this timestamp, the platform will apply the DefaultAction for the event. + public string WaitUntil { get; set; } + /// Specifies the exact UTC timestamp in ISO 8601 format till when the customer can delay the lifecycle hook event. The customer will not be allowed to delay the event to a timestamp beyond this time. + public string MaxWaitUntil { get; set; } + /// The UTC timestamp in ISO 8601 format at which the platform creates the VMScaleSet lifecycle hook event entity. + public string TimeCreated { get; set; } + /// Specify the action that will be aplied on the a target resource in the VMScaleSet lifecycle hook event, if the platform does not get a response from the customer for the target resource before waitUntil. + public LifecycleHookAction? DefaultAction { get; set; } + /// List of resources which are getting processed in the lifecycle hook event. + public IList TargetResources { get; } + /// Additional key-value pairs set on the lifecycle hook event that gives customer some useful context/data. + public IDictionary AdditionalContext { get; } + /// Specifies the state of the lifecycle hook event. + public VmScaleSetLifecycleHookEventState? State { get; set; } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.Serialization.cs new file mode 100644 index 000000000000..f6325f389080 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.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.Compute.Models +{ + internal partial class VmScaleSetLifecycleHookEventListResult : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventListResult)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VmScaleSetLifecycleHookEventListResult 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(VmScaleSetLifecycleHookEventListResult)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement, options); + } + + internal static VmScaleSetLifecycleHookEventListResult DeserializeVmScaleSetLifecycleHookEventListResult(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string 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(VmScaleSetLifecycleHookEvent.DeserializeVmScaleSetLifecycleHookEvent(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmScaleSetLifecycleHookEventListResult(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, AzureResourceManagerComputeContext.Default); + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventListResult)} does not support writing '{options.Format}' format."); + } + } + + VmScaleSetLifecycleHookEventListResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventListResult)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.cs new file mode 100644 index 000000000000..61d18217d941 --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventListResult.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.Compute.Models +{ + /// The List VMScaleSet lifecycle hook events operation response. + internal partial class VmScaleSetLifecycleHookEventListResult + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The list of VMScaleSet lifecycle hook events. + /// is null. + internal VmScaleSetLifecycleHookEventListResult(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// The list of VMScaleSet lifecycle hook events. + /// The uri to fetch the next page of VMScaleSet lifecycle hook events. Call ListNext() with this to fetch the next page of VMScaleSet lifecycle hook events. + /// Keeps track of any properties unknown to the library. + internal VmScaleSetLifecycleHookEventListResult(IReadOnlyList value, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VmScaleSetLifecycleHookEventListResult() + { + } + + /// The list of VMScaleSet lifecycle hook events. + public IReadOnlyList Value { get; } + /// The uri to fetch the next page of VMScaleSet lifecycle hook events. Call ListNext() with this to fetch the next page of VMScaleSet lifecycle hook events. + public string NextLink { get; } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventState.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventState.cs new file mode 100644 index 000000000000..9145b7688a9e --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventState.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.Compute.Models +{ + /// The states that a VMScaleSet lifecycle hook event can be in. This is not settable by the customer. It is set only by the VMSS platform. + public readonly partial struct VmScaleSetLifecycleHookEventState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VmScaleSetLifecycleHookEventState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ActiveValue = "Active"; + private const string CompletedValue = "Completed"; + + /// The lifecycle hook event is active. E.g., waiting on a response from the customer. + public static VmScaleSetLifecycleHookEventState Active { get; } = new VmScaleSetLifecycleHookEventState(ActiveValue); + /// The lifecycle hook event is completed. i.e., all the target resources in the event have moved to a terminal state. + public static VmScaleSetLifecycleHookEventState Completed { get; } = new VmScaleSetLifecycleHookEventState(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(VmScaleSetLifecycleHookEventState left, VmScaleSetLifecycleHookEventState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VmScaleSetLifecycleHookEventState left, VmScaleSetLifecycleHookEventState right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator VmScaleSetLifecycleHookEventState(string value) => new VmScaleSetLifecycleHookEventState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VmScaleSetLifecycleHookEventState other && Equals(other); + /// + public bool Equals(VmScaleSetLifecycleHookEventState 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/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.Serialization.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.Serialization.cs new file mode 100644 index 000000000000..957643b207cd --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.Serialization.cs @@ -0,0 +1,175 @@ +// 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.Compute.Models +{ + public partial class VmScaleSetLifecycleHookEventTargetResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventTargetResource)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Resource)) + { + writer.WritePropertyName("resource"u8); + JsonSerializer.Serialize(writer, Resource); + } + if (Optional.IsDefined(ActionState)) + { + writer.WritePropertyName("actionState"u8); + writer.WriteStringValue(ActionState.Value.ToString()); + } + if (Optional.IsCollectionDefined(AdditionalContext)) + { + writer.WritePropertyName("additionalContext"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalContext) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + VmScaleSetLifecycleHookEventTargetResource 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(VmScaleSetLifecycleHookEventTargetResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVmScaleSetLifecycleHookEventTargetResource(document.RootElement, options); + } + + internal static VmScaleSetLifecycleHookEventTargetResource DeserializeVmScaleSetLifecycleHookEventTargetResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WritableSubResource resource = default; + LifecycleHookActionState? actionState = default; + IDictionary additionalContext = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("resource"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resource = JsonSerializer.Deserialize(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("actionState"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + actionState = new LifecycleHookActionState(property.Value.GetString()); + continue; + } + if (property.NameEquals("additionalContext"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()); + } + additionalContext = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VmScaleSetLifecycleHookEventTargetResource(resource, actionState, additionalContext ?? 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, AzureResourceManagerComputeContext.Default); + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventTargetResource)} does not support writing '{options.Format}' format."); + } + } + + VmScaleSetLifecycleHookEventTargetResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeVmScaleSetLifecycleHookEventTargetResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VmScaleSetLifecycleHookEventTargetResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.cs new file mode 100644 index 000000000000..70ae1a0ca8aa --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/Models/VmScaleSetLifecycleHookEventTargetResource.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.Compute.Models +{ + /// Define a single target resource in a lifecycle hook event. Currently, the resource can either be a VMSS or a VMSS VM. + public partial class VmScaleSetLifecycleHookEventTargetResource + { + /// + /// 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 VmScaleSetLifecycleHookEventTargetResource() + { + AdditionalContext = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Specifies the target ARM resource. Currently, can be a VMSS resource or an individual VM resource in a VMSS. + /// State of the lifecycle hook for the target resource. The customer can patch this property to move the lifecycle hook to a terminal state. + /// Additional key-value pairs set for the target resource that gives customer some useful context/data. + /// Keeps track of any properties unknown to the library. + internal VmScaleSetLifecycleHookEventTargetResource(WritableSubResource resource, LifecycleHookActionState? actionState, IDictionary additionalContext, IDictionary serializedAdditionalRawData) + { + Resource = resource; + ActionState = actionState; + AdditionalContext = additionalContext; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Specifies the target ARM resource. Currently, can be a VMSS resource or an individual VM resource in a VMSS. + internal WritableSubResource Resource { get; set; } + /// Gets or sets Id. + public ResourceIdentifier ResourceId + { + get => Resource is null ? default : Resource.Id; + set + { + if (Resource is null) + Resource = new WritableSubResource(); + Resource.Id = value; + } + } + + /// State of the lifecycle hook for the target resource. The customer can patch this property to move the lifecycle hook to a terminal state. + public LifecycleHookActionState? ActionState { get; set; } + /// Additional key-value pairs set for the target resource that gives customer some useful context/data. + public IDictionary AdditionalContext { get; } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/RestOperations/VirtualMachineScaleSetLifeCycleHookEventsRestOperations.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/RestOperations/VirtualMachineScaleSetLifeCycleHookEventsRestOperations.cs new file mode 100644 index 000000000000..e29d17674d3b --- /dev/null +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/RestOperations/VirtualMachineScaleSetLifeCycleHookEventsRestOperations.cs @@ -0,0 +1,325 @@ +// 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.Compute.Models; + +namespace Azure.ResourceManager.Compute +{ + internal partial class VirtualMachineScaleSetLifeCycleHookEventsRestOperations + { + private readonly TelemetryDetails _userAgent; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// Initializes a new instance of VirtualMachineScaleSetLifeCycleHookEventsRestOperations. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The application id to use for user agent. + /// server parameter. + /// Api Version. + /// or is null. + public VirtualMachineScaleSetLifeCycleHookEventsRestOperations(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-11-01"; + _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); + } + + internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent) + { + 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.Compute/virtualMachineScaleSets/", false); + uri.AppendPath(virtualMachineScaleSetName, true); + uri.AppendPath("/lifecycleHookEvents/", false); + uri.AppendPath(lifeCycleHookEventName, true); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent) + { + 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.Compute/virtualMachineScaleSets/", false); + uri.AppendPath(virtualMachineScaleSetName, true); + uri.AppendPath("/lifecycleHookEvents/", false); + uri.AppendPath(lifeCycleHookEventName, 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(vmssLchEvent, ModelSerializationExtensions.WireOptions); + request.Content = content; + _userAgent.Apply(message); + return message; + } + + /// The operation to update an VMScaleSet lifecycle hook event. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VMScaleSet. + /// The name of the VMScaleSet lifecycle hook event. + /// Parameters supplied to the Update VMScaleSet lifecycle hook event. + /// 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 virtualMachineScaleSetName, string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + Argument.AssertNotNullOrEmpty(lifeCycleHookEventName, nameof(lifeCycleHookEventName)); + Argument.AssertNotNull(vmssLchEvent, nameof(vmssLchEvent)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualMachineScaleSetName, lifeCycleHookEventName, vmssLchEvent); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEvent value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = VmScaleSetLifecycleHookEvent.DeserializeVmScaleSetLifecycleHookEvent(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// The operation to update an VMScaleSet lifecycle hook event. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VMScaleSet. + /// The name of the VMScaleSet lifecycle hook event. + /// Parameters supplied to the Update VMScaleSet lifecycle hook event. + /// 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 virtualMachineScaleSetName, string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + Argument.AssertNotNullOrEmpty(lifeCycleHookEventName, nameof(lifeCycleHookEventName)); + Argument.AssertNotNull(vmssLchEvent, nameof(vmssLchEvent)); + + using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, virtualMachineScaleSetName, lifeCycleHookEventName, vmssLchEvent); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEvent value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = VmScaleSetLifecycleHookEvent.DeserializeVmScaleSetLifecycleHookEvent(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListRequestUri(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName) + { + 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.Compute/virtualMachineScaleSets/", false); + uri.AppendPath(virtualMachineScaleSetName, true); + uri.AppendPath("/lifecycleHookEvents", false); + uri.AppendQuery("api-version", _apiVersion, true); + return uri; + } + + internal HttpMessage CreateListRequest(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName) + { + 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.Compute/virtualMachineScaleSets/", false); + uri.AppendPath(virtualMachineScaleSetName, true); + uri.AppendPath("/lifecycleHookEvents", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + _userAgent.Apply(message); + return message; + } + + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VM scale set containing the lifecycle hook events. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListAsync(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEventListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = VmScaleSetLifecycleHookEventListResult.DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VM scale set containing the lifecycle hook events. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response List(string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + + using var message = CreateListRequest(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEventListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = VmScaleSetLifecycleHookEventListResult.DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName) + { + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + return uri; + } + + internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName) + { + 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; + } + + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VM scale set containing the lifecycle hook events. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public async Task> ListNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualMachineScaleSetName); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEventListResult value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); + value = VmScaleSetLifecycleHookEventListResult.DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// The URL to the next page of results. + /// Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + /// The name of the resource group. + /// The name of the VM scale set containing the lifecycle hook events. + /// The cancellation token to use. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + public Response ListNextPage(string nextLink, string subscriptionId, string resourceGroupName, string virtualMachineScaleSetName, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(nextLink, nameof(nextLink)); + Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); + Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); + Argument.AssertNotNullOrEmpty(virtualMachineScaleSetName, nameof(virtualMachineScaleSetName)); + + using var message = CreateListNextPageRequest(nextLink, subscriptionId, resourceGroupName, virtualMachineScaleSetName); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + VmScaleSetLifecycleHookEventListResult value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); + value = VmScaleSetLifecycleHookEventListResult.DeserializeVmScaleSetLifecycleHookEventListResult(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/VirtualMachineScaleSetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/VirtualMachineScaleSetResource.cs index 859984200f71..899f1f42c66f 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/Generated/VirtualMachineScaleSetResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/src/Generated/VirtualMachineScaleSetResource.cs @@ -40,6 +40,8 @@ public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, private readonly VirtualMachineScaleSetsRestOperations _virtualMachineScaleSetRestClient; private readonly ClientDiagnostics _virtualMachineScaleSetRollingUpgradeClientDiagnostics; private readonly VirtualMachineScaleSetRollingUpgradesRestOperations _virtualMachineScaleSetRollingUpgradeRestClient; + private readonly ClientDiagnostics _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics; + private readonly VirtualMachineScaleSetLifeCycleHookEventsRestOperations _virtualMachineScaleSetLifeCycleHookEventsRestClient; private readonly VirtualMachineScaleSetData _data; /// Gets the resource type for the operations. @@ -70,6 +72,8 @@ internal VirtualMachineScaleSetResource(ArmClient client, ResourceIdentifier id) _virtualMachineScaleSetRollingUpgradeClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Compute", VirtualMachineScaleSetRollingUpgradeResource.ResourceType.Namespace, Diagnostics); TryGetApiVersion(VirtualMachineScaleSetRollingUpgradeResource.ResourceType, out string virtualMachineScaleSetRollingUpgradeApiVersion); _virtualMachineScaleSetRollingUpgradeRestClient = new VirtualMachineScaleSetRollingUpgradesRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, virtualMachineScaleSetRollingUpgradeApiVersion); + _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.Compute", ProviderConstants.DefaultProviderNamespace, Diagnostics); + _virtualMachineScaleSetLifeCycleHookEventsRestClient = new VirtualMachineScaleSetLifeCycleHookEventsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint); #if DEBUG ValidateResourceId(Id); #endif @@ -2263,6 +2267,140 @@ public virtual ArmOperation StartExtensionUpgradeVirtualMachineScaleSetRollingUp } } + /// + /// The operation to update an VMScaleSet lifecycle hook event. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/lifecycleHookEvents/{lifeCycleHookEventName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSetLifeCycleHookEvents_Update + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// + /// The name of the VMScaleSet lifecycle hook event. + /// Parameters supplied to the Update VMScaleSet lifecycle hook event. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual async Task> UpdateVirtualMachineScaleSetLifeCycleHookEventAsync(string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(lifeCycleHookEventName, nameof(lifeCycleHookEventName)); + Argument.AssertNotNull(vmssLchEvent, nameof(vmssLchEvent)); + + using var scope = _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics.CreateScope("VirtualMachineScaleSetResource.UpdateVirtualMachineScaleSetLifeCycleHookEvent"); + scope.Start(); + try + { + var response = await _virtualMachineScaleSetLifeCycleHookEventsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, lifeCycleHookEventName, vmssLchEvent, cancellationToken).ConfigureAwait(false); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// The operation to update an VMScaleSet lifecycle hook event. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/lifecycleHookEvents/{lifeCycleHookEventName} + /// + /// + /// Operation Id + /// VirtualMachineScaleSetLifeCycleHookEvents_Update + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// + /// The name of the VMScaleSet lifecycle hook event. + /// Parameters supplied to the Update VMScaleSet lifecycle hook event. + /// The cancellation token to use. + /// is an empty string, and was expected to be non-empty. + /// or is null. + public virtual Response UpdateVirtualMachineScaleSetLifeCycleHookEvent(string lifeCycleHookEventName, VmScaleSetLifecycleHookEvent vmssLchEvent, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(lifeCycleHookEventName, nameof(lifeCycleHookEventName)); + Argument.AssertNotNull(vmssLchEvent, nameof(vmssLchEvent)); + + using var scope = _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics.CreateScope("VirtualMachineScaleSetResource.UpdateVirtualMachineScaleSetLifeCycleHookEvent"); + scope.Start(); + try + { + var response = _virtualMachineScaleSetLifeCycleHookEventsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, lifeCycleHookEventName, vmssLchEvent, cancellationToken); + return response; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/lifecycleHookEvents + /// + /// + /// Operation Id + /// VirtualMachineScaleSetLifeCycleHookEvents_List + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// + /// The cancellation token to use. + /// An async collection of that may take multiple service requests to iterate over. + public virtual AsyncPageable GetVirtualMachineScaleSetLifeCycleHookEventsAsync(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _virtualMachineScaleSetLifeCycleHookEventsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _virtualMachineScaleSetLifeCycleHookEventsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => VmScaleSetLifecycleHookEvent.DeserializeVmScaleSetLifecycleHookEvent(e), _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics, Pipeline, "VirtualMachineScaleSetResource.GetVirtualMachineScaleSetLifeCycleHookEvents", "value", "nextLink", cancellationToken); + } + + /// + /// Gets a list of all lifecycle hook in a VMScaleSet. + /// + /// + /// Request Path + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/lifecycleHookEvents + /// + /// + /// Operation Id + /// VirtualMachineScaleSetLifeCycleHookEvents_List + /// + /// + /// Default Api Version + /// 2024-11-01 + /// + /// + /// + /// The cancellation token to use. + /// A collection of that may take multiple service requests to iterate over. + public virtual Pageable GetVirtualMachineScaleSetLifeCycleHookEvents(CancellationToken cancellationToken = default) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => _virtualMachineScaleSetLifeCycleHookEventsRestClient.CreateListRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _virtualMachineScaleSetLifeCycleHookEventsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => VmScaleSetLifecycleHookEvent.DeserializeVmScaleSetLifecycleHookEvent(e), _virtualMachineScaleSetLifeCycleHookEventsClientDiagnostics, Pipeline, "VirtualMachineScaleSetResource.GetVirtualMachineScaleSetLifeCycleHookEvents", "value", "nextLink", cancellationToken); + } + /// /// Add a tag to the current resource. /// diff --git a/sdk/compute/Azure.ResourceManager.Compute/src/autorest.md b/sdk/compute/Azure.ResourceManager.Compute/src/autorest.md index 1366fb3e33ff..3734835b3023 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/src/autorest.md +++ b/sdk/compute/Azure.ResourceManager.Compute/src/autorest.md @@ -10,7 +10,7 @@ Run `dotnet build /t:GenerateCode` to generate code. azure-arm: true library-name: Compute namespace: Azure.ResourceManager.Compute -require: https://github.com/Azure/azure-rest-api-specs/blob/883abbe08d313739069c0007eb820aa0a0710748/specification/compute/resource-manager/readme.md +require: https://github.com/Azure/azure-rest-api-specs/blob/39d6109d15013a061a50f93b9735e7d85b6ff83e/specification/compute/resource-manager/readme.md #tag: package-2025-02-01 output-folder: $(this-folder)/Generated clear-output-folder: true diff --git a/sdk/compute/Azure.ResourceManager.Compute/tests/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/tests/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs index 7b17b52288f1..b27dfaa51c72 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/tests/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/tests/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs @@ -1598,5 +1598,62 @@ public async Task StartExtensionUpgradeVirtualMachineScaleSetRollingUpgrade_Star Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task UpdateVirtualMachineScaleSetLifeCycleHookEvent_VirtualMachineScaleSetLifeCycleHookEventUpdateGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-11-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetLifeCycleHookEvent_Update_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetLifeCycleHookEvents_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "RG01"; + string virtualMachineScaleSetName = "VMSS01"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation + string lifeCycleHookEventName = "445c0a08-cfc5-4ef6-bb89-fe77c5178628"; + VmScaleSetLifecycleHookEvent vmssLchEvent = new VmScaleSetLifecycleHookEvent(); + VmScaleSetLifecycleHookEvent result = await virtualMachineScaleSet.UpdateVirtualMachineScaleSetLifeCycleHookEventAsync(lifeCycleHookEventName, vmssLchEvent); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineScaleSetLifeCycleHookEvents_VirtualMachineScaleSetLifeCycleHookEventListGenJson() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-11-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetLifeCycleHookEvent_List_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetLifeCycleHookEvents_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "RG01"; + string virtualMachineScaleSetName = "VMSS01"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation and iterate over the result + await foreach (VmScaleSetLifecycleHookEvent item in virtualMachineScaleSet.GetVirtualMachineScaleSetLifeCycleHookEventsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } } }