diff --git a/doc/GeneratorMigration/Library_Inventory.md b/doc/GeneratorMigration/Library_Inventory.md index 2ba0f5a6c7f7..fd7a9a3f60d4 100644 --- a/doc/GeneratorMigration/Library_Inventory.md +++ b/doc/GeneratorMigration/Library_Inventory.md @@ -14,8 +14,8 @@ - Total libraries: 401 - Management Plane (MPG): 227 - - Autorest/Swagger: 154 - - New Emitter (TypeSpec): 55 + - Autorest/Swagger: 153 + - New Emitter (TypeSpec): 56 - Old TypeSpec: 18 - Data Plane (DPG): 174 - Autorest/Swagger: 87 @@ -171,7 +171,7 @@ Libraries that have not yet been migrated to the new TypeSpec emitter. Total: 87 Libraries that provide resource management APIs for Azure services and have been migrated to the new TypeSpec emitter. -**Migration Status**: 55 / 73 (75.3%) +**Migration Status**: 56 / 74 (75.7%) | Service | Library | New Emitter | | ------- | ------- | ----------- | @@ -206,6 +206,7 @@ Libraries that provide resource management APIs for Azure services and have been | fileshares | Azure.ResourceManager.FileShares | ✅ | | grafana | Azure.ResourceManager.Grafana | ✅ | | hardwaresecuritymodules | Azure.ResourceManager.HardwareSecurityModules | ✅ | +| healthbot | Azure.ResourceManager.HealthBot | ✅ | | healthdataaiservices | Azure.ResourceManager.HealthDataAIServices | ✅ | | hybridconnectivity | Azure.ResourceManager.HybridConnectivity | | | hybridkubernetes | Azure.ResourceManager.Kubernetes | ✅ | @@ -252,7 +253,7 @@ Libraries that provide resource management APIs for Azure services and have been ## Management Plane Libraries (MPG) - Still on Swagger -Libraries that have not yet been migrated to the new TypeSpec emitter. Total: 154 +Libraries that have not yet been migrated to the new TypeSpec emitter. Total: 153 | Service | Library | | ------- | ------- | @@ -323,7 +324,6 @@ Libraries that have not yet been migrated to the new TypeSpec emitter. Total: 15 | graphservices | Azure.ResourceManager.GraphServices | | guestconfiguration | Azure.ResourceManager.GuestConfiguration | | hdinsight | Azure.ResourceManager.HDInsight | -| healthbot | Azure.ResourceManager.HealthBot | | healthcareapis | Azure.ResourceManager.HealthcareApis | | hybridaks | Azure.ResourceManager.HybridContainerService | | hybridcompute | Azure.ResourceManager.HybridCompute | diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net10.0.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net10.0.cs index f82a3d4c4c42..d60dca0ba6b2 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net10.0.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net10.0.cs @@ -29,7 +29,10 @@ public HealthBotData(Azure.Core.AzureLocation location, Azure.ResourceManager.He public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.Models.ResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -105,6 +108,7 @@ public static partial class ArmHealthBotModelFactory public static Azure.ResourceManager.HealthBot.HealthBotData HealthBotData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKey HealthBotKey(string keyName = null, string value = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult HealthBotKeysResult(System.Collections.Generic.IEnumerable secrets = null) { throw null; } + public static Azure.ResourceManager.HealthBot.Models.HealthBotPatch HealthBotPatch(Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null, System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState, System.Uri botManagementPortalLink, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState = null, System.Uri botManagementPortalLink = null, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties = null, string accessControlMethod = null) { throw null; } } @@ -113,7 +117,10 @@ public partial class HealthBotKey : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -124,7 +131,10 @@ public partial class HealthBotKeysResult : System.ClientModel.Primitives.IJsonMo { internal HealthBotKeysResult() { } public System.Collections.Generic.IReadOnlyList Secrets { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -138,7 +148,10 @@ public HealthBotKeyVaultProperties(string keyName, System.Uri keyVaultUri) { } public System.Uri KeyVaultUri { get { throw null; } set { } } public string KeyVersion { get { throw null; } set { } } public string UserIdentity { get { throw null; } set { } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -153,7 +166,10 @@ public HealthBotPatch() { } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -167,7 +183,10 @@ public HealthBotProperties() { } public System.Uri BotManagementPortalLink { get { throw null; } } public Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties KeyVaultProperties { get { throw null; } set { } } public string ProvisioningState { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -178,7 +197,10 @@ public partial class HealthBotSku : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net8.0.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net8.0.cs index f82a3d4c4c42..d60dca0ba6b2 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net8.0.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.net8.0.cs @@ -29,7 +29,10 @@ public HealthBotData(Azure.Core.AzureLocation location, Azure.ResourceManager.He public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.Models.ResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -105,6 +108,7 @@ public static partial class ArmHealthBotModelFactory public static Azure.ResourceManager.HealthBot.HealthBotData HealthBotData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKey HealthBotKey(string keyName = null, string value = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult HealthBotKeysResult(System.Collections.Generic.IEnumerable secrets = null) { throw null; } + public static Azure.ResourceManager.HealthBot.Models.HealthBotPatch HealthBotPatch(Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null, System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState, System.Uri botManagementPortalLink, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState = null, System.Uri botManagementPortalLink = null, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties = null, string accessControlMethod = null) { throw null; } } @@ -113,7 +117,10 @@ public partial class HealthBotKey : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -124,7 +131,10 @@ public partial class HealthBotKeysResult : System.ClientModel.Primitives.IJsonMo { internal HealthBotKeysResult() { } public System.Collections.Generic.IReadOnlyList Secrets { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -138,7 +148,10 @@ public HealthBotKeyVaultProperties(string keyName, System.Uri keyVaultUri) { } public System.Uri KeyVaultUri { get { throw null; } set { } } public string KeyVersion { get { throw null; } set { } } public string UserIdentity { get { throw null; } set { } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -153,7 +166,10 @@ public HealthBotPatch() { } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -167,7 +183,10 @@ public HealthBotProperties() { } public System.Uri BotManagementPortalLink { get { throw null; } } public Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties KeyVaultProperties { get { throw null; } set { } } public string ProvisioningState { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -178,7 +197,10 @@ public partial class HealthBotSku : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.netstandard2.0.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.netstandard2.0.cs index f82a3d4c4c42..d60dca0ba6b2 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.netstandard2.0.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/api/Azure.ResourceManager.HealthBot.netstandard2.0.cs @@ -29,7 +29,10 @@ public HealthBotData(Azure.Core.AzureLocation location, Azure.ResourceManager.He public Azure.ResourceManager.Models.ManagedServiceIdentity Identity { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } + protected virtual Azure.ResourceManager.Models.ResourceData JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.Models.ResourceData PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.HealthBotData System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -105,6 +108,7 @@ public static partial class ArmHealthBotModelFactory public static Azure.ResourceManager.HealthBot.HealthBotData HealthBotData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType resourceType = default(Azure.Core.ResourceType), Azure.ResourceManager.Models.SystemData systemData = null, System.Collections.Generic.IDictionary tags = null, Azure.Core.AzureLocation location = default(Azure.Core.AzureLocation), Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKey HealthBotKey(string keyName = null, string value = null) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult HealthBotKeysResult(System.Collections.Generic.IEnumerable secrets = null) { throw null; } + public static Azure.ResourceManager.HealthBot.Models.HealthBotPatch HealthBotPatch(Azure.ResourceManager.HealthBot.Models.HealthBotProperties properties = null, System.Collections.Generic.IDictionary tags = null, Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? skuName = default(Azure.ResourceManager.HealthBot.Models.HealthBotSkuName?), Azure.ResourceManager.Models.ManagedServiceIdentity identity = null, Azure.Core.AzureLocation? location = default(Azure.Core.AzureLocation?)) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState, System.Uri botManagementPortalLink, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties) { throw null; } public static Azure.ResourceManager.HealthBot.Models.HealthBotProperties HealthBotProperties(string provisioningState = null, System.Uri botManagementPortalLink = null, Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties keyVaultProperties = null, string accessControlMethod = null) { throw null; } } @@ -113,7 +117,10 @@ public partial class HealthBotKey : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKey System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -124,7 +131,10 @@ public partial class HealthBotKeysResult : System.ClientModel.Primitives.IJsonMo { internal HealthBotKeysResult() { } public System.Collections.Generic.IReadOnlyList Secrets { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeysResult System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -138,7 +148,10 @@ public HealthBotKeyVaultProperties(string keyName, System.Uri keyVaultUri) { } public System.Uri KeyVaultUri { get { throw null; } set { } } public string KeyVersion { get { throw null; } set { } } public string UserIdentity { get { throw null; } set { } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -153,7 +166,10 @@ public HealthBotPatch() { } public Azure.ResourceManager.HealthBot.Models.HealthBotProperties Properties { get { throw null; } set { } } public Azure.ResourceManager.HealthBot.Models.HealthBotSkuName? SkuName { get { throw null; } set { } } public System.Collections.Generic.IDictionary Tags { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotPatch PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotPatch System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -167,7 +183,10 @@ public HealthBotProperties() { } public System.Uri BotManagementPortalLink { get { throw null; } } public Azure.ResourceManager.HealthBot.Models.HealthBotKeyVaultProperties KeyVaultProperties { get { throw null; } set { } } public string ProvisioningState { get { throw null; } } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties JsonModelCreateCore(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } + protected virtual Azure.ResourceManager.HealthBot.Models.HealthBotProperties PersistableModelCreateCore(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } + protected virtual System.BinaryData PersistableModelWriteCore(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotProperties System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } @@ -178,7 +197,10 @@ public partial class HealthBotSku : System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } void System.ClientModel.Primitives.IJsonModel.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { } Azure.ResourceManager.HealthBot.Models.HealthBotSku System.ClientModel.Primitives.IPersistableModel.Create(System.BinaryData data, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Azure.ResourceManager.HealthBot.csproj b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Azure.ResourceManager.HealthBot.csproj index e60d0d8662e8..b0626f72f5cf 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Azure.ResourceManager.HealthBot.csproj +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Azure.ResourceManager.HealthBot.csproj @@ -6,6 +6,5 @@ Azure.ResourceManager.HealthBot Microsoft Azure Resource Manager client SDK for Azure resource provider Microsoft.HealthBot. azure;management;arm;resource manager;healthbot - true diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/HealthBotData.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/HealthBotData.cs new file mode 100644 index 000000000000..44c5c20fe513 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/HealthBotData.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using Azure.Core; +using Azure.ResourceManager.HealthBot.Models; + +namespace Azure.ResourceManager.HealthBot +{ + // Add it back manually to ensure compatibility + public partial class HealthBotData + { + /// Initializes a new instance of . + /// The location. + /// SKU of the Azure Health Bot. + /// is null. + public HealthBotData(AzureLocation location, HealthBotSku sku) : base(location) + { + Argument.AssertNotNull(sku, nameof(sku)); + + Sku = sku; + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSku.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSku.cs new file mode 100644 index 000000000000..861d921c6d34 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSku.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +namespace Azure.ResourceManager.HealthBot.Models +{ + public partial class HealthBotSku + { } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSkuName.cs similarity index 94% rename from sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.cs rename to sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSkuName.cs index 828b3fed3c13..9880d8e963c2 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Custom/Models/HealthBotSkuName.cs @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - #nullable disable +using System.ComponentModel; + namespace Azure.ResourceManager.HealthBot.Models { /// The name of the Azure Health Bot SKU. diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ArmHealthBotModelFactory.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ArmHealthBotModelFactory.cs index ad18a8835635..f4f41680287e 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ArmHealthBotModelFactory.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ArmHealthBotModelFactory.cs @@ -9,14 +9,66 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using Azure; using Azure.Core; +using Azure.ResourceManager.HealthBot; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.HealthBot.Models { - /// Model factory for models. + /// A factory class for creating instances of the models for mocking. public static partial class ArmHealthBotModelFactory { + + /// The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. + /// The provisioning state of the Azure Health Bot resource. + /// The link. + /// KeyVault properties for the resource encryption. + /// The access control method for the Azure Health Bot resource. + /// A new instance for mocking. + public static HealthBotProperties HealthBotProperties(string provisioningState = default, Uri botManagementPortalLink = default, HealthBotKeyVaultProperties keyVaultProperties = default, string accessControlMethod = default) + { + return new HealthBotProperties(provisioningState, botManagementPortalLink, keyVaultProperties, accessControlMethod, additionalBinaryDataProperties: null); + } + + /// Properties of Azure Health Bot. + /// Tags for a Azure Health Bot. + /// The name of the Azure Health Bot SKU. + /// The identity of the Azure Health Bot. + /// + /// A new instance for mocking. + public static HealthBotPatch HealthBotPatch(HealthBotProperties properties = default, IDictionary tags = default, HealthBotSkuName? skuName = default, ManagedServiceIdentity identity = default, AzureLocation? location = default) + { + tags ??= new ChangeTrackingDictionary(); + + return new HealthBotPatch( + properties, + tags, + skuName is null ? default : new HealthBotSku(skuName.Value, null), + identity, + location, + additionalBinaryDataProperties: null); + } + + /// Health Bot Keys Response. + /// Array of Azure Health Bot Secrets. + /// A new instance for mocking. + public static HealthBotKeysResult HealthBotKeysResult(IEnumerable secrets = default) + { + secrets ??= new ChangeTrackingList(); + + return new HealthBotKeysResult(secrets.ToList(), additionalBinaryDataProperties: null); + } + + /// An entry of HealthBotKeysResponse. + /// The name of the key. + /// The value of the key. + /// A new instance for mocking. + public static HealthBotKey HealthBotKey(string keyName = default, string value = default) + { + return new HealthBotKey(keyName, value, additionalBinaryDataProperties: null); + } + /// Initializes a new instance of . /// The id. /// The name. @@ -28,62 +80,32 @@ public static partial class ArmHealthBotModelFactory /// The identity of the Azure Health Bot. /// The set of properties specific to Azure Health Bot resource. /// A new instance for mocking. - public static HealthBotData HealthBotData(ResourceIdentifier id = null, string name = null, ResourceType resourceType = default, SystemData systemData = null, IDictionary tags = null, AzureLocation location = default, HealthBotSkuName? skuName = null, ManagedServiceIdentity identity = null, HealthBotProperties properties = null) + public static HealthBotData HealthBotData(ResourceIdentifier id = default, string name = default, ResourceType resourceType = default, SystemData systemData = default, IDictionary tags = default, AzureLocation location = default, HealthBotSkuName? skuName = default, ManagedServiceIdentity identity = default, HealthBotProperties properties = default) { - tags ??= new Dictionary(); + tags ??= new ChangeTrackingDictionary(); return new HealthBotData( id, name, resourceType, systemData, + additionalBinaryDataProperties: null, tags, location, - skuName.HasValue ? new HealthBotSku(skuName.Value, serializedAdditionalRawData: null) : null, - identity, properties, - serializedAdditionalRawData: null); + default, + identity); } /// Initializes a new instance of . /// The provisioning state of the Azure Health Bot resource. /// The link. /// KeyVault properties for the resource encryption. - /// The access control method for the Azure Health Bot resource. /// A new instance for mocking. - public static HealthBotProperties HealthBotProperties(string provisioningState = null, Uri botManagementPortalLink = null, HealthBotKeyVaultProperties keyVaultProperties = null, string accessControlMethod = null) - { - return new HealthBotProperties(provisioningState, botManagementPortalLink, keyVaultProperties, accessControlMethod, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// Array of Azure Health Bot Secrets. - /// A new instance for mocking. - public static HealthBotKeysResult HealthBotKeysResult(IEnumerable secrets = null) - { - secrets ??= new List(); - - return new HealthBotKeysResult(secrets?.ToList(), serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The name of the key. - /// The value of the key. - /// A new instance for mocking. - public static HealthBotKey HealthBotKey(string keyName = null, string value = null) - { - return new HealthBotKey(keyName, value, serializedAdditionalRawData: null); - } - - /// Initializes a new instance of . - /// The provisioning state of the Azure Health Bot resource. - /// The link. - /// KeyVault properties for the resource encryption. - /// A new instance for mocking. [EditorBrowsable(EditorBrowsableState.Never)] public static HealthBotProperties HealthBotProperties(string provisioningState, Uri botManagementPortalLink, HealthBotKeyVaultProperties keyVaultProperties) { - return HealthBotProperties(provisioningState: provisioningState, botManagementPortalLink: botManagementPortalLink, keyVaultProperties: keyVaultProperties, accessControlMethod: default); + return HealthBotProperties(provisioningState, botManagementPortalLink, keyVaultProperties, accessControlMethod: default); } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllAsyncCollectionResultOfT.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..b9835a774dfe --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllAsyncCollectionResultOfT.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.HealthBot.Models; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class BotsGetAllAsyncCollectionResultOfT : AsyncPageable + { + private readonly Bots _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of BotsGetAllAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bots client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BotsGetAllAsyncCollectionResultOfT(Bots client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of BotsGetAllAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BotsGetAllAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + BotResponseList result = BotResponseList.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableHealthBotSubscriptionResource.GetHealthBots"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllCollectionResultOfT.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllCollectionResultOfT.cs new file mode 100644 index 000000000000..c97e7fc1494c --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetAllCollectionResultOfT.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.HealthBot.Models; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class BotsGetAllCollectionResultOfT : Pageable + { + private readonly Bots _client; + private readonly string _subscriptionId; + private readonly RequestContext _context; + + /// Initializes a new instance of BotsGetAllCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bots client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BotsGetAllCollectionResultOfT(Bots client, string subscriptionId, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _context = context; + } + + /// Gets the pages of BotsGetAllCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BotsGetAllCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + BotResponseList result = BotResponseList.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetAllRequest(nextLink, _subscriptionId, _context) : _client.CreateGetAllRequest(_subscriptionId, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("MockableHealthBotSubscriptionResource.GetHealthBots"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupAsyncCollectionResultOfT.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupAsyncCollectionResultOfT.cs new file mode 100644 index 000000000000..ebc0330b5368 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupAsyncCollectionResultOfT.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.HealthBot.Models; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class BotsGetByResourceGroupAsyncCollectionResultOfT : AsyncPageable + { + private readonly Bots _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of BotsGetByResourceGroupAsyncCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bots client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BotsGetByResourceGroupAsyncCollectionResultOfT(Bots client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of BotsGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BotsGetByResourceGroupAsyncCollectionResultOfT as an enumerable collection. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = await GetNextResponseAsync(pageSizeHint, nextPage).ConfigureAwait(false); + if (response is null) + { + yield break; + } + BotResponseList result = BotResponseList.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private async ValueTask GetNextResponseAsync(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("HealthBotCollection.GetAll"); + scope.Start(); + try + { + return await _client.Pipeline.ProcessMessageAsync(message, _context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupCollectionResultOfT.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupCollectionResultOfT.cs new file mode 100644 index 000000000000..8481000db77e --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/CollectionResults/BotsGetByResourceGroupCollectionResultOfT.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.ResourceManager.HealthBot.Models; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class BotsGetByResourceGroupCollectionResultOfT : Pageable + { + private readonly Bots _client; + private readonly string _subscriptionId; + private readonly string _resourceGroupName; + private readonly RequestContext _context; + + /// Initializes a new instance of BotsGetByResourceGroupCollectionResultOfT, which is used to iterate over the pages of a collection. + /// The Bots client used to send requests. + /// The ID of the target subscription. The value must be an UUID. + /// The name of the resource group. The name is case insensitive. + /// The request options, which can override default behaviors of the client pipeline on a per-call basis. + public BotsGetByResourceGroupCollectionResultOfT(Bots client, string subscriptionId, string resourceGroupName, RequestContext context) : base(context?.CancellationToken ?? default) + { + _client = client; + _subscriptionId = subscriptionId; + _resourceGroupName = resourceGroupName; + _context = context; + } + + /// Gets the pages of BotsGetByResourceGroupCollectionResultOfT as an enumerable collection. + /// A continuation token indicating where to resume paging. + /// The number of items per page. + /// The pages of BotsGetByResourceGroupCollectionResultOfT as an enumerable collection. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + Uri nextPage = continuationToken != null ? new Uri(continuationToken) : null; + while (true) + { + Response response = GetNextResponse(pageSizeHint, nextPage); + if (response is null) + { + yield break; + } + BotResponseList result = BotResponseList.FromResponse(response); + yield return Page.FromValues(result.Value, nextPage?.AbsoluteUri, response); + nextPage = result.NextLink; + if (nextPage == null) + { + yield break; + } + } + } + + /// Get next page. + /// The number of items per page. + /// The next link to use for the next page of results. + private Response GetNextResponse(int? pageSizeHint, Uri nextLink) + { + HttpMessage message = nextLink != null ? _client.CreateNextGetByResourceGroupRequest(nextLink, _subscriptionId, _resourceGroupName, _context) : _client.CreateGetByResourceGroupRequest(_subscriptionId, _resourceGroupName, _context); + using DiagnosticScope scope = _client.ClientDiagnostics.CreateScope("HealthBotCollection.GetAll"); + scope.Start(); + try + { + return _client.Pipeline.ProcessMessage(message, _context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/HealthBotExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/HealthBotExtensions.cs index 625df1ac0146..38d0423d7c31 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/HealthBotExtensions.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/HealthBotExtensions.cs @@ -8,7 +8,9 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.HealthBot.Mocking; using Azure.ResourceManager.Resources; @@ -17,30 +19,32 @@ namespace Azure.ResourceManager.HealthBot /// A class to add extension methods to Azure.ResourceManager.HealthBot. public static partial class HealthBotExtensions { + /// private static MockableHealthBotArmClient GetMockableHealthBotArmClient(ArmClient client) { - return client.GetCachedClient(client0 => new MockableHealthBotArmClient(client0)); + return client.GetCachedClient(client0 => new MockableHealthBotArmClient(client0, ResourceIdentifier.Root)); } - private static MockableHealthBotResourceGroupResource GetMockableHealthBotResourceGroupResource(ArmResource resource) + /// + private static MockableHealthBotResourceGroupResource GetMockableHealthBotResourceGroupResource(ResourceGroupResource resourceGroupResource) { - return resource.GetCachedClient(client => new MockableHealthBotResourceGroupResource(client, resource.Id)); + return resourceGroupResource.GetCachedClient(client => new MockableHealthBotResourceGroupResource(client, resourceGroupResource.Id)); } - private static MockableHealthBotSubscriptionResource GetMockableHealthBotSubscriptionResource(ArmResource resource) + /// + private static MockableHealthBotSubscriptionResource GetMockableHealthBotSubscriptionResource(SubscriptionResource subscriptionResource) { - return resource.GetCachedClient(client => new MockableHealthBotSubscriptionResource(client, resource.Id)); + return subscriptionResource.GetCachedClient(client => new MockableHealthBotSubscriptionResource(client, subscriptionResource.Id)); } /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The resource ID of the resource to get. /// is null. /// Returns a object. @@ -52,15 +56,15 @@ public static HealthBotResource GetHealthBotResource(this ArmClient client, Reso } /// - /// Gets a collection of HealthBotResources in the ResourceGroupResource. + /// Gets a collection of HealthBots in the /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// is null. - /// An object representing collection of HealthBotResources and their operations over a HealthBotResource. + /// An object representing collection of HealthBots and their operations over a HealthBotResource. public static HealthBotCollection GetHealthBots(this ResourceGroupResource resourceGroupResource) { Argument.AssertNotNull(resourceGroupResource, nameof(resourceGroupResource)); @@ -70,34 +74,15 @@ public static HealthBotCollection GetHealthBots(this ResourceGroupResource resou /// /// Get a HealthBot. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The name of the Bot resource. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static async Task> GetHealthBotAsync(this ResourceGroupResource resourceGroupResource, string botName, CancellationToken cancellationToken = default) { @@ -108,34 +93,15 @@ public static async Task> GetHealthBotAsync(this Res /// /// Get a HealthBot. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The name of the Bot resource. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. [ForwardsClientCalls] public static Response GetHealthBot(this ResourceGroupResource resourceGroupResource, string botName, CancellationToken cancellationToken = default) { @@ -146,33 +112,15 @@ public static Response GetHealthBot(this ResourceGroupResourc /// /// Returns all the resources of a particular type belonging to a subscription. - /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots - /// - /// - /// Operation Id - /// Bots_List - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The cancellation token to use. /// is null. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public static AsyncPageable GetHealthBotsAsync(this SubscriptionResource subscriptionResource, CancellationToken cancellationToken = default) { Argument.AssertNotNull(subscriptionResource, nameof(subscriptionResource)); @@ -182,30 +130,12 @@ public static AsyncPageable GetHealthBotsAsync(this Subscript /// /// Returns all the resources of a particular type belonging to a subscription. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots - /// - /// - /// Operation Id - /// Bots_List - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// /// - /// Mocking - /// To mock this method, please mock instead. + /// Mocking. + /// To mock this method, please mock instead. /// /// - /// The instance the method will execute against. + /// The the method will execute against. /// The cancellation token to use. /// is null. /// A collection of that may take multiple service requests to iterate over. diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotArmClient.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotArmClient.cs index 222fa5c4c19f..9e17d86aecf3 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotArmClient.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotArmClient.cs @@ -6,38 +6,27 @@ #nullable disable using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Mocking { - /// A class to add extension methods to ArmClient. + /// A class to add extension methods to . public partial class MockableHealthBotArmClient : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableHealthBotArmClient for mocking. protected MockableHealthBotArmClient() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableHealthBotArmClient(ArmClient client, ResourceIdentifier id) : base(client, id) { } - internal MockableHealthBotArmClient(ArmClient client) : this(client, ResourceIdentifier.Root) - { - } - - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// - /// Gets an object representing a along with the instance operations that can be performed on it but with no data. - /// You can use to create a from its components. - /// + /// Gets an object representing a along with the instance operations that can be performed on it but with no data. /// The resource ID of the resource to get. /// Returns a object. public virtual HealthBotResource GetHealthBotResource(ResourceIdentifier id) diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotResourceGroupResource.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotResourceGroupResource.cs index f0c31d13b304..8b666aef6479 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotResourceGroupResource.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotResourceGroupResource.cs @@ -8,33 +8,31 @@ using System; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; +using Azure.ResourceManager.HealthBot; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.HealthBot.Mocking { - /// A class to add extension methods to ResourceGroupResource. + /// A class to add extension methods to . public partial class MockableHealthBotResourceGroupResource : ArmResource { - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableHealthBotResourceGroupResource for mocking. protected MockableHealthBotResourceGroupResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableHealthBotResourceGroupResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } - - /// Gets a collection of HealthBotResources in the ResourceGroupResource. - /// An object representing collection of HealthBotResources and their operations over a HealthBotResource. + /// Gets a collection of HealthBots in the . + /// An object representing collection of HealthBots and their operations over a HealthBotResource. public virtual HealthBotCollection GetHealthBots() { return GetCachedClient(client => new HealthBotCollection(client, Id)); @@ -44,20 +42,16 @@ public virtual HealthBotCollection GetHealthBots() /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -68,6 +62,8 @@ public virtual HealthBotCollection GetHealthBots() [ForwardsClientCalls] public virtual async Task> GetHealthBotAsync(string botName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(botName, nameof(botName)); + return await GetHealthBots().GetAsync(botName, cancellationToken).ConfigureAwait(false); } @@ -75,20 +71,16 @@ public virtual async Task> GetHealthBotAsync(string /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -99,6 +91,8 @@ public virtual async Task> GetHealthBotAsync(string [ForwardsClientCalls] public virtual Response GetHealthBot(string botName, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(botName, nameof(botName)); + return GetHealthBots().Get(botName, cancellationToken); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotSubscriptionResource.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotSubscriptionResource.cs index 3017ee452fc6..eed61acc567f 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotSubscriptionResource.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Extensions/MockableHealthBotSubscriptionResource.cs @@ -6,87 +6,79 @@ #nullable disable using System.Threading; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; +using Azure.ResourceManager.HealthBot; +using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.HealthBot.Mocking { - /// A class to add extension methods to SubscriptionResource. + /// A class to add extension methods to . public partial class MockableHealthBotSubscriptionResource : ArmResource { - private ClientDiagnostics _healthBotBotsClientDiagnostics; - private BotsRestOperations _healthBotBotsRestClient; + private ClientDiagnostics _botsClientDiagnostics; + private Bots _botsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of MockableHealthBotSubscriptionResource for mocking. protected MockableHealthBotSubscriptionResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal MockableHealthBotSubscriptionResource(ArmClient client, ResourceIdentifier id) : base(client, id) { } - private ClientDiagnostics HealthBotBotsClientDiagnostics => _healthBotBotsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.HealthBot", HealthBotResource.ResourceType.Namespace, Diagnostics); - private BotsRestOperations HealthBotBotsRestClient => _healthBotBotsRestClient ??= new BotsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, GetApiVersionOrNull(HealthBotResource.ResourceType)); + private ClientDiagnostics BotsClientDiagnostics => _botsClientDiagnostics ??= new ClientDiagnostics("Azure.ResourceManager.HealthBot.Mocking", ProviderConstants.DefaultProviderNamespace, Diagnostics); - private string GetApiVersionOrNull(ResourceType resourceType) - { - TryGetApiVersion(resourceType, out string apiVersion); - return apiVersion; - } + private Bots BotsRestClient => _botsRestClient ??= new Bots(BotsClientDiagnostics, Pipeline, Endpoint, "2025-11-01"); /// /// Returns all the resources of a particular type belonging to a subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots - /// - /// - /// Operation Id - /// Bots_List + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetHealthBotsAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => HealthBotBotsRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => HealthBotBotsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new HealthBotResource(Client, HealthBotData.DeserializeHealthBotData(e)), HealthBotBotsClientDiagnostics, Pipeline, "MockableHealthBotSubscriptionResource.GetHealthBots", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new BotsGetAllAsyncCollectionResultOfT(BotsRestClient, Id.SubscriptionId, context), data => new HealthBotResource(Client, data)); } /// /// Returns all the resources of a particular type belonging to a subscription. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots - /// - /// - /// Operation Id - /// Bots_List + /// Request Path. + /// /subscriptions/{subscriptionId}/providers/Microsoft.HealthBot/healthBots. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_List. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -94,9 +86,11 @@ public virtual AsyncPageable GetHealthBotsAsync(CancellationT /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetHealthBots(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => HealthBotBotsRestClient.CreateListRequest(Id.SubscriptionId); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => HealthBotBotsRestClient.CreateListNextPageRequest(nextLink, Id.SubscriptionId); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new HealthBotResource(Client, HealthBotData.DeserializeHealthBotData(e)), HealthBotBotsClientDiagnostics, Pipeline, "MockableHealthBotSubscriptionResource.GetHealthBots", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new BotsGetAllCollectionResultOfT(BotsRestClient, Id.SubscriptionId, context), data => new HealthBotResource(Client, data)); } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotCollection.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotCollection.cs index a60c4ea71114..a3e66bbd0498 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotCollection.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotCollection.cs @@ -8,12 +8,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; -using Autorest.CSharp.Core; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.HealthBot @@ -25,51 +26,49 @@ namespace Azure.ResourceManager.HealthBot /// public partial class HealthBotCollection : ArmCollection, IEnumerable, IAsyncEnumerable { - private readonly ClientDiagnostics _healthBotBotsClientDiagnostics; - private readonly BotsRestOperations _healthBotBotsRestClient; + private readonly ClientDiagnostics _botsClientDiagnostics; + private readonly Bots _botsRestClient; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of HealthBotCollection for mocking. protected HealthBotCollection() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. - /// The identifier of the parent resource that is the target of operations. + /// The identifier of the resource that is the target of operations. internal HealthBotCollection(ArmClient client, ResourceIdentifier id) : base(client, id) { - _healthBotBotsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.HealthBot", HealthBotResource.ResourceType.Namespace, Diagnostics); - TryGetApiVersion(HealthBotResource.ResourceType, out string healthBotBotsApiVersion); - _healthBotBotsRestClient = new BotsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, healthBotBotsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(HealthBotResource.ResourceType, out string healthBotApiVersion); + _botsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.HealthBot", HealthBotResource.ResourceType.Namespace, Diagnostics); + _botsRestClient = new Bots(_botsClientDiagnostics, Pipeline, Endpoint, healthBotApiVersion ?? "2025-11-01"); + ValidateResourceId(id); } + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceGroupResource.ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceGroupResource.ResourceType), id); + } } /// /// Create a new Azure Health Bot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Create + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Create. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -77,21 +76,34 @@ internal static void ValidateResourceId(ResourceIdentifier id) /// The name of the Bot resource. /// The parameters to provide for the created Azure Health Bot. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> CreateOrUpdateAsync(WaitUntil waitUntil, string botName, HealthBotData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.CreateOrUpdate"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.CreateOrUpdate"); scope.Start(); try { - var response = await _healthBotBotsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, botName, data, cancellationToken).ConfigureAwait(false); - var operation = new HealthBotArmOperation(new HealthBotOperationSource(Client), _healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, HealthBotData.ToRequestContent(data), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + HealthBotArmOperation operation = new HealthBotArmOperation( + new HealthBotOperationSource(Client), + _botsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -105,20 +117,16 @@ public virtual async Task> CreateOrUpdateAsync(W /// Create a new Azure Health Bot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Create + /// Operation Id. + /// HealthBots_Create. /// /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -126,21 +134,34 @@ public virtual async Task> CreateOrUpdateAsync(W /// The name of the Bot resource. /// The parameters to provide for the created Azure Health Bot. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// or is null. + /// is an empty string, and was expected to be non-empty. public virtual ArmOperation CreateOrUpdate(WaitUntil waitUntil, string botName, HealthBotData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); Argument.AssertNotNull(data, nameof(data)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.CreateOrUpdate"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.CreateOrUpdate"); scope.Start(); try { - var response = _healthBotBotsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, botName, data, cancellationToken); - var operation = new HealthBotArmOperation(new HealthBotOperationSource(Client), _healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, HealthBotData.ToRequestContent(data), context); + Response response = Pipeline.ProcessMessage(message, context); + HealthBotArmOperation operation = new HealthBotArmOperation( + new HealthBotOperationSource(Client), + _botsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) + { operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -154,38 +175,42 @@ public virtual ArmOperation CreateOrUpdate(WaitUntil waitUnti /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Get + /// Operation Id. + /// HealthBots_Get. /// /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetAsync(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.Get"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.Get"); scope.Start(); try { - var response = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -199,38 +224,42 @@ public virtual async Task> GetAsync(string botName, /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Get(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.Get"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.Get"); scope.Start(); try { - var response = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -244,50 +273,44 @@ public virtual Response Get(string botName, CancellationToken /// Returns all the resources of a particular type belonging to a resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots. /// /// - /// Operation Id - /// Bots_ListByResourceGroup + /// Operation Id. + /// HealthBots_ListByResourceGroup. /// /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The cancellation token to use. - /// An async collection of that may take multiple service requests to iterate over. + /// A collection of that may take multiple service requests to iterate over. public virtual AsyncPageable GetAllAsync(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _healthBotBotsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _healthBotBotsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => new HealthBotResource(Client, HealthBotData.DeserializeHealthBotData(e)), _healthBotBotsClientDiagnostics, Pipeline, "HealthBotCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new AsyncPageableWrapper(new BotsGetByResourceGroupAsyncCollectionResultOfT(_botsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new HealthBotResource(Client, data)); } /// /// Returns all the resources of a particular type belonging to a resource group /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots - /// - /// - /// Operation Id - /// Bots_ListByResourceGroup + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_ListByResourceGroup. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// @@ -295,45 +318,61 @@ public virtual AsyncPageable GetAllAsync(CancellationToken ca /// A collection of that may take multiple service requests to iterate over. public virtual Pageable GetAll(CancellationToken cancellationToken = default) { - HttpMessage FirstPageRequest(int? pageSizeHint) => _healthBotBotsRestClient.CreateListByResourceGroupRequest(Id.SubscriptionId, Id.ResourceGroupName); - HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => _healthBotBotsRestClient.CreateListByResourceGroupNextPageRequest(nextLink, Id.SubscriptionId, Id.ResourceGroupName); - return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => new HealthBotResource(Client, HealthBotData.DeserializeHealthBotData(e)), _healthBotBotsClientDiagnostics, Pipeline, "HealthBotCollection.GetAll", "value", "nextLink", cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + return new PageableWrapper(new BotsGetByResourceGroupCollectionResultOfT(_botsRestClient, Id.SubscriptionId, Id.ResourceGroupName, context), data => new HealthBotResource(Client, data)); } /// /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> ExistsAsync(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.Exists"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.Exists"); scope.Start(); try { - var response = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(HealthBotData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((HealthBotData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -347,36 +386,50 @@ public virtual async Task> ExistsAsync(string botName, Cancellati /// Checks to see if the resource exists in azure. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Get + /// Operation Id. + /// HealthBots_Get. /// /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual Response Exists(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.Exists"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.Exists"); scope.Start(); try { - var response = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(HealthBotData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((HealthBotData)null, result); + break; + default: + throw new RequestFailedException(result); + } return Response.FromValue(response.Value != null, response.GetRawResponse()); } catch (Exception e) @@ -390,38 +443,54 @@ public virtual Response Exists(string botName, CancellationToken cancellat /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Default Api Version - /// 2025-05-25 + /// Operation Id. + /// HealthBots_Get. /// /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual async Task> GetIfExistsAsync(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.GetIfExists"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.GetIfExists"); scope.Start(); try { - var response = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken: cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + await Pipeline.SendAsync(message, context.CancellationToken).ConfigureAwait(false); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(HealthBotData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((HealthBotData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -435,38 +504,54 @@ public virtual async Task> GetIfExistsAsync( /// Tries to get details for this resource from the service. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Get + /// Operation Id. + /// HealthBots_Get. /// /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// + /// Default Api Version. + /// 2025-11-01. /// /// /// /// The name of the Bot resource. /// The cancellation token to use. - /// is an empty string, and was expected to be non-empty. /// is null. + /// is an empty string, and was expected to be non-empty. public virtual NullableResponse GetIfExists(string botName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotCollection.GetIfExists"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotCollection.GetIfExists"); scope.Start(); try { - var response = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, botName, cancellationToken: cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, botName, context); + Pipeline.Send(message, context.CancellationToken); + Response result = message.Response; + Response response = default; + switch (result.Status) + { + case 200: + response = Response.FromValue(HealthBotData.FromResponse(result), result); + break; + case 404: + response = Response.FromValue((HealthBotData)null, result); + break; + default: + throw new RequestFailedException(result); + } if (response.Value == null) + { return new NoValueResponse(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -486,6 +571,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetAll().GetEnumerator(); } + /// The cancellation token to use. IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(CancellationToken cancellationToken) { return GetAllAsync(cancellationToken: cancellationToken).GetAsyncEnumerator(cancellationToken); diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.Serialization.cs index 420a9e93e6e2..1f0372c0c373 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.Serialization.cs @@ -10,16 +10,23 @@ using System.Collections.Generic; using System.Text; using System.Text.Json; +using Azure; using Azure.Core; using Azure.ResourceManager.HealthBot.Models; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.HealthBot { - public partial class HealthBotData : IUtf8JsonSerializable, IJsonModel + /// Azure Health Bot resource definition. + public partial class HealthBotData : TrackedResourceData, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HealthBotData() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -31,13 +38,17 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotData)} does not support writing '{format}' format."); } - base.JsonModelWriteCore(writer, options); + if (Optional.IsDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteObjectValue(Properties, options); + } writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); if (Optional.IsDefined(Identity)) @@ -45,135 +56,151 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WritePropertyName("identity"u8); ((IJsonModel)Identity).Write(writer, options); } - if (Optional.IsDefined(Properties)) - { - writer.WritePropertyName("properties"u8); - writer.WriteObjectValue(Properties, options); - } } - HealthBotData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => (HealthBotData)JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual ResourceData JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotData)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotData(document.RootElement, options); } - internal static HealthBotData DeserializeHealthBotData(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotData DeserializeHealthBotData(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - HealthBotSku sku = default; - ManagedServiceIdentity identity = default; - HealthBotProperties properties = default; - IDictionary tags = default; - AzureLocation location = default; ResourceIdentifier id = default; string name = default; - ResourceType type = default; + ResourceType resourceType = default; SystemData systemData = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + IDictionary tags = default; + AzureLocation location = default; + HealthBotProperties properties = default; + HealthBotSku sku = default; + ManagedServiceIdentity identity = default; + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("sku"u8)) + if (prop.NameEquals("id"u8)) { - sku = HealthBotSku.DeserializeHealthBotSku(property.Value, options); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + id = new ResourceIdentifier(prop.Value.GetString()); + continue; + } + if (prop.NameEquals("name"u8)) + { + name = prop.Value.GetString(); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("type"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerHealthBotContext.Default); + resourceType = new ResourceType(prop.Value.GetString()); continue; } - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("systemData"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = HealthBotProperties.DeserializeHealthBotProperties(property.Value, options); + systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerHealthBotContext.Default); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } tags = dictionary; continue; } - if (property.NameEquals("location"u8)) - { - location = new AzureLocation(property.Value.GetString()); - continue; - } - if (property.NameEquals("id"u8)) + if (prop.NameEquals("location"u8)) { - id = new ResourceIdentifier(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } - if (property.NameEquals("name"u8)) + if (prop.NameEquals("properties"u8)) { - name = property.Value.GetString(); + if (prop.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + properties = HealthBotProperties.DeserializeHealthBotProperties(prop.Value, options); continue; } - if (property.NameEquals("type"u8)) + if (prop.NameEquals("sku"u8)) { - type = new ResourceType(property.Value.GetString()); + sku = HealthBotSku.DeserializeHealthBotSku(prop.Value, options); continue; } - if (property.NameEquals("systemData"u8)) + if (prop.NameEquals("identity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - systemData = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerHealthBotContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerHealthBotContext.Default); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new HealthBotData( id, name, - type, + resourceType, systemData, + additionalBinaryDataProperties, tags ?? new ChangeTrackingDictionary(), location, - sku, - identity, properties, - serializedAdditionalRawData); + sku, + identity); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -183,15 +210,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions optio } } - HealthBotData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => (HealthBotData)PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual ResourceData PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotData(document.RootElement, options); } default: @@ -199,6 +231,26 @@ HealthBotData IPersistableModel.Create(BinaryData data, ModelRead } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(HealthBotData healthBotData) + { + if (healthBotData == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(healthBotData, ModelSerializationExtensions.WireOptions); + return content; + } + + /// The to deserialize the from. + internal static HealthBotData FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHealthBotData(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.cs index 2705a2dcca0f..e093aae50499 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotData.cs @@ -13,94 +13,51 @@ namespace Azure.ResourceManager.HealthBot { - /// - /// A class representing the HealthBot data model. - /// Azure Health Bot resource definition - /// + /// Azure Health Bot resource definition. public partial class HealthBotData : TrackedResourceData { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . - /// The location. - /// SKU of the Azure Health Bot. - /// is null. - public HealthBotData(AzureLocation location, HealthBotSku sku) : base(location) - { - Argument.AssertNotNull(sku, nameof(sku)); - - Sku = sku; - } - - /// Initializes a new instance of . - /// The id. - /// The name. - /// The resourceType. - /// The systemData. - /// The tags. - /// The location. + /// Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + /// The name of the resource. + /// The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". + /// Azure Resource Manager metadata containing createdBy and modifiedBy information. + /// Keeps track of any properties unknown to the library. + /// Resource tags. + /// The geo-location where the resource lives. + /// The set of properties specific to Azure Health Bot resource. /// SKU of the Azure Health Bot. /// The identity of the Azure Health Bot. - /// The set of properties specific to Azure Health Bot resource. - /// Keeps track of any properties unknown to the library. - internal HealthBotData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary tags, AzureLocation location, HealthBotSku sku, ManagedServiceIdentity identity, HealthBotProperties properties, IDictionary serializedAdditionalRawData) : base(id, name, resourceType, systemData, tags, location) + internal HealthBotData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary additionalBinaryDataProperties, IDictionary tags, AzureLocation location, HealthBotProperties properties, HealthBotSku sku, ManagedServiceIdentity identity) : base(id, name, resourceType, systemData, tags, location) { + _additionalBinaryDataProperties = additionalBinaryDataProperties; + Properties = properties; Sku = sku; Identity = identity; - Properties = properties; - _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal HealthBotData() - { - } + /// The set of properties specific to Azure Health Bot resource. + public HealthBotProperties Properties { get; set; } /// SKU of the Azure Health Bot. internal HealthBotSku Sku { get; set; } + + /// The identity of the Azure Health Bot. + public ManagedServiceIdentity Identity { get; set; } + /// The name of the Azure Health Bot SKU. public HealthBotSkuName? SkuName { - get => Sku is null ? default(HealthBotSkuName?) : Sku.Name; + get + { + return Sku is null ? default : Sku.Name; + } set { - Sku = value.HasValue ? new HealthBotSku(value.Value) : null; + Sku = value.HasValue ? new HealthBotSku(value.Value) : default; } } - - /// The identity of the Azure Health Bot. - public ManagedServiceIdentity Identity { get; set; } - /// The set of properties specific to Azure Health Bot resource. - public HealthBotProperties Properties { get; set; } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.Serialization.cs index c5a6fb6bcde4..af99757f1bdb 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.Serialization.cs @@ -8,22 +8,33 @@ using System; using System.ClientModel.Primitives; using System.Text.Json; +using Azure.ResourceManager; namespace Azure.ResourceManager.HealthBot { - public partial class HealthBotResource : IJsonModel + /// + public partial class HealthBotResource : ArmResource, IJsonModel { - private static HealthBotData s_dataDeserializationInstance; - private static HealthBotData DataDeserializationInstance => s_dataDeserializationInstance ??= new(); + private static IJsonModel s_dataDeserializationInstance; + private static IJsonModel DataDeserializationInstance => s_dataDeserializationInstance ??= new HealthBotData(); + + /// The writer to serialize the model to. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => ((IJsonModel)Data).Write(writer, options); - HealthBotData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => ((IJsonModel)DataDeserializationInstance).Create(ref reader, options); + /// The reader for deserializing the model. + /// The client options for reading and writing models. + HealthBotData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => DataDeserializationInstance.Create(ref reader, options); + /// The client options for reading and writing models. BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => ModelReaderWriter.Write(Data, options, AzureResourceManagerHealthBotContext.Default); + /// The binary data to be processed. + /// The client options for reading and writing models. HealthBotData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => ModelReaderWriter.Read(data, options, AzureResourceManagerHealthBotContext.Default); - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => ((IPersistableModel)DataDeserializationInstance).GetFormatFromOptions(options); + /// The client options for reading and writing models. + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => DataDeserializationInstance.GetFormatFromOptions(options); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.cs index 1510b80d6d30..a3c2b4e4052d 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/HealthBotResource.cs @@ -7,47 +7,37 @@ using System; using System.Collections.Generic; -using System.Globalization; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; using Azure.ResourceManager.HealthBot.Models; using Azure.ResourceManager.Resources; namespace Azure.ResourceManager.HealthBot { /// - /// A Class representing a HealthBot along with the instance operations that can be performed on it. - /// If you have a you can construct a - /// from an instance of using the GetHealthBotResource method. - /// Otherwise you can get one from its parent resource using the GetHealthBot method. + /// A class representing a HealthBot along with the instance operations that can be performed on it. + /// If you have a you can construct a from an instance of using the GetResource method. + /// Otherwise you can get one from its parent resource using the GetHealthBots method. /// public partial class HealthBotResource : ArmResource { - /// Generate the resource identifier of a instance. - /// The subscriptionId. - /// The resourceGroupName. - /// The botName. - public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string botName) - { - var resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"; - return new ResourceIdentifier(resourceId); - } - - private readonly ClientDiagnostics _healthBotBotsClientDiagnostics; - private readonly BotsRestOperations _healthBotBotsRestClient; + private readonly ClientDiagnostics _botsClientDiagnostics; + private readonly Bots _botsRestClient; private readonly HealthBotData _data; - /// Gets the resource type for the operations. public static readonly ResourceType ResourceType = "Microsoft.HealthBot/healthBots"; - /// Initializes a new instance of the class for mocking. + /// Initializes a new instance of HealthBotResource for mocking. protected HealthBotResource() { } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The resource that is the target of operations. internal HealthBotResource(ArmClient client, HealthBotData data) : this(client, data.Id) @@ -56,71 +46,92 @@ internal HealthBotResource(ArmClient client, HealthBotData data) : this(client, _data = data; } - /// Initializes a new instance of the class. + /// Initializes a new instance of class. /// The client parameters to use in these operations. /// The identifier of the resource that is the target of operations. internal HealthBotResource(ArmClient client, ResourceIdentifier id) : base(client, id) { - _healthBotBotsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.HealthBot", ResourceType.Namespace, Diagnostics); - TryGetApiVersion(ResourceType, out string healthBotBotsApiVersion); - _healthBotBotsRestClient = new BotsRestOperations(Pipeline, Diagnostics.ApplicationId, Endpoint, healthBotBotsApiVersion); -#if DEBUG - ValidateResourceId(Id); -#endif + TryGetApiVersion(ResourceType, out string healthBotApiVersion); + _botsClientDiagnostics = new ClientDiagnostics("Azure.ResourceManager.HealthBot", ResourceType.Namespace, Diagnostics); + _botsRestClient = new Bots(_botsClientDiagnostics, Pipeline, Endpoint, healthBotApiVersion ?? "2025-11-01"); + ValidateResourceId(id); } /// Gets whether or not the current instance has data. public virtual bool HasData { get; } /// Gets the data representing this Feature. - /// Throws if there is no data loaded in the current instance. public virtual HealthBotData Data { get { if (!HasData) + { throw new InvalidOperationException("The current instance does not have data, you must call Get first."); + } return _data; } } + /// Generate the resource identifier for this resource. + /// The subscriptionId. + /// The resourceGroupName. + /// The botName. + public static ResourceIdentifier CreateResourceIdentifier(string subscriptionId, string resourceGroupName, string botName) + { + string resourceId = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}"; + return new ResourceIdentifier(resourceId); + } + + /// + [Conditional("DEBUG")] internal static void ValidateResourceId(ResourceIdentifier id) { if (id.ResourceType != ResourceType) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), nameof(id)); + { + throw new ArgumentException(string.Format("Invalid resource type {0} expected {1}", id.ResourceType, ResourceType), id); + } } /// /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Get + /// Operation Id. + /// HealthBots_Get. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetAsync(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Get"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Get"); scope.Start(); try { - var response = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -134,33 +145,41 @@ public virtual async Task> GetAsync(CancellationToke /// Get a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Get + /// Operation Id. + /// HealthBots_Get. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response Get(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Get"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Get"); scope.Start(); try { - var response = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); if (response.Value == null) + { throw new RequestFailedException(response.GetRawResponse()); + } return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } catch (Exception e) @@ -171,38 +190,55 @@ public virtual Response Get(CancellationToken cancellationTok } /// - /// Delete a HealthBot. + /// Patch a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Delete + /// Operation Id. + /// HealthBots_Update. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters to provide for the required Azure Health Bot. /// The cancellation token to use. - public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> UpdateAsync(WaitUntil waitUntil, HealthBotPatch patch, CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Update"); scope.Start(); try { - var response = await _healthBotBotsRestClient.DeleteAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - var operation = new HealthBotArmOperation(_healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, HealthBotPatch.ToRequestContent(patch), context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + HealthBotArmOperation operation = new HealthBotArmOperation( + new HealthBotOperationSource(Client), + _botsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -213,38 +249,55 @@ public virtual async Task DeleteAsync(WaitUntil waitUntil, Cancell } /// - /// Delete a HealthBot. + /// Patch a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Delete + /// Operation Id. + /// HealthBots_Update. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. + /// The parameters to provide for the required Azure Health Bot. /// The cancellation token to use. - public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) + /// is null. + public virtual ArmOperation Update(WaitUntil waitUntil, HealthBotPatch patch, CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Delete"); + Argument.AssertNotNull(patch, nameof(patch)); + + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Update"); scope.Start(); try { - var response = _healthBotBotsRestClient.Delete(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - var operation = new HealthBotArmOperation(_healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, HealthBotPatch.ToRequestContent(patch), context); + Response response = Pipeline.ProcessMessage(message, context); + HealthBotArmOperation operation = new HealthBotArmOperation( + new HealthBotOperationSource(Client), + _botsClientDiagnostics, + Pipeline, + message.Request, + response, + OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletionResponse(cancellationToken); + { + operation.WaitForCompletion(cancellationToken); + } return operation; } catch (Exception e) @@ -255,42 +308,45 @@ public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancel } /// - /// Patch a HealthBot. + /// Delete a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Update + /// Operation Id. + /// HealthBots_Delete. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters to provide for the required Azure Health Bot. /// The cancellation token to use. - /// is null. - public virtual async Task> UpdateAsync(WaitUntil waitUntil, HealthBotPatch patch, CancellationToken cancellationToken = default) + public virtual async Task DeleteAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Update"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Delete"); scope.Start(); try { - var response = await _healthBotBotsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken).ConfigureAwait(false); - var operation = new HealthBotArmOperation(new HealthBotOperationSource(Client), _healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + HealthBotArmOperation operation = new HealthBotArmOperation(_botsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); + { + await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); + } return operation; } catch (Exception e) @@ -301,42 +357,45 @@ public virtual async Task> UpdateAsync(WaitUntil } /// - /// Patch a HealthBot. + /// Delete a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}. /// /// - /// Operation Id - /// Bots_Update + /// Operation Id. + /// HealthBots_Delete. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// if the method should wait to return until the long-running operation has completed on the service; if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples. - /// The parameters to provide for the required Azure Health Bot. /// The cancellation token to use. - /// is null. - public virtual ArmOperation Update(WaitUntil waitUntil, HealthBotPatch patch, CancellationToken cancellationToken = default) + public virtual ArmOperation Delete(WaitUntil waitUntil, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(patch, nameof(patch)); - - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.Update"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.Delete"); scope.Start(); try { - var response = _healthBotBotsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken); - var operation = new HealthBotArmOperation(new HealthBotOperationSource(Client), _healthBotBotsClientDiagnostics, Pipeline, _healthBotBotsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.Location); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateDeleteRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response response = Pipeline.ProcessMessage(message, context); + HealthBotArmOperation operation = new HealthBotArmOperation(_botsClientDiagnostics, Pipeline, message.Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) - operation.WaitForCompletion(cancellationToken); + { + operation.WaitForCompletionResponse(cancellationToken); + } return operation; } catch (Exception e) @@ -350,31 +409,41 @@ public virtual ArmOperation Update(WaitUntil waitUntil, Healt /// List all secrets of a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets. /// /// - /// Operation Id - /// Bots_ListSecrets + /// Operation Id. + /// HealthBots_ListSecrets. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> GetSecretsAsync(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.GetSecrets"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.GetSecrets"); scope.Start(); try { - var response = await _healthBotBotsRestClient.ListSecretsAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetSecretsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotKeysResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -388,31 +457,41 @@ public virtual async Task> GetSecretsAsync(Cancell /// List all secrets of a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/listSecrets. /// /// - /// Operation Id - /// Bots_ListSecrets + /// Operation Id. + /// HealthBots_ListSecrets. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response GetSecrets(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.GetSecrets"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.GetSecrets"); scope.Start(); try { - var response = _healthBotBotsRestClient.ListSecrets(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetSecretsRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotKeysResult.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -426,31 +505,41 @@ public virtual Response GetSecrets(CancellationToken cancel /// Regenerate the API JWT Secret of a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret. /// /// - /// Operation Id - /// Bots_RegenerateApiJwtSecret + /// Operation Id. + /// HealthBots_RegenerateApiJwtSecret. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual async Task> RegenerateApiJwtSecretAsync(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.RegenerateApiJwtSecret"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.RegenerateApiJwtSecret"); scope.Start(); try { - var response = await _healthBotBotsRestClient.RegenerateApiJwtSecretAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateRegenerateApiJwtSecretRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotKey.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -464,31 +553,41 @@ public virtual async Task> RegenerateApiJwtSecretAsync(Ca /// Regenerate the API JWT Secret of a HealthBot. /// /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret + /// Request Path. + /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName}/regenerateApiJwtSecret. /// /// - /// Operation Id - /// Bots_RegenerateApiJwtSecret + /// Operation Id. + /// HealthBots_RegenerateApiJwtSecret. /// /// - /// Default Api Version - /// 2025-05-25 + /// Default Api Version. + /// 2025-11-01. /// /// - /// Resource - /// + /// Resource. + /// . /// /// /// /// The cancellation token to use. public virtual Response RegenerateApiJwtSecret(CancellationToken cancellationToken = default) { - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.RegenerateApiJwtSecret"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.RegenerateApiJwtSecret"); scope.Start(); try { - var response = _healthBotBotsRestClient.RegenerateApiJwtSecret(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateRegenerateApiJwtSecretRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotKey.FromResponse(result), result); + if (response.Value == null) + { + throw new RequestFailedException(response.GetRawResponse()); + } return response; } catch (Exception e) @@ -498,27 +597,7 @@ public virtual Response RegenerateApiJwtSecret(CancellationToken c } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -528,28 +607,34 @@ public virtual async Task> AddTagAsync(string key, s Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.AddTag"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.AddTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues[key] = value; - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new HealthBotPatch(); - foreach (var tag in current.Tags) + HealthBotData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -560,27 +645,7 @@ public virtual async Task> AddTagAsync(string key, s } } - /// - /// Add a tag to the current resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// + /// Add a tag to the current resource. /// The key for the tag. /// The value for the tag. /// The cancellation token to use. @@ -590,28 +655,34 @@ public virtual Response AddTag(string key, string value, Canc Argument.AssertNotNull(key, nameof(key)); Argument.AssertNotNull(value, nameof(value)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.AddTag"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.AddTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues[key] = value; - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new HealthBotPatch(); - foreach (var tag in current.Tags) + HealthBotData current = Get(cancellationToken: cancellationToken).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags[key] = value; - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -622,53 +693,39 @@ public virtual Response AddTag(string key, string value, Canc } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual async Task> SetTagsAsync(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.SetTags"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.SetTags"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + await GetTagResource().DeleteAsync(WaitUntil.Completed, cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.ReplaceWith(tags); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new HealthBotPatch(); + HealthBotData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); patch.Tags.ReplaceWith(tags); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -679,53 +736,39 @@ public virtual async Task> SetTagsAsync(IDictionary< } } - /// - /// Replace the tags on the resource with the given set. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// - /// The set of tags to use as replacement. + /// Replace the tags on the resource with the given set. + /// The tags to set on the resource. /// The cancellation token to use. /// is null. public virtual Response SetTags(IDictionary tags, CancellationToken cancellationToken = default) { Argument.AssertNotNull(tags, nameof(tags)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.SetTags"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.SetTags"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - GetTagResource().Delete(WaitUntil.Completed, cancellationToken: cancellationToken); - var originalTags = GetTagResource().Get(cancellationToken); + GetTagResource().Delete(WaitUntil.Completed, cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.ReplaceWith(tags); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new HealthBotPatch(); + HealthBotData current = Get(cancellationToken: cancellationToken).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); patch.Tags.ReplaceWith(tags); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -736,27 +779,7 @@ public virtual Response SetTags(IDictionary t } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -764,28 +787,34 @@ public virtual async Task> RemoveTagAsync(string key { Argument.AssertNotNull(key, nameof(key)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.RemoveTag"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.RemoveTag"); scope.Start(); try { - if (await CanUseTagResourceAsync(cancellationToken: cancellationToken).ConfigureAwait(false)) + if (await CanUseTagResourceAsync(cancellationToken).ConfigureAwait(false)) { - var originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); + Response originalTags = await GetTagResource().GetAsync(cancellationToken).ConfigureAwait(false); originalTags.Value.Data.TagValues.Remove(key); - await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken).ConfigureAwait(false); - var originalResponse = await _healthBotBotsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + await GetTagResource().CreateOrUpdateAsync(WaitUntil.Completed, originalTags.Value.Data, cancellationToken).ConfigureAwait(false); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = await Pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; - var patch = new HealthBotPatch(); - foreach (var tag in current.Tags) + HealthBotData current = (await GetAsync(cancellationToken: cancellationToken).ConfigureAwait(false)).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); + ArmOperation result = await UpdateAsync(WaitUntil.Completed, patch, cancellationToken: cancellationToken).ConfigureAwait(false); return Response.FromValue(result.Value, result.GetRawResponse()); } } @@ -796,27 +825,7 @@ public virtual async Task> RemoveTagAsync(string key } } - /// - /// Removes a tag by key from the resource. - /// - /// - /// Request Path - /// /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HealthBot/healthBots/{botName} - /// - /// - /// Operation Id - /// Bots_Get - /// - /// - /// Default Api Version - /// 2025-05-25 - /// - /// - /// Resource - /// - /// - /// - /// + /// Removes a tag by key from the resource. /// The key for the tag. /// The cancellation token to use. /// is null. @@ -824,28 +833,34 @@ public virtual Response RemoveTag(string key, CancellationTok { Argument.AssertNotNull(key, nameof(key)); - using var scope = _healthBotBotsClientDiagnostics.CreateScope("HealthBotResource.RemoveTag"); + using DiagnosticScope scope = _botsClientDiagnostics.CreateScope("HealthBotResource.RemoveTag"); scope.Start(); try { - if (CanUseTagResource(cancellationToken: cancellationToken)) + if (CanUseTagResource(cancellationToken)) { - var originalTags = GetTagResource().Get(cancellationToken); + Response originalTags = GetTagResource().Get(cancellationToken); originalTags.Value.Data.TagValues.Remove(key); - GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken: cancellationToken); - var originalResponse = _healthBotBotsRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); - return Response.FromValue(new HealthBotResource(Client, originalResponse.Value), originalResponse.GetRawResponse()); + GetTagResource().CreateOrUpdate(WaitUntil.Completed, originalTags.Value.Data, cancellationToken); + RequestContext context = new RequestContext + { + CancellationToken = cancellationToken + }; + HttpMessage message = _botsRestClient.CreateGetRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, context); + Response result = Pipeline.ProcessMessage(message, context); + Response response = Response.FromValue(HealthBotData.FromResponse(result), result); + return Response.FromValue(new HealthBotResource(Client, response.Value), response.GetRawResponse()); } else { - var current = Get(cancellationToken: cancellationToken).Value.Data; - var patch = new HealthBotPatch(); - foreach (var tag in current.Tags) + HealthBotData current = Get(cancellationToken: cancellationToken).Value.Data; + HealthBotPatch patch = new HealthBotPatch(); + foreach (KeyValuePair tag in current.Tags) { patch.Tags.Add(tag); } patch.Tags.Remove(key); - var result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); + ArmOperation result = Update(WaitUntil.Completed, patch, cancellationToken: cancellationToken); return Response.FromValue(result.Value, result.GetRawResponse()); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Argument.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Argument.cs index 00f0724e2198..66011f646148 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Argument.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Argument.cs @@ -11,8 +11,10 @@ namespace Azure.ResourceManager.HealthBot { - internal static class Argument + internal static partial class Argument { + /// The value. + /// The name. public static void AssertNotNull(T value, string name) { if (value is null) @@ -21,8 +23,10 @@ public static void AssertNotNull(T value, string name) } } + /// The value. + /// The name. public static void AssertNotNull(T? value, string name) - where T : struct + where T : struct { if (!value.HasValue) { @@ -30,6 +34,8 @@ public static void AssertNotNull(T? value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(IEnumerable value, string name) { if (value is null) @@ -51,6 +57,8 @@ public static void AssertNotNullOrEmpty(IEnumerable value, string name) } } + /// The value. + /// The name. public static void AssertNotNullOrEmpty(string value, string name) { if (value is null) @@ -62,68 +70,5 @@ public static void AssertNotNullOrEmpty(string value, string name) throw new ArgumentException("Value cannot be an empty string.", name); } } - - public static void AssertNotNullOrWhiteSpace(string value, string name) - { - if (value is null) - { - throw new ArgumentNullException(name); - } - if (string.IsNullOrWhiteSpace(value)) - { - throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); - } - } - - public static void AssertNotDefault(ref T value, string name) - where T : struct, IEquatable - { - if (value.Equals(default)) - { - throw new ArgumentException("Value cannot be empty.", name); - } - } - - public static void AssertInRange(T value, T minimum, T maximum, string name) - where T : notnull, IComparable - { - if (minimum.CompareTo(value) > 0) - { - throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); - } - if (maximum.CompareTo(value) < 0) - { - throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); - } - } - - public static void AssertEnumDefined(Type enumType, object value, string name) - { - if (!Enum.IsDefined(enumType, value)) - { - throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); - } - } - - public static T CheckNotNull(T value, string name) - where T : class - { - AssertNotNull(value, name); - return value; - } - - public static string CheckNotNullOrEmpty(string value, string name) - { - AssertNotNullOrEmpty(value, name); - return value; - } - - public static void AssertNull(T value, string name, string message = null) - { - if (value != null) - { - throw new ArgumentException(message ?? "Value must be null.", name); - } - } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/AsyncPageableWrapper.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/AsyncPageableWrapper.cs new file mode 100644 index 000000000000..232adbaf6009 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/AsyncPageableWrapper.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class AsyncPageableWrapper : AsyncPageable + { + /// The source async pageable value of type AsyncPageable<T>. + private AsyncPageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the AsyncPageableWrapper class. + /// The source async pageable value of type AsyncPageable<T>. + /// The converter function from T to U. + public AsyncPageableWrapper(AsyncPageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from AsyncPageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override async IAsyncEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + await foreach (Page page in _source.AsPages(continuationToken, pageSizeHint).ConfigureAwait(false)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingDictionary.cs index eb27976288b0..72e940cc0b19 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingDictionary.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -11,7 +11,8 @@ namespace Azure.ResourceManager.HealthBot { - internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + internal partial class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary + where TKey : notnull { private IDictionary _innerDictionary; @@ -19,6 +20,7 @@ public ChangeTrackingDictionary() { } + /// The inner dictionary. public ChangeTrackingDictionary(IDictionary dictionary) { if (dictionary == null) @@ -28,6 +30,7 @@ public ChangeTrackingDictionary(IDictionary dictionary) _innerDictionary = new Dictionary(dictionary); } + /// The inner dictionary. public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) { if (dictionary == null) @@ -41,16 +44,22 @@ public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerDictionary == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + /// Gets the Keys. public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + /// Gets the Values. public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + /// Gets or sets the value associated with the specified key. public TValue this[TKey key] { get @@ -67,8 +76,10 @@ public TValue this[TKey key] } } + /// Gets the Keys. IEnumerable IReadOnlyDictionary.Keys => Keys; + /// Gets the Values. IEnumerable IReadOnlyDictionary.Values => Values; public IEnumerator> GetEnumerator() @@ -89,6 +100,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(KeyValuePair item) { EnsureDictionary().Add(item); @@ -99,6 +111,7 @@ public void Clear() EnsureDictionary().Clear(); } + /// The item to search for. public bool Contains(KeyValuePair item) { if (IsUndefined) @@ -108,6 +121,8 @@ public bool Contains(KeyValuePair item) return EnsureDictionary().Contains(item); } + /// The array to copy. + /// The index. public void CopyTo(KeyValuePair[] array, int index) { if (IsUndefined) @@ -117,6 +132,7 @@ public void CopyTo(KeyValuePair[] array, int index) EnsureDictionary().CopyTo(array, index); } + /// The item to remove. public bool Remove(KeyValuePair item) { if (IsUndefined) @@ -126,11 +142,14 @@ public bool Remove(KeyValuePair item) return EnsureDictionary().Remove(item); } + /// The key. + /// The value to add. public void Add(TKey key, TValue value) { EnsureDictionary().Add(key, value); } + /// The key to search for. public bool ContainsKey(TKey key) { if (IsUndefined) @@ -140,6 +159,7 @@ public bool ContainsKey(TKey key) return EnsureDictionary().ContainsKey(key); } + /// The key. public bool Remove(TKey key) { if (IsUndefined) @@ -149,6 +169,8 @@ public bool Remove(TKey key) return EnsureDictionary().Remove(key); } + /// The key to search for. + /// The value. public bool TryGetValue(TKey key, out TValue value) { if (IsUndefined) diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingList.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingList.cs index 56ca5f3bea08..20d53dc68e1a 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingList.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ChangeTrackingList.cs @@ -12,7 +12,7 @@ namespace Azure.ResourceManager.HealthBot { - internal class ChangeTrackingList : IList, IReadOnlyList + internal partial class ChangeTrackingList : IList, IReadOnlyList { private IList _innerList; @@ -20,6 +20,7 @@ public ChangeTrackingList() { } + /// The inner list. public ChangeTrackingList(IList innerList) { if (innerList != null) @@ -28,6 +29,7 @@ public ChangeTrackingList(IList innerList) } } + /// The inner list. public ChangeTrackingList(IReadOnlyList innerList) { if (innerList != null) @@ -36,12 +38,16 @@ public ChangeTrackingList(IReadOnlyList innerList) } } + /// Gets the IsUndefined. public bool IsUndefined => _innerList == null; + /// Gets the Count. public int Count => IsUndefined ? 0 : EnsureList().Count; + /// Gets the IsReadOnly. public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + /// Gets or sets the value associated with the specified key. public T this[int index] { get @@ -85,6 +91,7 @@ IEnumerator IEnumerable.GetEnumerator() return GetEnumerator(); } + /// The item to add. public void Add(T item) { EnsureList().Add(item); @@ -95,6 +102,7 @@ public void Clear() EnsureList().Clear(); } + /// The item. public bool Contains(T item) { if (IsUndefined) @@ -104,6 +112,8 @@ public bool Contains(T item) return EnsureList().Contains(item); } + /// The array to copy to. + /// The array index. public void CopyTo(T[] array, int arrayIndex) { if (IsUndefined) @@ -113,6 +123,7 @@ public void CopyTo(T[] array, int arrayIndex) EnsureList().CopyTo(array, arrayIndex); } + /// The item. public bool Remove(T item) { if (IsUndefined) @@ -122,6 +133,7 @@ public bool Remove(T item) return EnsureList().Remove(item); } + /// The item. public int IndexOf(T item) { if (IsUndefined) @@ -131,11 +143,14 @@ public int IndexOf(T item) return EnsureList().IndexOf(item); } + /// The inner list. + /// The item. public void Insert(int index, T item) { EnsureList().Insert(index, item); } + /// The inner list. public void RemoveAt(int index) { if (IsUndefined) diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ClientPipelineExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ClientPipelineExtensions.cs new file mode 100644 index 000000000000..2c56b1b219c0 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ClientPipelineExtensions.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.ResourceManager.HealthBot +{ + internal static partial class ClientPipelineExtensions + { + public static async ValueTask ProcessMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + await pipeline.SendAsync(message, userCancellationToken).ConfigureAwait(false); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static Response ProcessMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + (CancellationToken userCancellationToken, ErrorOptions statusOption) = context.Parse(); + pipeline.Send(message, userCancellationToken); + + if (message.Response.IsError && (context?.ErrorOptions & ErrorOptions.NoThrow) != ErrorOptions.NoThrow) + { + throw new RequestFailedException(message.Response); + } + + return message.Response; + } + + public static async ValueTask> ProcessHeadAsBoolMessageAsync(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = await pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + + public static Response ProcessHeadAsBoolMessage(this HttpPipeline pipeline, HttpMessage message, RequestContext context) + { + Response response = pipeline.ProcessMessage(message, context); + switch (response.Status) + { + case >= 200 and < 300: + return Response.FromValue(true, response); + case >= 400 and < 500: + return Response.FromValue(false, response); + default: + return new ErrorResult(response, new RequestFailedException(response)); + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenMemberAttribute.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenMemberAttribute.cs new file mode 100644 index 000000000000..72778edeb7e4 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenMemberAttribute.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Property | AttributeTargets.Field))] + internal partial class CodeGenMemberAttribute : CodeGenTypeAttribute + { + /// The original name of the member. + public CodeGenMemberAttribute(string originalName) : base(originalName) + { + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSerializationAttribute.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSerializationAttribute.cs new file mode 100644 index 000000000000..dfcabf517497 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSerializationAttribute.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Struct), AllowMultiple = true, Inherited = true)] + internal partial class CodeGenSerializationAttribute : Attribute + { + /// The property name which these hooks apply to. + public CodeGenSerializationAttribute(string propertyName) + { + PropertyName = propertyName; + } + + /// The property name which these hooks apply to. + /// The serialization name of the property. + public CodeGenSerializationAttribute(string propertyName, string serializationName) + { + PropertyName = propertyName; + SerializationName = serializationName; + } + + /// Gets or sets the property name which these hooks should apply to. + public string PropertyName { get; } + + /// Gets or sets the serialization name of the property. + public string SerializationName { get; set; } + + /// + /// Gets or sets the method name to use when serializing the property value (property name excluded). + /// The signature of the serialization hook method must be or compatible with when invoking: private void SerializeHook(Utf8JsonWriter writer); + /// + public string SerializationValueHook { get; set; } + + /// + /// Gets or sets the method name to use when deserializing the property value from the JSON. + /// private static void DeserializationHook(JsonProperty property, ref TypeOfTheProperty propertyValue); // if the property is required + /// private static void DeserializationHook(JsonProperty property, ref Optional<TypeOfTheProperty> propertyValue); // if the property is optional + /// + public string DeserializationValueHook { get; set; } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSuppressAttribute.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSuppressAttribute.cs new file mode 100644 index 000000000000..38d536e69173 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenSuppressAttribute.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct), AllowMultiple = true)] + internal partial class CodeGenSuppressAttribute : Attribute + { + /// The member to suppress. + /// The types of the parameters of the member. + public CodeGenSuppressAttribute(string member, params Type[] parameters) + { + Member = member; + Parameters = parameters; + } + + /// Gets the Member. + public string Member { get; } + + /// Gets the Parameters. + public Type[] Parameters { get; } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenTypeAttribute.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenTypeAttribute.cs new file mode 100644 index 000000000000..f36b5f513173 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/CodeGenTypeAttribute.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Microsoft.TypeSpec.Generator.Customizations +{ + [AttributeUsage((AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct))] + internal partial class CodeGenTypeAttribute : Attribute + { + /// The original name of the type. + public CodeGenTypeAttribute(string originalName) + { + OriginalName = originalName; + } + + /// Gets the OriginalName. + public string OriginalName { get; } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ErrorResult.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ErrorResult.cs new file mode 100644 index 000000000000..df57e8373062 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ErrorResult.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using Azure; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class ErrorResult : Response + { + private readonly Response _response; + private readonly RequestFailedException _exception; + + public ErrorResult(Response response, RequestFailedException exception) + { + _response = response; + _exception = exception; + } + + /// Gets the Value. + public override T Value => throw _exception; + + /// + public override Response GetRawResponse() + { + return _response; + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ModelSerializationExtensions.cs index 366e8c803eca..6f0fa5e54da4 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/ModelSerializationExtensions.cs @@ -10,19 +10,18 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; +using System.Runtime.InteropServices; using System.Text.Json; -using System.Xml; -using Azure.Core; namespace Azure.ResourceManager.HealthBot { - internal static class ModelSerializationExtensions + internal static partial class ModelSerializationExtensions { - internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); - internal static readonly ModelReaderWriterOptions WireV3Options = new ModelReaderWriterOptions("W|v3"); - internal static readonly ModelReaderWriterOptions JsonV3Options = new ModelReaderWriterOptions("J|v3"); - internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions + { + MaxDepth = 256 + }; public static object GetObject(this JsonElement element) { @@ -48,14 +47,14 @@ public static object GetObject(this JsonElement element) case JsonValueKind.Null: return null; case JsonValueKind.Object: - var dictionary = new Dictionary(); + Dictionary dictionary = new Dictionary(); foreach (var jsonProperty in element.EnumerateObject()) { dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); } return dictionary; case JsonValueKind.Array: - var list = new List(); + List list = new List(); foreach (var item in element.EnumerateArray()) { list.Add(item.GetObject()); @@ -93,7 +92,7 @@ public static char GetChar(this JsonElement element) { if (element.ValueKind == JsonValueKind.String) { - var text = element.GetString(); + string text = element.GetString(); if (text == null || text.Length != 1) { throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); @@ -107,14 +106,14 @@ public static char GetChar(this JsonElement element) } [Conditional("DEBUG")] - public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + public static void ThrowNonNullablePropertyIsNull(this JsonProperty @property) { - throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + throw new JsonException($"A property '{@property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); } public static string GetRequiredString(this JsonElement element) { - var value = element.GetString(); + string value = element.GetString(); if (value == null) { throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); @@ -181,9 +180,6 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, T value, Mode case IJsonModel jsonModel: jsonModel.Write(writer, options ?? WireOptions); break; - case IUtf8JsonSerializable serializable: - serializable.Write(writer); - break; case byte[] bytes: writer.WriteBase64StringValue(bytes); break; @@ -260,150 +256,13 @@ public static void WriteObjectValue(this Utf8JsonWriter writer, object value, Mo writer.WriteObjectValue(value, options); } - internal static bool IsSentinelValue(BinaryData value) - { - ReadOnlySpan sentinelSpan = SentinelValue.ToMemory().Span; - ReadOnlySpan valueSpan = value.ToMemory().Span; - return sentinelSpan.SequenceEqual(valueSpan); - } - - internal static class TypeFormatters + public static BinaryData GetUtf8Bytes(this JsonElement element) { - private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; - public const string DefaultNumberFormat = "G"; - - public static string ToString(bool value) => value ? "true" : "false"; - - public static string ToString(DateTime value, string format) => value.Kind switch - { - DateTimeKind.Utc => ToString((DateTimeOffset)value, format), - _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") - }; - - public static string ToString(DateTimeOffset value, string format) => format switch - { - "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), - "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), - "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), - "R" => value.ToString("r", CultureInfo.InvariantCulture), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(TimeSpan value, string format) => format switch - { - "P" => XmlConvert.ToString(value), - _ => value.ToString(format, CultureInfo.InvariantCulture) - }; - - public static string ToString(byte[] value, string format) => format switch - { - "U" => ToBase64UrlString(value), - "D" => Convert.ToBase64String(value), - _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) - }; - - public static string ToBase64UrlString(byte[] value) - { - int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; - int size = checked(numWholeOrPartialInputBlocks * 4); - char[] output = new char[size]; - - int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); - - int i = 0; - for (; i < numBase64Chars; i++) - { - char ch = output[i]; - if (ch == '+') - { - output[i] = '-'; - } - else - { - if (ch == '/') - { - output[i] = '_'; - } - else - { - if (ch == '=') - { - break; - } - } - } - } - - return new string(output, 0, i); - } - - public static byte[] FromBase64UrlString(string value) - { - int paddingCharsToAdd = (value.Length % 4) switch - { - 0 => 0, - 2 => 2, - 3 => 1, - _ => throw new InvalidOperationException("Malformed input") - }; - char[] output = new char[(value.Length + paddingCharsToAdd)]; - int i = 0; - for (; i < value.Length; i++) - { - char ch = value[i]; - if (ch == '-') - { - output[i] = '+'; - } - else - { - if (ch == '_') - { - output[i] = '/'; - } - else - { - output[i] = ch; - } - } - } - - for (; i < output.Length; i++) - { - output[i] = '='; - } - - return Convert.FromBase64CharArray(output, 0, output.Length); - } - - public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch - { - "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), - _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) - }; - - public static TimeSpan ParseTimeSpan(string value, string format) => format switch - { - "P" => XmlConvert.ToTimeSpan(value), - _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) - }; - - public static string ConvertToString(object value, string format = null) => value switch - { - null => "null", - string s => s, - bool b => ToString(b), - int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), - byte[] b0 when format != null => ToString(b0, format), - IEnumerable s0 => string.Join(",", s0), - DateTimeOffset dateTime when format != null => ToString(dateTime, format), - TimeSpan timeSpan when format != null => ToString(timeSpan, format), - TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), - Guid guid => guid.ToString(), - BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), - _ => value.ToString() - }; +#if NET9_0_OR_GREATER + return new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(element).ToArray()); +#else + return BinaryData.FromString(element.GetRawText()); +#endif } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Optional.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Optional.cs index 2107b60407a1..1c6752cd1684 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Optional.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Optional.cs @@ -10,7 +10,7 @@ namespace Azure.ResourceManager.HealthBot { - internal static class Optional + internal static partial class Optional { public static bool IsCollectionDefined(IEnumerable collection) { @@ -28,7 +28,7 @@ public static bool IsCollectionDefined(IReadOnlyDictionary(T? value) - where T : struct + where T : struct { return value.HasValue; } @@ -38,14 +38,14 @@ public static bool IsDefined(object value) return value != null; } - public static bool IsDefined(JsonElement value) + public static bool IsDefined(string value) { - return value.ValueKind != JsonValueKind.Undefined; + return value != null; } - public static bool IsDefined(string value) + public static bool IsDefined(JsonElement value) { - return value != null; + return value.ValueKind != JsonValueKind.Undefined; } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/PageableWrapper.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/PageableWrapper.cs new file mode 100644 index 000000000000..5cbc6096f1ae --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/PageableWrapper.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure; + +namespace Azure.ResourceManager.HealthBot +{ + internal partial class PageableWrapper : Pageable + { + /// The source pageable value of type Pageable<T>. + private Pageable _source; + /// The converter function from T to U. + private Func _converter; + + /// Initializes a new instance of the PageableWrapper class. + /// The source pageable value of type Pageable<T>. + /// The converter function from T to U. + public PageableWrapper(Pageable source, Func converter) + { + _source = source; + _converter = converter; + } + + /// Converts the pages from Pageable to Page. + /// A continuation token from a previous response. + /// An optional hint to specify the desired size of each page. + /// An enumerable of pages containing converted items of type U. + public override IEnumerable> AsPages(string continuationToken, int? pageSizeHint) + { + foreach (Page page in _source.AsPages(continuationToken, pageSizeHint)) + { + List convertedItems = new List(); + foreach (T item in page.Values) + { + convertedItems.Add(_converter.Invoke(item)); + } + yield return Page.FromValues(convertedItems, page.ContinuationToken, page.GetRawResponse()); + } + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RawRequestUriBuilderExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RawRequestUriBuilderExtensions.cs new file mode 100644 index 000000000000..644e357a64e2 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RawRequestUriBuilderExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.ResourceManager.HealthBot +{ + internal static partial class RawRequestUriBuilderExtensions + { + public static void AppendQueryDelimited(this RawRequestUriBuilder builder, string name, IEnumerable value, string delimiter, SerializationFormat format = SerializationFormat.Default, bool escape = true) + { + delimiter ??= ","; + IEnumerable stringValues = value.Select(v => TypeFormatters.ConvertToString(v, format)); + builder.AppendQuery(name, string.Join(delimiter, stringValues), escape); + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RequestContextExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RequestContextExtensions.cs new file mode 100644 index 000000000000..16b4508b6887 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/RequestContextExtensions.cs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading; +using Azure; + +namespace Azure.ResourceManager.HealthBot +{ + internal static partial class RequestContextExtensions + { + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + public static ValueTuple Parse(this RequestContext context) + { + if (context == null) + { + return (CancellationToken.None, ErrorOptions.Default); + } + return (context.CancellationToken, context.ErrorOptions); + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/SerializationFormat.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/SerializationFormat.cs new file mode 100644 index 000000000000..02614a0231f3 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/SerializationFormat.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.ResourceManager.HealthBot +{ + internal enum SerializationFormat + { + /// The default serialization format. + Default = 0, + /// The RFC1123 date time format. + DateTime_RFC1123 = 1, + /// The RFC3339 date time format. + DateTime_RFC3339 = 2, + /// The RFC7231 date time format. + DateTime_RFC7231 = 3, + /// The ISO8601 date time format. + DateTime_ISO8601 = 4, + /// The Unix date time format. + DateTime_Unix = 5, + /// The ISO8601 date format. + Date_ISO8601 = 6, + /// The ISO8601 duration format. + Duration_ISO8601 = 7, + /// The constant duration format. + Duration_Constant = 8, + /// The seconds duration format. + Duration_Seconds = 9, + /// The seconds duration format with float precision. + Duration_Seconds_Float = 10, + /// The seconds duration format with double precision. + Duration_Seconds_Double = 11, + /// The milliseconds duration format. + Duration_Milliseconds = 12, + /// The milliseconds duration format with float precision. + Duration_Milliseconds_Float = 13, + /// The milliseconds duration format with double precision. + Duration_Milliseconds_Double = 14, + /// The ISO8601 time format. + Time_ISO8601 = 15, + /// The Base64Url bytes format. + Bytes_Base64Url = 16, + /// The Base64 bytes format. + Bytes_Base64 = 17 + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/TypeFormatters.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/TypeFormatters.cs new file mode 100644 index 000000000000..0c2f00a792c3 --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/TypeFormatters.cs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Xml; + +namespace Azure.ResourceManager.HealthBot +{ + internal static partial class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Generated clients require it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked (value.Length + 2) / 3; + int size = checked (numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ToFormatSpecifier(SerializationFormat format) => format switch + { + SerializationFormat.DateTime_RFC1123 => "R", + SerializationFormat.DateTime_RFC3339 => "O", + SerializationFormat.DateTime_RFC7231 => "R", + SerializationFormat.DateTime_ISO8601 => "O", + SerializationFormat.Date_ISO8601 => "D", + SerializationFormat.DateTime_Unix => "U", + SerializationFormat.Bytes_Base64Url => "U", + SerializationFormat.Bytes_Base64 => "D", + SerializationFormat.Duration_ISO8601 => "P", + SerializationFormat.Duration_Constant => "c", + SerializationFormat.Duration_Seconds => "%s", + SerializationFormat.Duration_Seconds_Float => "s\\.FFF", + SerializationFormat.Duration_Seconds_Double => "s\\.FFFFFF", + SerializationFormat.Time_ISO8601 => "T", + _ => null + }; + + public static string ConvertToString(object value, SerializationFormat format = SerializationFormat.Default) + { + string formatSpecifier = ToFormatSpecifier(format); + + return value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when formatSpecifier != null => ToString(b0, formatSpecifier), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when formatSpecifier != null => ToString(dateTime, formatSpecifier), + TimeSpan timeSpan when format == SerializationFormat.Duration_Seconds => Convert.ToInt32(timeSpan.TotalSeconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan0 when format == SerializationFormat.Duration_Seconds_Float || format == SerializationFormat.Duration_Seconds_Double => timeSpan0.TotalSeconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan1 when format == SerializationFormat.Duration_Milliseconds => Convert.ToInt32(timeSpan1.TotalMilliseconds).ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan2 when format == SerializationFormat.Duration_Milliseconds_Float || format == SerializationFormat.Duration_Milliseconds_Double => timeSpan2.TotalMilliseconds.ToString(CultureInfo.InvariantCulture), + TimeSpan timeSpan3 when formatSpecifier != null => ToString(timeSpan3, formatSpecifier), + TimeSpan timeSpan4 => XmlConvert.ToString(timeSpan4), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Utf8JsonRequestContent.cs index 1fa37e9d3d9f..f93c22318c6f 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Utf8JsonRequestContent.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -13,7 +13,7 @@ namespace Azure.ResourceManager.HealthBot { - internal class Utf8JsonRequestContent : RequestContent + internal partial class Utf8JsonRequestContent : RequestContent { private readonly MemoryStream _stream; private readonly RequestContent _content; @@ -25,20 +25,26 @@ public Utf8JsonRequestContent() JsonWriter = new Utf8JsonWriter(_stream); } + /// Gets the JsonWriter. public Utf8JsonWriter JsonWriter { get; } + /// The stream containing the data to be written. + /// The cancellation token to use. public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) { await JsonWriter.FlushAsync().ConfigureAwait(false); await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); } + /// The stream containing the data to be written. + /// The cancellation token to use. public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) { JsonWriter.Flush(); _content.WriteTo(stream, cancellationToken); } + /// public override bool TryComputeLength(out long length) { length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperation.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperation.cs index 31f8d2801932..0c8034193dd0 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperation.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperation.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.HealthBot { -#pragma warning disable SA1649 // File name should match first type name - internal class HealthBotArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class HealthBotArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected HealthBotArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal HealthBotArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response); @@ -36,12 +37,20 @@ internal HealthBotArmOperation(Response response, RehydrationToken? rehydrationT _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal HealthBotArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,48 +58,49 @@ internal HealthBotArmOperation(ClientDiagnostics clientDiagnostics, HttpPipeline _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(nextLinkOperation, clientDiagnostics, response, "HealthBotArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + nextLinkOperation, + clientDiagnostics, + response, + "HealthBotArmOperation", + null, + new SequentialDelayStrategy()); } + /// Gets the Id. + public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; + + /// Gets the HasCompleted. + public override bool HasCompleted => _operation.HasCompleted; + + /// The token to rehydrate a long-running operation. private string GetOperationId(RehydrationToken? rehydrationToken) { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerHealthBotContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); + return rehydrationToken?.Id; } - /// - public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// + /// public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - /// - public override bool HasCompleted => _operation.HasCompleted; - - /// + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(cancellationToken); - /// + /// public override Response WaitForCompletionResponse(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponse(pollingInterval, cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(cancellationToken); - /// + /// public override ValueTask WaitForCompletionResponseAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionResponseAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperationOfT.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperationOfT.cs index 4de9b3f3edd7..4473ba41c164 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperationOfT.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotArmOperationOfT.cs @@ -6,18 +6,16 @@ #nullable disable using System; -using System.ClientModel.Primitives; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; +using Azure.ResourceManager; namespace Azure.ResourceManager.HealthBot { -#pragma warning disable SA1649 // File name should match first type name - internal class HealthBotArmOperation : ArmOperation -#pragma warning restore SA1649 // File name should match first type name + internal partial class HealthBotArmOperation : ArmOperation { private readonly OperationInternal _operation; private readonly RehydrationToken? _completeRehydrationToken; @@ -29,6 +27,9 @@ protected HealthBotArmOperation() { } + /// + /// The operation response. + /// The token to rehydrate the operation. internal HealthBotArmOperation(Response response, RehydrationToken? rehydrationToken = null) { _operation = OperationInternal.Succeeded(response.GetRawResponse(), response.Value); @@ -36,12 +37,21 @@ internal HealthBotArmOperation(Response response, RehydrationToken? rehydrati _operationId = GetOperationId(rehydrationToken); } + /// + /// The instance of . + /// The instance of . + /// The instance of . + /// The operation request. + /// The operation response. + /// The finalStateVia of the operation. + /// If should skip Api version override. + /// The Api version override value. internal HealthBotArmOperation(IOperationSource source, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response, OperationFinalStateVia finalStateVia, bool skipApiVersionOverride = false, string apiVersionOverrideValue = null) { - var nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); - if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationValue) + IOperation nextLinkOperation = NextLinkOperationImplementation.Create(pipeline, request.Method, request.Uri.ToUri(), response, finalStateVia, skipApiVersionOverride, apiVersionOverrideValue); + if (nextLinkOperation is NextLinkOperationImplementation nextLinkOperationImplementation) { - _nextLinkOperation = nextLinkOperationValue; + _nextLinkOperation = nextLinkOperationImplementation; _operationId = _nextLinkOperation.OperationId; } else @@ -49,54 +59,55 @@ internal HealthBotArmOperation(IOperationSource source, ClientDiagnostics cli _completeRehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(request.Method, request.Uri.ToUri(), response, finalStateVia); _operationId = GetOperationId(_completeRehydrationToken); } - _operation = new OperationInternal(NextLinkOperationImplementation.Create(source, nextLinkOperation), clientDiagnostics, response, "HealthBotArmOperation", fallbackStrategy: new SequentialDelayStrategy()); + _operation = new OperationInternal( + NextLinkOperationImplementation.Create(source, nextLinkOperation), + clientDiagnostics, + response, + "HealthBotArmOperation", + null, + new SequentialDelayStrategy()); } - private string GetOperationId(RehydrationToken? rehydrationToken) - { - if (rehydrationToken is null) - { - return null; - } - var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureResourceManagerHealthBotContext.Default); - using var document = JsonDocument.Parse(data); - var lroDetails = document.RootElement; - return lroDetails.GetProperty("id").GetString(); - } - /// + /// Gets the Id. public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; - /// - public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; - - /// + /// Gets the Value. public override T Value => _operation.Value; - /// + /// Gets the HasValue. public override bool HasValue => _operation.HasValue; - /// + /// Gets the HasCompleted. public override bool HasCompleted => _operation.HasCompleted; - /// + /// The token to rehydrate a long-running operation. + private string GetOperationId(RehydrationToken? rehydrationToken) + { + return rehydrationToken?.Id; + } + + /// + public override RehydrationToken? GetRehydrationToken() => _nextLinkOperation?.GetRehydrationToken() ?? _completeRehydrationToken; + + /// public override Response GetRawResponse() => _operation.RawResponse; - /// + /// public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken); - /// + /// public override ValueTask UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken); - /// + /// public override Response WaitForCompletion(CancellationToken cancellationToken = default) => _operation.WaitForCompletion(cancellationToken); - /// + /// public override Response WaitForCompletion(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletion(pollingInterval, cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken); - /// + /// public override ValueTask> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotOperationSource.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotOperationSource.cs index d4c10c8e5ea4..893be2b6f2e8 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotOperationSource.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/LongRunningOperation/HealthBotOperationSource.cs @@ -5,32 +5,45 @@ #nullable disable -using System.ClientModel.Primitives; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Azure; using Azure.Core; +using Azure.ResourceManager; namespace Azure.ResourceManager.HealthBot { - internal class HealthBotOperationSource : IOperationSource + /// + internal partial class HealthBotOperationSource : IOperationSource { private readonly ArmClient _client; + /// + /// internal HealthBotOperationSource(ArmClient client) { _client = client; } + /// The response from the service. + /// The cancellation token to use. + /// HealthBotResource IOperationSource.CreateResult(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHealthBotContext.Default); + using JsonDocument document = JsonDocument.Parse(response.ContentStream); + HealthBotData data = HealthBotData.DeserializeHealthBotData(document.RootElement, ModelSerializationExtensions.WireOptions); return new HealthBotResource(_client, data); } + /// The response from the service. + /// The cancellation token to use. + /// async ValueTask IOperationSource.CreateResultAsync(Response response, CancellationToken cancellationToken) { - var data = ModelReaderWriter.Read(response.Content, ModelReaderWriterOptions.Json, AzureResourceManagerHealthBotContext.Default); - return await Task.FromResult(new HealthBotResource(_client, data)).ConfigureAwait(false); + using JsonDocument document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false); + HealthBotData data = HealthBotData.DeserializeHealthBotData(document.RootElement, ModelSerializationExtensions.WireOptions); + return new HealthBotResource(_client, data); } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/AzureResourceManagerHealthBotContext.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/AzureResourceManagerHealthBotContext.cs index e94aad59efea..1dd0ba1d8a53 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/AzureResourceManagerHealthBotContext.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/AzureResourceManagerHealthBotContext.cs @@ -6,6 +6,7 @@ #nullable disable using System.ClientModel.Primitives; +using Azure; using Azure.ResourceManager.HealthBot.Models; using Azure.ResourceManager.Models; @@ -13,7 +14,7 @@ namespace Azure.ResourceManager.HealthBot { /// /// Context class which will be filled in by the System.ClientModel.SourceGeneration. - /// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md' + /// For more information /// [ModelReaderWriterBuildable(typeof(BotResponseList))] [ModelReaderWriterBuildable(typeof(HealthBotData))] @@ -25,6 +26,7 @@ namespace Azure.ResourceManager.HealthBot [ModelReaderWriterBuildable(typeof(HealthBotResource))] [ModelReaderWriterBuildable(typeof(HealthBotSku))] [ModelReaderWriterBuildable(typeof(ManagedServiceIdentity))] + [ModelReaderWriterBuildable(typeof(ResponseError))] [ModelReaderWriterBuildable(typeof(SystemData))] [ModelReaderWriterBuildable(typeof(UserAssignedIdentity))] public partial class AzureResourceManagerHealthBotContext : ModelReaderWriterContext diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.Serialization.cs index a58dd0480aae..c1fba8ea78b1 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - internal partial class BotResponseList : IUtf8JsonSerializable, IJsonModel + /// The list of Azure Health Bot operation response. + internal partial class BotResponseList : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,36 +30,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(BotResponseList)} does not support writing '{format}' format."); } - - if (options.Format != "W" && Optional.IsDefined(NextLink)) - { - writer.WritePropertyName("nextLink"u8); - writer.WriteStringValue(NextLink); - } - if (options.Format != "W" && Optional.IsCollectionDefined(Value)) + if (options.Format != "W") { writer.WritePropertyName("value"u8); writer.WriteStartArray(); - foreach (var item in Value) + foreach (HealthBotData item in Value) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink.AbsoluteUri); + } + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -66,64 +67,70 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - BotResponseList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + BotResponseList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual BotResponseList JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(BotResponseList)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeBotResponseList(document.RootElement, options); } - internal static BotResponseList DeserializeBotResponseList(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static BotResponseList DeserializeBotResponseList(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } - string nextLink = default; IReadOnlyList value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + Uri nextLink = default; + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("nextLink"u8)) + if (prop.NameEquals("value"u8)) { - nextLink = property.Value.GetString(); + List array = new List(); + foreach (var item in prop.Value.EnumerateArray()) + { + array.Add(HealthBotData.DeserializeHealthBotData(item, options)); + } + value = array; continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("nextLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(HealthBotData.DeserializeHealthBotData(item, options)); - } - value = array; + nextLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new BotResponseList(nextLink, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new BotResponseList(value, nextLink, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -133,15 +140,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opt } } - BotResponseList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + BotResponseList IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual BotResponseList PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeBotResponseList(document.RootElement, options); } default: @@ -149,6 +161,14 @@ BotResponseList IPersistableModel.Create(BinaryData data, Model } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static BotResponseList FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeBotResponseList(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.cs index 187e244948b4..811829768323 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/BotResponseList.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { /// The list of Azure Health Bot operation response. internal partial class BotResponseList { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal BotResponseList() @@ -52,19 +24,20 @@ internal BotResponseList() } /// Initializes a new instance of . - /// The link used to get the next page of bot service resources. - /// Gets the list of Azure Health Bot results and their properties. - /// Keeps track of any properties unknown to the library. - internal BotResponseList(string nextLink, IReadOnlyList value, IDictionary serializedAdditionalRawData) + /// The HealthBot items on this page. + /// The link to the next page of items. + /// Keeps track of any properties unknown to the library. + internal BotResponseList(IReadOnlyList value, Uri nextLink, IDictionary additionalBinaryDataProperties) { - NextLink = nextLink; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + NextLink = nextLink; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } - /// The link used to get the next page of bot service resources. - public string NextLink { get; } - /// Gets the list of Azure Health Bot results and their properties. + /// The HealthBot items on this page. public IReadOnlyList Value { get; } + + /// The link to the next page of items. + public Uri NextLink { get; } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.Serialization.cs index cf29b36d6481..223f9f4f8791 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotKey : IUtf8JsonSerializable, IJsonModel + /// An entry of HealthBotKeysResponse. + public partial class HealthBotKey : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +30,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKey)} does not support writing '{format}' format."); } - if (Optional.IsDefined(KeyName)) { writer.WritePropertyName("keyName"u8); @@ -44,15 +45,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("value"u8); writer.WriteStringValue(Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,55 +62,61 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotKey IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotKey JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKey)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotKey(document.RootElement, options); } - internal static HealthBotKey DeserializeHealthBotKey(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotKey DeserializeHealthBotKey(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } string keyName = default; string value = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("keyName"u8)) + if (prop.NameEquals("keyName"u8)) { - keyName = property.Value.GetString(); + keyName = prop.Value.GetString(); continue; } - if (property.NameEquals("value"u8)) + if (prop.NameEquals("value"u8)) { - value = property.Value.GetString(); + value = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HealthBotKey(keyName, value, serializedAdditionalRawData); + return new HealthBotKey(keyName, value, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -119,15 +126,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - HealthBotKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotKey IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotKey PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotKey(document.RootElement, options); } default: @@ -135,6 +147,14 @@ HealthBotKey IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static HealthBotKey FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHealthBotKey(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.cs index 5e9c7fa8b55a..74a53d4bebb7 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKey.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.HealthBot.Models /// An entry of HealthBotKeysResponse. public partial class HealthBotKey { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal HealthBotKey() @@ -53,16 +24,17 @@ internal HealthBotKey() /// Initializes a new instance of . /// The name of the key. /// The value of the key. - /// Keeps track of any properties unknown to the library. - internal HealthBotKey(string keyName, string value, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotKey(string keyName, string value, IDictionary additionalBinaryDataProperties) { KeyName = keyName; Value = value; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the key. public string KeyName { get; } + /// The value of the key. public string Value { get; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.Serialization.cs index 21e851430ce5..749cd6a8c6b9 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotKeyVaultProperties : IUtf8JsonSerializable, IJsonModel + /// Properties of the key vault. + public partial class HealthBotKeyVaultProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HealthBotKeyVaultProperties() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +34,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKeyVaultProperties)} does not support writing '{format}' format."); } - writer.WritePropertyName("keyName"u8); writer.WriteStringValue(KeyName); if (Optional.IsDefined(KeyVersion)) @@ -48,15 +53,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("userIdentity"u8); writer.WriteStringValue(UserIdentity); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -65,22 +70,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotKeyVaultProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotKeyVaultProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotKeyVaultProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKeyVaultProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotKeyVaultProperties(document.RootElement, options); } - internal static HealthBotKeyVaultProperties DeserializeHealthBotKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotKeyVaultProperties DeserializeHealthBotKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -89,43 +99,44 @@ internal static HealthBotKeyVaultProperties DeserializeHealthBotKeyVaultProperti string keyVersion = default; Uri keyVaultUri = default; string userIdentity = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("keyName"u8)) + if (prop.NameEquals("keyName"u8)) { - keyName = property.Value.GetString(); + keyName = prop.Value.GetString(); continue; } - if (property.NameEquals("keyVersion"u8)) + if (prop.NameEquals("keyVersion"u8)) { - keyVersion = property.Value.GetString(); + keyVersion = prop.Value.GetString(); continue; } - if (property.NameEquals("keyVaultUri"u8)) + if (prop.NameEquals("keyVaultUri"u8)) { - keyVaultUri = new Uri(property.Value.GetString()); + keyVaultUri = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("userIdentity"u8)) + if (prop.NameEquals("userIdentity"u8)) { - userIdentity = property.Value.GetString(); + userIdentity = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HealthBotKeyVaultProperties(keyName, keyVersion, keyVaultUri, userIdentity, serializedAdditionalRawData); + return new HealthBotKeyVaultProperties(keyName, keyVersion, keyVaultUri, userIdentity, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -135,15 +146,20 @@ BinaryData IPersistableModel.Write(ModelReaderWrite } } - HealthBotKeyVaultProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotKeyVaultProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotKeyVaultProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotKeyVaultProperties(document.RootElement, options); } default: @@ -151,6 +167,7 @@ HealthBotKeyVaultProperties IPersistableModel.Creat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.cs index fa415ec7fe7e..36c2673a09a0 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeyVaultProperties.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { /// Properties of the key vault. public partial class HealthBotKeyVaultProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The name of the key vault key. @@ -63,27 +35,25 @@ public HealthBotKeyVaultProperties(string keyName, Uri keyVaultUri) /// The version of the key vault key. /// The Uri of the key vault. /// The user assigned identity (ARM resource id) that has access to the key. - /// Keeps track of any properties unknown to the library. - internal HealthBotKeyVaultProperties(string keyName, string keyVersion, Uri keyVaultUri, string userIdentity, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotKeyVaultProperties(string keyName, string keyVersion, Uri keyVaultUri, string userIdentity, IDictionary additionalBinaryDataProperties) { KeyName = keyName; KeyVersion = keyVersion; KeyVaultUri = keyVaultUri; UserIdentity = userIdentity; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal HealthBotKeyVaultProperties() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the key vault key. public string KeyName { get; set; } + /// The version of the key vault key. public string KeyVersion { get; set; } + /// The Uri of the key vault. public Uri KeyVaultUri { get; set; } + /// The user assigned identity (ARM resource id) that has access to the key. public string UserIdentity { get; set; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.Serialization.cs index 38758d455093..d5132447a9d9 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.Serialization.cs @@ -9,14 +9,16 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotKeysResult : IUtf8JsonSerializable, IJsonModel + /// Health Bot Keys Response. + public partial class HealthBotKeysResult : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,31 +30,30 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKeysResult)} does not support writing '{format}' format."); } - if (Optional.IsCollectionDefined(Secrets)) { writer.WritePropertyName("secrets"u8); writer.WriteStartArray(); - foreach (var item in Secrets) + foreach (HealthBotKey item in Secrets) { writer.WriteObjectValue(item, options); } writer.WriteEndArray(); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -61,39 +62,43 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotKeysResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotKeysResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotKeysResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotKeysResult)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotKeysResult(document.RootElement, options); } - internal static HealthBotKeysResult DeserializeHealthBotKeysResult(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotKeysResult DeserializeHealthBotKeysResult(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } IReadOnlyList secrets = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("secrets"u8)) + if (prop.NameEquals("secrets"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + foreach (var item in prop.Value.EnumerateArray()) { array.Add(HealthBotKey.DeserializeHealthBotKey(item, options)); } @@ -102,17 +107,19 @@ internal static HealthBotKeysResult DeserializeHealthBotKeysResult(JsonElement e } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HealthBotKeysResult(secrets ?? new ChangeTrackingList(), serializedAdditionalRawData); + return new HealthBotKeysResult(secrets ?? new ChangeTrackingList(), additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -122,15 +129,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - HealthBotKeysResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotKeysResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotKeysResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotKeysResult(document.RootElement, options); } default: @@ -138,6 +150,14 @@ HealthBotKeysResult IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to deserialize the from. + internal static HealthBotKeysResult FromResponse(Response response) + { + using JsonDocument document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeHealthBotKeysResult(document.RootElement, ModelSerializationExtensions.WireOptions); + } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.cs index c2b3b7802ca6..11eafaadf821 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotKeysResult.cs @@ -7,43 +7,15 @@ using System; using System.Collections.Generic; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { /// Health Bot Keys Response. public partial class HealthBotKeysResult { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . internal HealthBotKeysResult() @@ -53,11 +25,11 @@ internal HealthBotKeysResult() /// Initializes a new instance of . /// Array of Azure Health Bot Secrets. - /// Keeps track of any properties unknown to the library. - internal HealthBotKeysResult(IReadOnlyList secrets, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotKeysResult(IReadOnlyList secrets, IDictionary additionalBinaryDataProperties) { Secrets = secrets; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Array of Azure Health Bot Secrets. diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.Serialization.cs index a5b9d109c3bf..c9a88b2e4765 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.Serialization.cs @@ -11,14 +11,16 @@ using System.Text; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.HealthBot; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotPatch : IUtf8JsonSerializable, IJsonModel + /// Parameters for updating a Azure Health Bot. + public partial class HealthBotPatch : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -30,12 +32,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotPatch)} does not support writing '{format}' format."); } - if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); @@ -48,6 +49,11 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit foreach (var item in Tags) { writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } writer.WriteStringValue(item.Value); } writer.WriteEndObject(); @@ -67,15 +73,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("location"u8); writer.WriteStringValue(Location.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -84,22 +90,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotPatch JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotPatch)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotPatch(document.RootElement, options); } - internal static HealthBotPatch DeserializeHealthBotPatch(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotPatch DeserializeHealthBotPatch(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -109,79 +120,87 @@ internal static HealthBotPatch DeserializeHealthBotPatch(JsonElement element, Mo HealthBotSku sku = default; ManagedServiceIdentity identity = default; AzureLocation? location = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("properties"u8)) + if (prop.NameEquals("properties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - properties = HealthBotProperties.DeserializeHealthBotProperties(property.Value, options); + properties = HealthBotProperties.DeserializeHealthBotProperties(prop.Value, options); continue; } - if (property.NameEquals("tags"u8)) + if (prop.NameEquals("tags"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } Dictionary dictionary = new Dictionary(); - foreach (var property0 in property.Value.EnumerateObject()) + foreach (var prop0 in prop.Value.EnumerateObject()) { - dictionary.Add(property0.Name, property0.Value.GetString()); + if (prop0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(prop0.Name, null); + } + else + { + dictionary.Add(prop0.Name, prop0.Value.GetString()); + } } tags = dictionary; continue; } - if (property.NameEquals("sku"u8)) + if (prop.NameEquals("sku"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - sku = HealthBotSku.DeserializeHealthBotSku(property.Value, options); + sku = HealthBotSku.DeserializeHealthBotSku(prop.Value, options); continue; } - if (property.NameEquals("identity"u8)) + if (prop.NameEquals("identity"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureResourceManagerHealthBotContext.Default); + identity = ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(prop.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureResourceManagerHealthBotContext.Default); continue; } - if (property.NameEquals("location"u8)) + if (prop.NameEquals("location"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - location = new AzureLocation(property.Value.GetString()); + location = new AzureLocation(prop.Value.GetString()); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; return new HealthBotPatch( properties, tags ?? new ChangeTrackingDictionary(), sku, identity, location, - serializedAdditionalRawData); + additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -191,15 +210,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions opti } } - HealthBotPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotPatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotPatch PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotPatch(document.RootElement, options); } default: @@ -207,6 +231,19 @@ HealthBotPatch IPersistableModel.Create(BinaryData data, ModelRe } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// The to serialize into . + internal static RequestContent ToRequestContent(HealthBotPatch healthBotPatch) + { + if (healthBotPatch == null) + { + return null; + } + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(healthBotPatch, ModelSerializationExtensions.WireOptions); + return content; + } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.cs index 02890a07ff89..1d4312983e42 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotPatch.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using Azure.Core; +using Azure.ResourceManager.HealthBot; using Azure.ResourceManager.Models; namespace Azure.ResourceManager.HealthBot.Models @@ -15,37 +16,8 @@ namespace Azure.ResourceManager.HealthBot.Models /// Parameters for updating a Azure Health Bot. public partial class HealthBotPatch { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public HealthBotPatch() @@ -59,36 +31,43 @@ public HealthBotPatch() /// SKU of the Azure Health Bot. /// The identity of the Azure Health Bot. /// - /// Keeps track of any properties unknown to the library. - internal HealthBotPatch(HealthBotProperties properties, IDictionary tags, HealthBotSku sku, ManagedServiceIdentity identity, AzureLocation? location, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotPatch(HealthBotProperties properties, IDictionary tags, HealthBotSku sku, ManagedServiceIdentity identity, AzureLocation? location, IDictionary additionalBinaryDataProperties) { Properties = properties; Tags = tags; Sku = sku; Identity = identity; Location = location; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// Properties of Azure Health Bot. public HealthBotProperties Properties { get; set; } + /// Tags for a Azure Health Bot. public IDictionary Tags { get; } + /// SKU of the Azure Health Bot. internal HealthBotSku Sku { get; set; } + + /// The identity of the Azure Health Bot. + public ManagedServiceIdentity Identity { get; set; } + + /// Gets or sets the Location. + public AzureLocation? Location { get; set; } + /// The name of the Azure Health Bot SKU. public HealthBotSkuName? SkuName { - get => Sku is null ? default(HealthBotSkuName?) : Sku.Name; + get + { + return Sku is null ? default : Sku.Name; + } set { - Sku = value.HasValue ? new HealthBotSku(value.Value) : null; + Sku = value.HasValue ? new HealthBotSku(value.Value) : default; } } - - /// The identity of the Azure Health Bot. - public ManagedServiceIdentity Identity { get; set; } - /// Gets or sets the location. - public AzureLocation? Location { get; set; } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.Serialization.cs index bf6aabcaf2ae..9bcd4e8d3bcb 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.Serialization.cs @@ -9,14 +9,15 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotProperties : IUtf8JsonSerializable, IJsonModel + /// The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. + public partial class HealthBotProperties : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,12 +29,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotProperties)} does not support writing '{format}' format."); } - if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { writer.WritePropertyName("provisioningState"u8); @@ -54,15 +54,15 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("accessControlMethod"u8); writer.WriteStringValue(AccessControlMethod); } - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -71,22 +71,27 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotProperties JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotProperties)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotProperties(document.RootElement, options); } - internal static HealthBotProperties DeserializeHealthBotProperties(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotProperties DeserializeHealthBotProperties(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; @@ -95,51 +100,52 @@ internal static HealthBotProperties DeserializeHealthBotProperties(JsonElement e Uri botManagementPortalLink = default; HealthBotKeyVaultProperties keyVaultProperties = default; string accessControlMethod = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("provisioningState"u8)) + if (prop.NameEquals("provisioningState"u8)) { - provisioningState = property.Value.GetString(); + provisioningState = prop.Value.GetString(); continue; } - if (property.NameEquals("botManagementPortalLink"u8)) + if (prop.NameEquals("botManagementPortalLink"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - botManagementPortalLink = new Uri(property.Value.GetString()); + botManagementPortalLink = string.IsNullOrEmpty(prop.Value.GetString()) ? null : new Uri(prop.Value.GetString()); continue; } - if (property.NameEquals("keyVaultProperties"u8)) + if (prop.NameEquals("keyVaultProperties"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) + if (prop.Value.ValueKind == JsonValueKind.Null) { continue; } - keyVaultProperties = HealthBotKeyVaultProperties.DeserializeHealthBotKeyVaultProperties(property.Value, options); + keyVaultProperties = HealthBotKeyVaultProperties.DeserializeHealthBotKeyVaultProperties(prop.Value, options); continue; } - if (property.NameEquals("accessControlMethod"u8)) + if (prop.NameEquals("accessControlMethod"u8)) { - accessControlMethod = property.Value.GetString(); + accessControlMethod = prop.Value.GetString(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HealthBotProperties(provisioningState, botManagementPortalLink, keyVaultProperties, accessControlMethod, serializedAdditionalRawData); + return new HealthBotProperties(provisioningState, botManagementPortalLink, keyVaultProperties, accessControlMethod, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -149,15 +155,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions } } - HealthBotProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotProperties PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotProperties(document.RootElement, options); } default: @@ -165,6 +176,7 @@ HealthBotProperties IPersistableModel.Create(BinaryData dat } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.cs index 93c18ac279a7..4dae32a147e9 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotProperties.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.HealthBot.Models /// The properties of a Azure Health Bot. The Health Bot Service is a cloud platform that empowers developers in Healthcare organizations to build and deploy their compliant, AI-powered virtual health assistants and health bots, that help them improve processes and reduce costs. public partial class HealthBotProperties { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . public HealthBotProperties() @@ -55,22 +26,25 @@ public HealthBotProperties() /// The link. /// KeyVault properties for the resource encryption. /// The access control method for the Azure Health Bot resource. - /// Keeps track of any properties unknown to the library. - internal HealthBotProperties(string provisioningState, Uri botManagementPortalLink, HealthBotKeyVaultProperties keyVaultProperties, string accessControlMethod, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotProperties(string provisioningState, Uri botManagementPortalLink, HealthBotKeyVaultProperties keyVaultProperties, string accessControlMethod, IDictionary additionalBinaryDataProperties) { ProvisioningState = provisioningState; BotManagementPortalLink = botManagementPortalLink; KeyVaultProperties = keyVaultProperties; AccessControlMethod = accessControlMethod; - _serializedAdditionalRawData = serializedAdditionalRawData; + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The provisioning state of the Azure Health Bot resource. public string ProvisioningState { get; } + /// The link. public Uri BotManagementPortalLink { get; } + /// KeyVault properties for the resource encryption. public HealthBotKeyVaultProperties KeyVaultProperties { get; set; } + /// The access control method for the Azure Health Bot resource. public string AccessControlMethod { get; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.Serialization.cs index 522580f72a59..94a189e315de 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.Serialization.cs @@ -9,14 +9,20 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; -using Azure.Core; +using Azure.ResourceManager.HealthBot; namespace Azure.ResourceManager.HealthBot.Models { - public partial class HealthBotSku : IUtf8JsonSerializable, IJsonModel + /// The resource model definition representing SKU. + public partial class HealthBotSku : IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + /// Initializes a new instance of for deserialization. + internal HealthBotSku() + { + } + /// The JSON writer. + /// The client options for reading and writing models. void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { writer.WriteStartObject(); @@ -28,23 +34,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti /// 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; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotSku)} does not support writing '{format}' format."); } - writer.WritePropertyName("name"u8); writer.WriteStringValue(Name.ToSerialString()); - if (options.Format != "W" && _serializedAdditionalRawData != null) + if (options.Format != "W" && _additionalBinaryDataProperties != null) { - foreach (var item in _serializedAdditionalRawData) + foreach (var item in _additionalBinaryDataProperties) { writer.WritePropertyName(item.Key); #if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); + writer.WriteRawValue(item.Value); #else - using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + using (JsonDocument document = JsonDocument.Parse(item.Value)) { JsonSerializer.Serialize(writer, document.RootElement); } @@ -53,49 +58,55 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } } - HealthBotSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + /// The JSON reader. + /// The client options for reading and writing models. + HealthBotSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => JsonModelCreateCore(ref reader, options); + + /// The JSON reader. + /// The client options for reading and writing models. + protected virtual HealthBotSku JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { throw new FormatException($"The model {nameof(HealthBotSku)} does not support reading '{format}' format."); } - using JsonDocument document = JsonDocument.ParseValue(ref reader); return DeserializeHealthBotSku(document.RootElement, options); } - internal static HealthBotSku DeserializeHealthBotSku(JsonElement element, ModelReaderWriterOptions options = null) + /// The JSON element to deserialize. + /// The client options for reading and writing models. + internal static HealthBotSku DeserializeHealthBotSku(JsonElement element, ModelReaderWriterOptions options) { - options ??= ModelSerializationExtensions.WireOptions; - if (element.ValueKind == JsonValueKind.Null) { return null; } HealthBotSkuName name = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property in element.EnumerateObject()) + IDictionary additionalBinaryDataProperties = new ChangeTrackingDictionary(); + foreach (var prop in element.EnumerateObject()) { - if (property.NameEquals("name"u8)) + if (prop.NameEquals("name"u8)) { - name = property.Value.GetString().ToHealthBotSkuName(); + name = prop.Value.GetString().ToHealthBotSkuName(); continue; } if (options.Format != "W") { - rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + additionalBinaryDataProperties.Add(prop.Name, BinaryData.FromString(prop.Value.GetRawText())); } } - serializedAdditionalRawData = rawDataDictionary; - return new HealthBotSku(name, serializedAdditionalRawData); + return new HealthBotSku(name, additionalBinaryDataProperties); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The client options for reading and writing models. + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => PersistableModelWriteCore(options); + /// The client options for reading and writing models. + protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": @@ -105,15 +116,20 @@ BinaryData IPersistableModel.Write(ModelReaderWriterOptions option } } - HealthBotSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + /// The data to parse. + /// The client options for reading and writing models. + HealthBotSku IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => PersistableModelCreateCore(data, options); + /// The data to parse. + /// The client options for reading and writing models. + protected virtual HealthBotSku PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) + { + string format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": + using (JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions)) { - using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); return DeserializeHealthBotSku(document.RootElement, options); } default: @@ -121,6 +137,7 @@ HealthBotSku IPersistableModel.Create(BinaryData data, ModelReader } } + /// The client options for reading and writing models. string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.cs index ef3074b6a70d..e5b3260e4374 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSku.cs @@ -13,37 +13,8 @@ namespace Azure.ResourceManager.HealthBot.Models /// The resource model definition representing SKU. public partial class HealthBotSku { - /// - /// 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; + /// Keeps track of any properties unknown to the library. + private protected readonly IDictionary _additionalBinaryDataProperties; /// Initializes a new instance of . /// The name of the Azure Health Bot SKU. @@ -54,16 +25,11 @@ public HealthBotSku(HealthBotSkuName name) /// Initializes a new instance of . /// The name of the Azure Health Bot SKU. - /// Keeps track of any properties unknown to the library. - internal HealthBotSku(HealthBotSkuName name, IDictionary serializedAdditionalRawData) + /// Keeps track of any properties unknown to the library. + internal HealthBotSku(HealthBotSkuName name, IDictionary additionalBinaryDataProperties) { Name = name; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Initializes a new instance of for deserialization. - internal HealthBotSku() - { + _additionalBinaryDataProperties = additionalBinaryDataProperties; } /// The name of the Azure Health Bot SKU. diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.Serialization.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.Serialization.cs index 6315358d94a8..b5f2120c2e45 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.Serialization.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/Models/HealthBotSkuName.Serialization.cs @@ -11,23 +11,35 @@ namespace Azure.ResourceManager.HealthBot.Models { internal static partial class HealthBotSkuNameExtensions { + /// The value to serialize. public static string ToSerialString(this HealthBotSkuName value) => value switch { HealthBotSkuName.F0 => "F0", - HealthBotSkuName.S1 => "S1", HealthBotSkuName.C0 => "C0", HealthBotSkuName.PES => "PES", HealthBotSkuName.C1 => "C1", _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown HealthBotSkuName value.") }; + /// The value to deserialize. public static HealthBotSkuName ToHealthBotSkuName(this string value) { - if (StringComparer.OrdinalIgnoreCase.Equals(value, "F0")) return HealthBotSkuName.F0; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "S1")) return HealthBotSkuName.S1; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "C0")) return HealthBotSkuName.C0; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "PES")) return HealthBotSkuName.PES; - if (StringComparer.OrdinalIgnoreCase.Equals(value, "C1")) return HealthBotSkuName.C1; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "F0")) + { + return HealthBotSkuName.F0; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "C0")) + { + return HealthBotSkuName.C0; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "PES")) + { + return HealthBotSkuName.PES; + } + if (StringComparer.OrdinalIgnoreCase.Equals(value, "C1")) + { + return HealthBotSkuName.C1; + } throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown HealthBotSkuName value."); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ProviderConstants.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ProviderConstants.cs index 2d3dbab8778e..b3d72ab8f80d 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ProviderConstants.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/ProviderConstants.cs @@ -9,8 +9,9 @@ namespace Azure.ResourceManager.HealthBot { - internal static class ProviderConstants + internal static partial class ProviderConstants { + /// Gets the DefaultProviderNamespace. public static string DefaultProviderNamespace { get; } = ClientDiagnostics.GetResourceProviderNamespace(typeof(ProviderConstants).Assembly); } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/RestOperations/BotsRestOperations.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/RestOperations/BotsRestOperations.cs index 1176544fbad9..b547fc22fa9a 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/RestOperations/BotsRestOperations.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/Generated/RestOperations/BotsRestOperations.cs @@ -6,131 +6,44 @@ #nullable disable using System; -using System.Text.Json; -using System.Threading; -using System.Threading.Tasks; +using Azure; using Azure.Core; using Azure.Core.Pipeline; -using Azure.ResourceManager.HealthBot.Models; namespace Azure.ResourceManager.HealthBot { - internal partial class BotsRestOperations + internal partial class Bots { - private readonly TelemetryDetails _userAgent; - private readonly HttpPipeline _pipeline; private readonly Uri _endpoint; private readonly string _apiVersion; - /// Initializes a new instance of BotsRestOperations. - /// 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 BotsRestOperations(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 ?? "2025-05-25"; - _userAgent = new TelemetryDetails(GetType().Assembly, applicationId); - } - - internal RequestUriBuilder CreateCreateRequestUri(string subscriptionId, string resourceGroupName, string botName, HealthBotData data) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string botName, HealthBotData data) + /// Initializes a new instance of Bots for mocking. + protected Bots() { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(data, ModelSerializationExtensions.WireOptions); - request.Content = content; - _userAgent.Apply(message); - return message; } - /// Create a new Azure Health Bot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The parameters to provide for the created Azure Health Bot. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task CreateAsync(string subscriptionId, string resourceGroupName, string botName, HealthBotData data, CancellationToken cancellationToken = default) + /// Initializes a new instance of Bots. + /// The ClientDiagnostics is used to provide tracing support for the client library. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// Service endpoint. + /// + internal Bots(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint, string apiVersion) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - Argument.AssertNotNull(data, nameof(data)); - - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, botName, data); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } + ClientDiagnostics = clientDiagnostics; + _endpoint = endpoint; + Pipeline = pipeline; + _apiVersion = apiVersion; } - /// Create a new Azure Health Bot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The parameters to provide for the created Azure Health Bot. - /// The cancellation token to use. - /// , , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Create(string subscriptionId, string resourceGroupName, string botName, HealthBotData data, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - Argument.AssertNotNull(data, nameof(data)); + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline { get; } - using var message = CreateCreateRequest(subscriptionId, resourceGroupName, botName, data); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } - internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string botName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -139,15 +52,17 @@ internal RequestUriBuilder CreateGetRequestUri(string subscriptionId, string res uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); uri.AppendPath(botName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateCreateRequest(string subscriptionId, string resourceGroupName, string botName, RequestContent content, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -156,94 +71,19 @@ internal HttpMessage CreateGetRequest(string subscriptionId, string resourceGrou uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); uri.AppendPath(botName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Put; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); + request.Content = content; return message; } - /// Get a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> GetAsync(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, botName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - HealthBotData value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = HealthBotData.DeserializeHealthBotData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((HealthBotData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - /// Get a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Get(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateGetRequest(subscriptionId, resourceGroupName, botName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - HealthBotData value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = HealthBotData.DeserializeHealthBotData(document.RootElement); - return Response.FromValue(value, message.Response); - } - case 404: - return Response.FromValue((HealthBotData)null, message.Response); - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateUpdateRequestUri(string subscriptionId, string resourceGroupName, string botName, HealthBotPatch patch) + internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string botName, RequestContent content, RequestContext context) { - 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.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceGroupName, string botName, HealthBotPatch patch) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Patch; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -252,73 +92,19 @@ internal HttpMessage CreateUpdateRequest(string subscriptionId, string resourceG uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); uri.AppendPath(botName, true); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - request.Headers.Add("Content-Type", "application/json"); - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(patch, ModelSerializationExtensions.WireOptions); + request.Method = RequestMethod.Patch; + request.Headers.SetValue("Content-Type", "application/json"); + request.Headers.SetValue("Accept", "application/json"); request.Content = content; - _userAgent.Apply(message); return message; } - /// Patch a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The parameters to provide for the required Azure Health Bot. - /// 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 botName, HealthBotPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, botName, patch); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Patch a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The parameters to provide for the required Azure Health Bot. - /// 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 botName, HealthBotPatch patch, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - Argument.AssertNotNull(patch, nameof(patch)); - - using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, botName, patch); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 201: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string botName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -327,178 +113,74 @@ internal RequestUriBuilder CreateDeleteRequestUri(string subscriptionId, string uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); uri.AppendPath(botName, true); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Delete; + return message; } - internal HttpMessage CreateDeleteRequest(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateGetByResourceGroupRequest(string subscriptionId, string resourceGroupName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Delete; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder 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.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); + uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// Delete a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task DeleteAsync(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, botName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - /// Delete a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response Delete(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetByResourceGroupRequest(Uri nextPage, string subscriptionId, string resourceGroupName, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateDeleteRequest(subscriptionId, resourceGroupName, botName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - case 202: - case 204: - return message.Response; - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListSecretsRequestUri(string subscriptionId, string resourceGroupName, string botName) - { - 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.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); - uri.AppendPath("/listSecrets", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateListSecretsRequest(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateGetAllRequest(string subscriptionId, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder 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.HealthBot/healthBots/", false); - uri.AppendPath(botName, true); - uri.AppendPath("/listSecrets", false); + uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); return message; } - /// List all secrets of a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> ListSecretsAsync(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) + internal HttpMessage CreateNextGetAllRequest(Uri nextPage, string subscriptionId, RequestContext context) { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateListSecretsRequest(subscriptionId, resourceGroupName, botName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - HealthBotKeysResult value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = HealthBotKeysResult.DeserializeHealthBotKeysResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// List all secrets of a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response ListSecrets(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateListSecretsRequest(subscriptionId, resourceGroupName, botName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - HealthBotKeysResult value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = HealthBotKeysResult.DeserializeHealthBotKeysResult(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } + RawRequestUriBuilder uri = new RawRequestUriBuilder(); + uri.Reset(nextPage); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Get; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal RequestUriBuilder CreateRegenerateApiJwtSecretRequestUri(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateGetSecretsRequest(string subscriptionId, string resourceGroupName, string botName, RequestContext context) { - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -506,17 +188,19 @@ internal RequestUriBuilder CreateRegenerateApiJwtSecretRequestUri(string subscri uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.HealthBot/healthBots/", false); uri.AppendPath(botName, true); - uri.AppendPath("/regenerateApiJwtSecret", false); + uri.AppendPath("/listSecrets", false); uri.AppendQuery("api-version", _apiVersion, true); - return uri; + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; + request.Uri = uri; + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); + return message; } - internal HttpMessage CreateRegenerateApiJwtSecretRequest(string subscriptionId, string resourceGroupName, string botName) + internal HttpMessage CreateRegenerateApiJwtSecretRequest(string subscriptionId, string resourceGroupName, string botName, RequestContext context) { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Post; - var uri = new RawRequestUriBuilder(); + RawRequestUriBuilder uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); @@ -526,388 +210,12 @@ internal HttpMessage CreateRegenerateApiJwtSecretRequest(string subscriptionId, uri.AppendPath(botName, true); uri.AppendPath("/regenerateApiJwtSecret", false); uri.AppendQuery("api-version", _apiVersion, true); + HttpMessage message = Pipeline.CreateMessage(); + Request request = message.Request; request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Regenerate the API JWT Secret of a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public async Task> RegenerateApiJwtSecretAsync(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateRegenerateApiJwtSecretRequest(subscriptionId, resourceGroupName, botName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - HealthBotKey value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = HealthBotKey.DeserializeHealthBotKey(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Regenerate the API JWT Secret of a HealthBot. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The name of the Bot resource. - /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public Response RegenerateApiJwtSecret(string subscriptionId, string resourceGroupName, string botName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - Argument.AssertNotNullOrEmpty(botName, nameof(botName)); - - using var message = CreateRegenerateApiJwtSecretRequest(subscriptionId, resourceGroupName, botName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - HealthBotKey value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = HealthBotKey.DeserializeHealthBotKey(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupRequestUri(string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListByResourceGroupRequest(string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/resourceGroups/", false); - uri.AppendPath(resourceGroupName, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Returns all the resources of a particular type belonging to a resource group. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupAsync(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Returns all the resources of a particular type belonging to a resource group. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroup(string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupRequest(subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListRequestUri(string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); - uri.AppendQuery("api-version", _apiVersion, true); - return uri; - } - - internal HttpMessage CreateListRequest(string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/subscriptions/", false); - uri.AppendPath(subscriptionId, true); - uri.AppendPath("/providers/Microsoft.HealthBot/healthBots", false); - uri.AppendQuery("api-version", _apiVersion, true); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Returns all the resources of a particular type belonging to a subscription. - /// Azure Subscription ID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListAsync(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Returns all the resources of a particular type belonging to a subscription. - /// Azure Subscription ID. - /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public Response List(string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListRequest(subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListByResourceGroupNextPageRequestUri(string nextLink, string subscriptionId, string resourceGroupName) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListByResourceGroupNextPageRequest(string nextLink, string subscriptionId, string resourceGroupName) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); - return message; - } - - /// Returns all the resources of a particular type belonging to a resource group. - /// The URL to the next page of results. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public async Task> ListByResourceGroupNextPageAsync(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Returns all the resources of a particular type belonging to a resource group. - /// The URL to the next page of results. - /// Azure Subscription ID. - /// The name of the Bot resource group in the user subscription. - /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public Response ListByResourceGroupNextPage(string nextLink, string subscriptionId, string resourceGroupName, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); - - using var message = CreateListByResourceGroupNextPageRequest(nextLink, subscriptionId, resourceGroupName); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - internal RequestUriBuilder CreateListNextPageRequestUri(string nextLink, string subscriptionId) - { - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - return uri; - } - - internal HttpMessage CreateListNextPageRequest(string nextLink, string subscriptionId) - { - var message = _pipeline.CreateMessage(); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendRawNextLink(nextLink, false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - _userAgent.Apply(message); + request.Method = RequestMethod.Post; + request.Headers.SetValue("Accept", "application/json"); return message; } - - /// Returns all the resources of a particular type belonging to a subscription. - /// The URL to the next page of results. - /// Azure Subscription ID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public async Task> ListNextPageAsync(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions, cancellationToken).ConfigureAwait(false); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } - - /// Returns all the resources of a particular type belonging to a subscription. - /// The URL to the next page of results. - /// Azure Subscription ID. - /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public Response ListNextPage(string nextLink, string subscriptionId, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(nextLink, nameof(nextLink)); - Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); - - using var message = CreateListNextPageRequest(nextLink, subscriptionId); - _pipeline.Send(message, cancellationToken); - switch (message.Response.Status) - { - case 200: - { - BotResponseList value = default; - using var document = JsonDocument.Parse(message.Response.ContentStream, ModelSerializationExtensions.JsonDocumentOptions); - value = BotResponseList.DeserializeBotResponseList(document.RootElement); - return Response.FromValue(value, message.Response); - } - default: - throw new RequestFailedException(message.Response); - } - } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/src/autorest.md b/sdk/healthbot/Azure.ResourceManager.HealthBot/src/autorest.md.bak similarity index 100% rename from sdk/healthbot/Azure.ResourceManager.HealthBot/src/autorest.md rename to sdk/healthbot/Azure.ResourceManager.HealthBot/src/autorest.md.bak diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/tsp-location.yaml b/sdk/healthbot/Azure.ResourceManager.HealthBot/tsp-location.yaml new file mode 100644 index 000000000000..4196a286c4ff --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/healthbot/HealthBot.Management +commit: dfac30326328d23095e31f791bd74316615fd398 +repo: Azure/azure-rest-api-specs +emitterPackageJsonPath: "eng/azure-typespec-http-client-csharp-mgmt-emitter-package.json"