Skip to content

Commit bcdf23f

Browse files
Added InGuestPatch Test case. (Azure#38483)
1 parent bf0d40d commit bcdf23f

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

sdk/maintenance/Azure.ResourceManager.Maintenance/CHANGELOG.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# Release History
22

3-
## 1.2.0-beta.3 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 1.2.0-beta.3 (2023-09-05)
84

95
### Bugs Fixed
106

11-
### Other Changes
7+
- Fix the missing `MaintenanceConfigurationData.InstallPatches` serialization issue.
128

139
## 1.2.0-beta.2 (2023-07-24)
1410

@@ -115,4 +111,4 @@ This package follows the [new Azure SDK guidelines](https://azure.github.io/azur
115111

116112
This package is a Public Preview version, so expect incompatible changes in subsequent releases as we improve the product. To provide feedback, submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues).
117113

118-
> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet).
114+
> NOTE: For more information about unified authentication, please refer to [Microsoft Azure Identity documentation for .NET](https://docs.microsoft.com//dotnet/api/overview/azure/identity-readme?view=azure-dotnet).

sdk/maintenance/Azure.ResourceManager.Maintenance/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/maintenance/Azure.ResourceManager.Maintenance",
5-
"Tag": "net/maintenance/Azure.ResourceManager.Maintenance_860a3716dd"
5+
"Tag": "net/maintenance/Azure.ResourceManager.Maintenance_adc06a3324"
66
}

sdk/maintenance/Azure.ResourceManager.Maintenance/src/Custom/Models/MaintenanceConfigurationData.Serialization.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
using Azure.ResourceManager.Maintenance.Models;
1111
using Azure.ResourceManager.Models;
1212

13-
// Custom code to support custom datetime format for the 2 properties startDateTime and expirationDateTime
14-
// Here is an issue https://github.com/Azure/autorest.csharp/issues/3184 to track if codegen can support custom datetime format in the furture.
15-
1613
namespace Azure.ResourceManager.Maintenance
1714
{
1815
[CodeGenSuppress("global::Azure.Core.IUtf8JsonSerializable.Write", typeof(Utf8JsonWriter))]
@@ -62,13 +59,22 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
6259
writer.WritePropertyName("visibility"u8);
6360
writer.WriteStringValue(Visibility.Value.ToString());
6461
}
62+
if (Optional.IsDefined(InstallPatches))
63+
{
64+
writer.WritePropertyName("installPatches"u8);
65+
writer.WriteObjectValue(InstallPatches);
66+
}
6567
writer.WritePropertyName("maintenanceWindow"u8);
6668
writer.WriteStartObject();
69+
// Custom code to support custom datetime format for the 2 properties startDateTime and expirationDateTime
70+
// Here is an issue https://github.com/Azure/autorest.csharp/issues/3184 to track if codegen can support custom datetime format in the furture.
6771
if (Optional.IsDefined(StartOn))
6872
{
6973
writer.WritePropertyName("startDateTime"u8);
7074
writer.WriteStringValue(StartOn.Value, "yyyy-MM-dd hh:mm");
7175
}
76+
// Custom code to support custom datetime format for the 2 properties startDateTime and expirationDateTime
77+
// Here is an issue https://github.com/Azure/autorest.csharp/issues/3184 to track if codegen can support custom datetime format in the furture.
7278
if (Optional.IsDefined(ExpireOn))
7379
{
7480
writer.WritePropertyName("expirationDateTime"u8);
@@ -89,6 +95,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
8995
writer.WritePropertyName("recurEvery"u8);
9096
writer.WriteStringValue(RecurEvery);
9197
}
98+
9299
writer.WriteEndObject();
93100
writer.WriteEndObject();
94101
writer.WriteEndObject();

sdk/maintenance/Azure.ResourceManager.Maintenance/tests/Scenario/MaintenanceConfigurationTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Collections.Generic;
56
using System.Linq;
67
using System.Threading.Tasks;
78
using Azure.Core;
@@ -89,14 +90,19 @@ private async Task<MaintenanceConfigurationResource> CreateMaintenanceConfigurat
8990
MaintenanceConfigurationData data = new MaintenanceConfigurationData(Location)
9091
{
9192
Namespace = "Microsoft.Maintenance",
92-
MaintenanceScope = MaintenanceScope.Host,
93+
MaintenanceScope = MaintenanceScope.InGuestPatch,
9394
Visibility = MaintenanceConfigurationVisibility.Custom,
94-
StartOn = DateTimeOffset.Parse("2023-12-31 00:00"),
95+
StartOn = DateTimeOffset.Parse("2024-12-31 00:00"),
9596
ExpireOn = DateTimeOffset.Parse("9999-12-31 00:00"),
96-
Duration = TimeSpan.Parse("05:00"),
97+
Duration = TimeSpan.Parse("03:00"),
9798
TimeZone = "Pacific Standard Time",
9899
RecurEvery = "Day",
100+
InstallPatches = new MaintenancePatchConfiguration(MaintenanceRebootOption.Always,
101+
new MaintenanceWindowsPatchSettings(new List<string>(), new List<string>(), new List<string>() { "Security", "Critical" }, false),
102+
new MaintenanceLinuxPatchSettings(new List<string>(), new List<string>(), new List<string>() { "Security", "Critical" }))
99103
};
104+
data.ExtensionProperties.Add("InGuestPatchMode", "User");
105+
100106
ArmOperation<MaintenanceConfigurationResource> lro = await _configCollection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data);
101107
return lro.Value;
102108
}

0 commit comments

Comments
 (0)