diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/Azure.ResourceManager.CognitiveServices.sln b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/Azure.ResourceManager.CognitiveServices.sln index 0ff68dca0936a..e539fe95eca80 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/Azure.ResourceManager.CognitiveServices.sln +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/Azure.ResourceManager.CognitiveServices.sln @@ -57,6 +57,18 @@ Global {7F2D11EE-8853-45D8-AB2D-5518C4C87543}.Release|x64.Build.0 = Release|Any CPU {7F2D11EE-8853-45D8-AB2D-5518C4C87543}.Release|x86.ActiveCfg = Release|Any CPU {7F2D11EE-8853-45D8-AB2D-5518C4C87543}.Release|x86.Build.0 = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|x64.ActiveCfg = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|x64.Build.0 = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|x86.ActiveCfg = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Debug|x86.Build.0 = Debug|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|Any CPU.Build.0 = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|x64.ActiveCfg = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|x64.Build.0 = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|x86.ActiveCfg = Release|Any CPU + {6C76231F-3D6D-4E1D-BC60-9832AD145E3E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/CHANGELOG.md b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/CHANGELOG.md index 2844272daa4dd..74cd8fef151b7 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/CHANGELOG.md +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Reverted the flattening of `KeyVaultProperties` in `ServiceAccountEncryptionProperties` as service side does not support passing empty object for this property. + ### Other Changes ## 1.2.1 (2023-02-20) diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs index d657b0291467d..13d82b3f7883f 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/api/Azure.ResourceManager.CognitiveServices.netstandard2.0.cs @@ -475,6 +475,14 @@ public partial class CognitiveServicesIPRule public CognitiveServicesIPRule(string value) { } public string Value { get { throw null; } set { } } } + public partial class CognitiveServicesKeyVaultProperties + { + public CognitiveServicesKeyVaultProperties() { } + public System.Guid? IdentityClientId { get { throw null; } set { } } + public string KeyName { get { throw null; } set { } } + public System.Uri KeyVaultUri { get { throw null; } set { } } + public string KeyVersion { get { throw null; } set { } } + } public partial class CognitiveServicesMultiRegionSettings { public CognitiveServicesMultiRegionSettings() { } @@ -846,10 +854,19 @@ internal ServiceAccountCallRateLimit() { } public partial class ServiceAccountEncryptionProperties { public ServiceAccountEncryptionProperties() { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is obsolete and will be removed in a future release", false)] public System.Guid? IdentityClientId { get { throw null; } set { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is obsolete and will be removed in a future release", false)] public string KeyName { get { throw null; } set { } } public Azure.ResourceManager.CognitiveServices.Models.ServiceAccountEncryptionKeySource? KeySource { get { throw null; } set { } } + public Azure.ResourceManager.CognitiveServices.Models.CognitiveServicesKeyVaultProperties KeyVaultProperties { get { throw null; } set { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is obsolete and will be removed in a future release", false)] public System.Uri KeyVaultUri { get { throw null; } set { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + [System.ObsoleteAttribute("This property is obsolete and will be removed in a future release", false)] public string KeyVersion { get { throw null; } set { } } } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs index c0413e4105495..954abe8e4d2c5 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs @@ -54,10 +54,13 @@ public async Task CreateOrUpdate_CreateAccount() { Encryption = new ServiceAccountEncryptionProperties() { + KeyVaultProperties = new CognitiveServicesKeyVaultProperties() + { + KeyName = "KeyName", + KeyVersion = "891CF236-D241-4738-9462-D506AF493DFA", + KeyVaultUri = new Uri("https://pltfrmscrts-use-pc-dev.vault.azure.net/"), + }, KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, - KeyName = "KeyName", - KeyVersion = "891CF236-D241-4738-9462-D506AF493DFA", - KeyVaultUri = new Uri("https://pltfrmscrts-use-pc-dev.vault.azure.net/"), }, UserOwnedStorage = { diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Customized/Models/ServiceAccountEncryptionProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Customized/Models/ServiceAccountEncryptionProperties.cs new file mode 100644 index 0000000000000..a6f1e4bad6925 --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Customized/Models/ServiceAccountEncryptionProperties.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Properties to configure Encryption. + public partial class ServiceAccountEncryptionProperties + { + /// Name of the Key from KeyVault. + [Obsolete("This property is obsolete and will be removed in a future release", false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public string KeyName + { + get + { + if (KeyVaultProperties != null) + return KeyVaultProperties.KeyName; + else + return default; + } + set + { + if (KeyVaultProperties == null) + KeyVaultProperties = new CognitiveServicesKeyVaultProperties(); + KeyVaultProperties.KeyName = value; + } + } + /// Version of the Key from KeyVault. + [Obsolete("This property is obsolete and will be removed in a future release", false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public string KeyVersion + { + get + { + if (KeyVaultProperties != null) + return KeyVaultProperties.KeyVersion; + else + return default; + } + set + { + if (KeyVaultProperties == null) + KeyVaultProperties = new CognitiveServicesKeyVaultProperties(); + KeyVaultProperties.KeyVersion = value; + } + } + /// Uri of KeyVault. + [Obsolete("This property is obsolete and will be removed in a future release", false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public Uri KeyVaultUri + { + get + { + if (KeyVaultProperties != null) + return KeyVaultProperties.KeyVaultUri; + else + return default; + } + set + { + if (KeyVaultProperties == null) + KeyVaultProperties = new CognitiveServicesKeyVaultProperties(); + KeyVaultProperties.KeyVaultUri = value; + } + } + /// Gets or sets the identity client id. + [Obsolete("This property is obsolete and will be removed in a future release", false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public Guid? IdentityClientId + { + get + { + if (KeyVaultProperties != null) + return KeyVaultProperties.IdentityClientId; + else + return default; + } + set + { + if (KeyVaultProperties == null) + KeyVaultProperties = new CognitiveServicesKeyVaultProperties(); + KeyVaultProperties.IdentityClientId = value; + } + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.Serialization.cs new file mode 100644 index 0000000000000..fefaf72a235fc --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.Serialization.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + public partial class CognitiveServicesKeyVaultProperties : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsDefined(KeyName)) + { + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + } + if (Optional.IsDefined(KeyVersion)) + { + writer.WritePropertyName("keyVersion"u8); + writer.WriteStringValue(KeyVersion); + } + if (Optional.IsDefined(KeyVaultUri)) + { + writer.WritePropertyName("keyVaultUri"u8); + writer.WriteStringValue(KeyVaultUri.AbsoluteUri); + } + if (Optional.IsDefined(IdentityClientId)) + { + writer.WritePropertyName("identityClientId"u8); + writer.WriteStringValue(IdentityClientId.Value); + } + writer.WriteEndObject(); + } + + internal static CognitiveServicesKeyVaultProperties DeserializeCognitiveServicesKeyVaultProperties(JsonElement element) + { + Optional keyName = default; + Optional keyVersion = default; + Optional keyVaultUri = default; + Optional identityClientId = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("keyName"u8)) + { + keyName = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyVersion"u8)) + { + keyVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyVaultUri"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + keyVaultUri = null; + continue; + } + keyVaultUri = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("identityClientId"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + property.ThrowNonNullablePropertyIsNull(); + continue; + } + identityClientId = property.Value.GetGuid(); + continue; + } + } + return new CognitiveServicesKeyVaultProperties(keyName.Value, keyVersion.Value, keyVaultUri.Value, Optional.ToNullable(identityClientId)); + } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.cs new file mode 100644 index 0000000000000..58352ba26754d --- /dev/null +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/CognitiveServicesKeyVaultProperties.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.ResourceManager.CognitiveServices.Models +{ + /// Properties to configure keyVault Properties. + public partial class CognitiveServicesKeyVaultProperties + { + /// Initializes a new instance of CognitiveServicesKeyVaultProperties. + public CognitiveServicesKeyVaultProperties() + { + } + + /// Initializes a new instance of CognitiveServicesKeyVaultProperties. + /// Name of the Key from KeyVault. + /// Version of the Key from KeyVault. + /// Uri of KeyVault. + /// + internal CognitiveServicesKeyVaultProperties(string keyName, string keyVersion, Uri keyVaultUri, Guid? identityClientId) + { + KeyName = keyName; + KeyVersion = keyVersion; + KeyVaultUri = keyVaultUri; + IdentityClientId = identityClientId; + } + + /// Name of the Key from KeyVault. + public string KeyName { get; set; } + /// Version of the Key from KeyVault. + public string KeyVersion { get; set; } + /// Uri of KeyVault. + public Uri KeyVaultUri { get; set; } + /// Gets or sets the identity client id. + public Guid? IdentityClientId { get; set; } + } +} diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.Serialization.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.Serialization.cs index 12827d5c89e36..848b01bd67513 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.Serialization.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.Serialization.cs @@ -5,7 +5,6 @@ #nullable disable -using System; using System.Text.Json; using Azure.Core; @@ -16,100 +15,47 @@ public partial class ServiceAccountEncryptionProperties : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); + if (Optional.IsDefined(KeyVaultProperties)) + { + writer.WritePropertyName("keyVaultProperties"u8); + writer.WriteObjectValue(KeyVaultProperties); + } if (Optional.IsDefined(KeySource)) { writer.WritePropertyName("keySource"u8); writer.WriteStringValue(KeySource.Value.ToString()); } - writer.WritePropertyName("keyVaultProperties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(KeyName)) - { - writer.WritePropertyName("keyName"u8); - writer.WriteStringValue(KeyName); - } - if (Optional.IsDefined(KeyVersion)) - { - writer.WritePropertyName("keyVersion"u8); - writer.WriteStringValue(KeyVersion); - } - if (Optional.IsDefined(KeyVaultUri)) - { - writer.WritePropertyName("keyVaultUri"u8); - writer.WriteStringValue(KeyVaultUri.AbsoluteUri); - } - if (Optional.IsDefined(IdentityClientId)) - { - writer.WritePropertyName("identityClientId"u8); - writer.WriteStringValue(IdentityClientId.Value); - } - writer.WriteEndObject(); writer.WriteEndObject(); } internal static ServiceAccountEncryptionProperties DeserializeServiceAccountEncryptionProperties(JsonElement element) { + Optional keyVaultProperties = default; Optional keySource = default; - Optional keyName = default; - Optional keyVersion = default; - Optional keyVaultUri = default; - Optional identityClientId = default; foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("keySource"u8)) + if (property.NameEquals("keyVaultProperties"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } - keySource = new ServiceAccountEncryptionKeySource(property.Value.GetString()); + keyVaultProperties = CognitiveServicesKeyVaultProperties.DeserializeCognitiveServicesKeyVaultProperties(property.Value); continue; } - if (property.NameEquals("keyVaultProperties"u8)) + if (property.NameEquals("keySource"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } - foreach (var property0 in property.Value.EnumerateObject()) - { - if (property0.NameEquals("keyName"u8)) - { - keyName = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("keyVersion"u8)) - { - keyVersion = property0.Value.GetString(); - continue; - } - if (property0.NameEquals("keyVaultUri"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - keyVaultUri = null; - continue; - } - keyVaultUri = new Uri(property0.Value.GetString()); - continue; - } - if (property0.NameEquals("identityClientId"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - property0.ThrowNonNullablePropertyIsNull(); - continue; - } - identityClientId = property0.Value.GetGuid(); - continue; - } - } + keySource = new ServiceAccountEncryptionKeySource(property.Value.GetString()); continue; } } - return new ServiceAccountEncryptionProperties(Optional.ToNullable(keySource), keyName.Value, keyVersion.Value, keyVaultUri.Value, Optional.ToNullable(identityClientId)); + return new ServiceAccountEncryptionProperties(keyVaultProperties.Value, Optional.ToNullable(keySource)); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs index af98e37a428af..ecf019ca9198d 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/Generated/Models/ServiceAccountEncryptionProperties.cs @@ -5,8 +5,6 @@ #nullable disable -using System; - namespace Azure.ResourceManager.CognitiveServices.Models { /// Properties to configure Encryption. @@ -18,29 +16,17 @@ public ServiceAccountEncryptionProperties() } /// Initializes a new instance of ServiceAccountEncryptionProperties. + /// Properties of KeyVault. /// Enumerates the possible value of keySource for Encryption. - /// Name of the Key from KeyVault. - /// Version of the Key from KeyVault. - /// Uri of KeyVault. - /// - internal ServiceAccountEncryptionProperties(ServiceAccountEncryptionKeySource? keySource, string keyName, string keyVersion, Uri keyVaultUri, Guid? identityClientId) + internal ServiceAccountEncryptionProperties(CognitiveServicesKeyVaultProperties keyVaultProperties, ServiceAccountEncryptionKeySource? keySource) { + KeyVaultProperties = keyVaultProperties; KeySource = keySource; - KeyName = keyName; - KeyVersion = keyVersion; - KeyVaultUri = keyVaultUri; - IdentityClientId = identityClientId; } + /// Properties of KeyVault. + public CognitiveServicesKeyVaultProperties KeyVaultProperties { get; set; } /// Enumerates the possible value of keySource for Encryption. public ServiceAccountEncryptionKeySource? KeySource { get; set; } - /// Name of the Key from KeyVault. - public string KeyName { get; set; } - /// Version of the Key from KeyVault. - public string KeyVersion { get; set; } - /// Uri of KeyVault. - public Uri KeyVaultUri { get; set; } - /// Gets or sets the identity client id. - public Guid? IdentityClientId { get; set; } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md index 884eb6d9d249f..f2045ceb64ca0 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/src/autorest.md @@ -77,6 +77,7 @@ rename-mapping: MultiRegionSettings: CognitiveServicesMultiRegionSettings CommitmentPlanProperties.commitmentPlanGuid: -|uuid CommitmentPlanAssociation.commitmentPlanId: -|arm-id + KeyVaultProperties: CognitiveServicesKeyVaultProperties prepend-rp-prefix: - Account @@ -136,7 +137,6 @@ directive: transform: > $.CheckDomainAvailabilityParameter.properties.type['x-ms-format'] = 'resource-type'; $.CheckSkuAvailabilityParameter.properties.type['x-ms-format'] = 'resource-type'; - $.Encryption.properties.keyVaultProperties['x-ms-client-flatten'] = true; $.PrivateEndpointConnection.properties.properties['x-ms-client-flatten'] = true; delete $.AccountProperties.properties.internalId; # TODO, these configs will be replaced by the new rename-mapping